I’m struggling here. I can’t get the voltage multiplier to work correctly.
I am using a ESP32 based D1 Mini as I need a more powerful ESP for a GPS sensor. I created a resistor for 1.46M ohm (as that’s the closest I could get to 1.22M with the resistors I have. I have the resistors connected to the Voltage input from the DC power shield to the A0 pin (on the ESP32 that’s GPIO36).
The issue I am having is that the voltage is always 12v. I’ve got the ESP connected to my bench power supply and if I up the voltage to say, 14v, the sensor still shows 12v.
I tried adding attenuation to the config, as on the ESPHome docs it mentions there is a limit on the ESP32 but this didn’t make a difference other than increasing the voltage to 24v and 42.55v on the sensor.
ESP32 Attenuation
On the ESP32, the voltage measured with the ADC caps out at 1.1V by default as the sensing range or the attenuation of the ADC is set to 0db by default.
To measure voltages higher than 1.1V, set attenuation to one of the following values:
0db for a full-scale voltage of 1.1V (default)
2.5db for a full-scale voltage of 1.5V
6db for a full-scale voltage of 2.2V
11db for a full-scale voltage of 3.9V
I took a quick look at the esp32 d1 mini datasheet and it doesn’t look like it has a voltage divider.
If I remember corretly, the ESP32 ADC can read up to 3.3v so anything above 3.3v will always give the max value ( 12v in your case). Try to feed it something between 0 and 3.3 volts and see if you the readings go up and down with it.
It doesn’t, it’s GPIO36. The D1 mini esp32 has the same layout as the esp8266 version, just with extra pins. In esphome you can still use the esp8266 names.
I’ll try and find it. But either way I’ve tried it with both GPIO36 and A0.
The issue, as MrDIY stated above is that the ESP32 version doesn’t have the voltage divider. I created one using resistors between V in and GND and coming off the middle of the string to the ADC pin. This was 2.4v.
I was getting a voltage reading in ESPhome however the value was jumping around and didn’t seem to work correctly.
I still don’t see that the esp32 d1 mini exposes GPIO36. At least not on the pic I posted above, or in the github schematic that @MrDIY posted. In fact the schematic shows it a not connected.
What is the label that you have this actually connected to?
I do acknowledge that there are plenty of inaccurate schematics and pictures online, perhaps show us a pic of your device if you think it is different to what @MrDIY and I have posted.
That is good - you should get 2.4v. Using these resistors you can feed A0 directly into the ESP32 IO36 for 12v batteries.
I suspect your esp32 got damaged when you fed it the 14-20v earlier. Try to use your power supply and feed the esp32 0-3.3 volts and check the ADC values. If that is not working try another esp32.
This seems to be what they are labelling as “SVP” on the D1 mini esp32 boards. So you are right, it is GPIO36 and the labelling fooled me. Makes sense now I know SVP stands for sensor_vp.
You live and learn. Thanks for the pinout pdf, I have 6 of these devices sitting in a drawer, and that will be handy.
I have stumbled upon this excellent topic on creating a voltage sensor for - actually anything.
Newbie in HA and ESPHome.
Having a problem getting the above accepted in my configuration.yaml file.
Hellis81, thank you for your reply.
Picked it up just now. This has been greying my last brown strands of hair.
Also swapped state_topic & name:
Validates!!