Karl’s Home Automation Project – Part 2: 433 MHz / WiFi MQTT Bridge, Door & PIR Motion Sensors

Orange Pi Development Boards

Karl here again for part 2 of my home automation project. We will be looking at how to automate your lights based on time of day and motion. In the first part we setup Home Assistant and uploaded firmware to basic Sonoff Wifi switches. Today we will setup a 433 MHz to MQTT bridge and some sensors.

433 MHz

Depending on your country 433 MHz is an open frequency to use to communicate with. There are hundreds of different types of devices that use 433 MHz to communicate information. We will be focusing on 2 today from Gearbest: WMS07 motion sensor (left) and WDS07 door/window sensor (2 parts, right).

I am not taking the door/window sensor apart, since it is super basic, but I’ve included some photos of the PIR motion detector.

Click to Enlarge
Click to Enlarge

433 MHz Bridge

While contemplating how to get presence on a per room basis I ran across this project. It monitors 433 MHz signals and publishes it to the MQTT server. It is a really an easy project. It also has an IR to MQTT feature. I did have an IR receiver and tested it but have not implemented it. He has some good instructions on his page so I won’t go over too much. You can do the bare bones version and just leave off the unused sensors. I also went an extra step and added a light intensity sensor and DHT sensor to the project. It can be found here. I am not going to add those to this write up because trying to keep costs down.

What you will need is

  1. NodeMCU $5.69
  2. H3V4F Receiver Module $1.21
  3. Prototyping board $2.88

That is all that is needed. For about $10 you have an inexpensive 433 MHz bridge. You can put in a box if you want and hide it in a central location away from interference. I would suggest soldering headers to your board just in case something goes bad. I didn’t at first and made my life a pain. There are a ton of 433 MHz receivers. I purchased all the ones on Gearbest and this is by far the best. I did upgrade to a superheterodyne but I am not sure it is any better. I upgraded because I wanted to put the door sensor on my mailbox and get a notification when the mail was delivered. It is about 200’ away and is a little spotty even with a new 433 MHz receiver. I used this antenna design (see picture on right), as it seemed to work the best

Coverage is the biggest concern.  I have a brick single story ranch style home about 2000 square feet and it covers the inside with ease and a lot of the area around the house. If you have a multi-story house or would need multiple receivers you would need to change the MQTT topics to avoid getting duplicates. Below is the final project. To be honest temperature is really the only thing that is useful to me, but wanted to see what could be done. I purchase the DHT11 and the readings are not good. If you want to do this go with the DHT22. Below is a mostly loaded bridge. I don’t have an infrared transmitter yet. I have a different one coming that does the encoding/decoding on a chip and will follow up when I receive it. I am hoping it will be easier/better than using the Arduino library.

Motion Sensor

The motion sensor itself is really easy to setup with jumpers. I suggest turning the LED off, and the time to 5 min after finished setting up with the jumpers. If you notice there is a micro switch in the top left of this picture. It is meant to be a tamper switch but I use it as a toggle switch to quickly turn off the lights. The motion sensor is meant to be used for a security system but I just have them sitting on night stands and corner tables. It works really well to override or turn a light on when Home Assistant ignores the motion. A little squeeze of the box and the light will toggle states on or off.

After your bridge is set up and connected take the motion sensor out and put some batteries in it. Run your batch file to see what code is being sent. For this one we need 2: motion and tamper. Write these codes down.

Home Assistant

Below is the YAML code that I am using with Home Assistant. I made it find and replace friendly. If you copy and find the 4 items below it should work. I think it is relatively easy to follow. It is the typical timed lamp on motion that is on Home Assistant website with some slight modifications. I had to add the turn off motion script because the motion sensors only sends when it senses motion. I also had to add the tamper toggle switch. When you are adding multiple sensors you can only have one “binary_sensor:” group and one “automation:” group etc.

