Live data from Hacker News

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

matthew.science

31–40 of 221 posts

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

#31
Cool!

I didn't totally follow the issues with keeping the data in memory, and it sounds like it is solved now - but you could probably use a cardinality estimation algorithm to estimate the number of unique beacon IDs while only using constant space. https://en.wikipedia.org/wiki/Count-distinct_problem

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

#33
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,…

I designed my own chip for €,03 , a 180nm 8 core microcontroller with builtin moisture and other sensors. Minimal volume is 800.000 chips.

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

#35
post #23

Earlier quoted context omitted.

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…

The trees are all pretty close to each other, about 3-4 city block radius (map of trees [1]). The issue is that as far as I can tell there is no existing LoraWAN gateway on The Things Network I can tap into [2], which means I will have to setup my own gateway. Which is fine, but it may prove to be difficult to get this onto a tall building since I am just an apartment dweller. At the very least I can put the gateway in my apartment window.

[1] -- https://www.google.com/maps/d/u/0/viewer?mid=1e7K_VdEEYkxuAy... [2] -- https://www.thethingsnetwork.org/community/san-francisco/

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

#36
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…

Either a dfrobot: https://www.dfrobot.com/product-1385.html or M5Stack: https://shop.m5stack.com/products/earth-sensor-unit https://shop.m5stack.com/products/watering-unit-with-mositur...

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

#39
> and heap thrashing since we're allocating and deallocating the result structure every single callback.

This should not an issue. It is entirely possible to write this without any dynamic allocation (other than stack) at all, or it could be done be done with an arena. Consider with something as powerful as an esp32 a hash table is not even strictly necessary, surely for a single purpose use case like this.

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

#40

Cool! I didn't totally follow the issues with keeping the data in memory, and it sounds like it is solved now - but you could probably use a cardinality estimation algorithm to estimate the number of unique beacon IDs while only using constant space. https://en.wikipedia.org/wiki/Count-distinct_problem

That’s a really good point. I’ve been meaning to go to a football game recently and bring it, to stress test it with the largest gathering I can quickly access. If it can easily scan a couple thousand without a sweat, I’d consider it pretty solid anyway. But a fixed-size estimating data structure would be really cool to research. I will surely look into it, thank you for the suggestion!

Side note: Definitely one of my favorite parts of this project, that I get to investigate more in-depth and interesting CS concepts without having to worry about doing the easiest solution. I’m scratching an itch, not developing a solution to deliver ASAP.

Post reply on HN