Skip to end of metadata
Go to start of metadata

Component list

  1. Raspberry Pi (

  2. 16x2 LCD (
  3. 10K variable resistor (
  4. 330 ohm resister (
  5. Jumper wires (

Overall idea

We have already shown how GadgetKeeper works with events/triggers in Temperature/Humidity monitoring with Arduino and Event/Trigger tutorial. In this tutorial we will show how to display a temperature reading from Arduino on remote Raspberry Pi's LCD screen. Raspberry Pi is connected to the network and it use MQTT protocol to communicate with GadgetKeeper. In our tutorial we use single Raspberry Pi but the same configuration can be used for multiple units.



1. Create "weatherStation" Arduino

Please follow Temperature/Humidity monitoring with Arduino and Event/Trigger step by step tutorial

2. Configure GadgetKeeper

  1. create the "Raspberry" thing 
  2. Create "mqtt" connection as shown below:

  3. Create the "display" remote method as shown below:

  4. In "weatherStation" thing create "displayTemperatureOnTemperatureChanged" trigger as shown below:
  5. Click "Edit Script" button on "displayTemperatureOnTemperatureChanged" trigger and code trigger business logic:

3. Prepare Raspberry Pi

We need to install few additional packages on Raspberry Pi to drive a 16x2 LCD display. So lets do it first. Please follow the given steps below and install all the listed packages as described.


Now you have installed the required packages to Raspberry Pi. Its time to download the adafruit library to Pi.


If you are using Raspberry Pi model A, you can directly use the library. But if you are using model B , then you need to make a small change on a library file. Edit and change pin #21 to pin #27 as shown below. (You can use nano to edit this file)

def __init__(self, pin_rs=25, pin_e=24, pins_db=[23, 17, 21, 22], GPIO = None):


def __init__(self, pin_rs=25, pin_e=24, pins_db=[23, 17, 27, 22], GPIO = None):


Now we have modified the required library file. Then run the following commands and copy the edited library file to our script folder.

Now we need to create a script to handle MQTT commands from GadgetKeeper.

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

Create our python script file inside the /root/gadgetkeeper/LCD_mqtt/ directory and paste the following script on it.

Now change the THING_ID as necessary. Also you can change the welcome message in the welcome_msg() function.


4. Hardware preparation

Next step is connecting the LCD to Raspberry Pi. You can follow the wiring diagrams given below.(If your LCD module doesn't have inbuilt resister connected to LED back light in series, please connect 330ohm resister to supply the power to LED back light)

5. Test the system

Now you can test the code. First supply the power to Raspberry pi. Then it will light the back light LED of the LCD display. Now slowly tune the 10K variable resister.then it will appear white dots on the LCD display. Keep the variable resister at the correct position and run the following command.

Now the LCD will first display the welcome message and then will connect to the GadgetKeeper via MQTT protocol and listen for thermometer data. At this point you can feed temperature readings to GadgetKeeper using two following methods.

  1. Feed data with Arduino as described here
  2. Use curl command on shell terminal directly

Follow the given command format below and send data to GadgetKeeper and trigger the remote Raspberry Pi method:

For example:

Then you will see the following information on the LCD. First line shows the last data updated time and second line shows the temperature reading which send from the Arduino thermometer. You can easily understand the sample code and do some modifications to display any custom message and any other data readings on LCD such as humidity, light intensity, wind speed etc.