• How to interface potentiometer to ESP32 to read ADC Values

    Here is the simple code to read the ADC value and show it in the serial monitor of Arduino ide.

    const int Analog_channel_pin= 34;
    int ADC_VALUE = 0;
    float voltage_value = 0; 
    void setup() 
    {
    Serial.begin(115200);
    }
    void loop() 
    {
    ADC_VALUE = analogRead(Analog_channel_pin);
    Serial.print("ADC VALUE = ");
    Serial.println(ADC_VALUE);
    delay(1000);
    voltage_value = (ADC_VALUE * 3.3 ) / (4095);
    Serial.print("    Voltage = ");
    Serial.print(voltage_value);
    Serial.println("volts");
    delay(1000);
    }
    The output of serial monitor
  • Blown LM358P due to transients

    An LM358p is a dual opamp IC which I used in a single supply configuration. I drive the LM358 just shy of its absolute maximum voltage which is +30V. So I gave I supplied 28.8V (+-0.1V). It works flawless but the power supply is a Meanwell switching supply which introduces transient when plugging into the mains supply.

    The transient arise when I was plugging in the AC wire to the mains. I used an anchor 6A 3-pin male plug for connection. It was at the brief moment when the transient arise.

    The transient which arises apparently has enough power that it blew the epoxy off the silicon and it did with a loud bang.

    Blown LM358P due to transients

    Doing rough calculation at the moment this happened

    Let’s say the transient is double the supply voltage of = 2 x 28.9 V= 57.8V

    let’s say the current drawn by the IC is 40mA which is its absolute maximum.

    power = voltage x current = 57.8V x 40mA = 2.312W

    so for a brief moment, this 2W is radiated by the silicon chip. Which caused the heating up of the epoxy and generating enough expanding force which blew out like that.

    but let’s take a more reasonable transient voltage(ISO 7637-2: 2011) of approximately 110V at a rise time of 0.5uS.

    so power = 110V x 40mA = 4.4W .

  • FAKE BD139 NPN transistors

    I have recently found out that there are FAKE transistors in the market. I have a built a circuit design and when I bought the transistor from the Lajpat rai market in Delhi; I assembled the circuit on a test bench for measurements. But I was surprised that the BD139 did not work with 10mA at 30V and they began overheating. They heat up so much that bubbles appear on the front epoxy and it cracked. I thought that maybe it was damaged so I replaced the whole circuit with a new transistor set. But they also didn’t hold and this time they burnt a resistor along with them. I saw flames engulfing the 1/4 Watt resistors.

    So I again made the circuit using the minuscule BC546B. Which neither get warm nor went into thermal runaway.

    on the BD139 it was marked that it was manufactured by NXP. And I then checked the NXP website and found out that the NXP closed its manufacturing of this transistor in 2001.

    There are a lot of BD139 transistors circulating in the market. It is essential that you must buy from a good source.

  • Custom Aluminum Heatsink for Raspberry Pi

    Raspberry Pi is good a single-board Linux based computer system. But it runs OK for the most part and does not heat up if you’re not doing CPU hogging tasks.

    I use my raspberry pi for watching videos. Which heats up the CPU to about 60 degrees celsius.

    In Delhi, in the summer the ambient temperature is around 30 degrees celsius to about 34 degrees celsius.

    In the past, I have placed a small TO-220 package heatsink on it. By placing it sideways.

    I used fevicol which is a synthetic craft glue as I don’t have proper heat sink paste. But I found that fevicol glue works good and the heatsink stays quite firmly attached to the CPU.

    After Placing the Heatsink the CPU temperature never goes above 50 degrees celsius. Which is a 10-degree improvement.

  • How to generate custom fonts for LCD display

    There are various tools to generate font style for LCD display.

    1. Write your own fonts style. But this is will become hectic if you have a larger font size.
    2. Software tool
      1. The Dot Factory by Eran Duchan
      2. GLCD Font Creator

    I like “The Dot Factory” font creation tool. It is minimalistic and gets the job done.

    Here is the link to the Github page for The Dot Factory https://github.com/pavius/the-dot-factory

  • 15V Unregulated DC Power Supply using 12Vrms step-down transformer

    There are two ways to make DC power supply

    1. Linear
    2. Switching

    Linear Power Supply
    Continous control of voltage is done at any instance of time. It uses a pass transistor with an error amplifier to regulate the voltage supply.
    example: 7805, 7905, LM317 etc

    Switching Power Supply
    It also uses the pass transistor along with an inductor and a capacitor to store the energy and release the energy. By controlling the switching of the pass transistor, the Voltage is regulated. It is more complex than the linear power supply.
    The advantage of switching is that the transformer size gets reduced. Which reduced the cost of the power supply. The Reduced size also reduced the weight; which further increases the portability of the power supply.

    [ A C Mains ] -> [StepDown Transformer] -> [Bridge Rectifier] -> [Filter] -> [Unregulated DC]

    I am using a step-down transformer. Which transformer 220V 50Hz AC to 12 Vrms AC.

    The Vrms is converted to Vdc which is dc equivalent voltage.

    So, 12 Vrms = 12 x 1.414 Vdc

    = 16.968 (approx.) Vdc

    this Vdc is passed through the bridge rectifier which drops 1.5V to 1.8V

    = 16.968 – 1.8

    = 15.168 V

    which is then filtered through the Capacitor filter

    C = ( I x t ) / V

    I is the amount of current passing through the capacitor at maximum load.

    Let I = 1A

    t is the ripple time which is taken 10 mS if using 50Hz cycles.

    C = [1 x 10 x 10^(-3) ] / 15.168

    = 6.59 x 10^(-4) F

    = 659 micro Frad

    So we will use a standard capacitor that is either equal to or bigger than the above value i.e 1000uF will OK.

  • STM32F429I-DISC1

    Datasheet for stm32F429ZI https://www.st.com/en/microcontrollers-microprocessors/stm32f429zi.html

    This board have a 2.4 Resistive touch TFT LCD. which uses the ILI9341  controller.

    The touch screen which I got with this display is very bad. you have to press down on the screen before you power ON the device.

    The microcontroller is based on the ARM CORTEX M4F which can be clocked up to 180MHz. This particular board has an 8Mbyte of SDRAM included which is basically useless with this screen. If you want to see the full potential you have to use the LTDC peripheral which when configured with DMA2D gives you a very powerful development board with multimedia capabilites.

  • STM32F746IGT6 – An ARM CORTEX M7 Based Microcontroller

    Datasheet

    It’s an ARM Cortex M7 based microcontroller which has a maximum clock speed of 216Mhz.

    Well, it has a few peripherals which when combined with its CPU, makes it a very powerful controller.

    Those peripherals are LTDC, SDRAM Controller.

    It also has the usual set of peripherals from the ST. But these in particular makes it a very powerful microcontroller.

  • Do not connect microcontroller pins to the VGA monitor directly

    I tried to generate VGA signal on stm32f103

    I used two timers, the TIMER 2 generate the horizontal sync and then the second timer TIMER 3 is configured in gated slave mode which generates the vertical sync.

    Then I used HAL_SPI_TRANSMIT_DMA function inside the timer 2 interrupt handler.

    I in a hurried manner connected the video signal to the monitor directly. And that has burned the image onto the monitor.

    I connected the green video signal directly from the stm32f103 to the VGA connector.

    image is now burned in the monitor.

  • SIMcom A7670c LTE Module with UART

    This module can be used with Indian 4G bands. This means it can be used with Vodafone, Airtel or Jio networks.

    This module comes preconfigured with AT commands.

    The module offers UART to issue commands.

    Since the communication speed is really high so the 3.3V and 5V UART lines can not be used for communication with the board.

    The company offers technical documents on hardware design for the UART.

    Here is the circuit I am using for converting the 1.8V to 5V using the BC547 NPN BJT transistor.

    I connected the UART on the module to a USB-to-Serial convertor.

    I can then use AT commands to control the module functions like call, SMS, data etc.

    Here is the basic AT commands

    • For making calls,SMS or data etc from the module you will need a Registered SIM card
    • For making calls from module
      ATDxxxxxxxxxx;
      x’s are your telephone number
      semi colon must be inserted at the end
    • For issuing DTMF tones
      AT+VTS=[number],[duration]
      Example: DTMF tone for digit 8
      AT+VTS=8,500
    • For Receiving Incoming Calls
      ATA
    • For Disconeccting On-going call
      AT+CVHU=0
      ATH
    • For Sending SMS
      AT+CMGF=1
      AT+CMGF=”+[country ISD code][Mobile number]”
      after sending the above commands you can send your message.
      At the end of your message you need to send number 26 (hex 1A) to mark the end of your message.