Student Projects

Showing results for 
Search instead for 
Did you mean: 

myRIO SmartHome Motion Sensor and Sound Output


This document shows step by step how to implement a motion sensor and if the sensor detected somebody. If somebody is detected, a light goes on and stays on for a time that you can set in an html-page. Another page shows if somebody was detected, if the light is on and how long it will stay on.


The steps I did when I created this program were following:

1. Get Data from motion sensor (in this case without FPGA)

2. Analyze the values: what are the output values of the sensor?

3. Control the light

4. Sound (only the folder with Sound)




The motion sensor I used is A215/450. It uses Infrared and collects the heat of moving things. So it realizes persons as well as animals.

You need to compile the Main (FPGA).vi before you can run the project.



1. Get Data from motion sensor

The Sensor is connected to the myRIO like this:

Connect Motion Sensor to myRIO.png

The Voltage is read in the Motion Data (without FPGA) and then written to the global “Voltage from Motion Sensor”.



2. Analyze the values

There is no datasheet available that shows what the output values are if the sensor detects somebody or if it doesn’t detect somebody.  I recorded the output voltage from the sensor and analyzed it (I have one value per second).

Voltage from Motion Sensor.png

In seconds 10-20 and 40-45 I moved my hand in the range of the sensor. The voltage is not constant (see yellow marked signal). In seconds 0-10, 20-40 and 45-60 nobody was detected. The voltage is between 3 and 3.5 V (I use a bigger range to ensure that nobody is detected mistakenly, probably 3.1 to 3.4V would also work).


So I set the borders:

Voltage between 3 and 3.5 -> nobody detected

Voltage out of this range: somebody detected



3. Control light

If somebody is detected, you begin to count down from the value you enter at the html-page. The MotionValues.esp-page refreshes every second to get the newest values from the To get the value from the last iteration of the VI, I used feedback nodes (Case-structure in a while-loop does not work in a WebService-VI!!)


The Light Control uses the RF Transmitter from the following link: NI myRIO goes Smart Home - RF (315 MHz, 433 MHz, 868 MHz) Transmitter and Receiver




4. Sound

To play a sound from the mRIO, the .wav-file needs to be saved on the myRIO. For more Information, see Using WebDAV to Transfer Files to Real-Time Target
Note that the file path is different on the RealTime.OS than on Windows: Working with File Paths on Real-Time Targets


Hi,JuliaO.Your example is excellent.How can I just play music files on myrio like .mp3 or .wav files.

Hope for your reply.I will appreciate that.