Hacker News new | past | comments | ask | show | jobs | submit login
I made a cheap home motion sensor and controller (stavros.io)
116 points by stavros on March 18, 2016 | hide | past | favorite | 32 comments



For people looking to do interesting things with MQTT messages passing between devices, take a look at Home Assistant.

https://home-assistant.io

You can use it to integrate various 'smart home' devices, generic MQTT messaging, and a variety of web services.


Home assistant looks great, I had installed it a while ago but didn't have time to really configure it. I should go back and devote some more time, thanks for the mention.


I've been using it for a while and quite like it. it isn't as flexible as OpenHAB, but I actually think that's a positive because it is a million times simpler to set up and tweak. Home Assistant really feels like the fully realized version of the various scripts and dashboards I had made myself before finding it.


Yep, I'm going to change all my embedded controllers to be compatible with it and blog about it. Home Assistant also led me to OwnTracks and I love that too.


Wow, I really liked this article. The entire process looked great and the explanation was rather simple.


Thank you! I was afraid it didn't contain enough code, or enough interesting bits. I'm glad you like it! You can take a look at the code on Github, hopefully it'll be easy enough to understand (it's a bit ad-hoc, so I don't know how much sense it will make to others).


I liked the use of the Expounder tool as well. Less work than jumping up and down to read footnotes, the explanations were well-written and fit into the article flow, and the animation was quick but nice. Nicely done!


Thank you! I hate footnotes as well, so that's part of why I made Expounder.


Missed this in the article, but how are you actually turning on/off the lights after this controller sends a "turn on" signal?

Is this basically right : You have some separate receiver that the light or other accessory plugs into, which senses the MQTT signal sent from the controller unique for its channel, and turns on its connected accessory? Were those receivers custom designed as well?


The lights plug in to some cheap RF-controlled plugs, and the sensor board sends the signal with the RF transmitter to turn the plugs on and off. I reverse-engineered the timings in this post:

https://www.stavros.io/posts/how-remote-control-rf-devices-r...

Also, I designed this PCB that's basically a wifi-enabled ESP8266 LED controller:

http://dirtypcbs.com/view.php?share=16892&accesskey=996a11f9...

This allows you to control 5050 LEDs and change their color/intensity/etc over MQTT. I'm going to write a thing to slowly fade them to max as night falls, and make them progressively redder as I get nearer bed time. I'm just waiting for the PCBs to arrive, the prototype works fine.

You can subscribe to my blog to be notified when I write that post up as well.


That looks awesome! I made a similar thing: https://medium.com/@christophe.smet1/flux-irl-building-a-hue... Would you be interested in a collaboration ?


Definitely! Email is in my profile. I also made the same thing as you! Fits four boards per 5x5 panel, I'm going to write it up properly after it arrives.

http://dirtypcbs.com/view.php?share=16892&accesskey=996a11f9...


I'm working on a project like this as well!

Still in the early stages -- I just got my parts. I'm planning on using the ESP8266 chip + Arduino core (https://github.com/esp8266/Arduino) controlled with a simple web-app.

There's a handy library for doing the Chromecast style wifi setup here (https://github.com/tzapu/WiFiManager).


The hardest part of the LED project for me was finding the right components (especially MOSFETs). Send me an email at hi at stavros dot io if you want to talk about it, I can also send you my KiCad files for the controller PCB (which I'll blog about after I get the fabricated PCBs).


More circuit boards should have a label 'BRAINS'!


expounder's pretty neat, wish there was a way to click on the explanation after reading it to hide it tho


I got that from other people as well. My rationale is that, once clicked, the explanation now becomes part of the text, so why would you want to hide it? You read it and move on, so there's no sense for the link staying there and cluttering the text.

If there's significant demand, though, I can certainly make it an option. It sounds like leaving expanded stuff expanded bothers some people's OCD, which I can certainly understand :)


I'm in agreeance with you here. I like how it becomes part of the text. It's not like your adding paragraphs and that make the page unruly longer and cause you to lose you place. I say leave it as is. I thought it was really nifty when I saw it too. :)


