IoT Intruder System With Intel® Arduino 101 & DFRobot

IoT Intruder System With Intel® Arduino 101 & DFRobot

IoT intruder alarm system on an Intel® Arduino 101 with DFRobot LCD Keypad Shield, connected to the IoT using the IoT JumpWay MQTT Library.

  • 1,348 views
  • 2 comments
  • 4 respects

Components and supplies

Apps and online services

About this project

Introduction

Here you will find sample device scripts for connecting Intel® Arduino/Genuino 101 and DFRobot LCD Keypad Shield to the TechBubble Technologies IoT JumpWay using the Python MQTT Serial Library.

The tutorial will allow you to set up an intruder alarm system that is controlled by the DFRobot LCD Keypad Shield, and communication via the IoT JumpWay.

In addition to using the LCD Keypad Shield to arm and disarm the system / turn on and off the alarm, you can also use an application or autonomous device communication via the IoT JumpWay to switch the states of the buttons on the keypad.

This project uses three applications:

  • A device application (Arduino) which communicates via serial with a Python Serial/MQTT application.
  • The Python Serial/MQTT application which communicates with the Arduino/Genuio 101 / DFRobot LCD Keypad Shield, and the IoT JumpWay.
  • A Python commands application / device application that can send commands to the device to toggle the state of the buttons. In this tutorial we will use the Intel® Edison Dev Kit LED Python Example which has both a device application and commands application. (Optional)

Python Versions

  • 2.7 (Python Serial/MQTT application)
  • 3.4 or above (Python commands application)

Software requirements

  • Arduino/Genuino IDE
  • ArduinoJson

Hardware Requirements

  • Intel® Arduino/Genuino 101.
  • DFRobot LCD Keypad Shield
  • 1 x DFRobot Digital PIR Sensor Module
  • 1 x DFRobot Digital Buzzer Module
  • 4 x male / female jumper wires
  • 2 x male / male jumper wires

Before You Begin

If this is the first time you have used the TechBubble IoT JumpWay in your IoT projects, you will require a developer account and some basics to be set up before you can start creating your IoT devices. Visit the following link and check out the guides (Roughly 5 minutes) that take you through registration and setting up your Location Space, Zones, Devices and Applications.

TechBubble Technologies IoT JumpWay Developer Program (BETA) Docs

Adding The Arduino/Genuino Board To Arduino IDE

  • Tools -> Boards -> Boards Manager
  • Search for Curie, or Intel Curie
  • Right click on the right of the Curie section and click install

Install Requirements On Your PC & Arduino / Genuino 101

 $ pip install iot_jumpway_mqtt_serial
  • Install the ArduinoJson library in the Arduino IDE:
Sketch -> Include Library -> Manage Libraries
Search for ArduinoJson
Right click on the right of the ArduinoJson section and click

Setting Up Your Intel® Arduino/Genuino 101

First of all, you need to connect up your DFRobot LCD Keypad Shield to your Intel® Arduino/Genuino 101, and connect your DFRobot PIR Sensor Module & DFRobot Buzzer Module. Follow the next steps to accomplish this.

  • Place the shield on top of your Arduino as in the image above.
  • Connect 3 of your male / female jumper wires to one end of your DFRobot PIR sensor wires.
  • Connect the green wire to D2 on the DFRobot LCD Keypad Shield, red to VCC and black to GND.
  • Connect your final male / female jumper wire to the green DFRobot buzzer wire, and the 2 male / male wires to the red and black wires of the buzzer.
  • Connect the green wire to D3 on the DFRobot LCD Keypad Shield, red to VCC and black to GND.

