I am facing a issue with the ESP8266-01 as the following below:
chksum 0x42 csum 0x42 ~ld ets Jan 8 2013,rst cause:4, boot mode:(1,0) wdt reset
Anyone has the solution please help!!
#include <LiquidCrystal.h> //Load liquid Crystal Library
LiquidCrystal LCD(12, 11, 5, 4, 3, 2); //Create Liquid Crystal Object called LCD
#include <ESP8266WiFi.h>
const char* ssid = "your-ssid";
const char* password = "your-password";
const char* host = "your-localhost";
#define in 7
#define out 8
#define trigPin 10
#define echoPin 13
#define relay 2
#define led 6 //red color
#define led2 A0 //yellow color
#define led3 9 //green color
int count = 0;
int distanceCm;
long duration;
void IN()
{
count++;
LCD.clear();
LCD.print("Number of Item:");
LCD.setCursor(0,1);
LCD.print(count);
delay(10);
LCD.setCursor(3,1);
LCD.print(distanceCm);
delay(10);
LCD.setCursor(6,1);
LCD.print(" cm");
if(distanceCm <= 3){
delayMicroseconds(10);
LCD.setCursor(10,1);
LCD.print("Full");
digitalWrite(led, HIGH);
}else{
digitalWrite(led, LOW);
}
if(distanceCm > 3 && distanceCm <= 5){
delayMicroseconds(10);
LCD.setCursor(10,1);
LCD.print("Enable");
digitalWrite(led2, HIGH);
} else{
digitalWrite(led2, LOW);
}
if(distanceCm > 5){
delayMicroseconds(10);
LCD.setCursor(10,1);
LCD.print("Empty");
digitalWrite(led3, HIGH);
} else {
digitalWrite(led3, LOW);
}
delay(500);
}
void OUT()
{
count--;
LCD.clear();
LCD.print("Number of Item:");
LCD.setCursor(0,1);
LCD.print(count);
delay(10);
LCD.setCursor(3,1);
LCD.print(distanceCm);
LCD.setCursor(6,1);
LCD.print(" cm");
if(distanceCm <= 3){
delayMicroseconds(10);
LCD.setCursor(10,1);
LCD.print("Full");
digitalWrite(led, HIGH);
}else{
digitalWrite(led, LOW);
}
if(distanceCm > 3 && distanceCm <= 5){
delayMicroseconds(10);
LCD.setCursor(10,1);
LCD.print("Enable");
digitalWrite(led2, HIGH);
} else{
digitalWrite(led2, LOW);
}
if(distanceCm > 5){
delayMicroseconds(10);
LCD.setCursor(10,1);
LCD.print("Empty");
digitalWrite(led3, HIGH);
} else {
digitalWrite(led3, LOW);
}
delay(500);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
delay(10);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
LCD.begin(16,2);
LCD.print("Item Counter");
delay(2000);
pinMode(in, INPUT);
pinMode(out, INPUT);
pinMode(relay, OUTPUT);
LCD.clear();
LCD.print("Item In Box:");
LCD.setCursor(0,1);
LCD.print(count);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
// ESP.wdtFeed();
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// ESP.restart();
}
int value = 0;
void loop() {
delay(0);
delay(5000);
++value;
digitalWrite(trigPin, LOW);
delayMicroseconds(10);
digitalWrite(trigPin, HIGH);
delayMicroseconds(50);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distanceCm = duration * 0.034/2;
//******************************************************//
//IR Sensor Counting Object
if(digitalRead(in))
IN();
if(digitalRead(out))
OUT();
if(count<=0)
{
LCD.clear();
digitalWrite(relay, LOW);
LCD.clear();
LCD.print("No Item in box");
LCD.setCursor(0,1);
LCD.print("box is empty");
delay(200);
}
else{
digitalWrite(relay, HIGH);
}
Serial.print("connecting to ");
Serial.println(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 8095;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
if(WiFi.status() != WL_CONNECTED){
WiFi.begin(ssid,password);
while (WiFi.status()!= WL_CONNECTED)
{
Serial.println("Waiting for connection");
delay(0);
}
}
String IRCount, myDistance;
IRCount = String(count);
myDistance = String(distanceCm);
// We now create a URI for the request
String url = "/Registration/write_data.php";
url += "?item=";
url += IRCount;
url += "&distance=";
url += myDistance;
Serial.print("Requesting URL: ");
Serial.println(url);
// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
int timeout = millis() + 5000;
while (client.available() == 0) {
if (timeout - millis() < 0) {
Serial.println(">>> Client Timeout !");
client.stop();
return;
}
}
// Read all the lines of the reply from server and print them to Serial
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
Serial.println();
Serial.println("closing connection");
delay(0);
}