WIFI Connectivity issues

Hi all,

I developed a pool pump automation system. Basically it starts and stops the pool pump at two different time intervals set by Home Assistant and also reports back on current usage, temperature and humidity in the pump house.

When I installed the device in the pump house, it wouldn’t connect to my AP at all. I made the external antenna mod and it now connects. Sometimes it stays connected for hours, and sometimes it barely connects at all in a span of 24 hours. I also disabled the power saving setting.

Looking at the debug log, it shows a signal of -40db, but looking at my access point it shows a signal of -85db. Based on that, I’m deducting the ESP32 is receiving the WIFI signal ok, but the AP is not seeing the ESP with the same strength.

Has anyone experienced a similar issue? Is there a way to increase the TX power of the ESP32?

I’m attaching my code below for reference. Thank you!

esphome:
  name: poolpump
  platform: ESP32
  board: esp32doit-devkit-v1
  on_boot:
    then:
      lambda: |-
        if (id(pump_on_switch).state) { // ON mode
          id(pool_mode_auto).turn_off();
          id(pool_mode_off).turn_off();
          id(pool_mode_on).turn_on();
          id(pool_pump_run).turn_on();
        } else {
          if (id(pump_off_switch).state) { //OFF mode
            id(pool_pump_run).turn_off();
            id(pool_mode_auto).turn_off();
            id(pool_mode_on).turn_off();
            id(pool_mode_off).turn_on();
          } else {                        //AUTO mode
            id(pool_mode_on).turn_off();
            id(pool_mode_off).turn_off();
            id(pool_mode_auto).turn_on();
          }
        }


wifi:
  power_save_mode: none
  fast_connect: on
  networks:
    - ssid: xxxx
      password: xxxx

time:
  - platform: homeassistant
    id: homeassistant_time
    timezone: Australia/Sydney
    on_time:
      - seconds: 0
        minutes: /1
        then:
          - script.execute: minute_script

# Pump timer control
script:
  - id: minute_script
    then:
      lambda: |-
        if (id(pump_timer1).state) {
          if ((id(pump_start_minute1).state == id(homeassistant_time).now().minute) &&
          (id(pump_start_hour1).state == id(homeassistant_time).now().hour)) {
            id(pool_pump).turn_on();
          }
          if ((id(pump_stop_minute1).state == id(homeassistant_time).now().minute) &&
          (id(pump_stop_hour1).state == id(homeassistant_time).now().hour)) {
            id(pool_pump).turn_off();
          }
        }
        if (id(pump_timer2).state) {
          if ((id(pump_start_minute2).state == id(homeassistant_time).now().minute) &&
          (id(pump_start_hour2).state == id(homeassistant_time).now().hour)) {
            id(pool_pump).turn_on();
          }
          if ((id(pump_stop_minute2).state == id(homeassistant_time).now().minute) &&
          (id(pump_stop_hour2).state == id(homeassistant_time).now().hour)) {
            id(pool_pump).turn_off();
          }
        }

# Pins description
# 27: On Led   (Red)
# 26: Auto Led (Yellow)
# 25: Off Led  (Green)
#
# 33: Pump control (Output)
#
# 19: Power meter 500 pulses -> 1kWh
#
# 18: Pump mode sw On
# 13: Pump mode sw Off
#
# 14: DHT22 Temperature sensor (IO)
# A0: Pump current (AI)


switch:
  - platform: gpio
    pin: 27
    name: "Pool Pump Mode On"
    id: pool_mode_on
  - platform: gpio
    pin: 26
    name: "Pool Pump Mode Auto"
    id: pool_mode_auto
  - platform: gpio
    pin: 25
    name: "Pool Pump Mode Off"
    id: pool_mode_off
#Pool Pump Control: Internal switch
  - platform: gpio
    pin: 33
    id: pool_pump_run
    restore_mode: ALWAYS_OFF
  - platform: template
    name: "Pool Pump Run"
    id: pool_pump
    lambda: |-
      if (id(pool_pump_run).state) {
        return true;
      } else {
        return false;
      }
    turn_on_action:
      lambda: |-
        if (id(pool_mode_auto).state) {
          id(pool_pump_run).turn_on();
        }
    turn_off_action:
      lambda: |-
        if (id(pool_mode_auto).state) {
          id(pool_pump_run).turn_off();
        }


sensor:
  - platform: adc
    pin: A0
    id: pool_pump_ct
    update_interval: 15s
    attenuation: 11db
  - platform: ct_clamp
    sensor: pool_pump_ct
    name: "Pool Pump Current"
    update_interval: 15s
    filters:
      - calibrate_linear:
          # Measured value of 0 maps to 0A
          - 0.006 -> 0
          - 0.42 -> 6.1
          - 0.55 -> 8.5

    id: pool_pump_current
  - platform: dht
    model: DHT22
    pin: 14
    temperature:
      name: "Pumphouse Temperature"
    humidity:
      name: "Pumphouse Humidity"
    update_interval: 60s
