hello everyone i need some help. I have build a project with the help of nodeMCU and blynk aap to read DHT11 sensor , soil moister data. And on/off the relay through the aap. All the things are working perfectly but i am unable to read soil moister data.
here’s my code so pleas suggest me something to fix this problem.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include "DHT.h"
#include <I2CSoilMoistureSensor.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE,16);
int Sensorvalue=0;
int sensorPin=A0;
int sensorValuePercent=0;
SimpleTimer timer;
char auth[] = "2ba5c81befec4d9498e70fd09bf5ca0a";
char ssid[] = "Hathway1";
char pass[] = "1234@kalu";
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
timer.setInterval(2000, sendDHT);
}
void sendDHT()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
int hum = (int) h;
int tem = (int) t;
Blynk.virtualWrite(4, hum);
Blynk.virtualWrite(5, tem);
}
void Moisture()
{
int x = analogRead(A0);
int y = map(x, 600, 230, 0, 100);
if (y > 100)
{
y=100;
}
Blynk.virtualWrite(1,y);
}
void loop()
{
Blynk.run();
timer.run();
}