Device Connection Credentials & Actuator Settings

  • Retrieve your connection credentials by following the link above, and update the config.json file with your new connection credentials.
 "IoTJumpWaySettings": {
        "SystemLocation": 0,
        "SystemZone": 0,
        "SystemDeviceID": 0,
        "SystemDeviceName" : "Your Device Name",
        "SystemDeviceCom" : "Your Device Com Port"
    },
    "IoTJumpWayMQTTSettings": {
        "MQTTUsername": "Your Device MQTT Username",
        "MQTTPassword": "Your Device MQTT PASSWORD"
    }
 String JumpWaySensorType = "LCD Keypad";
 String JumpWaySensorID = "1";
 String JumpWaySensorType2 = "PIR Sensor";
 String JumpWaySensorID2 = "2";
 String JumpWaySensorType3 = "Buzzer";
 String JumpWaySensorID3 = "3";
  • You may also need to alter the debounceWait variable if the buttons trigger multiple times.
 int debounceWait = 150;

Execute The Python Program

As you have already uploaded your sketch, the program will now be running on your Arduino/Genuino 101. All that is left is to start the Python program with the following line:

$ python NameOfYourSerialApplication.py 

Autonomous Communication With Second Device

Each time you press a button, the device will send sensor data to the TechBubble IoT JumpWay and warning alerts will be sent when the motion sensor picks up activity. You can use sensor values and warning messages to trigger autonomous communication with other devices you have connected to the IoT JumpWay.

On the device edit page scroll down to the "Create Rules" section under the Actuators / Sensors. Here you can use the dropdown menu to create rules that allow your device to email you, or to autonomously communicate with other devices on its network in the event of status updates, sensor data and warnings.

Control Via Command Application

IoT JumpWay Developer Program (BETA) Location Applications give you the ability to plug in control features for all devices connected to your IoT JumpWay Locations into your own applications.

In this part of the tutorial we will focus on sending commands from our command application to replicate the buttons being pressed on the DFRobot LCD Keypad.

This feature means that you could have an Android/iOS/web application and be anywhere in the world and be able to turn on/off whatever device you connected to the keyboard functions in the step above.

Follow the next steps to set up your application:

  • Update the device related configs with the credentials you created from this tutorial. This will mean that the application will no longer be sending control commands to the Edison Dev Kit LED device, but to the Python Serial/MQTT application we created in this tutorial which will, in turn, send the commands to the device and switch the buttons. You need to update the SystemZone, SystemDeviceID, SystemDeviceName and Actuators settings as below, the Actuator settings should match the ones you modified in the Arduino sketch above:
