hello , i’m newbie here. my question is how to transfer data from sensor to web. just for monitoring. my program already can connect to blynk using nodeMCU but i did know how to transfer the data from sensor to cloud.
Below is my program :
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "my token";
const int sensorPin = D2;
const int sensorPin1 = A0;
int sensorState = 0;
int lastState = 0;
int analogSensor = analogRead(sensorPin1);
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, "wifi name", "my password");
pinMode(sensorPin, INPUT);
pinMode(sensorPin1, INPUT);
}
void loop()
{
Blynk.run();
sensorState = digitalRead(sensorPin);
Serial.println(sensorState);
analogSensor = analogRead(sensorPin1);
Serial.println(analogSensor);
if (sensorState == 1 && lastState == 0) {
Serial.println("WATER detected something PLIS ALERT, send notification");
Blynk.notify("WATER detected something PLIS ALERT");
lastState = 1;
delay(1000);
//send notification
}
else if (sensorState == 1 && lastState == 1) {
//do nothing, has not been watered yet
Serial.println("has not been watered yet");
delay(1000);
}
else {
//st
Serial.println("does not need water");
lastState = 0;
delay(1000);
}
if (analogSensor > 700)
{
Serial.println("Gas Detected something !! PLIS ALERT, send notification");
Blynk.notify("Gas Detected something !! PLIS ALERT");
}
else
{
Serial.println("Nothing happen");
delay(1000);
}
delay(100);
}