# Pump start stop times from Home Assistant
  - platform: homeassistant
#    name: "Pump Start Hour"
    entity_id: input_number.pump_start_hour1
    id: pump_start_hour1
  - platform: homeassistant
#    name: "Pump Start Minute"
    entity_id: input_number.pump_start_minute1
    id: pump_start_minute1
  - platform: homeassistant
#    name: "Pump Stop Hour"
    entity_id: input_number.pump_stop_hour1
    id: pump_stop_hour1
  - platform: homeassistant
#    name: "Pump Stop Minute"
    entity_id: input_number.pump_stop_minute1
    id: pump_stop_minute1
  - platform: homeassistant
#    name: "Pump Start Hour"
    entity_id: input_number.pump_start_hour2
    id: pump_start_hour2
  - platform: homeassistant
#    name: "Pump Start Minute"
    entity_id: input_number.pump_start_minute2
    id: pump_start_minute2
  - platform: homeassistant
#    name: "Pump Stop Hour"
    entity_id: input_number.pump_stop_hour2
    id: pump_stop_hour2
  - platform: homeassistant
#    name: "Pump Stop Minute"
    entity_id: input_number.pump_stop_minute2
    id: pump_stop_minute2

  - platform: pulse_counter
    pin: 19
    unit_of_measurement: 'kW'
    name: 'Pool Pump Power Meter'
    id: pump_power_meter
    filters:
      - multiply: 0.12
  - platform: total_daily_energy
    name: "Pool Pump Total Daily Energy"
    power_id: pump_power_meter


binary_sensor:
  - platform: gpio
    pin:
      number: 18
      inverted: True
      mode:
        input: True
        pullup: True
#   name: "Pump On Switch"
    id: pump_on_switch
    on_press:
      then:
        - switch.turn_on: pool_pump_run
        - switch.turn_on: pool_mode_on
        - switch.turn_off: pool_mode_auto
    on_release:
      then:
        - switch.turn_off: pool_mode_on
        - switch.turn_on: pool_mode_auto
  - platform: gpio
    pin:
      number: 13
      inverted: True
      mode:
        input: True
        pullup: True
#   name: "Pump Off Switch"
    id: pump_off_switch
    on_press:
      then:
        - switch.turn_off: pool_pump_run
        - switch.turn_on: pool_mode_off
        - switch.turn_off: pool_mode_auto
    on_release:
      then:
        - switch.turn_off: pool_mode_off
        - switch.turn_on: pool_mode_auto
  - platform: template
    id: pump_run_sensor
    name: "Pool Pump Running"
    lambda: |-
      if (id(pool_pump_current).state > 1.5) {
        return true;
      } else {
        return false;
      }
  - platform: homeassistant
#    name: "Pump Timer 1"
    entity_id: input_boolean.pump_timer1
    id: pump_timer1
  - platform: homeassistant
#    name: "Pump Timer 2"
    entity_id: input_boolean.pump_timer2
    id: pump_timer2

# Enable logging
logger:

api:

ota:

Did you try to use an ESP with the connector for an external antenna? Using a high gain antenna, even better if directional, would likely help.

Example I found on google:
image

I can’t vouch for this antenna but here is an example of what I was thinking about:

BTW, what is the antenna mod you are talking about?

This is the antenna mod I was referring to, because my esp doesn’t have a connector for an external antenna:

I do have an external antenna like this one:
https://www.amazon.com/Bingfu-Rosewill-Gigabyte-Wireless-Security/dp/B082SHKT3Q/ref=sr_1_2_sspa?crid=3DSG6IBPFUOT7&keywords=wifi+antenna&qid=1668924414&sprefix=wifi+anten%2Caps%2C286&sr=8-2-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&psc=1

What I’m curious about is:

  • Other esp devices that are further away have a better signal level when looking at the wifi router.
  • The big difference between the signal level my wifi router advertises (80db) as compared to what the esp advertises (40db)

That’s why I wonder whether there is an issue with the transmit power of the esp.

Thank you
Christian

Sounds right from all the reading I’ve done on the same subject.
IoT devices are typically physically small and low cost, some even battery powered. That means 802.11G standard (2.4GHz) wi-fi with a tiny aerial and usually low power driving the wi-fi signal.