"IoTJumpWaySettings": {
        "SystemLocation": 0,
        "SystemZone": 0,
        "SystemDeviceID": 0,
        "SystemDeviceName" : "Your Device Name",
        "SystemApplicationID": 0,
        "SystemApplicationName" : "Your Application Name"
    }
    "Actuators": {
        "LCD Keypad": {
            "ID": 1
        }
  • Finally you need to update the application itself. At the bottom of the application you will see the following code:
DevKitLedApplication.JumpWayMQTTClient.publishToDeviceChannel(
        "Commands",
        DevKitLedApplication.configs["IoTJumpWaySettings"]["SystemZone"],
        DevKitLedApplication.configs["IoTJumpWaySettings"]["SystemDeviceID"],
        {
            "Actuator":"LED",
            "ActuatorID":DevKitLedApplication.configs["Actuators"]["LED"]["ID"],
            "Command":"TOGGLE",
            "CommandValue":"ON"
        }
    )
    time.sleep(5)
    DevKitLedApplication.JumpWayMQTTClient.publishToDeviceChannel(
        "Commands",
        DevKitLedApplication.configs["IoTJumpWaySettings"]["SystemZone"],
        DevKitLedApplication.configs["IoTJumpWaySettings"]["SystemDeviceID"],
        {
            "Actuator":"LED",
            "ActuatorID":DevKitLedApplication.configs["Actuators"]["LED"]["ID"],
            "Command":"TOGGLE",
            "CommandValue":"OFF"
        }
    )
  • Change that code to the following:
DevKitLedApplication.JumpWayMQTTClient.publishToDeviceChannel(
        "Commands",
        DevKitLedApplication.configs["IoTJumpWaySettings"]["SystemZone"],
        DevKitLedApplication.configs["IoTJumpWaySettings"]["SystemDeviceID"],
        {
            "Actuator":"LCD Keypad",
            "ActuatorID":DevKitLedApplication.configs["Actuators"]["LCD Keypad"]["ID"],
            "Command":"TOGGLE",
            "CommandValue":"1"
        }
    )
    time.sleep(5)
    DevKitLedApplication.JumpWayMQTTClient.publishToDeviceChannel(
        "Commands",
        DevKitLedApplication.configs["IoTJumpWaySettings"]["SystemZone"],
        DevKitLedApplication.configs["IoTJumpWaySettings"]["SystemDeviceID"],
        {
            "Actuator":"LCD Keypad",
            "ActuatorID":DevKitLedApplication.configs["Actuators"]["LCD Keypad"]["ID"],
            "Command":"TOGGLE",
            "CommandValue":"2"
        }
    )
    time.sleep(5)
    DevKitLedApplication.JumpWayMQTTClient.publishToDeviceChannel(
        "Commands",
        DevKitLedApplication.configs["IoTJumpWaySettings"]["SystemZone"],
        DevKitLedApplication.configs["IoTJumpWaySettings"]["SystemDeviceID"],
        {
            "Actuator":"LCD Keypad",
            "ActuatorID":DevKitLedApplication.configs["Actuators"]["LCD Keypad"]["ID"],
            "Command":"TOGGLE",
            "CommandValue":"3"
        }
    )
    time.sleep(5)
    DevKitLedApplication.JumpWayMQTTClient.publishToDeviceChannel(
        "Commands",
        DevKitLedApplication.configs["IoTJumpWaySettings"]["SystemZone"],
        DevKitLedApplication.configs["IoTJumpWaySettings"]["SystemDeviceID"],
        {
            "Actuator":"LCD Keypad",
            "ActuatorID":DevKitLedApplication.configs["Actuators"]["LCD Keypad"]["ID"],
            "Command":"TOGGLE",
            "CommandValue":"4"
        }
    )
  • Start up the application with the following command, if the device and the Serial/MQTT applications are running, you will see the output in the Serial/MQTT application and the buttons 1 -4 will be triggered on the device, in turn, communicating with the device you connected up in the autonomous communication section above.
sudo python/python3 Dev-Kit-Led-Application.py

Viewing Your Data

Each time you press a button, it will send data to the TechBubble IoT JumpWay. You will be able to access the data in the TechBubble IoT JumpWay Developers Area. Once you have logged into the Developers Area, visit the TechBubble IoT JumpWay Location Devices Page, find your device and then visit the Sensor/Actuator page and the Warnings page to view the data sent from your device.

IoT JumpWay Intel® Arduino/Genuino 101 Examples Bugs/Issues

Please feel free to create issues for bugs and general issues you come across whilst using the IoT JumpWay Intel® Arduino/Genuino 101 Examples. You may also use the issues area to ask for general help whilst using the IoT JumpWay Intel® Arduino/Genuino 101 Examples in your IoT projects.

IoT JumpWay Intel® Arduino/Genuino 101 Examples Contributors

Code

Github
https://github.com/TechBubbleTechnologies/IoT-JumpWay-Python-MQTT-Serial-Client/blob/master/application.py
Github
https://github.com/TechBubbleTechnologies/IoT-JumpWay-Intel-Examples
Github
https://github.com/TechBubbleTechnologies/IoT-JumpWay-Docs/

Comments

Similar projects you might like

Rocky Rover: Robotic Vision System PixyCam & Arduino 101

Project tutorial by Ron Dagdag

  • 15,075 views
  • 7 comments
  • 104 respects

Smart Garbage Monitoring System Using Arduino 101

Project tutorial by Technovation

  • 21,474 views
  • 7 comments
  • 32 respects
Add projectSign up / Login