WiFi-automation directly on ESP-device

Hey guys,

my current project is a “climate automation” for my dog box in my car (my car provides its own WiFi). So it has WiFi but no internet access. My plan is that the ESP8266 is in deep sleep for 60 seconds, wakes up to check if the WiFi SSID is available. If it is available => do the automations. If it is not available (or not available anymore because the car was shut down) => go into deep sleep mode and check the availability after 60 seconds again and so on.

My question is: Is it possible to make the deep sleep depending on the WiFi availability? How would I implement this in the ESPHome YAML?

Thanks and best regards
Stefan

There is no wifi connected trigger available in ESPHome so you have to use polling. e.g.

interval:
  - interval: 1s
    then:
      if:
        condition:
          wifi.connected:
        then:
          - switch.turn_on: blue_led
        else:
          - switch.turn_off: blue_led
1 Like

I have no idea, if or how this could be made in ESPHome.

But I’d offer another solution: use a Shelly UNI. There you can measure the actual voltage in the car, to determine if it is running or not. It would just change the trigger. :slight_smile:

Actually interesting idea! :thinking: As my battery shows 12,3 V in standby and something like 14,3 V in running mode, how is the behavior with hot / cold temperatures or longer standby times?

If the battery charging is temperature compensated it will charge to a higher voltage in colder weather.

Why not just monitor the accessories circuit. This will be 12v (nominal) when the ignition is on and disconnected when the ignition is off. You should be able to pick up a circuit in the fuse box.

In fact, if you power the device from the accessory circuit (via a suitable voltage regulator) you don’t even have to worry about deep sleep or the device running your car battery flat.

If I understand it right, it’s more for the trigger purpose. If it is a dog ventilation system, it should run, after the car is turned off, but that needs power for the ESP and the vents. :slight_smile:

The Shelly UNI does have an ADC and two controllable outputs (I hope that’s the correct term). That should work great for this use case, at least I had it up on my list to make exactly that for my dog (the one in the avatar). :slight_smile:

With the ADC I can measure the battery power and send it to HA (this part I’m actually doing for a few months now, works great). And the two outputs can be controlled, that’s ideal for a relay to run seperate vents. And on top of all that the UNI is able to handle three temp/humidity sensors as well. :slight_smile:

While running, if you see a difference, go check your alternator and/or battery, one of them is clearly going out of business. :smiley: While not running, the voltage drops, the longer it is not used. That can go down to 11.7V where most cars bail out and won’t start.
As I said, I’m using the UNI as a battery monitor with HA connection, worked great over the colder months. :wink:

First: As I just finished my PCB I won’t use the Shelly hardware. I have some voltage sensors laying around so I could use one of them to read the battery level.

I should say one more thing: I’m powering the whole device via USB port in my trunk.

So this would not work since the USB port is powered even when the car is turned off - that’s why I thought of using the deep sleep.

I’m not quite sure about that. Let’s say I drove outside with my dog for a walk (in the summer / winter). For the let’s say two hours of walk the device and ventilation system can run, yes. But it needs to be turned off when I’m back in the garage, otherwise the battery won’t last very long.
That’s why I just want to turn it off after the car is off and turn it back on when the car is on.

My device won’t have internet access - how should I send the data to HA? And why should I use this “sending data in a circle” when I could implement the automation directly on the device?

I really think it might be easier to code this by myself, especially when the battery-voltage / its charging really depends on the temperature… I could store the data in the EEPROM, but I also don’t find any EEPROM support in ESPHome.

I really like the idea of checking a change in the supply voltage but I’m struggling with the implementation! :smiley: