Tutorial: Security System with your Microchip IoT Monitoring Kit

In this article, you will learn how to create a mock security system with your Microchip PIC32 board powered by MIPS processors from Imagination. You will first create a workflow that will enable the security system if the potentiometer is turned all the way to the left. The same workflow sends an SMS containing a 4 digit code to your device. This is the passcode, and you will need to press the buttons on the board in this order to disarm the system. The second workflow you will create checks the sequence of buttons you press

For this tutorial you need:

  • Completion of the Microchip Quick Start Guide found here.
  • The Medium One project from the Microchip tutorial and the activation email that came with it

Note: This tutorial does not require any additional sensors.

Step 1: Get familiar with potentiometer

First, locate the potentiometer on your board (shown in green box) and try to adjust it left and right.

In Sandbox account, go to Real Time Events Log file, and observe the values of ‘pot’ as you are turning the knob. For the purpose of this tutorial, turn the potentiometer all the way to the right; the ‘pot’ value in Real Time Events Log file should be set close to zero as shown below

Now you are ready for next step.

Step 2: Create your system arming workflow

In this step, you will create the workflow that monitors the potentiometer value and enables the security system if it is set at the maximum value, rotated completely to the left.

Go to Workflow Studio, and click Create a New Workflow. Name it “Security System Arming.” Under Tags and Triggers -> raw, drag “pot” onto the screen. Then, under Modules->Foundation, drag “Base Python” onto the screen. Connect the green box to the blue box. Finally, under “Outputs,” drag an orange “Processed Stream- Single” box onto the screen. Drag the bottom of the blue box into the orange box. Your workflow should look like below.

Double click on the blue Base Python box. Replace the code in there with the following.

 

Before clicking save, make sure you replace the text YOUR PHONE NUMBER with the number of a device that can receive SMS messages. Make sure to keep the quotes around it.
Click  “Check Syntax”; once syntax passes, click “Save and Activate.”

Step 3: Create your button sequence tracking workflow

Go back to the Workflow Studio and click Create a New Workflow again. Name the workflow “Button Sequence Tracking.” Under Tags and Triggers -> raw, drag “Button Press” onto the screen. Then, under Modules -> Foundation, drag “Base Python” onto the screen. Connect the green box to the blue box. Your workflow should look like below.

Double click on the blue Base Python box. Replace the code in there with the following.

Like the previous workflow, replace the text YOUR PHONE NUMBER with the number of a device that can receive SMS messages.Make sure to keep the quotes around it. Click “Save and Activate.”

Step 4: Test your new security system

Spin the potentiometer on your board all the way to the left. You should get a text message like this one. If not, double check that all the workflows are saved and activated and you correctly typed in the number of your SMS device.

On your board, note buttons 1, 2, 3, and 4. The button number is written in small text next to each button, and are also shown in the diagram below.

Type in the sequence of numbers in the text message you received. You should receive another text message saying Alarm Disabled.

There’s another way to see the alarm code. Go to Data Viewer-> Data Streams. Click on the Processed Stream.

In the upper right hand corner, click on “Configure.” Select the tag “processed.security_code.”  Click save.

You should see all of the past codes, starting with the most recent.

Congratulations! You have successfully created an alarm system!

Appendix A: Using Alexa

We can add another workflow to enable the alarm via Alexa! This is assuming you completed the Alexa LED control tutorial found here. We assume you understand how to create skills on the Amazon Developer website and link them to your project. First, create the following workflow. The green box can be found under Tags and Triggers –> alexa_requests, called requets.intent.name. The blue box is base python.

You will have to create a new skill on Alexa as well. For the Interaction Model past the following:

Under slots, create a new slot “enable_disable” with the two options:

Under Sample Utterences, enter the following.

Try it out! You can now enable the alarm using Alexa.

Comments are closed, but trackbacks and pingbacks are open.