I have seen people lowering the transmit power on their Wifi access points so they better match the incoming signals. Of course that means shorter range, so possibly more APs to cover a dwelling … as if we don’t already have enough wifi networks within range ;-(

Thank you for your reply.

I would accept this if I didn’t have an ESP8266, placed further away, without an external antenna reporting 60db on the AP as compared to 80db for the ESP32 with the external antenna.

It is possible this ESP32 is of lower quality components, just guessing.

Cheers

Honestly wi-fi is a real pain in the backside. I have been doing battle with my new ASUS router trying to stop devices in the same room from frequently dropping off the wifi, while some further away and reporting a weaker signal have stayed online for a week.

We can’t see the signals, so there’s no way to know what (if anything) is interfering. Metal (eg a refridgerator) tends to reflect radio signals, whereas water (eg a fish tank) absorbs the radio frequencies. That’s why your TV reception gets worse in the rain :wink:
I have heard stories of an installer who couldn’t get a decent wifi signal with his laptop sitting on the table literally next to the router; and of an ex telephone technician who cleaned the telephone connectors in his house and found his wifi improved noticably (probably as the wires corroded they were creating microscopic sparks ?).

It is quite possible the ESP32 is using cheaper lower quality components; but just as likely that there’s some other reason.

And yet the -ing sales droids tell customers that wifi is ideal for multiple 4K video streams, including to the TV next to the router. Grrr ! I suppose its their goal is to get the customer back to sell another, more expensive, mesh wifi system which runs on stronger magic.

Sorry I’m not being helpful; but it sounds like you’re already trying what you can … short of upgrading to one of those expensive mesh systems :wink:

Is the pump house constructed of metal or brick or wood? Metal would definitely degrade the output of the ESP32 wifi signal. That yagi/directional antenna shown above would also be a great improvement over the small 3 dBi non-directional antenna.

Hi Fred,
The pump house has brick walls and wooden doors. The doors face in the general direction of the AP. Leaving the doors open doesn’t make any noticeable difference.

I also have an antenna this type on order:

I’ll try with that and see what happens. At least having a cable would allow me to move it around, see if I get better reception. If that still doesn’t help, I might try with a yagi.

Thank you
Christian

Hi all,
I thought I would post an update to help anyone else that might have the same issue.

Thank you @donburch888, @aruffell and @FredTheFrog for your input as well.

I was noticing on the WiFi router that the signal of ESP32 was very low, however the readings from the ESP32 was showing I could see the router ok.

I tried different antennas as per the suggestions above to no avail and turns out the issue had nothing to do with WiFi per se.

I am using a DHT22 to read temperature and humidity. I was power this from 5V, understanding that the ESP is 5v safe. However, for some reason this impacts the WiFi transmitter. I changed the supply to 3.3v to the DHT22 and this solved the issue.

I’m very curious to understand why, having 5v pulses coming to the ESP from the DHT22 was impacting the WiFi transmission power. If anyone knows, I would appreciate the detail.

Thanks again.
Christian

In some cases, cloned/knockoff ESP devices use a lower capacity DC regulator. These are not capable of providing the necessary milli-amps of current, when stressed. Being lower capacity and lower quality components, that stress limit is often significantly lower than the standard design. Using 5VDC from the ESP to power the DHT22 combined with the current draw from the WiFi circuit was possibly pushing the limits of the regulator, and the WiFi output suffered.

Hi Keith,
That was my concern when I did the original design, hence decided to power the DHT22 with 5VDC directly from the power supply to avoid the ESP regulator altogether. Now I moved the DHT22 to using the ESP regulator that provides the 5V to 3.3V step down and solved the problem.

The problem is somewhere else related to the GPIO receiving 5V pulses from the DHT22. Maybe this generates some sort of current drain that reduces the WiFi output.

Cheers
Christian

@chrisp250 What esp32 specifically are you using? Did you ensure that specifc model doesn’t have something that already uses one or more of the GPIO you used? There are online resources which say what pins to avoid and based on randomnerdtutorials.com you avoided them but I imagine there single table does not cover 100% of the esp32 models.

Edit: this would not explain why moving the sensor to 3V seemingly fixed the issue but I would consider it a more likely cause given the esp32 is indeed 5v tolerant. Did you change anything else?

I had checked the reserved pin list and it was fine. I also switch pins just in case, same result. I even switched ESP32s, same issue.

Here is someone else with the same problem:

Interesting… now that I think about it I too had some weird issues (supposedly unrelated to the sensor itself) that cleared when I added a level shifter. Maybe the ESP32 is 5V tolerant in the sense it won’t break, but it can malfunction… or maybe the latter is true when using a cloned ESP32. Anyway… good to know. Something else we can add to the list when troubleshooting.