The SHT21 is a low cost humidity and temperature sensor. Its an I2C device so again is very simple to connect to any arduino. In this case we will send sesnor data to ubidots
The SHT2x sensors contain a capacitive type humidity sensor, a band gap temperature sensor and specialized analog and digital integrated circuit – all on a single CMOSens® chip. This yields in an unmatched sensor performance in terms of accuracy and stability as well as minimal power consumption.
You will need to head over to ubidots and create a new account – https://app.ubidots.com/
Once you have completed the signup process you need to create a data source under Data Sources, something like this
Now click on the data source and you should see an Add variable screen
You will need to get the variable id, click on the variable and you will see another page which lists various properties of the variable. The ID is listed you will need to take a note of this to update the code example later
Schematic
I dont have a SHT21 part in fritzing but its the same as an SHT31 (which is an updated version and would also work here)
Code
There are a couple of libraries to help you out with regards to SHT21
https://github.com/misenso/SHT2x-Arduino-Library
https://github.com/elechouse/SHT21_Arduino
[codesyntax lang=”cpp”]
#include <Ethernet.h> #include <SPI.h> #include <UbidotsEthernet.h> #include <Wire.h> #include <SHT2x.h> #define ID "variable ID" // Put here your Ubidots variable ID #define TOKEN "token here" // Put here your Ubidots TOKEN // Enter a MAC address if available byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // Set a static IP address to use if the DHCP fails to assign IPAddress ip(192, 168, 1, 177); Ubidots client(TOKEN); void setup() { Serial.begin(9600); Wire.begin(); if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // try to congifure using IP address instead of DHCP: Ethernet.begin(mac, ip); } delay(1000); } void loop() { client.add(ID, SHT2x.GetTemperature()); client.sendAll(); }
[/codesyntax]
testing
Open the serial monitor and all going well you should see something like this
Posting your variables
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 02 Nov 2016 22:15:54 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: close
Vary: Accept-Encoding
Vary: Accept
Allow: POST, OPTIONS
16
[{“status_code”: 201}]
0
Go back to ubidots and you now should see data being sent to your variable, here is the temperature being displayed from my SHT21 sensor, you can sit and watch this change providing the temperature is not exactly the same
Now double click on the variable and you can see a graph and a table with data, here is mine. There are various options
Links
these come in at about $7 for a useful breakout board with this sensor
Humidity Sensor – SHT21 Breakout Board