Find/Replace Explanation
generic use livingroom or masterbedroom etc no spaces
5555555 use the motion number you found earlier
8888888 make up a number around your tamper/motion number
9999999 use the tamper number you found earlier.

 

Door Sensor

For the mailbox sensor here is an example. Same thing on this one run the batch file and find the open and closed codes. I have it send me a notification via pushbullet.

Almost there

We are almost there. Lights are turning on and off magically. Life is good. But there is one situation where it’s not so good. The gloomy day. With the automations above we cannot determine if the blinds are pulled or it is gloomy. We still need the lights to come on under those circumstances to make it really cool. In the next installment we are going to take the motion sensors above and add a light intensity sensor to them. We will be able to do this cheap. We still have a pretty good budget. With the bridge above you open yourself to a bunch of battery operated sensors. You can also control devices, as well, with a transmitter. Any of the transmitters should work on GearBest. You can get the one linked and throw away the receiver. It’s only $1.25.  If you have any questions or concerns feel free to leave a comment.

Item Qty Price Total
Initial Setup Sonoff Basic 5 $4.85 $24.25
Headers 1 $1.50 $1.50
USB to TTL 1 $2.54 $2.54
$28.29
Motion Sensors NodeMCU 1 $5.69 $5.69
H3V4F Receiver 1 $1.21 $1.21
Prototyping board 1 $2.88 $2.88
Motion Sensor 4 $7.03 $28.12
$37.90
Grand Total $66.19

Continue reading “Part 3: Adding Light Detection to a Motion Sensor“.

11
Leave a Reply

avatar
11 Comment threads
0 Thread replies
5 Followers
 
Most reacted comment
Hottest comment thread
7 Comment authors
Lúcio CorrêaedNathanKarl JohnsonDave Essex Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Harley
Guest
Harley
d1dd1
Guest
d1dd1

Great to get some insights to Home Assistant and also the Sonoffs are great.

Personally I would not start a project with 433Mhz nowadays, where dirty cheap alternatives are available. I am currently moving to the Xiaomi system, which uses some kind of zigbee and already works with some home automation gateways (I use openhab2). I chose them based on size (they are really tiny) and price 🙂
I bought them on gearbest sales: motion sensor ~$8.5 (tiny but works amazing, outperforms my other $60 ZWave Sensor in Range and speed), contact sensor ~$6.3, Temp and humidity for ~$12, also buttons, wall switches etc are available

Harley
Guest
Harley

By the way, the bridge project isn’t a bad business idea for Kickstarter/Indiegogo:

If someone would just steal that concept and make it into cheap enough nicely boxed appliance product that only acted as a “IR and 315/433 MHz to WiFi + MQTT Bridge ” then I think that alone could sell pretty well in some home automation niche markets.

“315 MHz /433 MHz and InfraRed to MQTT WiFi Bridge”

Reason for that is I really believe there is a commercial market for a such specific “315 MHz /433 MHz and InfraRed to MQTT WiFi Bridge” product because most existing commercial home automation hubs do not feature 315/433 MHz or InfraRed receivers or transmitters, but as most existing commercial home automation hubs does support MQTT there is a large potential market for customers who don’t want to use expensive ZigBee and Z-Wave sensors.

To keep cost down you would make and sell one 315 MHz model for North America and one 433 MHz model for Europe and Asia. So one model that is; “315 MHz and InfraRed to MQTT WiFi Bridge” and one model that is “433 MHz and InfraRed to MQTT WiFi Bridge”, and possibly you could also make a third product model that is a 868MHz bride; “868 MHz and InfraRed to MQTT WiFi Bridge”.

As listed there all that you really need as far as hardware components goes is a ESP8266 or ESP32 chip, InfraRed and 315 or 433 MHz transmitters, and InfraRed and 315 or 433 MHz receivers. The source code 315/433MHz protocols could be copied from the RFLink Gateway firmware project (and shared with that project) as long as you keep it open source under the same license. Regardless it would be a good idea to make the whole firmware open source as then you have the possibility of getting help with the code from the community, and open source projects also often get more passionate communities than those who keep their code proprietary and closed.

