This is my first IoT project and I actually made it with helps from this forum.
I attached pictures of the board and sensor, coding and Blynk screenshot below, looking forward to your feedback for me to improve.
There is also some question I need to ask regarding the data sent from the moisture sensor and also the coding part:
1. Based on the pictures, I usually attached the digital pin from the sensor to analog pin in esp8266 board for the sensor to work properly. Because if I pin the wire to Analog on the moisture sensor, the sensor will always notify me "water your plants" even though I put the sensor inside a glass of water. Why is that?
2. About the code, is there any modification I need to change so the value of the moisture level can change slowly not only 110 and the 1024? I need the data for me to know if there is any significant changes in 1 hour period.
3. What else can I improve from this soil moisture sensor?
Thank you for your time and looking forward to collaborate.
Project pictures:
https://imgur.com/a/y8VezJ0
Arduino IDE code:
'''
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "d66667f3ca9845ca94c52ae5d5fe2553";
const int sensorPin = A0;
int sensorState = 0;
int lastState = 250;
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, "SSID", "PASSWORD");
pinMode(sensorPin, INPUT);
}
void loop()
{
Blynk.run();
sensorState = analogRead(sensorPin);
Serial.println(sensorState);
if (sensorState >= lastState) {
Serial.println("needs water, send notification");
Blynk.notify("Water your plants");
lastState = 250;
delay(10000);
//send notification
}
else if (sensorState <= lastState) {
//do nothing, has not been watered yet
Serial.println("has not been watered yet");
delay(10000);
}
else {
//st
Serial.println("does not need water");
lastState = 250;
delay(10000);
}
delay(10000);
}
'''