Arduino uno and EthernetShield with new Blynk 2.0

Hello everyone,
hope all are good. i have sketch that monitor temperature and humidity with arduino uno and ethernet shield with old blynk application. can someone please edit my code that work with new blynk application. thank you
this is my code

#define BLYNK_AUTH_TOKEN            "q8CtRZycPcqbOgPE6kwzWvvV6xGkwbC3"
#define BLYNK_PRINT Serial

#include <SPI.h>
#include <Wire.h>   //  library for I2C protocol
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <DHT.h>
#include <LiquidCrystal_I2C.h>  // library for I2C LCD

LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display

char auth[] = BLYNK_AUTH_TOKEN;

#define DHTPIN 2          // What digital pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
#define DHTTYPE DHT21   // DHT 21, AM2301

DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

const int waterSens1 = A0;//define water sensor to pin A0
int SensorValue1;//create sensor data variable

const int waterSens2 = A1;//define water sensor to pin A0
int SensorValue2;//create sensor data variable

const int waterSens3 = A2;//define water sensor to pin A0
int SensorValue3;//create sensor data variable

const int waterSens4 = A3;//define water sensor to pin A0
int SensorValue4;//create sensor data variable


void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);

  int sensorValue1 = analogRead(waterSens1);//read the water sensor value

    if (sensorValue1 >= 50){
    Blynk.virtualWrite(V1, 1);
    }
    else
    {
    Blynk.virtualWrite(V1, 0);
    }

    int sensorValue2 = analogRead(waterSens2);//read the water sensor value

    if (sensorValue2 >= 50){
    Blynk.virtualWrite(V2, 1);
    }
    else
    {
    Blynk.virtualWrite(V2, 0);
    }

    int sensorValue3 = analogRead(waterSens3);//read the water sensor value

    if (sensorValue3 >= 50){
    Blynk.virtualWrite(V3, 1);
    }
    else
    {
    Blynk.virtualWrite(V3, 0);
    }

    int sensorValue4 = analogRead(waterSens4);//read the water sensor value

    if (sensorValue4 >= 50){
    Blynk.virtualWrite(V4, 1);
    }
    else
    {
    Blynk.virtualWrite(V4, 0);
    }

    if(sensorValue1 >= 50 || sensorValue2 >= 50 || sensorValue3 >= 50 || sensorValue4 >= 50)
    {
      Blynk.virtualWrite(V0, 1);
       Blynk.email("nomanjameel26@gmail.com", "Water Alert", "Water Sensor 1 Alarm!");
       Blynk.notify("Water Alert - Water Sensor 1 Alarm!");
    }
    else
    {
      Blynk.virtualWrite(V0, 0);
    }
}


void setup() {
  lcd.init();
  lcd.backlight();
  dht.begin();
  lcd.setCursor(0, 0);
  lcd.print("Temp:");
  lcd.setCursor(0, 1);
  lcd.print("Humidity:");
  lcd.setCursor(0, 2);
  lcd.print("Leakage:");
  Serial.begin(9600);
  Blynk.begin(auth);
  timer.setInterval(1000L, sendSensor);

}

void loop() {

  delay(500);

int sensorValue1 = analogRead(waterSens1);//read the water sensor value

    if (sensorValue1 >= 50){
    lcd.setCursor(1, 3);
    lcd.print("1");
    }
    else
    {
    lcd.setCursor(1, 3);
    lcd.print("0");
    }

int sensorValue2 = analogRead(waterSens2);//read the water sensor value

    if (sensorValue2 >= 50){
    lcd.setCursor(2, 3);
    lcd.print("1");
    }
    else
    {
    lcd.setCursor(2, 3);
    lcd.print("0");
    }

    int sensorValue3 = analogRead(waterSens3);//read the water sensor value

    if (sensorValue3 >= 50){
    lcd.setCursor(3, 3);
    lcd.print("1");
    }
    else
    {
    lcd.setCursor(3, 3);
    lcd.print("0");
    }

    int sensorValue4 = analogRead(waterSens4);//read the water sensor value

    if (sensorValue4 >= 50){
    lcd.setCursor(4, 3);
    lcd.print("1");
    }
    else
    {
    lcd.setCursor(4, 3);
    lcd.print("0");
    }

  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(h) || isnan(t)) {
    lcd.print("ERROR");
    return;
  }
  lcd.setCursor(5,0);
  lcd.print(t);
  lcd.setCursor(9,1);
  lcd.print(h);
{
  Blynk.run(); // Initiates Blynk
  timer.run(); // Initiates SimpleTimer
}
}

Hey there.
To make this sketch work with blynk iot jast add #define BLYNK_TEMPLATE_ID “YourTemplateID”

@Noman please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

@Noman I would recommend starting you with the Quick Start Guide. You’ll get a basic sketch in that case and applying your code changes would be trivial after that.

@PeteKnight Please check it now i urgent need the code thank you

@Dmitriy @PeteKnight in new blynk there is no auth token what can i do for auth token.
can someone post simple code for arduino uno with ethernet shield that can monitor dht11 temperature and humidity

Yes there is, when you create a device you get the auth token, template ID and device name, which need to go at the top of your code.

You really need to read your DHT sensor less frequently and clean-up your void loop. And remove the delays too.

Pete.

@PeteKnight i create a device but i receive template id and device name please find the attached picture.

@John93 @Dmitriy @PeteKnight someone please post a simple code for ethernet shield thank you

Go to blynk examples.

@John93 where can i get auth token in device info only get templete id and device name

To find the device auth token go to my devices then choose your device then device info.

@John93 thank you so much sir i found it

Okay buddy if you need anything I will be here.

Greetings.

1 Like

@John93 hello john do you know how to send Alarm notification on blynk 2.0

Yes sure. You will use automations.

@Dmitriy how can i enable automation in setting

When you create a datastream there’s a option says expose to automation just enable it and check available in conditions and available in actions.

@John93 i am very thankful to you i found and resolve this.sorry for my bad english

No problem bro. If you face any issue just feel free to ask.

Greetings.