You could possibly make cheaper by making a receiver only model as a “lite” version, but personally I don’t think there would be a large enough market for a such stripped down version to make it worth the little extra cost that a 315/433 MHz transmitter adds, (as proven with Telldus Tellstick ZNet Lite v1 which did not sell so well because it only had a 433 MHz receiver, so Telldus Tellstick ZNet Lite v2 also added a 433 MHz transmitter too).

As stretch goals Kickstarter/Indiegogo you could add a DHT22 humidity + temperature sensor and a light sensor.

In any case I think that this concept alone have the potential of becoming a proper commercial product if someone here have both the coding skills and enough business sense to push a such idea.

Dave Essex
Guest
Dave Essex

I love all of you. Damn I wish I had a friend this versed to teach me some places to start, etc… I am just mentally inefficient to keep track of things. And to express my elf well. But I still keep reading bits from this great blog.

Karl Johnson
Guest
Karl Johnson

Great feeback and alternatives. I wasn’t aware of the the Xiaomi solution. Looks like there is some integration with Home assistant. https://community.home-assistant.io/t/beta-xiaomi-gateway-integration/8213. Very cost effective

I was debating on making a wifi sensor box with motion, light intensity, IR, and Temp/humidity. Using a esp8266 as the brains. The only think that concerns me is making it wife approved. I would need a nice looking box.

I do see one advantage to using the motion sensor in the write up. I get 2 boxes in one. I get and motion sensor and push button. Well squeeze button.

Nathan
Guest
Nathan

Thank you.

ed
Guest

Thanks for the link to my article about the antenna (that’s my hand in the pic 🙂 ). Interesting article. I am currently working on an RF433/RF868-LongeRange/IR/-MQTT gateway though it will probably be different from yours. Nevertheless, very interesting article. Will have a thorough read to see if you encountered any pitfalls I should avoid.

ed
Guest

@d1dd1 With regard to the starting of a 433 MHz system I think you are right. Currently however I have a system that relies on 433 MHz switches and I am gradually incorporating that into an MQTT driven system. I could replace them all with say a sonoff (have those as well), but as the 433MHz can be easily driven by an ESP8266, might be better to just keep that part of the system.
But yes, should I start fresh, I’d stick to sonoff for every switch

Harley
Guest
Harley

@d1dd1

Do you or anyone know of any cheap ZigBee USB dongles that works with PC (Windows and Linux) and supports four most common ZigBee 2006 and 2007 protocol specification stacks that are Smart Energy, Home Automation, ZigBee Light Link, as well as ZigBee PRO?

I would like to test it with different Xiaomi sensors and the new Ikea Tradfri (Trådfri) smart lightbulb series.

Lúcio Corrêa
Guest
Lúcio Corrêa

d1dd1 :
Great to get some insights to Home Assistant and also the Sonoffs are great.
Personally I would not start a project with 433Mhz nowadays, where dirty cheap alternatives are available. I am currently moving to the Xiaomi system, which uses some kind of zigbee and already works with some home automation gateways (I use openhab2). I chose them based on size (they are really tiny) and price
I bought them on gearbest sales: motion sensor ~$8.5 (tiny but works amazing, outperforms my other $60 ZWave Sensor in Range and speed), contact sensor ~$6.3, Temp and humidity for ~$12, also buttons, wall switches etc are available

Do you have the links to the zigbee sensors on Gearbest?

Harley
Guest
Harley

@Lúcio Corrêa
You can get them from all popular China suppliers, just search “Xiaomi Mi Smart Home”.

You can get them cheap from Aliexpress, eBay, Gearbest, Geecr, DX.com, and more.

Make sure that you get the “Version 2” (Ver 2) which is second-generation version.