Hi, is there anyone out there using a ESP32 board and HC-SR04 sensor running on batteries?
I implemented this little project to detect if the car is in the garage. I’m using a 4 AAA battery holder to provide the power.
It works fine EXCEPT the batteries seem to drain very quickly (dead in about a day).
Is anyone using the project for a similar purpose and running on batteries?
What’s your experience with the battery life?
Thanks.
Are you putting the ESP to sleep at all?
Wifi draws quite a bit of power if left on.
Assuming your 4 series AAA batteries have a 1200mAh capacity, lets be generous and say the ESP draws on average 120mA (can be up to 300mA 400mA spikes) then that will last:
1200mAh / 120mA = 10 hours.
If you put the ESP to sleep it will draw about 5µA.
So that is 1200mAh / 0.005mA = 27 years asleep.
Of course it would be completely useless if it never woke up so you need to define how often you want it to wake and how long for vs how long you want the battery to last.
Yeah, I’ve been reading up on putting it to sleep but if I put it to sleep for 5 minutes then it’ll take a long while because by then, the car sensor is probably picked up that the car is already gone.
I was hoping to use it to detect the car is in the garage do the door won’t close automatically.
Can’t you wire the sensor to a hardware interrupt to wake it up? I haven’t played with putting ESP’s to sleep but I thought this was possible.
EDIT:
Of course, I was just demonstrating the lifetime at the two extreme ends of the range, always awake vs always asleep.
Though an interrupt with a HC-SR04 might be a bit tricky as it relies on being powered to measure.
@bevanting so no power outlets in your garage at all?
Yeah true… probably chomps a bit of power to leave that on all the time too.
Yes I have power outlets but as I’m trying to determine if the car is in garage or not, I thought I would place it near the garage door so that the car has to be completely out of the garage (instead of placing it at the other end of the garage, and then if I backed the car out just a little bit just to get something from the front of the garage, the sensor shows no car and the garage door then automatically closes ).
But close to garage door I have a challenge to place the sensor where the power outlet is…
So have to think about it more.
Hardware interrupt seems like a good idea but that means more wiring (and think of something to wake the thing up) and as Tom said, it’ll need being powered to interrupt. I’m a software guy more than hardware guy hence I can’t even work out how to calculate how long the batteries last!
I guess the other option is to use rechargeable batteries.
I currently have 3 sensors: 1 for distance, 1 for wifi signal and 1 for uptime.
Do you think if I delete the other two sensors (wifi signal and uptime), it’ll use less battery power?
Break-beam sensor across the door?
That’s getting too high tech. This is supposed to be a small project!
I think I’m going to have to run “hidden” extension cords etc and use power outlets for this.
Thanks for all the suggestions, everyone.
I question why use batteries at all if a power source is in the same room but, who cares what i think…
If your just need something that will detect if the car is in fhe garage, there’s a strong argument for not even needing rhe HC-SR04 and the esp32 attached to it, its all quite overkill IMO and especially if it needs battery powered.
If your open minded, give these a thought.
Put a BT beacon in the car or on the keychain and you now know if the car is in there, it also serves as a presence detection method and you get the bonus of never losing your keys because you can track it from your phone or in HA dashboard. Heres a keychain beacon of mine for example. I lnow which room its in and how far it is from the esp node in that room.
Depending on how much your into doing DIY, something as simple as triggering an RF transmitter to send an On/Off state change. How you do that just depends on how much or little DIY spirit you want to put into it.
Id just do BT beacon honestly. You get a bunch of extra bonus uses and the batteries last like 15-20 months.
Im a big supporter of this person and you can find them in here and actively helping people that may need it. See if you get that kind of customer support on Aliexpress!
Like I said before, power outlet not close to where I want to place the sensors hence I thought I’d use batteries so it’s portable.
Anyway, I already use BT beacons in my cars. In fact, I use two per car to cut out the false positives and quicker response times but still, they still flip to “not home” from time to time hence I thought I’d use these sensors to make the auto close automation algorithm more robust.
Doesn’t matter now, I’ve called my electrician to come run some cables…won’t be using batteries anymore.
I had investigated the blue charm beacons before and I’d love to buy some but it’s super expensive to have one ship to Australia and I need two of them.
My idea would be to mount 2x VL53L0X LiDARs or LD2410 mmWave radars on the roof, and use deep sleep to wakeup every 2-5 minutes. If the cars are close enough, you can probably use 1 esp and 2 sensors pointing to either side.
You can also probably use a generic HC-SR501 PIR sensor as trigger as the cars moving should produce enough IR to trigger it. Just tune the sensitivity and timeout. For example, set the timeout to around 2 minutes, and when the PIR no longer detects a movement, start the power-hungry Sonar/LiDar/mmWave sensors. This is also what I have been doing in my battery-powered human presence sensors.
Avoid using wifi because it consumes a lot of power. I’ve tried using ble broadcast from esphome and it works really well. It does depend on which variant of esp being used tho. I have a esp32c3 super mini that has an external antenna, and it works really well.
Wow that’s interesting. But wouldn’t the PIR be triggered when people walk under it too? Also wouldn’t the PIR need to be “awake” to detect movement?
I cannot afford to have it wake up every 2-5 minutes. If I did that I might as well use voice command to close the garage door, then what would be the fun in that?
I’ve always used wifi for my esp because it allows me to access and control them etc. Can you do that (eg update ESPHome firmware) if you only connect via BT?
Sorry if this sounds stupid, I am not an electronics person so I’ve just followed other people’s instructions, got the necessary components, put them together and just got it to work and then start tinkering a bit to try and understand how it works.
The PIR needs to be awake, but the power draw is negligible. My PIR + low-power mmWave + esp32c3 deep sleep setup just consume 0.6-0.9 mA at idle.
Yes it would trigger when people walked under it. But it would be way better, as the frequency of people walking under it would be lower than waking it up every couple of minutes. It just serves as a wake-up, and the actual car detection is done by something else. The thought is that, there has to be people moving for the car to get out
You cannot update the firmware over BT. At V1 of my sensor, I use a hidden reed switch and a magnet to tell the esp to connect to WiFi next time it wakes up.
At V3 I just skipped that entirely. If I need to change the configs I just compile the firmware and upload it with esphome web and a usb cable.
From my experience, I don’t need to change the configs in V1 after 2 days of deployment. If it works, dont fix it.
Pir comes from passive infrared, in theory it doesn’t need to be powered and it’s often used to wake up other electronics from sleep. Battery operated wifi “security cams” for example. In practice ready made pir modules draw little bit current, but it’s usually next to nothing.
My left garage is such that the left passenger needs to get out before the car goes in. So if the sensor is at the roof it’ll detect the people walking in / out the space.
If I use the ultrasonic sensor, it’ll be mounted on the side wall and I can control the distance it detects. Practically no one would walk that close to the side wall so the only thing it’ll detect is basically the car.
My use of Bluetooth beacons actually works quite well with ESPresense, but from time to time, it flicks over to “not_home” and I don’t know why (one of beacon’s range is actually quite far - goes all the way to the street). So I want to use this extra sensor to verify that the not_home is real.
Bonus with this is I can now tell if the car is “outside” or not.
So you have few options. Either you adjust sensibility and orientation of that PIR sensor the way it doesn’t detect people OR you use PIR only to wake up your ultrasonic sensor from sleep. Using only ultrasonic 24/7 would drain your battery quickly.
Some ready built battery operated sensor would be an option. I have Shelly Blu Motion, it has years of battery life with single (thick) coin cell.
Thanks for the suggestions.
Thats why I was suggesting the use of PIR to wake the esp up to do the actual distance detection. The distance detection can be ultrasound, LiDAR, mmWave, you name it. The PIR is there just to make sure it only wakes up when it needs to.
You can set the sleep time to be very long (e.g. 30m or even 24h) and just rely on the PIR to wake it up.
Oh…I see your point now.
So all I have to do is wire up the PIR using the other pins on the ESP board and add those pins to the configuration file and that’s it?
That’s a great idea! Thanks!