Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Component list

...

  1. Raspberry Pi (http://en.wikipedia.org/wiki/Raspberry_Pi)

  2. 16x2 LCD (http://www.adafruit.com/product/181)
  3. 10K variable resistor (https://learn.adafruit.com/adafruit-arduino-lesson-8-analog-inputs/variable-resistors-pots)
  4. 330 ohm resister (https://www.sparkfun.com/products/8377)
  5. Jumper wires (http://www.adafruit.com/products/824)

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:

    Code Block
    language js
    function onEvent(event){
      var rb=context.things["Raspberry"].me;
      rb.display(event.value);
    }

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

...