ESP32 tank KH controller

Hi,

I started a project to control some devices in an attempt to perform KH tests for my aquarium.

But the problem is my ESP32 board is overheating and stop working. I have followed many tutorials on the internet to wire each component correctly, and I am a little bit lost to find what is wrong in my setup.

I tried to make it as simple as possible with a sketch for the wiring process :

And here’s my code in ESPhome :

esphome:
  name: kh-controller
  friendly_name: KH controller

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: ""

ota:
  - platform: esphome
    password: ""

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  power_save_mode: none

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Kh-Controller Fallback Hotspot"
    password: ""

captive_portal:


i2c:
  sda: 21
  scl: 22
  scan: true
  id: bus_a
  
ads1115:
  - address: 0x48

sensor:
#PH SENSOR
  - platform: ads1115
    multiplexer: 'A0_GND'
    gain: 6.144
    name: "Reef pH KHcontroller"
    id: ph_khcontroller
    update_interval: 10s
    filters:
      - median:
          window_size: 6
          send_every: 6
          send_first_at: 1
    unit_of_measurement: "mV"
    icon: "mdi:water"
    accuracy_decimals: 3

#Gestion du Ventilateur PWM
  - platform: pulse_counter
    pin: GPIO13
    name: PWM Fan RPM
    id: fan_pulse
    unit_of_measurement: 'RPM'
    filters:
      - multiply: 0.5
    count_mode:
      rising_edge: INCREMENT
      falling_edge: DISABLE
    update_interval: 3s

#Ventilateur
output:
  - platform: ledc
    pin: GPIO12
    frequency: 10000 Hz
    id: fanhub_pwm

#GPIO outputs for L9110S module
  - platform: gpio
    pin: GPIO32    #IN1 for PUMP 1
    id: pump1_forward
  - platform: gpio
    pin: GPIO33    #IN2 for PUMP 1
    id: pump1_reverse
  - platform: gpio
    pin: GPIO25    #IN1 for PUMP 2
    id: pump2_forward
  - platform: gpio
    pin: GPIO26    #IN2 for PUMP 2
    id: pump2_reverse
  
#Switches for the peristaltic pumps: 
switch:
  - platform: template
    name: "Pump1 Forward"
    turn_on_action:
      - output.turn_on: pump1_forward
      - output.turn_off: pump1_reverse
    turn_off_action: 
      - output.turn_off: pump1_forward
  - platform: template
    name: "Pump1 Reverse"
    turn_on_action:
      - output.turn_on: pump1_reverse
      - output.turn_off: pump1_forward
    turn_off_action: 
      - output.turn_off: pump1_reverse
  - platform: template
    name: "Pump2 Forward"
    turn_on_action:
      - output.turn_on: pump1_forward
      - output.turn_off: pump1_reverse
    turn_off_action: 
      - output.turn_off: pump1_forward
  - platform: template
    name: "Pump2 reverse"
    turn_on_action:
      - output.turn_on: pump1_reverse
      - output.turn_off: pump1_forward
    turn_off_action: 
      - output.turn_off: pump1_reverse

fan:
  - platform: speed
    output: fanhub_pwm
    name: "PWM Fan"

Everything is powered with a 12V 2A adapter, I have a LM2596S to get 12V to 5V, I have checked that the output is 5V and it is.

Should I change something?

When Esp heats up, usually quite a lot…
You need to power ADS1115 at 3.3V, otherwise you are abusing the Esp pins connected to it.
You need to adjust the ph-sensor a way it doesn’t output more than 3.3V to ADS1115.

Most importantly, disconnect all wires from L9110S except 12V and GND. Then measure the voltage between those 4 pins and GND. What you get?
I have seen crap modules that have pullups to VCC… 12V in your case.

Ok so I plugged the ADS1115 and the probe board to 3.3V, and checked the output voltage of the 4 pins of the L9110S which are 4.08V, VCC to 12V and GND connected to the GND of the ESP32 module.

The ESP module doesn’t boot anymore in ESPhome and HA, so I ordered another one to continue testing.

Also, should I use the same GND of the ESP32 board for the whole projet, or a different GND for each module?
Because actually, I only use one GND pin for the whole project.

It’s absolutely important to have common GND. But if you power everything from same power supply, GND is automatically common.

It’s not clear to me how you measured the L9110S logic voltage. While powered at 12V, measure voltage between GND and those 4 pins (disconnected).

Honestly, if you don’t need speed control or reverse polarity for your pump, you could simply use a relay module.
Or some other driver that is not L9110 or L293/L298.

Ok thank you, it is the same power supply for the whole project, I have used the 3 GND pins of the ESP board to avoid soldering to much cables together.

To measure the voltage I used the GND pin of the L9110S module with the negative probe of the multimeter, and the positive probe for the 4 pins of the module. And the wiring of the L9110S module was : VCC connected to the 12V power supply while the GND of the module was pinned to the GND of the ESP module, like it is planned to work for the project.

I need the reverse polarity because one pump will have to pour some water sample into a beaker, and once the test done, it will put the water back in the tank. And I didn’t specified in the first post that the peristaltic pumps are 12V.

And result was 4.08V? That’s kind of strange.

Yes, I have measured all 4 pins. I will check again to be sure, but I got 4,08 on 3 pins and 4,07 on one pin.

EDIT: I confirm the measures. I checked again and I got 4,03V this time. I have unpinned everything for the power supply execpt the ESP32 and the L9110S module, and the result remains the same.

