Blur about how to program Cloud

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);
}

I already sent you a link to the article which you just simply ignored. It has all the information you need to complete your task

Nobody will write a code for you. You need to understand basic principles. Please spend five minutes on trying to understand how Blynk works. This will help you to save hours of frustration after that

1 Like

what do you mean by “cloud” ?
is it blynk cloud or HTML ?

@Fata45 Also, spend the 30 seconds it takes to look back at your first post and see how I edited it to properly format any posted code here :stuck_out_tongue_winking_eye:

And… ohhh… that bad void loop() :open_mouth: NOT Blynk friendly.

2 Likes

sorry i did’t understand

blynk loop :slight_smile:

void loop()
{ 
  Blynk.run();
} 

nothing else

thanks bro

1 Like