Overview

Skill Level: Beginner

Ingredients

• Raspberry 3.

• L-Tek IoT Sensor (L-Tek FF1502 Sensor BLE).

• Philips Hue Led Strip.

• Philips Hue Bridge.

• IBM Cloud Account.

• IBM IoT Account.

Step-by-step

  1. IBM Cloud Account

    First of all we need to create a resource in our IBM Cloud Account,

    Screenshot_1

     

    Now we will Click in the first one, we will see a new screen asking for name of the service and what plan we want to use. We will use the free plan, after that we click in create.

     

    Screenshot_2

    Now we will Click in the first one, we will see a new screen asking for name of the service and what plan we want to use. We will use the free plan, after that we click in create.

     

     

     

    Screenshot_3

    Now we will do the same with the Weather Company Data.

    If we go to our Dashboard we will see our Resource summary there we will see our app.
    If we click in Cloud Foundry Apps, we will see something like this.

     

    Screenshot_4

    If we choose aletestiot, it will show us information about our app and the URL to our Node Red environment.

    Screenshot_5

     

    If we choose that it will send us to our editor, by default we will see a few nodes, you can delete them or create a new one, it’s your choice.

  2. IBM IoT Plattform

    Now we will forget about node red and configure our IoT platform. We should go to this web page to create our IoT organization.
    https://internetofthings.ibmcloud.com/
    Once we are log in, we will see a Dashboard, in the corner we will see the name of our organization.

    Screenshot_6

    Now we will add our Raspberry Pi, you need to give it a Device ID and a device type.

    Screenshot_7

    We can leave empty the next screen, after that it will ask for a authentication token.

    Screenshot_8

    And we will see a summary with all the info, Now we can click Done.

    Screenshot_9

    We will see a resume of the Information recommend you to copy everything to a notepad. We will need it later.

    Screenshot_10

     

     

  3. Set up the Raspberry Pi

    Now we should go to our Raspberry Pi.
    We need to copy the file RPI_Gateway.py that we will see inside the folder RPI_Nodes.
    https://github.com/Hezemans/IoTIBM

    Screenshot_11

    Open RPI_Gateway.py file and change the lines in the picture below, following directions in the comments of the code.

     

    Screenshot_12

     

  4. Node Red in the Cloud

    Ok now we will go back to our Cloud Node Red.
    In the GitHub you will find the code for the next Flow. Inside Cloud_Nodes.

     Screenshot_13

     

    Ok, let me explain what this flow does.
    When we start the flow, it will go to the weather service and save the reply into our cloudant db, it will check what time it is and look for the weather and with the weather it will send the signal to our Raspberry pi and it will turn on the lights depending of the weather.
    Once a day it will ask the weather service for todays forecast and store it in the database and every hour it will read from the database and change the colors. And at night it will delete the info that we have in the database and ask the service for new info.

     

  5. Node Red in the Raspberry Pi

    Now we go to our RPi Node Red.
    How to launch Node Red in the RPi.

    Screenshot_14

     

    Now we go to a web browser and write the IP address the node red terminal show us.

    Screenshot_15

    We copy the Flow, it will send the command to the Hue controller to turn off and on the lights and to change colors. You will need to change the IP Address and the user in the web socket node.

    Screenshot_16

    Screenshot_17

     

    Screenshot_18

    Time to configure our HUE Lights.
    Follow this tutorial.
    https://developers.meethue.com/develop/get-started-2/
    Once you have done it, you can start playing with the lights.

     

  6. Using Cloud and the Sensor

    With this Flow we will send the information to the cloud. This flow is in the cloud.

    Screenshot_19

    Now in our Raspberry we will add a Flow to read the temperature from our L-Tek FF1502 Sensor BLE and change the lights to the temperature of the room.

    Screenshot_20

     

    First, we need to run the RPI_Gateway file in the RPi, and we will see something like this. The sensor must be on.

    Screenshot_21

    It will get the temperature from the sensor and turn the lights red or blue according to the temperature.
    Now we will connect the Flows in the cloud to check if the sensor is on, if it is it will show the lights according to the temperature of the room, if its off it will go to the weather service and change the colors according the weather.

    Screenshot_22

  7. Final Result

Join The Discussion