Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Esp8266 and deep sleep mode #1715

Open
manudax opened this issue Feb 21, 2024 · 0 comments
Open

Esp8266 and deep sleep mode #1715

manudax opened this issue Feb 21, 2024 · 0 comments

Comments

@manudax
Copy link

manudax commented Feb 21, 2024

Hi,
I try to set the deep sleep mode with wifimanager and I cannot get the full deep sleep mode.
Without wifimanager I get 0.25µA in deep sleep mode but with my code even if I bypass the init in the setup I get 15mA of consuming.
Is there any solution for this issue ?

`
#include <WiFiManager.h>
#include <ESP8266WiFi.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <RH_ASK.h>

bool SerialPrt = true; // Si on veux la sortie série
long Time2Sleep = 30e6; // Temps du Deep Sleep en secondes
String Message = "";
int CapteurTemp = 13;
int TXRF = 12;
int RXRF = 0;
int Bpy = 5; // si passé à 0 alors on bypass

RH_ASK driver(2000, RXRF, TXRF, 0);
OneWire oneWire(CapteurTemp);
DallasTemperature sensors(&oneWire);
DeviceAddress sensorDeviceAddress;

void Transmit(String ToTransmit) {
byte DataLength = ToTransmit.length() + 1;
char Data2Send[DataLength];
ToTransmit.toCharArray(Data2Send, DataLength); // Converted String to char.
driver.send((uint8_t*)Data2Send, strlen(Data2Send));
driver.waitPacketSent();
}

float GetTempDS18() {
float NewTemp = 20.5;
return NewTemp;
}

float GetVoltage() {
float Tension = 5.00;
return Tension;
}

void setup() {

pinMode(CapteurTemp, INPUT_PULLUP);
pinMode(Bpy, INPUT_PULLUP);

if (SerialPrt) {
Serial.begin(115200);
Serial.println(" ");
Serial.print("Bpy : ");
Serial.println(digitalRead(Bpy));
}

if (digitalRead(Bpy) == false) {
//********* WiFiManager *********
WiFiManager wifiManager;
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
wifiManager.setConfigPortalTimeout(180);
wifiManager.autoConnect("xxx", "xxx");
//********* WiFiManager *********
} else {
// wifi_status_led_uninstall();
// WiFiMode(WIFI_STA);
WiFi.disconnect();
WiFi.mode(WIFI_OFF);
WiFi.forceSleepBegin();
delay(1);

driver.init();

if (SerialPrt) Serial.println("{\"Sync\":\"1ACFFC1D\",\"Module\":1,\"Temp\":" + String(GetTempDS18()) + ",\"Batt\":" + String(GetVoltage()) + "}");
Transmit("{\"Sync\":\"1ACFFC1D\",\"Module\":1,\"Temp\":" + String(GetTempDS18()) + ",\"Batt\":" + String(GetVoltage()) + "}");
ESP.deepSleep(Time2Sleep);

}
}

void loop() {
delay(250);
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant