Analog sensor data send to blynk cloud
The analog sensor data can be sent from your ESP8266 to the blynk cloud to monitor the data. First of all we will send the analog data value from 0 to 1023 and after that we will send calculated data of different sensors.
Circuit Diagram
Code
#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL09mgzGQd"
#define BLYNK_DEVICE_NAME "project1"
#define BLYNK_AUTH_TOKEN "qT1XpiEBwwW-U54IdimqyOfrEtFFNHsp"
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "qT1XpiEBwwW-U54IdimqyOfrEtFFNHsp";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
int sensor1;
BlynkTimer timer;
void mytimer()
{
Blynk.virtualWrite(V2, sensor1);
}
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(A0,INPUT);
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000l, mytimer);
}
void loop()
{
sensor1=analogRead(A0);
Blynk.run();
Timer.run();
}
Now go to your blynk dashboard and follow the following command serially.
Go to templates
Click on edit button.
Then go to datastreams. And click on the new datastream and choose the virtual pin.
Then choose pin V2 and change maximum value to 1023 and create it.
Now go to web dashboard and drag the gauge and go to setting to choose the virtual pin V2.
Then choose v2 and save it.
Then click on save and apply .
Then go to the search button and click on your project which you will see below.
Circuit diagram:
Components required:
i) Breadboard
ii) NodeMCU ESP8266
iv) Jumper wires
v) MQ6 gas sensor
vi) Type B USB cable
Now upload the code after selecting the port. After uploading, go to your blynk dashboard. And observe the sensor data.
Comments
Post a Comment