Live data from Hacker News

Building an occupancy sensor with a $5 ESP32 and a serverless DB

matthew.science

21–30 of 221 posts

Re: Building an occupancy sensor with a $5 ESP32 and a serverless DB

#21
Awesome write up, I liked how accessible the writing is, as well as the fun tone.

I have a problem where I will need to monitor the soil moisture of 20 trees in San Francisco. My current thought is to strap an ESP32, Lora module, battery, and capacitive soil moisture sensor and to send data once every 6 hours or so.

I was wondering if off the cuff you have any suggestions or pointers on how to best approach this. Thanks and once again, thank you for sharing this!

Re: Building an occupancy sensor with a $5 ESP32 and a serverless DB

#22
post #21

Awesome write up, I liked how accessible the writing is, as well as the fun tone. I have a problem where I will need to monitor the soil moisture of 20 trees in San Francisco. My current thought is to strap an ESP32, Lora module, battery, and capacitive soil moisture sensor and to send data once every 6 hours or so. I was wondering if off the cuff you have any suggestions or pointers on how to best approach this. Tha…

Do you need an ESP32 vs an 8266? I believe the 8266’s are more energy efficient.

In either case, you can put them in a deep sleep that uses minuscule amounts of energy and can wake back up on a timer. I’d start there.

Re: Building an occupancy sensor with a $5 ESP32 and a serverless DB

#23
post #22
post #21

Awesome write up, I liked how accessible the writing is, as well as the fun tone. I have a problem where I will need to monitor the soil moisture of 20 trees in San Francisco. My current thought is to strap an ESP32, Lora module, battery, and capacitive soil moisture sensor and to send data once every 6 hours or so. I was wondering if off the cuff you have any suggestions or pointers on how to best approach this. Tha…

Do you need an ESP32 vs an 8266? I believe the 8266’s are more energy efficient. In either case, you can put them in a deep sleep that uses minuscule amounts of energy and can wake back up on a timer. I’d start there.

I think I am largely MCU agnostic, although preferably something where I can use Arduino since I am familiar with that. Good to know that ESP8266 is more energy efficient. I have seen this video which demonstrates that the ESP8266 can run off 2 AA batteries for 425 days [1].

Another thought I was having was to write a mobile app that as volunteers walk by the sensor would send data to their phone, which would then forward it to my backend. I suppose this is a mesh network of sorts? Not sure if this is feasible or a good idea though :/

[1] - https://youtu.be/IYuYTfO6iOs?si=oLuJiGxdQ8VHyu29&t=837

Re: Building an occupancy sensor with a $5 ESP32 and a serverless DB

#24
post #21

Awesome write up, I liked how accessible the writing is, as well as the fun tone. I have a problem where I will need to monitor the soil moisture of 20 trees in San Francisco. My current thought is to strap an ESP32, Lora module, battery, and capacitive soil moisture sensor and to send data once every 6 hours or so. I was wondering if off the cuff you have any suggestions or pointers on how to best approach this. Tha…

There are esp-lora boards including lipo power management you can start with.

The ESP has a few deep sleep modes, and there's a lot you can do to optimize them.

I highly recommend Andreas Spiess on youtube.

EDIT: Heads up that moisture sensors have reliability issues, Andreas's video 463 talks about them.

Re: Building an occupancy sensor with a $5 ESP32 and a serverless DB

#25
post #21

Awesome write up, I liked how accessible the writing is, as well as the fun tone. I have a problem where I will need to monitor the soil moisture of 20 trees in San Francisco. My current thought is to strap an ESP32, Lora module, battery, and capacitive soil moisture sensor and to send data once every 6 hours or so. I was wondering if off the cuff you have any suggestions or pointers on how to best approach this. Tha…

If it is only 20 trees, you could use off the shelf sensors.

Its much better and cheaper to design from scatch, use an $0.04 ultra-low power Arm microcontroller with ADC or a Padauk, add a single layer pcb with two well proportioned pcb traces in a plastic bag as a capacitive moisture censor (better than resistive sensor) and a $0.12 solar cell or rechargable battery. Single sensor cost around $0.41 excluding labor, mass produced $0.08 including labor and sensor network

Re: Building an occupancy sensor with a $5 ESP32 and a serverless DB

#26
post #21

Awesome write up, I liked how accessible the writing is, as well as the fun tone. I have a problem where I will need to monitor the soil moisture of 20 trees in San Francisco. My current thought is to strap an ESP32, Lora module, battery, and capacitive soil moisture sensor and to send data once every 6 hours or so. I was wondering if off the cuff you have any suggestions or pointers on how to best approach this. Tha…

