Someone please help me figure this out im so frustrated. My sketch was working just fine, and now it won’t upload at all.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
//My auth token to connect to the Blynk app.
char auth[] = "ac5db357d3bb404893bdd2cdd1e49c4f";
//My Wifi SSID and password.
char ssid[] = "BHNTG1682G85ED";
char pass[] = "9bef4b7a";
// These 3 define what Digital pin we're connected to. (NodeMCU Esp8266 was a weird pin layout
#define DHTPIN 14
#define DHTPIN2 12
#define DHTPIN3 13
//Defines which DHT type I have.
#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
DHT dht(DHTPIN, DHTTYPE);
DHT dht2(DHTPIN2, DHTTYPE);
DHT dht3(DHTPIN3, DHTTYPE);
BlynkTimer timer;
const int sensorPin = 15;
int sensorState = 0;
int lastState = 0;
const int sensorPin2 = 2;
int sensorState2 = 0;
int lastState2 = 0;
const int sensorPin3 = 0;
int sensorState3 = 0;
int lastState3 = 0;
// This function sends Arduino's up time every second to Virtual Pins.
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
float h2 = dht2.readHumidity();
float t2 = dht2.readTemperature();
float h3 = dht3.readHumidity();
float t3 = dht3.readTemperature();
if (isnan(h) || isnan(t) || isnan(h2) || isnan(t2) || isnan(h3) || isnan(t3)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
Blynk.virtualWrite(V1, h2);
Blynk.virtualWrite(V2, t2);
Blynk.virtualWrite(V3, h3);
Blynk.virtualWrite(V4, t3);
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
dht.begin();
pinMode(sensorPin, INPUT);
pinMode(sensorPin2, INPUT);
pinMode(sensorPin3, INPUT);
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
sensorState = digitalRead(sensorPin);
Serial.println(sensorState);
sensorState2 = digitalRead(sensorPin2);
Serial.println(sensorState2);
sensorState3 = digitalRead(sensorPin2);
Serial.println(sensorState3);
if (sensorState == 1 && lastState == 0) {
Serial.println("1 needs water, send notification");
Blynk.notify("Water plant 1");
lastState = 1;
delay(500);
//send notification
}
else if (sensorState == 1 && lastState == 1) {
//do nothing, has not been watered yet
Serial.println("1 has not been watered yet");
delay(500);
}
else {
//st
Serial.println("1 does not need water");
lastState = 0;
delay(500);
}
if (sensorState2 == 1 && lastState2 == 0) {
Serial.println("2 needs water, send notification");
Blynk.notify("Water plant 2");
lastState2 = 1;
delay(500);
//send notification
}
else if (sensorState2 == 1 && lastState2 == 1) {
//do nothing, has not been watered yet
Serial.println("2 has not been watered yet");
delay(500);
}
else {
//st
Serial.println("2 does not need water");
lastState2 = 0;
delay(500);
}
if (sensorState3 == 1 && lastState3 == 0) {
Serial.println("3 needs water, send notification");
Blynk.notify("Water plant 3");
lastState3 = 1;
delay(500);
//send notification
}
else if (sensorState3 == 1 && lastState3 == 1) {
//do nothing, has not been watered yet
Serial.println("3 has not been watered yet");
delay(500);
}
else {
//st
Serial.println("3 does not need water");
lastState3 = 0;
delay(500);
}
}
I get this error
esptool v0.4.13 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
setting board to nodemcu
setting baudrate from 115200 to 115200
setting port from COM1 to COM3
setting address from 0x00000000 to 0x00000000
espcomm_upload_file
espcomm_upload_mem
setting serial port timeouts to 1000 ms
opening bootloader
resetting board
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 80 instead of C0
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 80 instead of C0
resetting board
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 80 instead of C0
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 80 instead of C0
resetting board
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 80 instead of C0
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 80 instead of C0
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
IT WONT EVEN UPLOAD THE NULL SKETCH
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
I get this error!
Uploading 250256 bytes from C:\Users\Laurel\AppData\Local\Temp\arduino_build_484144/sketch_apr02a.ino.bin to flash at 0x00000000
warning: espcomm_send_command: didn't receive command response
warning: espcomm_send_command(FLASH_DOWNLOAD_BEGIN) failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
Someone please help me with this, this is for a project.