1. Home
  2. Docs
  3. Device Kits
  4. Temperature Sensor on a Raspberry Pi

Temperature Sensor on a Raspberry Pi

This tutorial is intended for a RaspberryPi and will show how easy it is to integrate Avimesa Gadget with Node.JS and some temperature sensors. We will be using the child_process npm module to control Gadget. The temperature sensor being used is a DHT11/DHT22/AM2302. We will also be using the bcm2835 C library to assist in reading the digital outputs from the sensors.

Avimesa Node.js DHT11/22 Dev Kit


Hardware Setup

First you’ll want to wire the DHT sensor to the Raspberry Pi. In this case we will be using a DHT22 which has the following configuration:

alt text

Attach the sensor to the breadboard along with the wires in their respective places. The Raspberry Pi that I am using follows this pinout.

3 Wires are required: * From VCC to Pin 1 (3V3) on the RPi * From Data to Pin 7 (GPIO4) on the RPi * From Ground to Pin 9 (Ground) on the RPi

Software Setup

To get started download this project here.

  1. Move the file onto your RaspberryPi and unzip the file on your raspberry pi with: unzip Avimesa_DHT_Developer_Kit.zip.

  2. cd into the bcm2835-1.46 library and install it by running the following commands.

    sudo make check
    sudo make install

    This provides access to GPIO and other IO functions on the RaspberryPi.

  3. Now make sure you have Avimesa Gadget downloaded and installed.

  4. Next cd into the gadget_dht folder from the zip file to enter into the main folder for running Gadget.

  5. Configure the program to work with your Avimesa Credentials

    • Make sure you have an Avimesa DeviceID and Authentication Code ready

    • Now run a text-editor such as vi to edit the configuration in the index.js file. Enter your:

      • deviceid: The ID for the Device you want the data to flow to
      • authcode: The Authentication Key for the Device
      • Interval: The amount in milliseconds for how long it will wait to send data again
      • dhtSensor: Either a value of 11 or 22 depending on which sensor you have.
      • gpio: The GPIO that you are using on the RPi that is connected to the Data terminal on the sensor/breadboard.
  6. Run the program by running node index.js


Now we can go and add the new sensors to Avimesa.Live so that we can view the output data

  1. Login to your Avimesa.Live account. Go to Devices and select the Device that you are using.

  2. Add the temperature and humidity sensor. Make sure that the Temperature is in channel 0 and Humidity in channel 1. alt text alt text

  3. Now after a couple of minutes, if you are running the node index.js from earlier, you should see real-time data flowing from your Sensor earlier. alt text