• Worldwide Shipping

  • 24/7 Customer Support

  • FAQ
  • Worldwide Shipping

  • 24/7 Customer Support

  • FAQ

dweet.io + Croduino NOVA

INTRODUCTION

In this tutorial, we will describe how we can save all the values we measure using sensors (humidity, temperature) to the cloud on the Internet easily and access them from other devices via the Internet. We will use Croduino Nova 2 to measure and send data, and the service that allows us to save the data is called dweet.io.

 

WHAT IS DWEET.IO?

Dweet.io is an online service that allows us to easily save data from our microcontroller that is connected to the Internet. This service is simple because it does not require registration and login, we simply send the data, which are then ready for review, the only problem is the fact that anyone can access our data. When Croduino Nova 2 is connected to the Internet, we just need to point it to the dweet.io station, and to the URL, we add the name of the variable we want to save to the service. The data is stored on the page for one day, i.e. only the last 5 sent dweets (a set of data sent in one post). If we need to keep the data longer, we can use paid options.

GRAPHICAL REPRESENTATION OF DATA

Dweet.io also allows us to graphically display the data we send from our sensors. In order to get a graphical display of the information we sent to dweet.io, we only need to enter the following address to the Internet browser: https://dweet.io/follow/OurName (since we use CroduinoNova2 in the name example, our URL will be https://dweet.io/follow/CroduinoNova2) and the information we sent to dweet.io will be graphically shown under the name CroduinoNova2. An example of a graphical representation of the temperature we send to dweet.io with Croduino Nova is shown in the image.

HOW TO CONNECT IT?

As an example, we will use the DHT11 temperature and humidity sensor and send the measured values to dweet.io. Connecting the DHT11 sensor to the Croduino Nova 2 is very simple because, to the sensor, we need to connect +3.3V to the Vcc pin, GND to GND pin, and DATA pin to Croduino pin 5. The pinout for the DHT11 and DHT22 sensors is shown in the image, and as we can see they have the same layout, which allows us to easily replace them if necessary (in the code, we only need to change which sensor we are using).

ARDUINO CODE

For this code example, we need a DHT library, and we need to add Croduino Nova2 to the Arduino IDE according to the tutorial. If you do not know how to install the library, check the tutorial that describes how to install the library.
In the image, we see what sending the data to dweet.io. looks like. Red indicates where the name of the device (that we have selected in the code) from which we are sending data is written.
The yellow rectangle shows the part where it was recorded when the data was sent, and the green one shows the data we have sent. We can also see how only the last 5 pieces of data sent were saved. We have selected CroduinoNova2 as the name in the code, but we can change that, and then, when searching, in the web browser we need to enter the corresponding name that we have selected.

//including the ESP8266WiFi library that allows working with WiFi on the ESP8266 module
#include "ESP8266WiFi.h"
//including the DHT library that allows working with the DHT temperature sensor
#include "DHT.h"
//setting the SSID and the password of the network we are connecting to
const char* ssid = "SSID_network";
const char* password = "Password";
//defining the pin to which we connect the DHT sensor
#define DHTPIN 5
//defining the type of sensor we are using (DHT11 or DHT22)
#define DHTTYPE DHT11
//DHT library constructor
DHT dht(DHTPIN, DHTTYPE, 15);
//setting the host to which we send the data
const char* host = "dweet.io";
void setup() {
//starting serial communication (115200 baud)
Serial.begin(115200);
delay(10);
//starting communication with the DHT sensor
dht.begin();
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
//connecting to the network whose data we have entered in the beginning
WiFi.begin(ssid, password);
//up until we have connected, the while loop is executed so that we won't continue further execution of the code until we have connected to the network
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
//displaying that we are connected on the Serial monitor, printing the IP address
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
Serial.print("Connecting to ");
Serial.println(host);
//using the WiFiClient class to create the TCP connection
WiFiClient client;
const int httpPort = 80;//setting the port to 80
//connecting to the host (the page that we have entered in the beginning)
//if we weren't able to connect, go back to the void loop
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
//saving the humidity reading from the sensor to the h variable
int h = dht.readHumidity();
//saving the temperature from the sensor to the t variable
int t = dht.readTemperature();
//sending the request to the host, and within that request, we send the temperature and humidity readings from the sensor
//if we want to send another parameter to the host, we need to add the following line to the request
//behind the String(h) + we add ( "&name_oftheparameter=" + String(variable)+)
//in the end, after all the variables, there must be " HTTP/1.1\r\n" ...
//to the Internet browser, we enter https://dweet.io/get/dweets/for/CroduinoNova2 (instead of CroduinoNova2 we can enter the name we want to
//but then we search it using that name)
client.print(String("GET /dweet/for/CroduinoNova2?temperature=") + String(t) + "&humidity=" + String(h) + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(10);
//reading all the lines of the host's answer and displaying them on the Serial monitor
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
//displaying that the connection is closed on the Serial monitor
Serial.println();
Serial.println("closing connection");
//10 second pause
delay(10000);
}
Leave a Reply