So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By johndey
#65515 My setup consists of using a ESP8266-01S as a standalone module for processing and sending sensor data to a website. I have successfully compiled and loaded my code to the ESP module using the Arduino IDE and a FTDI 232R USB-to-serial device connected to my MacBook Air computer. The FTDI outputs power at 3.5v. After loading the code, I removed the FTDI device and connected an external power regulator which provides 3.3v to the ESP module and 5v (on a separate bus) to the sensor device.
My first attempt was to push data to the ThingSpeak site at 15 sec intervals. The system worked for 2 cycles of output, after which my WiFi router/modem crashed.
For my second attempt I used a different ESP8266-01S which I programmed to post data to "Google Sheets" at 15 minute (vs 15 second) intervals. I got one cycle of data posted, after which my WiFi router/modem again crashed.
In the meantime, my voltage regulator burned out (I had left it tuned on for 8 continuous hours).

I programmed a Baud rate in both instances of 115000. I recently read that newer ESP8266-01s (which I believe I have) operate at 9600 Baud. Could this be the cause of my problem?
User avatar
By johndey
#65616 Here is some additional info relative to my problem:

With the FTDI connected to the ESP module RX(FTDI)-toTX(ESP) I get the following series of comments on my serial monitor:

ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v3de0c112
~ld

ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v3de0c112
~ld

ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v3de0c112
~ld

ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v3de0c112
~ld

When I connect TX(FTDI)-to-RX(ESP) my WiFi router/modem crashes.

Note: Router/modem crashes with above connection even when RX(FTDI)-toTX(ESP) is not connected.

Sketch follows:

Code: Select all/*
  H2O_Flo_WiFi

  Measures the flow rate of water flowing through a 3/4-inch PVC pipe using a DIGITEN Hall effect sensor and displaying results on thingspeak.com using an ESP8266-01S
  Sensor date wire connected to Uno pin D2
  The sensor output is in the form of the duration in milliseconds of a square wave pulse and the relationship to the water flowrate is:

  F = 4.8 * Q  ( in liters per minute)

 ThingSpeak ( https://www.thingspeak.com ) is an analytic IoT platform service that allows you to aggregate, visualize and
  analyze live data streams in the cloud.

  Documentation for the ThingSpeak Communication Library for Arduino is in the extras/documentation folder where the library was installed.

*/
#include <ESP8266WiFi.h>

#include <ThingSpeak.h>

// WiFi SSD and Password

char ssid[] = "tracy";

char password[] = "Mange161";

char server[] = "api.thingspeak.com";

//Initialize the client library
WiFiClient client;

#include <SPI.h>

void setup()  {

 pinMode(2, INPUT);

  Serial.begin(115200);

  delay(1000);

  // init done



  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  ThingSpeak.begin(client);

}

void loop()   {

  const unsigned long duration = pulseIn(2, HIGH);
  //Pulse duration in microseconds

  float dursec = duration / 1000000.0;
  //Pulse duration in seconds

  float pulsefreq = 10.0;

  if ( duration  != 0 )
  {
    pulsefreq = 1.0 / dursec;
  }
  else
  {
    pulsefreq = 0.0;
  }

  //Pulse frequency in Hz

  float flolit = (pulsefreq  / 4.8);
  float flolitr = 60.0 * flolit;
  //Flow rate in Liters/hour

  float flogal = flolitr * .26417;
  //Flow rate in Gallons/hour
  float flocuft = flolitr * .035315;
  //Flow rate in cu ft/hour

  // Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8 different
  // pieces of information in a channel.  Here, we write to field 1.

  ThingSpeak.writeField( 255517, 1, flogal, "0ZUS9CDG08ZU6VJ2");


  delay(600000);
  // ThingSpeak will only accept updates every 15 seconds.

}





User avatar
By atexit8
#65735 Whether you ESP-01 module has a default baud rate of 9600 or 115200 could easily be ascertained.
Simply connect to it using USB-TTL adapter easily purchased on eBay and use the Arduino IDE Serial Monitor to talk to the ESP-01 with AT commands.
User avatar
By pranavsharma2504
#65775 A better way to deal with stuff that is to be done at timed intervals is to compare the time since it was last done.

Code: Select allvoid loop(){
  static unsigned long lastTime = 0;
  if( (unsigned long) (millis() - lastTime) > 15*1000){
    lastTime = millis();
    doSomethingEvery15Seconds();
  }
}

void doSomethingEvery15Seconds(){
  Serial.println("Ma! Look! 15 seconds have passed!!");
}


What you're experiencing is a watchdog timer reset (WDT Reset) which is called when the watchdog timer is not 'fed' within a certain time. It is basically a function to reset the device if it feels that the code is stuck somewhere.
You can feed the watchdog timer by calling yield(); in your code wherever it may take longer than a second to execute, or it is fed automatically when your program reaches the end of loop()
The issue in your code might be the long delay, however I'm not sure if delay(...) calls yield() internally or not.
Also, if pulseIn() takes a long time to return, that may be a possible cause as well.