For pool temperature I just use a yolink outdoor sensor. It’s a LoRa so the distance is great and its battery powered. I have the sensor mounted in my skimmer and the hub sits in the basement and integrates easily with my HA. It is cloud connected but my pool temp is not a critical service for me.
You don’t need elaborate variant of the ESP32 for the project as described. The one you chose is perfect.
Please note that the ESP32’s operating voltage is 2.7V ~ 3.6V, therefore you will need to step down the PSU (Power supply Unit) to attain this voltage range.
This is done using a ‘Level converter / shifter’, with your 5V PSU. This can be ordered cheaply from Amazon or any other electronic distributor.
( Word of caution…, Please ensure to check the output voltage of the level shifter before plugging it into the ESP32, it must be within the operating range of the ESP32)
For a PSU, I would suggest you purchase a simple USB wall charger with Micro-usb to USB cable. The cable will also serve you to initially flash the ESP32 from HA.
I can not power my ESP32 dev kit is via the USB port ? I was thinking to use a standard 5 VDC power supply, connected trough micro USB port from ESP. I need also to use the Level converter ? This version is right one ?
I also saw this part on some tutorials. I guess makes same thing but connecting to 5V and GND ?
Yes, you power your ESP32 ‘Dev’ board via the USB port on the PC, in this case the level shifter is already integrated on the board and therefore not necessary. To clarify, my assumption from your initial question was the you were using a bare ESP32 board in this case you would require the level shifter to power the ESP32 board.
Assuming that your plan is to use your ‘Dev’ board for the final product (which is perfectly reasonable…) then you don’t need to purchase the level shifter.
PS. the first level shifter you reference is perfectly good for the bare board application. Your second option is over kill (6Amp), as its current rating is overkill for your application.
Hello, i just installed the sensors on esp32 and link to HA. seems to work fine. Even tho in the connection says to use an 4,7 resistor, i just used the plug attached.
Next plan is to command a relay, that will power on the hot water pump. I want to make a condition, that when water in the heat system is hotter with 30C, than pool water, pump will start. Is this possible? Is it safe to use 5V / 220v relays with esp32 board ?
This would be this model:
I also can use some sonoff basic relays, in order to stop/ start the poll pump. Is more safe than regular relays ?
‘’ Next plan is to command a relay, that will power on the hot water pump. I want to make a condition, that when water in the heat system is hotter with 30C, than pool water, pump will start. Is this possible? Is it safe to use 5V / 220v relays with esp32 board ? "
Yes, it’s certainly possible, although it’s advisable to isolate the relay from the ESP32, through the use of a transistor and/or an opto-isolator ( as shown below).
The link you provide to the relay module with Optocoupler should work, as it already has an opto-isolator which will decouple the 3.3V from the 5.0V coil supply used to energize the relay.
Note: given that you are driving 220VAC, it is critical that you exercise care when working with the switch side of the relay, and that the relay is rated appropriately for the current the the pump will draw.
Typical relays are rated between 10-15 Amps, however check your pump to establish its current requirement
The circuit below explains how it works:
When the output of the ESP32/MCU (GPIO pin) goes high i.e. 3.3V this will activate D1&Q1 (Opto-isolator, note that this is powered by 5V supply). This will put a high (5.0V minus drop across R2) at the base of transistor Q2, which will in turn energize Q2 and the relay (also powered by 5V)
Great explanations again !
As i fail to completely understand the separate relays in esp32, i played with some SONOFF r2 relays i already had in pocket
I was able to power on / off the plug depending on temperature i set based on sensors, but i could not make A RELATIONS between them. So i could not say like: When sensor_1 is above 30C than sensor_2 → power on plug
This is a condition i would like, so depending the temperature in the pool and heat system, this will run or not.
Yes, it’s sometimes difficult to understand what the Yaml is doing, so I’ll try and give you an example related to your temperature sensor used with binary sensor (threshold) that controls the switch component to switch the relay on or off.
In your case, I would use the Analog Threshold binary sensor sensor. In your Yaml code, I would insert the following where the trigger threshold is set to 30 deg:
switch:
- platform: gpio
pin: GPIO35 # Choose which output pin the relay is connected to.
id: relay_status
inverted: false # You may need to change this to false depending on your logic
name: "Relay Status"
# Defines the ESP32 pin the Dallas Temp sensor is attached to.
dallas:
- pin: GPIO34 # Choose which input pin the temp analog signal is connected to.
# Individual sensors
sensor:
- platform: dallas
address: 0x1c0000031edd2a28 # If you have multiple sensors the address will need to be different for each sensor.
name: "temperature_sensor_1" # The name used is linked with the binary_sensor below.
binary_sensor:
- platform: analog_threshold
name: "Pump controller"
sensor_id: temperature_sensor_1
threshold: 30 # Set this to the temperature you want to turn on/off the pump.
on_state:
then:
- switch.turn_on: relay_status # If temp above threshold the relay will either be on.
off_state:
then:
- switch.turn_off: relay_status # If temp below threshold the relay will either be off.
Note that for the Analog Threshold binary component, there are upper and lower limits that can be set independently.
The comments in the code should help you understand the relationship between the sensor(s), logic and switch.
Hi,
For sure i will test this configuration. I’m missing tho the logic.As above obly one sensor is used , so how i will measure my pool temperature ?
Basically in my automation, i want to have:
Sensor 1: introduced in the pool
Sensor 2: introduced in the inflow pipe of the solar heating system. This will measure how hot the water from solar system got.
Condition:
When sensor2 is 30C + sensor1 temperature > Pump stat ~> water will get to be pumped in the pool. I want to start the pump only when temperature from heat system is hotter with 30 C than actual pool temperature
You defined the temperature sensor(s) as input(s) to the system each assigned their own unique addresses. You also defined the relay by id (relay_status) as the output from your system.
The logic is controlled by in original case, the analog threshold binary sensor. Where if above the 30deg threshold, turns the relay with id (relay_status) ON, and OFF when the water temperature falls below the 30deg threshold.
You may discover that you need to have different upper and lower bounds for temperature in the logic, otherwise your pump may oscillate when the temperature is close to your target. (see the previous link to the documentation for guidance)
New Case:
Sensor 1: introduced in the pool
Sensor 2: introduced in the inflow pipe of the solar heating system. This will measure how hot the water from solar system go
In this case you need to define two temperature sensors. Refer to the documentation on the “Getting Sensor ID’s” section of the Dallas Temperature Sensor
The switch component will remain as before, this defines the output that controls the relay.
The binary sensor logic will be per below (note that I haven’t tested it so you will have to do this…)
binary_sensor:
- platform: analog_threshold
name: "Pump controller"
sensor_id: temperature_sensor_1
threshold: 30 # Set this to the temperature you want to turn on/off the pump.
on_state:
then:
- if:
condition:
lambda: id(temperature_sensor_1).state + (id(temperature_sensor_2).state if "temperature_sensor_2" in locals() else 0) > 30
then:
- switch.turn_on: relay_status
else:
- switch.turn_off: relay_status
@GavinCampbell - you still recommend YouLink for getting Pool Temp into HA? (I’m happy to pay a few dollars more to make it easier I think) Does it integrate directly/easily into HA?
This is an awesome solution, even if cloud only at the moment. I do see local access to the hub as coming feature in their Dev’s reddit posts. I very much like the idea of battery powered DC around the pool versus a mains based transformer - you can get pool UL/CA approved safety (where a fault is protected from shorting over to the low volt side powering pool sensors) transformers but they are pretty pricey.
They actually have a pool temperature device as well as soil moisture and temp sensors which I also utilize. Its RF and all local. You just need their device and their gateway and you can tie it into HA nicely.
I have both Ecowitt and YoLink and utilize them for different things. In the pool I put one in the skimmer and one at the ladder as an experiment to see if the temp is different. But both of them report the same temperature so that is a good thing.
You can leave the sensor box out in the open. I have one located in the skimmer (its mounted to the side and the probe is in the water) and another on the ladder (mounted on the ladder in the open and probe in the water).
I mainly did this as I wanted to see if their is a difference in temp, but surprisingly they both measure the same temperature so I’m just going to keep the skimmer one next year.