Skip to end of metadata
Go to start of metadata

1. Component list

  1. Arduino UNO board (

  2. Arduino Ethernet shield (
  3. Common anode RGB led x 1
  4. 330 ohm resisters x 3

Arduino UNO board

Ethernet shield



2. Overall idea

We already have discussed few ways to monitor the temperature and humidity in a remote site using Arduino or Raspberry pi with the support of GadgetKeeper. Also we have discussed, how to trigger email alert when exceed the pre-configured threshold levels. So this is the next step.You can easily setup this simple but useful circuit for visualized notifications. This tutorial shows how to setup the blink notifier and how to use it for notifications. The unit consists of Arduino UNO board and Ethernet shield with a RGB led connected to it. The unit keep on connected to the internet and subscribe with GadgetKeeper mqtt service and listen for commands. Once it receives a valid command from the GadgetKeeper via mqtt service, it analyzes the command contain data and activate the LED. The basic json formatted  instruction set contains the following information at the moment. You can easily follow the sample code and extend it to support more settings or even more RGB LEDs. Not only that you can connect a buzzer with few modification in the code and trigger some sounds parallel with the LED notification.

current json data format as follows.


You can set the following parameters via mqtt command.

  • colour (red, green, blue)
  • led fading speed (in millisecond)
  • notification duration (in millisecond)


3. How to configure GadgetKeeper to use with Arduino blinker

Basically you need to follow the steps given below to prepare the GadgetKeeper for this test. All the necessary steps are given below with details,

  1. Create the BlinkRequest data type.
  2. Create blink thing.
  3. Create blink method.
  4. Create the mqttBlink connection to communicate with blink hardware.
  5. Create the thermometer thing.
  6. Create the mqtt connection to communicate with the temperature sensor hardware.
  7. Create the temperature property.
  8. Create the temperatureChanged event.
  9. Create the highTemperatureBlink trigger.
  10. Add the action script to trigger.


  1. Create the BlinkRequest data type.
    Click on Data Types icon and define the data format as shown below. You should at least define colour (String), fadeSpeed (int) and duration (int) to communicate with blink hardware at the moment as shown below.

  2. Create blink thing.
    Then create the blink thing as shown below.
  3. Create blink method.
    Next step is to create the blink method as shown below.
  4. Create the mqttBlink connection to communicate with blink hardware.
    Then create the mqtt connection as shown below. This is the connection GadgetKeeper use to communicate with blink hardware.

  5. Create the thermometer thing.
    Next step is to create the thermometer thing.
  6. Create the mqtt connection to communicate with the temperature sensor hardware.
    Since we are connecting a mqtt supported thermometer with the GadgetKeeper, we need to create this mqtt connection to communicate with that thermometer. Make sure to set the timeout parameter to 10000ms to avoid common network timeout problems.
  7. Create the temperature property.
    next add the temperature property to thermometer thing as shown below. Make sure to set the Data Type to float and Type to remote.
  8. Create the temperatureChanged event.
    Create the temperatureChanged event as shown below.
  9. Create the highTemperatureBlink trigger.
    Then create the highTemperatureBlink trigger as shown in the figure. Make sure to select the thing and event correctly as shown in the sample snap.

  10. Add the action script to trigger.
    We have already discussed in this step by step tutorial about how to configure the email notification on temperatureChanged event. But we are not sending email notification in this stage. So we should invoke the blink method in the blink thing instead. Then it will send the blink command to Arduino via mqtt connection and trigger the LED. So lets change the action script as shown below.



Now the GadgetKeeper configuration part is finished. Next step is to prepare the Arduino hardware, compile the sketch and upload it to Arduino.

4. Prepare the blinker hardware

It is so simple circuit. You can setup it easily. We only use the Arduino D3, D5, D6 pins to drive R G B colours respectively. Also please make sure to use 330 ohm resisters with each R G B terminals  to control the current to LED. Have a look at the following prototype circuit.


5. Arduino libraries required

We have used Arduino 1.5.6-r2 version as the IDE. You can download it from this url.( Also make sure to download and  include following libraries to the sketch if not already exists. (Most of the libraries comes with the Arduino IDE by default)

  1. SPI.h

  2. Ethernet.h

  3. PubSubClient.h

  4. JsonParser.h

Note*** - You need to make small modification on one of the Arduino library you used for this tutorial.

First open the PubSubClient.h library header file and make the following simple modification in that file. (increase the packet size as shown below). The GadgetKeeper MQTT request is bigger in size. So the default packet size defined in Arduino library is not enough to handle the MQTT request at Arduino side. So increase the packet size to 256 as shown below. Then restart the Arduino IDE.

6. Arduino sketch

Check more details on implementing JSON-RPC handler with JSON-RPC over Messaging

Use the following Arduino sketch with necessary modifications to match with your settings.


Please note that we have specially used millis(); function to manage long delay periods within the void loop() section in the script. We can't use standard delay(); function for this with long time periods. Because it will stop listening to mqtt messages while the delay function is called. However still we have used the standard delay(); function to handle short time periods in the sketch.

7. How to test

Make sure to connect the Arduino blink module to Gadgetkeeper before testing. Then click on the event in thermometer thing and click on Push Event button. Now you can see the blink module LED is getting blink and notify the high temperature state. Also you can further modify the action script and control the different LED blink status as shown below.


function onEvent(event){
    var blink=context.things["blink"].me;
        blink.blink({colour:"red", fadeSpeed:"5", duration:"100000"});
    }else if(event.value>25){
        blink.blink({colour:"red", fadeSpeed:"10", duration:"200000"});


8. How to debug the blinker device

Open the serial terminal in 9600 baud rate. Then you can see all the arduino debug messages from your blinker application. Please check the example below.

(Arduino capture the instruction set and blink according to the instruction received.)


  1. Connect buzzer to Arduino and ring it when receive blink commands from GadgetKeeper.
  2. Modify the sketch to support for different colours like orange, yellow etc.          


  • No labels