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

Moderator: igrr

User avatar
By JerryESPN
#51126 Thanks for all the hints!

@eduperez: You´re right. I had a look at all these posts but didn´t mention it. What my findings were:

    Deep Sleep: Not possible with ESP-01, except with a little bit of soldering; deep sleep doesn´t work well at all
    Light Sleep: Possible without soldering, but although not working very well
    Modem Sleep: Always on???

All i´ve found were some code-snippets, but what i´m missing is a kind of documentation of this features.

@Ken Shaw: Exactly what i´ve trying to avoid :)

@schufti: Maybe you can provide a picture?

So, any other ideas? One of my thougths:

Code: Select allSerial.println("Waiting…");
// thingspeak needs minimum 15 sec delay between updates
delay(20000);
}


Changing delay to 5 Minutes. As far as i know, power consumption is much higher while sendig Data, right?

Thanks in forward!
Last edited by JerryESPN on Sat Jul 23, 2016 2:35 pm, edited 1 time in total.
User avatar
By schufti
#51170 a) found one without "blob"
b) deep-sleep working well for me. have outside temp/hup/bar sensor with ESP-01 working for over 1 month now w/o any problem on 2 old LiIon cells from Laptopbattery.
c) modem-sleep also working ok for my "light-clock" that fetches time via ntp every 4h to keep synced.
You do not have the required permissions to view the files attached to this post.
User avatar
By JerryESPN
#51900 Okay, tried to max out delay:

Sending Data every 20 Seconds = 6h lasting
Sending Date every 5 Min. = 72h lasting!


That´s already great, but not enough.

As far as i understand modem sleep, it automatically turns on whenever a delay happens. As long, as the ESP is in Station mode.

So:

Code: Select alldht.begin();

WiFi.mode(WIFI_STA); // added!
WiFi.begin(ssid, password);

Serial.println();


Result: Look above, 72h with 5 Min. delay.

After that, i´ve tried:

Code: Select all// Required for LIGHT_SLEEP_T delay mode
extern "C" {
#include "user_interface.h"
}
...
...
...
Serial.println("Waiting…");
// thingspeak needs minimum 15 sec delay between updates

wifi_set_sleep_type(LIGHT_SLEEP_T); // added

delay(900000); // 15 Min.
}


Battery was empty in less than one day!

I think, i´m still missing something. Maybe anyone can help me to implement Light Sleep the right way?

Thanks!

PS: Actual Sketch

Code: Select all#include <DHT.h>
#include <ESP8266WiFi.h>

// replace with your channel’s thingspeak API key,
String apiKey = "adfadfgadfgadfgadfg";
const char* ssid = "adfgadfg";
const char* password = "12121212121212";

const char* server = "api.thingspeak.com";
#define DHTPIN 2 // what pin we’re connected to

DHT dht(DHTPIN, DHT11,15);
WiFiClient client;

// Required for LIGHT_SLEEP_T delay mode
extern "C" {
#include "user_interface.h"
}

void setup() {
Serial.begin(115200);
delay(10);
dht.begin();

WiFi.mode(WIFI_STA); // added 230716
WiFi.begin(ssid, password);

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");

}

void loop() {

float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}

if (client.connect(server,80)) { // "184.106.153.149" or api.thingspeak.com
String postStr = apiKey;
postStr +="&field1=";
postStr += String(t);
postStr +="&field2=";
postStr += String(h);
postStr += "\r\n\r\n";

client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);

Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" degrees Celcius Humidity: ");
Serial.print(h);
Serial.println("% send to Thingspeak");
}
client.stop();

Serial.println("Waiting…");
// thingspeak needs minimum 15 sec delay between updates

wifi_set_sleep_type(LIGHT_SLEEP_T);

delay(900000);
}
User avatar
By Orcanbull
#52279 Hi,

I recently wrote a post on continuous power saving, (viewtopic.php?f=29&t=11132) , Not sure if its relevant to you though, it significantly reduces your power especially since you don't use deepSleep . Another thing, is to control the power to the sensor using the ESP8266, Whenever you sleep you completely shut off the sensors you can use a simple transistor for this.

Are you using a voltage regulator? or do you directly power the ESP from the battery ?