Im making a project about a fire detection system using arduino nano 33 ble sense with an esp01. The system is supposed to send an email to the user in case of a fire. I'm facing a problem with the esp01, every time i'm trying to upload the sketch i would get this error: "A fatal esptool.py error occurred: Failed to connect to ESP8266: Timed out waiting for packet header"
This is the circuit that i'm following:
And this is my code:
#include <ESP8266WiFi.h>
const char* ssid = "xxxxx";
const char* password = "xxxxxx";
const char* host = "maker.ifttt.com";
void setup()
{
Serial.begin(115200);
Serial.println("Email from Node Mcu");
delay(100);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop()
{
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort))
{
Serial.println("connection failed");
return;
}
if(Serial.available( ) > 0) // It will only send data when the received data is greater than 0.
{
int receivedData = Serial.read(); // It will read the incoming or arriving data byte
//Serial.println(receivedData,DEC);
char state = char(receivedData); // print the character for the ASCII value
//Serial.println(exercise);
int value = state - '0';
if(state == '1')
{
String url = "/trigger/fire_detected/json/with/key/(key)"; //the key is supposed to be added here
Serial.print("Requesting URL: ");
Serial.println(url);
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
}
}
}
Any suggestions on what could be wrong here?