This is the error below:
SmartAgricultureMonitoring:12:10: fatal error: BlynkTimer.h: No such file or directory
Multiple libraries were found for "BlynkSimpleEsp8266.h"
12 | #include <BlynkTimer.h>
Used: C:\Users\veget\OneDrive\Documents\Arduino\libraries\Blynk-1.0.1
| ^~~~~~~~~~~~~~
Not used: C:\Users\veget\OneDrive\Documents\Arduino\libraries\Blynk
compilation terminated.
exit status 1
BlynkTimer.h: No such file or directory
This is my code below:
#include <dummy.h>
#include <dummy.h>
// Viral Science www.viralsciencecreativity.com www.youtube.com/c/viralscience
// Blynk IOT Smart Agriculture Monitoring System
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <BlynkTimer.h>
#include <DHT.h>
#define BLYNK_PRINT Serial
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS D2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
char auth[] = "----------------"; //Authentication code sent by Blynk
char ssid[] = "-------"; //WiFi SSID
char pass[] = "-------"; //WiFi Password
#define pirPin D1
int pirValue;
int pinValue;
#define sensorPin D6
#define rainPin D5
int sensorState = 0;
int rainState = 0;
int lastState = 0;
int lastRainState = 0;
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;
BLYNK_WRITE(V0)
{
pinValue = param.asInt();
}
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Blynk.virtualWrite(V5, h); //V5 is for Humidity
Blynk.virtualWrite(V6, t); //V6 is for Temperature
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(sensorPin, INPUT);
pinMode(rainPin, INPUT);
pinMode(pirPin, INPUT);
dht.begin();
timer.setInterval(1000L, sendSensor);
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
sensors.begin();
}
int sensor=0;
void sendTemps()
{
sensor=analogRead(A0);
sensors.requestTemperatures();
float temp = sensors.getTempCByIndex(0);
Serial.println(temp);
Serial.println(sensor);
Blynk.virtualWrite(V1, temp);
Blynk.virtualWrite(V2,sensor);
delay(1000);
}
void getPirValue(void) //Get PIR Data
{
pirValue = digitalRead(pirPin);
if (pirValue)
{
Serial.println("Motion detected");
Blynk.notify("Motion detected");
}
}
void loop()
{
Blynk.run();
timer.run();
sendTemps();
sensorState = digitalRead(sensorPin);
Serial.println(sensorState);
if (sensorState == 1 && lastState == 0) {
Serial.println("needs water, send notification");
Blynk.notify("Water your plants");
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);
}
rainState = digitalRead(rainPin);
Serial.println(rainState);
if (rainState == 0 && lastRainState == 0) {
Serial.println("Its Raining!");
Blynk.notify("Its Raining!");
lastRainState = 1;
delay(1000);
//send notification
}
else if (rainState == 0 && lastRainState == 1) {
delay(1000);
}
else {
Serial.println("No Rains");
lastRainState = 0;
delay(1000);
}
if (pinValue == HIGH)
{
getPirValue();
}
Blynk.run();
delay(100);
}