Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By PavloP
#52928 Hello
I'm making a simple temperature logger on Sparkfun ESP8266-01 and to extend battery life I need deep sleep mode
So as I`ve read there no hardware support of deep sleep on this board, but it can be established with some soldering skills. I`ve soldered a wire between GPIO16 and Reset, wrote a program with ESP.deepSleep(20000000) in it and expected it to wake up in 20sec. But after 20 seconds ESP sends only some symbols and that`s all
Code: Select allWiFi connected
IP address:
192.168.44.69
Temperature: 24.06
Requesting URL: /objects/?script=espdata&idesp=esptest&dhtt1=24.06
HTTP/1.1 200 OK
Date: Sun, 14 Aug 2016 14:44:32 GMT
Server: Apache/2.4.10 (Debian)
Content-Length: 0
Connection: close
Content-Type: text/html; charset=utf-8


closing connection
Good night
0‚~–4‡


Could you please help me with this problem?
Thanks in advance
User avatar
By PavloP
#53118
Chris Ryan wrote:Would you be able to post the arduino sketch that you are uploading?


Code: Select all#include <ESP8266WiFi.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <FloatToString.h>

const char* ssid     = "SSID";
const char* password = "passwd";

const char* host = "192.168.43.50"; // server address

#define ONE_WIRE_BUS 2  // DS18B20 pin
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float oldTemp;

void WIFI_Connect() {
  digitalWrite(LED_BUILTIN, LOW);
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.disconnect();
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    digitalWrite(LED_BUILTIN, LOW);
    delay(500);
    Serial.print(".");
    digitalWrite(LED_BUILTIN, HIGH);
  }

  Serial.println("");
  Serial.println("WiFi connected"); 
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  digitalWrite(LED_BUILTIN, HIGH); 
}

void  dumpInfo (float *results) //Send data as HTTP-Request
{
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }

// We now create a URI for the request
  String url = "/objects/?script=espdata&idesp=esptest&dhtt1=";
  char buffer[25]; 
  url +=  floatToString(buffer, *results, 2);
 
  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");
  unsigned long timeout = millis();
  while (client.available() == 0) {
    if (millis() - timeout > 5000) {
      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");   
 
}

void  setup ( )
{
  pinMode(LED_BUILTIN, OUTPUT); 
  Serial.begin(9600);   // Status message will be sent to PC at 9600 baud
  oldTemp = -1;

  WIFI_Connect();

  Serial.println("Good morning");
  float temp;
 
  do {
    DS18B20.requestTemperatures();
    temp = DS18B20.getTempCByIndex(0);
  } while (temp == 85.0 || temp == (-127.0));
 
  if (temp != oldTemp)
  {
    Serial.print("Temperature: ");
    Serial.println(temp);
    dumpInfo(&temp);
    oldTemp = temp;
  }

  WIFI.disconnect();
  Serial.println("Going to sleep");
  ESP.deepSleep(20000000);
}


martinayotte wrote:Those symbols are printed by the booloader at 74880 baud.
So, that pretty normal.
If you add a print in your setup(), are you seeing it ?

As you can see in the code I have wifi connection messages in setup(), but I don't see them after wake up and also after those symbols ESP stops doing anything. I'll try to change UART speed to read that bootloader message today