IoT Device Controller With Intel® Arduino 101 & DFRobot

IoT Device Controller With Intel® Arduino 101 & DFRobot

Control your IoT devices with Arduino 101, DFRobot LCD Keypad Shield and autonomous IoT communication via the IoT JumpWay.

  • 664 views
  • 0 comments
  • 3 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 allow you to set up an IoT device that can control other IoT devices on the same network using the LCD Keypad Shield and communication via the IoT JumpWay.

In addition to using the LCD Keypad Shield, you can also use a 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:

1. A device application (Arduino) which communicates via serial with a Python Serial/MQTT application.

2. The Python Serial/MQTT application which communicates with the Arduino/Genuio 101 / DFRobot LCD Keypad Shield, and the IoT JumpWay.

3. 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
  • An IoT device connected to the TechBubble IoT JumpWay (Optional)

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 that take you through registration and setting up your Location Space, Zones, Devices and Applications (Roughly 5 minutes).

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 hand side of the Curie section and click install to install the latest version

Install Requirements On Your PC & Arduino/Genuino 101

1. For the Python Serial/MQTT application we will need the TechBubble IoT JumpWay Python MQTT Serial Library installed on our PC/laptop/Mac. To Install the library, issue the following command on your chosen device:

 $ pip install iot_jumpway_mqtt_serial

2. 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 install.

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, place the shield on top of your Arduino as in the image above.

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 JumpWayActuatorID = "1"; 
  • 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 actuator data to the TechBubble IoT JumpWay. You can use actuator data values 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

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 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

Intel Arduino 101 BLE Blynk Tank

Project tutorial by Johnathan Hottell

  • 11,722 views
  • 6 comments
  • 45 respects

Arduino 101 Controller

Project showcase by Team TATCO Inc

  • 2,044 views
  • 0 comments
  • 9 respects

Rocky Rover: Robotic Vision System PixyCam & Arduino 101

Project tutorial by Ron Dagdag

  • 18,826 views
  • 7 comments
  • 125 respects
Add projectSign up / Login