This is my first question in this forum.
I'm a (total) beginner in electronics, and I have a question about my circuit.
I’m using a pH soil sensor (see link below) and an ESP32-C6 Zero.
In my code, the sensor takes a measurement, and then the ESP goes into deep sleep for 4 hours.
The sensor can be powered with 5V, which I get from the 5V output of the ESP32-C6 Zero.
Now to my probably stupid beginner questions:
I believe that even in deep sleep, the 5V output of the ESP still provides power, so the sensor keeps consuming energy even when it's not doing anything. Is that correct? Should I use a relay or a MOSFET between the ESP’s 5V output and the sensor’s VCC wire?
The sensor works with 5V, but the ESP’s logic level is 3.X volts. So I’m wondering: do the signal pins from the RS485 converter send 5V signals to the ESP’s TX/RX pins? Could that damage the board? Is this a problem? Should I use resistors to drop the voltage to 3.6V? (Actually, I’m not even sure if resistors can do that.)
Yes. Find out from datasheet or measure how much it's drawing.
You are correct with you concern.
You could power the RS485 converter from 3.3V pin and sensor at 5V.
Max485 is 5V chip but from my experience it works reliably powered from 3.3V.
Another option is level shifting.
Thank you for your reply!
I updated the diagram to check if I understood you correctly.
Now the sensor is connected to the 5V output, and the RS485 converter is connected to the 3.3V output.
However, since the sensor is still running on 5V, I'm wondering if the voltage going to the ESP is still 5V, even though the converter is powered with 3.3V.
Yes it is the way to go.
PS:
Sensors, if they are low-power devices, can be powered from ESP32 pin directly, but there is a limit of 20mA (which can be adjusted to 40mA). Your sensor spec says 0.5W at 24v so yes power MOSFET.
It's possible that the sensor goes into some low power sleep mode after some time with no communication from the RS485 bus.
It's possible there is a sleep command that can be sent to the sensor over the bus that will make it go into low power mode until the next communication.
If either of the above is true, it may not be worthwhile cutting the power using relays or MOSFETs.
If neither are true, remember that a relay takes a lot of power to switch on and keep switched on. That might outweigh any savings. A MOSFET would be more efficient.
I thought that using some kind of relay for power saving might be best practice.
Ideally, I’d like to supply power only through the USB port of the ESP board and use its 5V and 3.3V OUT pins.
I think you’re probably right — it doesn’t really make sense to worry about power saving, since the sensor doesn’t draw much current when it’s not actively working. And as another comment mentioned, it might even go into some kind of sleep mode on its own.
But what about the current? Is my calculation correct?
0.5W / 5V = 100mA - so the sensor would need 100mA.
And if the ESP board only provides 20–40mA, that wouldn’t be enough, right?
So I would need the MOSFET to switch an external power source — like a 9V battery — to provide enough current for the sensor?
The power draw at 5V is probably less than at 24V.
Anyway, Esp32 5V pin doesn't have current source limit like gpio pins have.
You can draw 100mA from 5V pin without worries.
If you power your ESP32 from USB, then it is ok to connect your sensor to 5v ESP32 board pin. ESP32 itself does not provide 5v. This 5v pin is connected directly to USB 5v line.
How do you power your device? Battery? USB?
If I were you I would measure sensor current (idle and active) to decide.
Thanks a lot! I'm still very confused about the terminology and often mix things up — for example, the specs of the different pins.
But yes, I understand now: the GPIOs are limited to 20–40 mA (with 20 mA being the recommended max), but that’s not an issue here, since the sensor is powered through the 5V OUT pin, not through a GPIO.
So I can remove the MOSFET, and I “only” need to figure out the resistor setup to make sure the voltage coming from the sensor or the converter doesn’t overload the TX/RX pins or the GPIOs of the ESP.
Thanks a lot — I didn’t realize that the 5V pin is directly connected to the USB power line and not provided by the ESP32 itself. That really helped clarify things for me.
I’ll be powering the device via USB, so it sounds like I can safely use the 5V pin for the sensor.
Thanks again for pointing that out!
Tomorrow I’ll be the proud owner of a multimeter — and then I’ll start measuring like crazy!
Thank you very much!
I think I still have the issue that the sensor, or the RS485 converter, outputs 5V, while the TX/RX pins and GPIO 1 can only handle 3V. So I think I need to do some level shifting. However, I’m not sure how to do that. Is it possible with resistors, and if so, what resistor values should I use, and where exactly should they go?
I’ve already tested the sensor a few times without resistors or a MOSFET (maybe about 30 measurements), and it worked without any issues. But I’ve heard that too much voltage could damage the pins.
Thank you, but since I don’t have much (any) experience with this, I’m assuming that when the sensor is still running at 5V like in post 4. I think these 5V would reach the converter and possibly be passed on to the TX, RX, and GPIO1 pins.
I’m probably wrong about that.