Archive

Posts Tagged ‘motion’

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

March 2nd, 2017 11 comments

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“.

Infineon Showcases the Radar Board used in Google’s Project Soli, and Sense2Go Development Kit (Video)

June 30th, 2016 2 comments

Google’s Project Soli sensing technology uses a miniature radar to detect touchless gesture interactions, so that you can control devices such as wearables using gestures without having to physical touch the product. The 60 GHz radar technology used in the project has been developed by Infineon, and the company was recently interviewed by Arrow Electronics where they showcased Soli board, as well as another 24 GHz radar development kit called Sense2Go.

Click to Enlarge

Click to Enlarge

The Soli board called BGT60TR24 features Infineon XMC4500 ARM Cortex M4 MCU, and a 60 GHz “CRIS20” radar chip designed specially for Project Soli by Infineon, and allowing 20mm resolution, falling to less than one millimeter with Google’s algorithms. The micro USB port will be used for power and programming. This board should be the one included in Project Soli development kit to be shipped to developers this fall.

Infineon also have a Sense2Go 24GHz sensor development kit that can detect motion, speed, and direction of movement in applications such as indoor/outdoor smart lighting, intruder alarm, motion detectors, intelligent door openers, and more.

Click to Enlarge

Click to Enlarge

Sense2Go board specifications:

  • MCU – Infineon XMC 4200 ARM Cortex M4 MCU @ 80 MHz with 256 KB flash, 40 KB RAM
  • Radar – BGT24MTR11 24 Ghz radar transmitter and receiver IC
  • USB – 1x micro USB port
  • Debugging – Cortex debug connector
  • Misc – 2x User LEDs, 2x 10-pin headers
  • Power – 5V via micro USB port or header
  • Dimensions – 4 x 3.5 cm

The CPU is already preprogrammed using Infineon’s DAVE development tool, and the module comes bundled with a standalone firmware for movement detection without the aid of a PC. It samples up to 2 IF channels of the transceiver chipset and communicates via USB interface to a connected PC, and provided PC application GUI (Windows XP/Vista/7/8) can be used to display and analyze acquired data in time and frequency domain.

Click to Enlarge

Click to Enlarge

The kit also includes a User’s Manual, schematic and Bill-of-Materials of the module, and a micro USB-to-USB cable. Sense2Go can be purchased from various distributors using part number, including Future Electronics ($244) and Avnet.

Tiny Microwave Radar Module Detects Movements Up to 9 Meters Away for $2

April 4th, 2016 19 comments

PIR sensors are used to detect motion for example to turn on or off a light bulb when motion is detection. One such sensor is HC-SR501 motion detector, which costs around $1, and is tiny (32 x 24 mm), but not quite thin due to the design that needs to capture infrared light, with an height of around 2 centimeters. If you’d like something almost as cheap, just as small, but much thinner, microwave radar modules could be a good alternative.

XYC Microwave Radar Module vs HC-SR05 PIR Sensor

XYC-WB-DC Microwave Radar Module vs HC-SR501 PIR Sensor

XYC-WB-DC is one of those modules with the following specs:

  • Operating Frequency – 5.8 GHz
  • Detection angle – 360°
  • Detection range – 6-9 meters
  • Working Voltage – 3.3-20VDC;
  • Standby current –  <3mA;
  • Transmit power – <2mW;
  • Dimensions – 32 x 23 mm
  • Operating temperature range – -20 ~ +80 Centigrade;

Potential advantages over PIR sensors include wider detection angle, and lower power consumption, HC-SR501 datasheet reports respectively 120 degrees detection, and 65 mA “power consumption” @ 5V. The range is about the same for both PIR and Microwave radar modules, but the microwave module will also work through walls (which may be an advantage or an inconvenient), and the signal can be blocked by metal.

The module will output high signal (3.3V) when motion is detected, and the detection delay can be adjusted from 1 second to hundreds of second (two minutes max) by adjusting R6 resistor on the board as explained on this Taobao page (Chinese). By default there’s no resistor and the delay is 30 seconds, and you can adjust the delay by using 1K to 250K resistor.

Microwave_Radar_ModuleI’m not sure what the other resistor (10K – 100K) is used for (maybe max distance), which brings me to the downside that there’s absolutely no info in English. However, I found this module on Pete Scargill blog, who tried it, and could confirm motion is properly detected.

Other applications for such modules include security, body sensors toys, industrial automation and control, auto-sensing electrical equipment, and battery-powered automatic control.

XYC-WB-DC microwave radar can be purchased for about $2 to $2.5 on Aliexpress, eBay, ICSstation, etc…

Categories: Hardware Tags: electronics, motion

How to Use Orange Pi Camera in Linux (with Motion)

September 26th, 2015 36 comments

Earlier this month, I wrote a Quick Start Guide for Orange Pi Allwinner H3 boards such as Orange Pi PC, and showed how to install and configure Debian on the boards. I’ve also received the $5.90 Orange Pi camera, which when combined an Orange Pi PC, costs around $27 including shipping. So today, I’ve attached the CSI camera to my Orange Pi 2 mini board, and used it with motion to transform for the board into an IP camera.

Orange_Pi_2_mini_CameraFirst, you’ll need to insert the camera into CON1 connector with the camera facing the ceiling, and close the black clip to keep it in place.

Now connect all cable and power on your board. First, I studied the steps described on that forum thread, and modified Allwinner configuration files, but after one or two hours, I found out some work at been done since May, and it was now much easier to use the camera since gc2035 drivers was part of the Debian image, and the script.bin file (allwinner config file) was already setup to be used with Orange pi camera.

Open a terminal window in the board to load drivers:

and then mostly followed the instructions for USB webcams on Orange Pi website to install and configure motion:

and enable the following line:

This will make sure the web server started by motion will be accessible from other network devices.

I’ve also changed target_dir to /home/orangepi/motion, as motion would crash each time it would create a file when detection motion.

You’ll also need to change the startup script

and change the only line in the file as follows:

Finally, we are ready to give it a try:

You can launch your favorite browser, or access localhost:8081 if you are using your board, or <orange_ip_address>:8081 from another machine on the network, and you should the the picture camera updated into your web browser about twice per second.

Orange_Pi_PC_Camera_Motion

Click to Enlarge

If the system detects motion will save pictures and videos in target_dir directory, which I set to /home/orangepi/motion earlier. The image resolution is set to 800×600, and it ignored width and height settings (320×240) set in motion.conf.

Motion will start automatically, but you still need to load the modules automatically at boot time for this to work. Simply edit /etc/modules, and add the two required modules at the end of the file.

Now motion will run automatically, and the camera work properly each time the board starts.