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
Components
- A RaspberryPi running with Raspbian
- A DHT11 or DHT22/AM2302 Temperature Sensor
- A breadboard and wiring (female and male)
- A Valid set of Avimesa Device Credentials. Get a free account here
- An Avimesa Gadget installation
- A Node.JS installation
- Avimesa_DHT_Developer_Kit.zip
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: 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.
-
Move the file onto your RaspberryPi and unzip the file on your raspberry pi with:
unzip Avimesa_DHT_Developer_Kit.zip
. -
cd
into the bcm2835-1.46 library and install it by running the following commands../configure make sudo make check sudo make install
This provides access to GPIO and other IO functions on the RaspberryPi.
-
Now make sure you have Avimesa Gadget downloaded and installed.
-
Next
cd
into thegadget_dht
folder from the zip file to enter into the main folder for running Gadget. -
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 theindex.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
or22
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.
-
-
Run the program by running
node index.js
Avimesa.Live
Now we can go and add the new sensors to Avimesa.Live so that we can view the output data
-
Login to your Avimesa.Live account. Go to Devices and select the Device that you are using.
-
Add the temperature and humidity sensor. Make sure that the Temperature is in channel 0 and Humidity in channel 1.
-
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.