19 ms·
Building an occupancy sensor with a $5 ESP32 and a serverless DB
- ezconnect 3y agoHe could have just placed a microphone and correlate noise to occupancy level.
- sodality2 3y agoI cannot measure that from a closed dorm room, also plenty of environmental noise in empty rooms or silent, full rooms (during finals!).
- filterfiber 3y agoThis is an excellent write up! > Seeed Studio XIAO ESP32S3/C3, WaveShare ESP32S3 Zero, Unbranded ESP32-WROOM with OLED, Orange Pi Zero W (untouched), Raspberry Pi Zero W (L->R, T->D) After testing all of these, the only one reliable to work for long periods of time (one month currently) was the XIAO ESP32C3/S3. I suspect they may be having power issues? For the ESP32's specifically I highly recommend adding a beefy capacitor over the power rails, as those can be rather sensitive to voltage fluctuations especially when transmitting. Both the RPi and ESP's can be finicky depending on the power supply/cable/cable length too, and the RPi's sdcard does tend to fail from sudden power loss. They should all be capable of at least a month, my pi's and esp's have gone several months. I'd be curious to see the results from other ESP32's (or even the pi) with a larger capacitor added.
- sodality2 3y agoIt’s definitely not a reliability issue, with the platform - ESP32 in general is very popular so it’s surely an issue with my usage. I’m fairly certain it’s just a cheap manufacturer issue I ran into. I bought essentially a no-name ESP32 at first and that’s the one that refused to last. Proper manufacturer solved that issue for me and now ESP32 works just fine. The raspberry pi actually never worked, largely because I tried to shoehorn way too much complexity in and manage too many things. It’s just a BT scan and a HTTP call. I don’t think it’s a power issue as it’s getting 5V1A from a power outlet directly to USB-C into the device. Though that’s definitely something I need to look into, as the Xiao ESP32-S3 I have also had intermittent issues, and IIRC the XTensa cores are more power-hungry than its RISC-V based sibling, the ESP32-C3.
- filterfiber 3y ago> I don’t think it’s a power issue as it’s getting 5V1A from a power outlet directly to USB-C into the device. It's not the total voltage/wattage the PSU can provide, but the voltage at the processor. The ESP's varying current draw notoriously causes too much noise and a lot of boards don't have large enough decoupling capacitors so the voltage drops too much and it glitches out. Also a warning that USB PSU's can very MASSIVELY in quality (I'd suggest an apple one for testing if you have one handy). I think you're right that the RISC-V processor is either better behaved and draws power more consistently, or the board has shorter traces to it's bypass capacitor or a larger bypass capacitor.
- stavros 3y agoThis is correct, I thought it wasn't and was going crazy trying to debug my Pi 3 resetting my 3D printer every time, with any of ten power supplies I tried, including a configurable bench PSU. I switched to the official Pi PSU after someone said "trust me on this" online, and yep, zero issues in all the years since.
- numpad0 3y agoIt's voltage for Pi 3. They forgot to account for voltage drop due to protection or something. Official as well as third-party Pi 3 specific adapters are rated at 5.1V to mitigate that problem.
- nottheengineer 3y agoEarly alexa devices also have power supplies that are rated at 5.2V, those could be an alternative. I also had a good experience with a 30W oneplus warp charger after some power issues with cheap 5V2A ones.
- iicc 3y ago>don't have large enough decoupling capacitors Is this something you can eyeball to guess at quality?
- jetbalsa 3y agoI'm a huge fan of using Alpine with the RPi due to reducing writes to the SDCard. it will only save data to disk with a lbu commit -d and by default boots into a kind of tempfs.
- alias_neo 3y agoI have been using Alpine for a while but didn't know this! At the moment, I'm looking for a way to make my storage more resilient on a Pi I'm using to host Hashicorp Vault, for secrets in Filesystem mode. First I looked at high-resilience SD cards, but I don't really want them stored on the OS card anyway, also considered just getting a high-quality USB stick and mounting the secrets storage to that; It sounds like a combination of one of these (or perhaps another, similar option) alongside Alpine to reduce writes to the OS SD could be the ticket. I have a couple of Pis on my network edge running things like WireGuard, with the root mounted read-only to try and help with the issue of SD card resilience; I've killed dozens upon dozens of SD cards in Pis over the years.
- alias_neo 3y agoI have a bunch of ESP32s performing critical-infrastructure tasks in my Home Automation; they've been running flawlessly for about a year now; I update them occasionally (ESPHome) but haven't had any issues. Some of them perform multiple tasks, e.g. one of them is Bluetooth proxy in my home office, but it also runs the light strip along my Skadis wall boards. I'm using some random brand ones from a company called "AZDelivery" on Amazon. I haven't done anything special to them; they sit in 3D printed cases, and are plugged in with relatively short cables (usually <30cm where outlets allow) into at least 5V/1A adapters.
- hellweaver666 3y agoI have a number of similar devices but I use dirt cheap Wemos D1 Mini boards from Aliexpress, they usually cost around a buck each (and they come in ESP8266 and ESP32 variants).
- lesuorac 3y ago> Linux Bluetooth is incredibly painful to handle in a headless way. Binding to DBus requires cross-compiler magic and not even Cross was getting me out of it. That was my experience as well. I was doing something different so ultimately I just decided I'd put both the devices on the same WiFi network and then scan for "pi.local". Do wish I knew how all those other crates work though where it crashes at runtime if you don't have a library instead of refusing to build.
- wutwutwat 3y agoHome assistant does headless bt presence detection in ~200 lines of python I think the author had a painful experience because they wanted to do embedded and had to interface at a much lower level, where it's a long ago solved problem in higher level languages. Considering the tracker ended up in their door next to their computer, they could have stuck with the rpi that ran python and been fine https://github.com/home-assistant/core/blob/dev/homeassistant/components/bluetooth_tracker/device_tracker.py https://github.com/home-assistant/core/blob/dev/homeassistan... https://www.home-assistant.io/integrations/bluetooth_tracker/ https://www.home-assistant.io/integrations/bluetooth_tracker...
- lesuorac 3y agoI don't know the author's code but mine was at the same level as home assistant's. I believe I was using Bluer (BlueZ) [1] and afaik the problem is that the dependency needs an armv7 version of DBUS when it compiles which my non-armv7 laptop did not provide. If I do the home assistant route and just copy my source code over to the raspi and build the binary there it all compiles+runs fine. Except for the part where I can't compile it locally and so I don't know of a build issue until its been transferred + built. [1]: https://github.com/bluez/bluer https://github.com/bluez/bluer
- Animats 3y agoAnd with more of these, you could track where everyone is all the time! Here's a camera based video people counter.[1] This is a bit less intrusive. [1] https://github.com/saimj7/People-Counting-in-Real-Time https://github.com/saimj7/People-Counting-in-Real-Time
- sodality2 3y agoGiven manufacturer’s trends of enabling the privacy feature of randomizing the MAC address every n minutes, it would take some serious effort and analysis to reverse these general trends into individuals. I’ve linked a relevant article in the bibliography about these kinds of attacks [1] but in general, at least with user numbers in the hundreds, it would be very difficult. [1]: https://ieeexplore.ieee.org/document/9369628 https://ieeexplore.ieee.org/document/9369628
- michaelmior 3y agoJust skimming that paper, it doesn't look like they made use of any kind of fingerprinting. The paper below shows how BLE devices can be profiled to extract a potentially unique fingerprint. I don't know how well this would scale to large numbers of devices, but I'd imagine if you used such a fingerprint, you could dramatically improve the association between randomized MAC addresses even if the fingerprint is not 100% unique. https://inria.hal.science/hal-02359914/document https://inria.hal.science/hal-02359914/document
- reidjs 3y agois something like this possible for an outdoor setting like a beach?
- deleted 3y ago[deleted]
- sodality2 3y agoDefinitely, if there’s a solar panel and a battery hooked up + some sort of internet connection. Though I would worry about durability outdoors, probably needs to be sealed pretty tightly
- dylan604 3y agoI've heard talks of the toll tag companies wanting to be able to detect occupants in a car so they can properly charge the correct amount of fees when the occupancy changes the amount. I never looked into how that might happen, but I'm guessing Bluetooth would not be a solve here as it's too easy to circumvent if passengers disable bluetooth
- kurthr 3y agoOr (shudder) have more or less than the requisite single phone.
- dylan604 3y agoObviously a soccer mom taking her bus load of kids somewhere would ruin the bluetooth use case. I never did hear more about how they would actually do it. I just met someone randomly at a holiday gathering a couple of years ago that said that was something his company was working on. The conversation just didn't allow for follow up.
- HumblyTossed 3y agoCameras work well for front occupants. They're already being used to check if commercial drivers are wearing seat belts.
- dylan604 3y agoif a toll tag required me to power it and allow it to record video of the interior of my car at all times, then FUCK THAT NONSENSE!!!! even if they had it setup so that the camera was only turned on briefly by a signal as you approached and then turned off again as you passed the gates, that's still a hard no from me.
- alx__ 3y agoUh you're over thinking it. They just have cameras in the toll booths that snap a photo when the car crosses the sensor.
- Dowwie 3y agoThis would be an interesting way to measure crowds in general-- in concerts, attending political rallies, attending protests, etc. A handful of journalists attending an event could spread out and share their max value.
- Smoosh 3y agoThis makes me wonder if phone companies would have the ability to provide figures for mass gatherings. Would they only be able to count devices on their own network, or do they "see" all phones in range and then filter out the other-network ones?
- SCUSKU 3y agoAwesome 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!
- mwint 3y agoDo 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.
- SCUSKU 3y agoI 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 https://youtu.be/IYuYTfO6iOs?si=oLuJiGxdQ8VHyu29&t=837
- sodality2 3y agoAnother 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).
- mariocesar 3y agoInteresting DIY project! It reminds me of a startup called OccuSpace (https://occuspace.io/ 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?
- me_again 3y agoCool! 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 https://en.wikipedia.org/wiki/Count-distinct_problem
- sodality2 3y agoThat’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.
- lormayna 3y agoCan you use the variation of RSSI to track movement? I know thst it's multipath and cannot be really reliable, but maybe it can provide some useful information. Or maybe using 2 tracking devices and correlate the results.
- sodality2 3y agoInstead of triangulation like that, which could get real complicated, you could also simply place enough in the areas you’re counting and limit the RSSI cut-off enough to measure those right next to it. That would work for specific areas you want to measure trends in, instead of general 3d spatial triangulation. though some of the papers I read did this via measuring the time of flight of BT packets and how they were changed when people walked between them, and that really blew my mind!
- dividuum 3y agoI do something like that for my home assistant: I have a few shelly smart plugs that can scan BLE. They filter for apple watches and send the MAC and RSSI to my home assistant where a small neural net then tries to detect the location within my apartment. It works better than I expected given the high variance of signal strength, even when standing still.
- fullstop 3y agoESPresence [1] is an interesting project, and it works with the ESP32-C3. It is more designed to figure out which room you are in. 1. https://espresense.com/ https://espresense.com/
- summm 3y agoTheres this using ESP32 and LoRa, where you can order readymade hardware: https://cyberman54.github.io/ESP32-Paxcounter/ https://cyberman54.github.io/ESP32-Paxcounter/
- Havoc 3y agoYou can also get pretty check 24ghz radar that does reliable sensing till like 3m. Much much more accurate than the IR based stuff
- foxtrottbravo 3y agoWhile yes, these devices are cool and I use them in a couple of projects (mostly centered around home automation), I think there is no good way to count people that way (other than placing them above ingress and egress points). I think the original use case is not to know whether a dining hall is occupied at all but about how occupied it is (and if he should go to lunch now or wait another 20 minutes).
- epcoa 3y ago> 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.
- sodality2 3y agoI figure the internal data structure that already exists in the BT library probably uses something similar to a hash table, so I emulated it with less of the data being saved (just a MAC). You’re right though, there are smaller choices for data structures. I ended up upgrading to a better board with more memory, and just used the existing structure in the BT library. It fixed a number of other problems at the same time.
- davidw 3y agoHow do people "productize" their ESP32 projects? (Edit: not talking about mass-producing something, I just want a self-contained unit rather than a board with a bunch of wires sticking out) I see a lot of pages where they show some bare-looking board, but in the real world you want to package that up. If you're a software guy like me, you would likely prefer to pay a bit extra to just have that tidied up for you rather than fiddle around with stuff.
- lostapathy 3y ago3d printed enclosure?
- davidw 3y agoThat sounds like one of those "I have a problem... now I have two problems" jokes. I wanted something simple and cheap and now I need to go deal with this whole other thing I don't know much about and either rent or buy into it?
- krasin 3y agoJLCPCB would 3d print high-quality enclosures from a variety of UV resins: https://3d.jlcpcb.com/ https://3d.jlcpcb.com/ and decently cheap. The next best option is injection molding with PCBWay (or other similar provider): https://www.pcbway.com/rapid-prototyping/manufacture/?type=4&reffercode=TOP https://www.pcbway.com/rapid-prototyping/manufacture/?type=4... An alternative is a sheet metal enclosure: https://www.pcbway.com/rapid-prototyping/manufacture/?type=4&reffercode=TOP https://www.pcbway.com/rapid-prototyping/manufacture/?type=4... But 3d printing with JLCPCB is really the most convenient way unless you need a lot of parts (thousands) or the material properties of the UV resins would not be enough (high-temperature, outdoors, etc).
- Zetobal 3y agoYou can also pay someone to do it.
- lostapathy 3y ago
- barkingcat 3y agoI like the inclusion of the bibliography. I should do that with all my blog posts too (even if it's links to other posts, etc, the references still help to understand the post)
- post_break 3y agoThis paired with a TPMS scanner would be great for occupancy for the entire campus. Scan the TPMS at the major traffic zones, then compare with bluetooth signatures.
- fnordpiglet 3y agoWhile I don’t discourage learning a new language the immediate toss aside of rust on esp32 was perplexing. It sounds like a lot of the memory issues would have been mitigated by sticking with a language better understood. Rust’s esp32c3 support is pretty good IMO, that’s all I use. Writing in C++ makes me feel dirty in ways that even COBOL doesn’t. I also think I would have implemented presence by TTL, updating the TTL for each MAC when I see it and purging a TTL heap before updating my remote statistics. I didn’t fully grok the approach taken for maintaining the hash map, in a taxi off a long flight, but it didn’t seem super robust on my quick read.
- sodality2 3y agoThe hash map was definitely not robust enough, that’s why I ultimately switched back to the default behavior and increased the memory available on the board! Also, I am a Rust fanatic. I do nearly everything in it! I gave a talk on it at our last hackathon! I even wear a Rust t-shirt regularly! So rest assured I will be exploring my options with Rust. I would love to get rid of my dependence on Arduino. But C++ was easiest to get off the ground with, believe it or not, just because I have experience flashing Arduino boards.
- fnordpiglet 3y agoNo that’s awesome. Experiment and enjoy. But I would check out the esp33 toolchain for rust. It’s remarkably mature. Awesome project btw.
- kramerger 3y agoIs it possible to program this device without the espresso SDK and the arduino stuff? Whether I'll use C++ or Rust for my next project depends on which one I can first get working on this board with the standard toolchain (GCC and Rustc respectively)
- fnordpiglet 3y agohttps://esp-rs.github.io/book/ https://esp-rs.github.io/book/ Yes
- j1elo 3y agoAlways surprised to see people running around with their Bluetooth needlessly enabled. Maybe I worry to much about battery usage, but I just got used to always enable WiFi, Bluetooth, or NFC, only at the moment of usage, and disabled afterwards.
- szundi 3y agoGoogle/Apple obfuscating these mac addresses do not help anymore?
- ThrowAway1922A 3y agoI have a smartwatch and airpods, turning off Bluetooth would cause both not to work. I'm more surprised that anyone ever turns it off, battery use is negligible compared to the cellular modem as I browse the web/listen to music.
- landemva 3y agoI use Bluetooth maybe once or twice a year because I don't want to be tracked everwhere. Wired headphones. Phone in airplane mode much of the day. I suppose I am a privacy outlier, and I'm also not a slave responding to calls/texts.
- ThrowAway1922A 3y ago> and I'm also not a slave responding to calls/texts. You do you, but I enjoy talking with my friends and family and I don't see responding to them as "slavery".
- landemva 3y agoYes, I enjoy experience of life in real life.
- ThrowAway1922A 3y agoYou're also very judgmental. My family lives far away, thankfully my phone allows me to maintain contact.
- gyf304 3y agoDid something very similar years ago - https://blog.yifangu.com/tag/library-occupancy-project/ https://blog.yifangu.com/tag/library-occupancy-project/
- sodality2 3y agoWow, very cool! I would have used WiFi but unfortunately our beacons either separate or merge devices (so you either get just the users on the nearest beacon, which is not a set range of distance, or every user on that region's subnet, which could be entire dorm complexes). But that seems like a really good solution!
- qwertox 3y agoMy alarm clock consists of an ESP32 and has a somewhat big LED-array connected to it (powered by a transistor), a buzzer and a PIR sensor. It doesn't show the time, but buzzes (and flashes) and takes care of slowly brightening the room, or at night slowly dimming it into darkness some time after all the lights have been turned off. One added benefit I discovered afterwards is that even though the AP is not between me and the ESP, I seem to reflect enough RF so that logging the RSSI provides information not only about when I'm in the bed, but also when I change position at night. https://imgur.com/a/VixOlu5 https://imgur.com/a/VixOlu5 (edit: no erotic content despite the warning) The green one in the middle is the RSSI, the yellow at the bottom the PIR sensor, the top one a mix of the data from my Mi Band 3 plus an annotation of when I was in bed (yes I did spend a lot of time reading news before falling asleep and before getting up)
- picture 3y agoWhat was your stack like for data collection and visualization?
- punkybr3wster 3y agoDitto! I’d also love to know what is being used for the visualizations.
- outworlder 3y agoNot OP but the screenshot looks identical to Grafana.
- qwertox 3y agoSent via UDP to a small custom Python server which feeds it into InfluxDB, then Grafana for visualization.
- bayat 3y agoVery cool! Thank you for sharing this. I would love to see a picture the aforementioned alarm clock setup as well.
- caycep 3y agoapplications for cities w/ housing availability issues and vacant "investor properties" to apply/enforce a vacancy tax?
- neilv 3y agoSince this was done by a student at a university, and at some level this involves tracking people, that's an opportunity to ask a professor about what human subjects protocols you'd need if this was research. (A professor might be easier to ask than the university human subjects board -- who might refuse to talk with you because this isn't under their jurisdiction, or might get alarmed because you didn't talk with them sooner.) There might also be campus IT privacy&security policies that apply. Of course people are getting violated much harder by ordinary Web sites, apps, and IoT devices, but sometimes universities aspire to be better than the outer world.
- sodality2 3y agoYep, I’m talking to a professor about exactly this. Didn’t want to include that in case it doesn’t work out though!
- elijahwright 3y agoPeople lie to their IRBs all the time, unfortunately.
- alias_neo 3y agoI wonder what the "rules" are for things like tracking beacons. They're being broadcast, and they're almost certainly collected without consent everywhere we go. I happen to live at a junction where my home is regularly surrounded by large numbers of Bluetooth devices; I had considered setting up a BLE tracker purely for "fun" to see what I could collect and discern from the data. For example, one thing I'm certain of, is a correlation between poor air quality in my home and the arrival of these Bluetooth devices in the area.
- wutwutwat 3y ago> So a hidden industry of third-party location-marketing firms has proliferated in response. These companies take their beacon tracking code and bundle it into a toolkit developers can use. The makers of many popular apps, such as those for news or weather updates, insert these toolkits into their apps > Location marketing aims to understand “online-offline attribution.” If a Starbucks coffee ad is sent to your email, for example, marketers want to know if you actually went there and bought a coffee. The only way to know is to monitor your online and offline habits at all times. > Beacons are also being used for smart cities initiatives. The location company Gimbal provided beacons for LinkNYC kiosks that provoked privacy concerns about tracking passers-by. Beacon initiatives have been started in other cities, including Amsterdam (in partnership with Google), London and Norwich. https://web.archive.org/web/20231027211008/https://www.nytimes.com/interactive/2019/06/14/opinion/bluetooth-wireless-tracking-privacy.html https://web.archive.org/web/20231027211008/https://www.nytim... It's the wild west. We're illegally surveilled every day and the government uses the same data in product that allow them to track people without warrants https://en.wikipedia.org/wiki/Fog_Reveal https://en.wikipedia.org/wiki/Fog_Reveal There are no "rules" against receiving a signal. All you need is a radio that can pick them up. The rules apply to those broadcasting things afaik
- UncleEntity 3y agoBluetooth is fun. A while ago I was playing around with libble++[0] to read the data from some cheap temp/humidity sensors which broadcast their data as an advertising packet. Pretty simple, considering. Did some other playing to turn my laptop into a BLE beacon (which worked pretty well with some random app on my phone) and also tried (IIRC successfully) to emulate one of those apple airtags though that code is lost somewhere on said laptop. A quick glance at my temperature reading code and I'd say that counting the number of seen advertisements would be trivial using that library, I'm currently letting it do all the real work and just filtering the results to the devices I'm interested in. [0] https://github.com/edrosten/libblepp https://github.com/edrosten/libblepp --edit-- I also seem to have started writing a python C wrapper around libble++ but obviously never followed through so its completeness is doubtful.
- raajg 3y ago> not losing momentum in a nerd snipe like this is CRITICAL This line got me laughing! My nerd brain has tried so many times to convince me to splurge money with this exact line!
- alias_neo 3y agoIt's funny, but it's also true. There are definitely times when I'm more "in the mood" for projects; In the winter particularly, I work more on my electronic projects, and do more gaming (my Gaming "season" just started again last week). Of course the dramatic shift from "what do I feel like doing today" to "what am I in the mood for / have time for this season" has a lot to do with me being older and having children now, but with such huge gaps between me being willing/able to do such projects, losing momentum could mean coming back to something an entire year later, if ever. I started an electronics project, at least 10 years ago now. It's "infamous" in my family, particularly when my wife needs something to poke at with my projects, for being the project I started over a decade ago, spent a tidy sum on, and am still adamant I will finish one day!
- hasoleju 3y agoI can relate a lot. Having the momentum on your side is the main force that pushes such a project forward. Especially if you have family duties that ususally consume most of your free time. As long as children are smaller even things like scheduling time for your projects don't work very well. Usually because unexpected things happen that need to be handled. Sickness, children waking up early or taking longer to go to sleep, etc..
- alias_neo 3y agoAbsolutely, I just have to see how it goes on the day, if they get to sleep easily and on time I have a couple of hours maybe after doing the chores, but more often than not I'll come and sit down at my desk and just think; I'm too tired, or not in the mood for this, and I decided recently that that's fine. I was talking to my wife about this over dinner the other day. At one point, early after the kids came along, this really bothered me, not being able to do my projects/hobbies, but I came to a realisation, once things had settled down a bit. Even though I _want_ to do these things, I want to spend time with my kids, my family, more, and these other things are inconsequential whether they happen or not. I'm never likely to look back and think "I regret not building X with an ESP32", and I don't intend to look back and wish I'd spent more time with my kids, they grow up quick. Don't get me wrong, I still find time for hobbies, and little projects; much less so than I did, but now I just find I need/want to spend less of my time building/tinkering with things that no longer have the same value to me that they used to, my brain is slowly catching up with that realisation.
- H8crilA 3y agoThere are some very good frameworks out there for doing things like these: - ESPHome - Home Assistant You can a build a device like this, often without writing one line of code, with ESP32 firmware updates over the air from a web UI. I wish those ESP chips/mini boards had Zigbee. You can get much better connectivity on a Zigbee network than on wifi in a typical deployment, where every mains powered Zigbee device also acts as a router.
- sodality2 3y agoI have to say, my manual solution was a lot more fun and hands-on and let me learn a lot more skills (C++, Grafana, serverless) than a one-click solution. Though I will be prioritizing maintainability if I decide to go further with it!
- martinsnow 3y agoAgree with you fully. It's also a lot more easy to program behavior into an esp32 rather than rely on home assistant pre defined modules.
- H8crilA 3y agoIt's more about ESPHome rather than Home Assistant. But yeah it is more fun to do it bare bones :). However, over time I found myself "upgrading" my hand made IoT devices to more standard solutions. Standard solutions usually work better.
- hmottestad 3y agoUltra wide band can be used to detect tiny movements of humans in a room. It can detect a finger twitching from several meters away. https://www.eenewseurope.com/en/uwb-human-sensor-uses-impulse-radar-to-improve-reliability/ https://www.eenewseurope.com/en/uwb-human-sensor-uses-impuls...
- fotta 3y agoAqara makes a mmWave presence sensor https://www.aqara.com/us/product/presence-sensor-fp2 https://www.aqara.com/us/product/presence-sensor-fp2
- haddonist 3y agoMake It Work have reviewed 18 different home mmWave sensors, Aqara included: "Best mmWave Presence Sensors for Home Assistant!" https://www.youtube.com/watch?v=Kt1FpRM8R18 https://www.youtube.com/watch?v=Kt1FpRM8R18
- hmottestad 3y agoThat's even better!
- linvs 3y agoOutstanding write-up! We actually built a business based on this technology (occuspace.io) and have had to address almost all the questions that you brought up. To answer some of them here: Q: How accurate is BLE beacon count, as a proxy for occupancy? A: It's very highly correlated but different dining locations, classrooms and library floors have very different correlation factors. Consider using other, perhaps more complex features, as well. Q: How accurate is BLE beacon availability time, as a proxy for dwell time? A: We don't believe it is very accurate given that BT MAC's randomize every 8-20 mins depending on manufacturer. Q: Can we improve the accuracy by setting an RSSI minimum, for which devices weaker than it do not count, to ensure only those who are really nearby get counted? A: That's a great idea. It's worth noting that different types of spaces and depending on where you installed your sensor, will have different threshold levels.
- georgeashworth 3y agoDoes this type of occupancy tracking work accurately outdoors? I'm assuming it would be difficult because signals would travel further. (My startup needs occupancy tracking for tennis courts.) Maybe I could mount a BT device at a corner of the outdoor space and use its signal strength as the threshold value.
- rsaxvc 3y agoYou could mount one at each corner and use a directional antenna to help.
- rsaxvc 3y agoYou could use the BLE AoA extension as well to derive an angle: https://www.bluetooth.com/blog/new-aoa-aod-bluetooth-capabilities/ https://www.bluetooth.com/blog/new-aoa-aod-bluetooth-capabil...
- rsaxvc 3y agoIf you want to get really spicy, you can use two antennas and an SDR to compute angle of arrival using nothing but a BLE advertisement's data . This is different from BLE AoA as it doesn't require a cooperative transmitter.
- userbinator 3y agoI am also considering selling it to brick-and-mortar businesses that want to measure occupancy trends. They've been able to do that long before invasive solutions like this, or computers, even existed --- turnstiles.
- fy20 3y agoHow many stores have you visited recently that have turnstiles? You've probably been in more that are using a variation of this tech. There are a few companies offering it as a commercial product, and yes there are people that want to buy it. The value is not just knowing how many people are in a store, but where they are going, what they are spending their time looking at.
- simonbarker87 3y agoVery impressive. This made me chuckle: > I asked campus IT to whitelist the MAC address Back at my uni this would have been a multi week endeavour with a number of forms and likely a denial. This was 15 years ago so hopefully things have changed there now.
- sodality2 3y agoIt's actually because our WiFi portal doesn't allow printers, game consoles, etc without browsers to connect, we have to manually add it. Though there is a portal to add it ourselves without IT, I am at the max 5 devices through there so I have to ask for overrides :)
- demondemidi 3y agoReally should point out this is for BLE. I thought it was based on heartbeats, heat, ingress/egress, or something more physical. Also, ESP32 Rx sensitivity is kinda poor: -94 dBm, most devices are pushing -100, -102 and even -104 dBm. Makes a big difference.
- scrose 3y agoIt's great seeing all the different approaches people can come up with to do similar things! I recently worked on a similar side project but took a very different approach. It pretty much was just: 1. A bash script in a Raspberry Pi W that ran `bluetoothctl` once per minute and wrote the raw output for that minute to a file. 2. A systemd process that would ensure the script would get re-run if the process crashed or machine rebooted 3. A separate script that parsed the logs and pushed them to a local sqlite DB that tracked the minute the bluetooth id was found. 4. A daily push to my backup server that stored the sqlite DB I decided to use systemd and a simple(10loc) bash script since I faced a similar issue to the OP where my pi would crash(although it was purely my fault for messing with a bunch of cables) and I wanted a way to get it running again with the lowest overhead. I also wanted as few dependencies as possible. I went with SQLite because it made querying for trends and building dashboards simpler and more interesting(and because the real project was the sqlite interface I was building :) ) One thing I learned from running this which also may answer a couple of OPs questions: Apple devices like hiding themselves. The only way I could get my Apple laptops and phones to show up was to keep the bluetooth settings menu open on them. Otherwise, they wouldn't appear to the bluetooth scanner. I can't speak much to whether android devices are 'noisier', but the lack of bluetooth feeds for Apple devices alone cuts out a significant part of the value of bluetooth scanning for crowd sensing, given the market share for Apple devices.
- dekhn 3y agoI was initially skeptical, but these days most of my ESP32s just run micropython and I write my "firmware" in Python. This includes (low-performance) callbacks for interrupts, python dicts. Because the ESP32 has nice peripherals, lots of stuff is really just using python or C as a command-and-control to enable part of the chip, like PWM. And porting Python to C++ is usually pretty straightforward.
- stblack 3y agoThis kid is alright. He’s going to do great. Keep doing what you’re doing kid.
- Simon_ORourke 3y agoI'm wondering how accurate this might prove measuring automobile traffic on a relatively busy street? I've been pondering some way to track the number of vehicles that pass my house each day, and would like (but not ideal) to get their average speed too. Was thinking about computer vision, and even audio doppler approaches, but this seems simpler - if only the bluetooth sensing might work on a device moving at 50mph+ at a distance of maybe 20 to 100 yards.
- baybal2 3y ago[dead]
- the-kenny 3y agoI have an unorthodox suggestion: get a bicycle rear radar like the Garmin Varia. They communicate via Bluetooth LE incoming cars, their count, and an average speed (in a set of ranges like 0-15km/h, 15-30km/h, …). Mount this with a usb cable somewhere, add an ESP32 or anything with Bluetooth somewhere else to accumulate.
- Simon_ORourke 3y agoSeems workable - thanks!
- jve 3y ago> but some don't carry any devices at all (or keep Bluetooth off on their phone). Exactly. I always had a habit of turning BT off, hoping to conserve the battery. And then our security department advises it - if you don't use it at the moment, turn it off. For security reasons. Flaws in BT sometimes come up and good if a user can get that update.
- wutwutwat 3y agoTurning bt "off" in your settings likely doesn't actually turn off the radios. It probably just disables connections. If you use lost phone features like findmyiphone, the defaults are to participate in the "find my" network, a mesh network of bt low energy devices for airtags, etc. Most often, even turning off your entire phone won't help, as the incentive to participate in the "find my" network is they give you the feature of tracking your phone even when powered off https://en.wikipedia.org/wiki/Find_My https://en.wikipedia.org/wiki/Find_My https://en.wikipedia.org/wiki/IBeacon https://en.wikipedia.org/wiki/IBeacon
- logbiscuitswave 3y agoI have a couple of home automation projects that use Raspberry Pi boards and rely on BLE. One thing I’ve found is the onboard Bluetooth is pretty awful on the Pi 3 and not very good on the Pi 4. Switching to use a Bluetooth dongle made a huge difference with stability and reliability. I no longer had to continually run scripts to try to reset kernel drivers or the entire Bluetooth stack when things got cranky (which seemed to happen many times a day). As a bonus I got a Class 1 adapter that would let me tweak the power output.
- bArray 3y agoI'm one of those annoying people that keep BT, data and location services off to save power. WiFi I mostly keep on, so in theory you could collect data this way too. Regarding the ESP32's reliability, it's likely power supply related. I've seen exactly this before. I run ESP32 devices with a 1A 3v3 linear regulator with a little smoothing, and zero issues.
- hellweaver666 3y agoJust a tip, if you want an ESP32 board that has more memory etc, look at the range from Unexpected Maker!
- yonz 3y agoSomeone get this kid a job. Way at the bottom: Think this was cool? Hiring software engineering interns for Summer 2024? Check out my resume here: https://docs.google.com/document/d/1EN2k5ZUOLTvMs_NZtUq8tKVKawif5Idb/edit https://docs.google.com/document/d/1EN2k5ZUOLTvMs_NZtUq8tKVK...