HTE - Magnetic Door Sensor

Overview

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

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


What is a Magnetic Door Sensor?

A Magnetic Door Sensor sends a signal when the magnets are connected or not connected.


Assemble the Circuit

Picture

Name

Quantity

Link

Picture

Name

Quantity

Link

 

Magnetic Door Sensor

1

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:

One pin is connected to the GP6 pin of the Builder Base the other one is connected to the ground pin of the Builder Base. You could also connect the second pin to the 3.3V pin, but that would change the signal output we get.


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 “Door Contact”.

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 Door Contact. 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 “Front Door”. Next we need to configure the firmware. Click on the Front Door bar:

For the “Driver” we use GPIO. You can also use one of the “low energy” options if your builder base is running with a coin cell or battery as power source to safe power. For the Pin we use GP6 and the Pin mode is set to “Input Pull Up”. This means we will have a data send when the magnets are not connected so a door would be opened.

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 in our case we named it “WS2812” 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 “Door Contact”. Hit “Create”.

You will find yourself on the Canvas.

For this tutorial we will need a “Door Contact” hardware object and a “Text” interface objects. We also need a “Number Compare” and two “Static String“ code object.

When the door is closed and so the magnets touch each other the circuit is closed and it will send out 0 for Number 1. This number will be compared with Number 2. Number 2 is also set to 0 and so if the numbers are equal we will get a text massage “Closed”. If the door is opened the Number 1 will change to 1 and will be greater than 0. We will get a Text massage witch “Open”.

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 “Front Door” tab and choose the Client, which is connected to the Magnetic Door Sensor.

Once you done click “Save + Run”.


Run the App!

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

You can see the Front Door is open now.

And lets bring the magnets together. We should see a “Closed” then.

This is how you connect and use a Magnetic Door Sensor with the Quantum System.

Happy Making!