Yep, exactly. The idea is that you'd write the sentences being part of the text (as you would normally), and then just hide them behind an expounder link. You just need to take some minimal care for the next sentence to make sense, but other than that, it produces great results. For example, I like the effect it has on the "NodeMCU" link in the article, which you can click if you're unfamiliar with it and you'll get a fitting explanation.

Another section I like is the "rather optional", which explains the rationale for people who may not be aware of it. An author should not fall into the trap of hiding information that's not strictly relevant to the link, though, because then they trap the user into a "okay I need to expand all the links because who knows where the author has hidden useful information" mentality, which kills its usefulness.


This is really cool. How does one print these PCB's after design, is there some consumer grade printer?


I just send them off to dirtypcbs.com, and get 10 boards 2-4 weeks later. They're pretty cheap.


How hard would it be to add AI that could distinguish between human and dog/cat motion?


Impossible right now, as the sensor just gives you motion/no motion readouts. I think it has a way to configure for mass, though, so it only considers large masses moving. If anyone has any information on that, please let me know, because my blind cat keeps making my lamp turn on :P


I really don't know much, but was looking up exactly this because of your post. It seems like there are two ways. With a single device, you're limited to just smart placement (orienting it away from the floor or surfaces the animal climbs on) and adjusting the sensitivity of the detector, which will reduce the range and still trigger if the animal gets very close. The Adafruit PIRs come with a pot for this [0][1].

The other method, which most of the ones that seemed high quality used is a dual-sensor system, tuned for different ranges and sensitivity. Most of the commercial ones on Amazon seemed to use a combination of PIR and something else, like sonar or microwave detection.

My idea for a quick "hacky" way to do it, would be double up on the sensors and place one 3-4 feet above the other and maybe use some tape on the lenses so the detection areas don't overlap. This way it would trigger for a person walking by, but not a cat walking on the ground, or jumping past a higher sensor.

Awesome project by the way. I'm also working on my own home automation project as well, I'm mostly avoiding low-level hardware stuff for now, but definitely want to play with it in the future. Bookmarking this and your other posts for inspiration.

[0] https://learn.adafruit.com/assets/13829 [1] https://learn.adafruit.com/pir-passive-infrared-proximity-mo...


PIRs measure temperature changes, not motion. I set one up in my kitchen and it got very confused whenever I turned on the kettle or the toaster. :)

Sharp make a range of IR distance trackers that are more useful for checking whether or not there's an object/person in front of the sensor.

https://acroname.com/articles/sharp-infrared-ranger-comparis...

Adafruit sell one of the short range models, but the GP2Y0A710 is better for domestic applications.

If you're clever you could probably track the level of multiple WiFi receivers in an area and watch as people and pets change the distribution pattern. I think there was a commercial system that did that.

It sounds quite hacky and potentially unreliable to me, but I haven't tried it in practice.

I would have expect some kind of domestic super-RFID system to have appeared by now, but it doesn't seem to. There are issues with RFID and longer ranges but they should be solvable, and the potential market could be huge.


Thank you for that information! I'm definitely going to follow the first method initially, as it's super simple to do. Good luck on your project, and stop avoiding low-level hardware, it's lots of fun and easy to learn. Here are my notes, which I'm working on, but may help you:

https://www.stavros.io/notes/hardware/


Yeah, I think you'd have to have an actual camera image, and then you'd probably want a night vision lens of some sort... I'd imagine the logic for doing the detection might be available open-source somewhere...


Yeah, sounds like it. A much easier solution would be to adjust the sensitivity and put it somewhere your cat can't reach (like on a high shelf).


No need for AI. You can just use an rfid sensor on the animal's collar.


Definitely easier, though more hackable if you're building a security system.


There are encrypted RFID tags, like the Ultralight-C tags commonly used for transit systems.


At last year's Startup Conference, I really liked one of the pitches: Realiteer. It works with Google Cardboard, and it's the cheapest controller you'll ever see: 100% paper. And it worked really well, I tried it.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: