0

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);
}
  • 1
    it is a watchdog reset. what is flashed in the esp8266? – Juraj Dec 9 '18 at 9:51
  • @Juraj Flash Size: 1M(512K SPIFFS) flash Node: DIO – Annoymous20 Dec 9 '18 at 11:29
  • i tried all the flash size already but the error still there – Annoymous20 Dec 9 '18 at 11:34
  • that is not what I asked – Juraj Dec 9 '18 at 14:47
  • Sorry... i don't understand what you mean flashed in the esp8266 – Annoymous20 Dec 9 '18 at 15:04
1

esp-01 has 4 io pins: RX, TX, io 0 and io 2. other pins are not accessible. io 6 to io 11 are wired to on-board flash memory and can't be used.

what are you thinking by using other pins then 0 and 2? how did you wire those sensors and leds to esp-01?

  • Because for the sensors and leds... I want pass the sensors data to my server. So is it possible to save my sensor data into the MySQL database and display it on my webpage. I wired those wires on the Arduino UNO board – Annoymous20 Dec 10 '18 at 2:47
  • Do you have any ideas to pass the sensor data to the PHP localhost server webpage? or is it required to change another wifi receiver to pass the data to my localhost webpage? – Annoymous20 Dec 10 '18 at 3:22
  • My issue is the same as this forum before arduino.stackexchange.com/questions/48234/… But i don't see any solution for this – Annoymous20 Dec 10 '18 at 6:59
  • there is no magic that would read Uno pins in connected esp8266. you could use Firmata with Firmata Master esp8266 library but simpler is to write two sketches – Juraj Dec 10 '18 at 8:14
  • but the other sketches connect to the main sketches? – Annoymous20 Dec 10 '18 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.