There are esp-lora boards including lipo power management you can start with. The ESP has a few deep sleep modes, and there's a lot you can do to optimize them. I highly recommend Andreas Spiess on youtube. EDIT: Heads up that moisture sensors have reliability issues, Andreas's video 463 talks about them.

So my thought was to utilize the capacitive soil moisture sensor and then coat the sides of the PCB with a waterproofing epoxy as Andreas recommended. My hope being that even if it craps out, I can just swap out the sensor, and since they are so cheap it won't be a big deal.

Also, great to know that there esp-lora board w/ lipo power included!

Re: Building an occupancy sensor with a $5 ESP32 and a serverless DB

#27
Interesting DIY project! It reminds me of a startup called OccuSpace (https://occuspace.io/), which offers a similar occupancy solution but as a service. They may be leveraging similar technologies to provide real-time occupancy data, which is incredibly useful for managing space in offices, public venues, etc. It's a good example of how these concepts are scaling up commercially.

I wonder How well can your DIY sensor or OccuSpace figure out what kind of devices are in the room or who's using them. Can they tell different users or gadgets apart?

Re: Building an occupancy sensor with a $5 ESP32 and a serverless DB

#28
post #23
post #22

Earlier quoted context omitted.

Do you need an ESP32 vs an 8266? I believe the 8266’s are more energy efficient. In either case, you can put them in a deep sleep that uses minuscule amounts of energy and can wake back up on a timer. I’d start there.

I think I am largely MCU agnostic, although preferably something where I can use Arduino since I am familiar with that. Good to know that ESP8266 is more energy efficient. I have seen this video which demonstrates that the ESP8266 can run off 2 AA batteries for 425 days [1]. Another thought I was having was to write a mobile app that as volunteers walk by the sensor would send data to their phone, which would then fo…

Another option would be LoRa - it’s pretty long range. The problem would be that could add a lot to power usage. Though 6h should be plenty of time - wake up, send a small packet, sleep for 6 hours.

You would have a central LoRa receiver in a place that can reach all of the sensors. How far apart are the trees?

Other than that, I would suggest testing out lots of different hardware. I bought several different boards before any decisions were made, and I’m glad I didn’t stick to just one. Costed me maybe $30 to buy a gamut of devices and now I’ve settled on a single one that does what I need.

Also, make sure you’re flashing with the largest image size you can, if your code becomes too large. For me I had to enable an option in the board settings to use the full memory space.

Lastly, one thing you should do is the low power option. See which board supports it the best. Then, what I would do at startup is turn on all the sensors, collect and send data right away, then turn all your sensors off. Do ultra deep sleep for 6 hours. then when it wakes up, don’t bother doing any kind of loop to the beginning - hard reboot. That avoids any problems with memory allocation becoming too large somehow over the course of the program, since it always starts fresh (which is all you need!). I’m not sure the trade off here but for me, I reboot every 12 hours and it works great. (I would do it after every scan but I don’t delay between scans for more constant data, so it would be a lot of set up every single minute).

Re: Building an occupancy sensor with a $5 ESP32 and a serverless DB

#29
post #25
post #21

Awesome write up, I liked how accessible the writing is, as well as the fun tone. I have a problem where I will need to monitor the soil moisture of 20 trees in San Francisco. My current thought is to strap an ESP32, Lora module, battery, and capacitive soil moisture sensor and to send data once every 6 hours or so. I was wondering if off the cuff you have any suggestions or pointers on how to best approach this. Tha…

If it is only 20 trees, you could use off the shelf sensors. Its much better and cheaper to design from scatch, use an $0.04 ultra-low power Arm microcontroller with ADC or a Padauk, add a single layer pcb with two well proportioned pcb traces in a plastic bag as a capacitive moisture censor (better than resistive sensor) and a $0.12 solar cell or rechargable battery. Single sensor cost around $0.41 excluding labor,…

That's a great point. I have experience w/ Arduino and have made a carrier board one time [1], but am not familiar with full custom PCB + MCU designs. Do you have any suggestions on where to get started for someone with my medium level of experience here? And also, how difficult would you anticipate a custom MCU to be?

[1] -- https://zachbellay.com/projects/odaf/#iteration-3-phase-2-wi...

Re: Building an occupancy sensor with a $5 ESP32 and a serverless DB

#30
post #21

Awesome write up, I liked how accessible the writing is, as well as the fun tone. I have a problem where I will need to monitor the soil moisture of 20 trees in San Francisco. My current thought is to strap an ESP32, Lora module, battery, and capacitive soil moisture sensor and to send data once every 6 hours or so. I was wondering if off the cuff you have any suggestions or pointers on how to best approach this. Tha…

check this out

https://dynamax.com/products

Post reply on HN