Great! I am glad I could help. We all are learning and it’s great to have a community to share our experiences/knowledge with other.
Thanks for this! Just waiting for my power shields and then I’ll build them!
Anyone tried adding a ds18b20 temp sensor to it? Just for the fun of it to get the interior car temp during winter to see if the heater is working
I had thought about that myself, but decided not to as I mounted all my units at within the engine bay to get a direct reading from the battery. My alarm keyfob also shows the internal temperature anyway, so I know its nice and warm/cold before getting in after a remote start.
Awsome, my old cars isn’t that fancy
I think I have some with 1.5m cables around here somewhere, will add one just for the fun of it. Should be fine to push through some grommet between the engine bay and the car. Will report back when it’s done!
Thanks for your code and advice.
Am I right that this is so the wemos d1 can wake up from deep sleep? (indeed mine with your ESPHome code goes to deep sleep but does not wake up)
Am I also right that it’s no longer possible to program the wemos d1 after that connection, at least not via USB?
Just want to double check before I solder the pins
Yes, that is so that the D1 Mini can wake up from deep sleep. I have two devices that use deep sleep and they have been working without any problem for at least 5 months. The D1 mini should wake up.
In order to upload any code OTA, you can stop deep sleep on the D1 Mini. See the deep_sleep.prevent and deep_sleep.enter below under the MQTT section.
esphome:
name: ${devicename}
platform: ESP8266
board: d1_mini
deep_sleep:
run_duration: 60s
sleep_duration: 60min
id: battery_deep_sleep
mqtt:
broker: 192.168.XXXXXX
username: !secret mqtt_username
password: !secret mqtt_password
birth_message:
topic: battery_voltage/topic
payload: online
will_message:
topic: battery_voltage/topic
payload: offline
on_message:
- topic: deep_sleep/ota_mode
payload: 'ON'
then:
- deep_sleep.prevent: battery_deep_sleep
- topic: deep_sleep/ota_mode
payload: 'OFF'
then:
- deep_sleep.enter: battery_deep_sleep
I have an input boolean in HA. When I turn it off, it executes an automation and script to send an mqtt message to turn off deep sleep on my devices. The next time the D1 mini wakes up or if I reset it manually, it will not go to deep sleep.
These are the automations:
##############################################################
# DEEP SLEEP FOR ESPHOME DEVICES
##############################################################
- id: TurnOffDeepSleepForOTA
alias: Turn Off Deep Sleep For OTA
trigger:
platform: state
entity_id: input_boolean.deep_sleep
to: 'off'
action:
- service: script.turn_on
entity_id: script.stop_deep_sleep_on_esphome_devices
##############################################################
- id: TurnOnDeepSleepForOTA
alias: Turn On Deep Sleep For OTA
trigger:
platform: state
entity_id: input_boolean.deep_sleep
to: 'on'
action:
- service: script.turn_on
entity_id: script.resume_deep_sleep_on_esphomedevices
These are the scripts:
####################################################################
stop_deep_sleep_on_esphome_devices:
alias: Stop Deep Sleep
sequence:
- service: mqtt.publish
data:
topic: deep_sleep/ota_mode
payload: 'ON'
qos: 2
retain: true
- service: notify.mobile_app_my_iphone
data:
title: Deep Sleep
message: Deep sleep turned off for OTA updates
####################################################################
resume_deep_sleep_on_esphomedevices:
alias: Resume Deep Sleep
sequence:
- service: mqtt.publish
data:
topic: deep_sleep/ota_mode
payload: 'OFF'
qos: 2
retain: true
- service: notify.mobile_app_my_iphone
data:
title: Deep Sleep
message: Deep sleep turned on
####################################################################
Of course, you could have them combined instead of separated in automations/scripts.
I would not solder anything until you have tested that everything is working.
I hope this helps.
Thanks a lot for the explanation and all details
Will d1 mini run if i use one 1.5M ohm resistor instead of 1.44M ohm resistor one 1M ohm+220k ohm is it not 1,22MOhm?
The D1 mini has a built in 220k , so in total you’ll get 1M + 220k + 220k = 1.44M
I can’t see why it would not work, the idea of the 1.44 was that it would handle up to 16V input without burning the A0.
Thx did order som resistors whit 1m ohm and 220k ohm did not have so hi resitors home. Have 3 sensors 2 in cars and one in the caravan and it works perfect
Does anyone with better knowledge than me , know why after changing from my isp wifi and changing to unifi equipment (yet another rabbit hole) the D1s dont always connect to report the voltage. They worked 98% of the time before. I have created a 2.4 access point just from my Home automation, and used a new SSID, and re-flashed the D1s with the new details. When they do connect they have very good signal strength. One of my cars has not reported back now in 2 days? I am thinking it must be down to the unifi setup, but I have no issues with anything else (The D1s have static ip in the programming).
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).
I’m using ESPHome on the ESP and this is how I have the sensor setup.
# VCC input voltage
- platform: adc
pin: GPIO36
name: "BigBlue Battery Level"
update_interval: 10s
filters:
- multiply: 10.90909090909091
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 don’t get why…
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.
Hopefully your ADC was not damaged already.
If I measure the voltage between A0 and GND I get just over 3.3v.
The ESP32 doesn’t have a pin called A0. I suspect you have a ESP8266. ESP32 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials
Also the pics I can find of the ESP32 D1 mini doesn’t show any pin labelled A0.
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.
Where is that documented?
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.
Can you draw it and post the circuit diagram? Just pen, paper and a cellphone pic will do.