HTE - HC-SR501 Motion Sensor

Overview

For Fullscreen: https://www.youtube.com/watch?v=Ag1OkO2AYZo

This tutorial will show you how to use a Motion Sensor, connect it to the Quantum system, and create a simple demo using it.


What is a Motion Sensor?

A Motion Sensor sends out infrared waves which detects objects. The change in temperature of a give area changes the infrared wave and so a motion of a body oder object can be transferred into data.


Assemble the Circuit

Picture

Name

Quantity

Link

Picture

Name

Quantity

Link

 

Motion Sensor

1

You can purchase it here

Male to Male and Male to Female jumper wires

3

Included in Component Kit

Or you can purchase it here

Q-Client Builder Base

1

Q-Client

If you have all the parts listed above, we can go ahead and build the circuit. It should look like this:

Connect the red wire to the 5V of the Builder Base and to the vcc pin of the motion sensor. The green wire is connected two the second pin of the motion sensor and the GP0 pin of the Builder Base. It is used to get the collected data of the motion sensor. The last wire is the black one. It is connected to the ground of the Builder Base and the motion sensor.


Pair the Builder Base

Now we want to pair the Builder Base with our Q-Server. In order to do so, go to the Homescreen of your Q-Server.

Next click on the lift side symbol labeled “Clients”. Switch to the “Unpaired” tab at the top middle of the screen.

You should see your unpaired Builder Base. If not, check if you have plugged in the power supply for the Builder Base. Now move to the three dots below “Actions” and click “Pair”.

Once your Client is paired, click the “Setup” button.

Now you can edit your Client. Give him a Name you want and also a location where you are going to use it. Hit “Save” when you finished.


Build the Firmware

So once the Builder Base is paired and set up, we can start building our firmware. Move to the “Firmware” tab on the left side of your Q-Server interface. Hit “+ Create New”.

You will be prompted to give your new firmware a name. We named ours “PIR Sensor”.

Once you created the new firmware, hit the “+ Add Hardware” button on the top, next to the “Actions” button.

We are going to search for a motion sensor. You can use the search bar or scroll down till you find it. After this, you can give it a name and then click on “Add Hardware”. We named ours “PIR Sensor”. Next we need to configure the firmware. Click on the “PIR Sensor” bar:

For the “Driver” we choose “HC-SR501 Motion Sensor” because we are using this model. Then choose the right pin the motion sensor data output is connected to. In our case it is the GP0 pin.

Next we have to upload the firmware file to our Builder Base. Click on the three dots below “Actions” and click on “Upload”:

Choose the correct Builder Base and hit “Upload”. You should see a progress bar pop up at the right side of your screen.


Build the App

While the firmware is uploading, we can build the application for our Button. Move to the “Apps” tab on the left side. Click on “Create New” and give it a name you want. We named ours again “PIR Sensor”. Hit “Create”.

You will find yourself on the Canvas.

For this tutorial we will need a “Motion Sensor” hardware object and a “Debug” interface objects.

The Motion Sensor object will send a detected Motion to the Debug interface and will display it on our screen.

Click “Save App” on the top right. You will return to the first screen of the “Apps” tab. Now click the play button on the bar located at the right side.

Now we have to map the hardware and interface objects we have put together before to the actual hardware of the circuit. Click on the “PIR Sensor” tab and choose the Client, which is connected to the motion sensor.

Once you done click “Save + Run”.


Run the App!

Click on the “Dashboard” icon in the top right corner.

Select the LED Strip app.

Now the value should turn to off when we put nothing in front of the sensor.

If we put our hand now in front of the sensor the value will change to on.


Philips Hue light bulb

For the next demo we wan to activate a Philips Hue light bulb when we put our hand in front of the motion sensor.

To connect the Philips Hue light bulb with the Quantum System we need to download a Gateway. You can find the Philips Hue in the library tab.

When you downloaded the Gateway click on the Gateway tab on the left side.

Click on the three dots of the Action section and hit “Start”.

We already got the right IP Address loaded in. If you want more information on how to configure the Philips Hue watch https://www.youtube.com/watch?v=X941KESTxVk&t=0s. Now click “Next”.

As you can see we need to press the link button of the bridge. So make sure you press the button while clicking “Next”.

The username should be automatically filled by the gateway. Hit “Next”.

Now you are set up and you can click on “Activate”.

The “Status” should change to “Running”. If you move now to your clients tab you should see all your linked light bulbs to your Philips Hue appearing as a client.

Once we are sure our desired lamp or light bulb is connected to the system we can move on to configure our app. Move to the “Apps” tab on the left. We want to configure our existing app of the first demo so go ahead and click on the three dots and select “Edit”.

For the configuration you can delete the “Debug” interface object. We will need a “Light” hardware object, two “Slider Percent” interface objects and one “Color Picker” interface object.

So as we want to turn the light on and off with the motion sensor, we connect the “Motion Sensor” with the “On/Off” of the “Light” object. A “Slider Percent” connects to the “Dim” to control the brightness and one to the “Color Temperature” to control how warm the color should be. When you are done arranging and naming everything you can click on “Save App”.

You will return to the first screen of the “Apps” tab. Now click the play button on the bar located at the right side.

Now we have to map the hardware and interface objects we have put together before to the actual hardware of the circuit. Click on the “PIR Sensor” tab and choose Hue Bulb. You can now select one of the connected lamps in the client tab.

Once you done click “Save + Run”.

Move to the dashboard and click on the “PIR Sensor” app.

As you can see we can use now the options of the hardware and interface objects we put together in the app before. We can adjust the color, dim the lights or set the color temperature.

We are now going to adjust the time delay of the sensor and the signal. To do so we need to turn the left knob of the sensor counterclockwise. The range is between 3 seconds up to 5 minutes. This means that if the sensor registers something the light bulb will light up for 3 seconds or up to 5 minutes.

To make the system more compact and usable we made a 3d casing for the sensor and the Builder Base.

This is how you connect and use a Motion Sensor with the Quantum System. We also learned how to practically use the sensor with some Philips Hue light bulbs.

Happy Making!