I have found the solution, and it is all my fault. I did not pay attention that the GND of the L9110S module wasn’t plugged in the negative of the 12V power supply. The ESP32 board is running, no overheating. The correct wiring is as follow, at least I think :sweat_smile: :


I also had to change the pins of the fan because the ESP32 did not boot.

That made the module sinking 12V to Esp, like I wrote, if Esp heats up a lot there is usually a lot wrong. I personally wouldn’t use that board anymore.
I see you still supply ADS at 5V, that’s not ok.

Gpio12 is strapping pin.

I have changed the wiring, connected the ESP32 to USB cable, everything is connected correctly. No more overheating.

But I cannot manage to make things work properly, I think it is code related, I changed the code for the L9110S with H-Bridge Fan and it work but forward and reverse with one pump, but not with the other, also, since I have added the H-Bridge Fan code, the fan doesn’t work anymore :

esphome:
  name: kh-controller
  friendly_name: KH controller

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: ""

ota:
  - platform: esphome
    password: ""

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  power_save_mode: none
  manual_ip:
    # Set this to the IP of the ESP
    static_ip: 
    # Set this to the IP address of the router. Often ends with .1
    gateway: 
    # The subnet of the network. 255.255.255.0 works for most home networks.
    subnet: 

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Kh-Controller Fallback Hotspot"
    password: ""

captive_portal:


i2c:
  sda: 21
  scl: 22
  scan: true
  id: bus_a
  
ads1115:
  - address: 0x48

sensor:
#PH SENSOR
  - platform: ads1115
    multiplexer: 'A0_GND'
    gain: 6.144
    name: "Reef pH KHcontroller"
    id: ph_khcontroller
    update_interval: 10s
    filters:
      - median:
          window_size: 6
          send_every: 6
          send_first_at: 1
    unit_of_measurement: "mV"
    icon: "mdi:water"
    accuracy_decimals: 3

#Gestion du Ventilateur PWM
  - platform: pulse_counter
    pin: GPIO18
    name: PWM Fan RPM
    id: fan_pulse
    unit_of_measurement: 'RPM'
    filters:
      - multiply: 0.5
    count_mode:
      rising_edge: INCREMENT
      falling_edge: DISABLE
    update_interval: 3s

output:
#Ventilateur
  - platform: ledc
    pin: GPIO19
    frequency: 10000 Hz
    id: fanhub_pwm

#Pompes Doseuses 2
  - platform: ledc
    id: motor1_forward_pin
    pin: GPIO32
  - platform: ledc
    id: motor1_reverse_pin
    pin: GPIO33
#Pompes Doseuses 1
  - platform: ledc
    id: motor2_forward_pin
    pin: GPIO25
  - platform: ledc
    id: motor2_reverse_pin
    pin: GPIO26


fan:
#Ventilateur
  - platform: speed
    id: fan_khcontroller
    output: fanhub_pwm
    name: "PWM Fan"

# Gestion des pompes doseuses
  - platform: hbridge
    id: dosing_pump_khcontroller1
    name: "Pompes doseuses KH Controller 1"
    pin_a: motor1_forward_pin
    pin_b: motor1_reverse_pin
    #enable_pin: motor_enable
    decay_mode: slow   # slow decay mode (coasting) or fast decay (braking).

  - platform: hbridge
    id: dosing_pump_khcontroller2
    name: "Pompes doseuses KH Controller 2"
    pin_a: motor2_forward_pin
    pin_b: motor2_reverse_pin
    #enable_pin: motor_enable
    decay_mode: slow   # slow decay mode (coasting) or fast decay (braking).

I don’t see anything wrong with your setup.
Pwm fans usually require frequency around 25kHz.
Remember to adjust PH sensor to output max 3.3V.

What’s the stall (max) current draw of your pumps and fan?
Your power supply is max 2A for total and L9110s <800mA/channel.

The pH sensor is on the 3.3V pin. What do you mean by “Remember to adjust PH sensor to output max 3.3V.”, if it is on the 3.3V pin it should be ok right?

I’ve got that peristaltic pump and a Noctua fan the NF-A8 PWM. I cannot check the values actually, my board once again overheated all of a sudden with a 12V 1 A power supply, so I’m planning to use other parts that will be delivered in a few days.

Sorry, I didn’t notice that.

So “aliexpress documentation” gives 12/24V 6W for your pump. So with two of them 1A psu doesn’t have a lot of margin for total current draw. Also, be aware L9110s has quite noticeable voltage drop, the pump voltage is probably 10-11V. Maybe still ok for that pump, but not guaranteed.

Like I wrote before I wouldn’t trust anymore that Esp from your last trial, neither L9110s.
If you can substitute them with new ones, you take some odds out…

I have ordered new ones on AliExpress and swapping L9110S with a L298N.

They have same characteristics. Next time pick TB6612 or DRV88xx

I see that the TB6612 have a 12V and 5v logic and 3 GND. So the ESP module is not wired with the 12V at all, even with the GND pin?

Because the 12V supply/5V logic and GND à close together.

Esp32 has 3.3V operating voltage, not 5V!
GND is common ground.
So you wire Esp32 3.3V to VCC and GND to GND
Motor power supply positive to VM and negative to GND.

Ok so the motor and the ESP use separate GND of the TB6612 board is that it?

No, they use common ground.
All the ground pads are interconnected on the module.

Ok thanks you, I have ordered the TB6612 module.