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

Moderator: igrr

User avatar
By Mattia Durli
#42834 Hello,
I'm developing a very simple device based on an Adafruit Huzzah ESP8266 (developing on the Feather version), that should connect via wifi every n seconds (probably 60) to my server and send some data about the connection (BSSID, RSSI, status of the battery). The unit will move around in a building roaming between various access points.
I use a 3,7V 500mAH battery to power it, and will charge it with an inductive charger.

The very first draft of the Arduino code, based on the wificlient sample in the Adafruit webpage, works, connects in the setup function and stays in the loop.
I did a test with communication every 5s and battery lasted 12 hours.

I'd like to optimize now, and I'm asking what are my options.
Is the deepSleep like ESP.deepSleep(s*1000000, WAKE_RF_DEFAULT) a possibility?
I read that there's some wiring to do, is there any detailed explanation or picture for both Huzzah and Deather Huzzah? is always RST to GPIO16?
Sorry but I'm quite new to this kind of electronic, I'm a programmer, quite scared to burn things.
In the deepSleep case all the code whould have to go in the setup function, right?

Any other suggestion on how to optimize power consumption?

More help:
1) to get battery status I use "float vdd =readvdd33();", it starts at 3.5 and slowly moves down to 2.x until it turns off
Is this a good way to measure battery status?
In this sample https://learn.adafruit.com/using-ifttt- ... -io/wiring
a different way is used, why?

2) I'd like the unit to be sealed, so how would you suggest to configure it (change SSID and password of AP to connect to, timing of pings, etc) without having to open it?
I was thinking of something like, when it turns on, it tries to connect first to a "config" SSID, and later to the "configured" SSID AP
If it founds "config" AP, connects to it and to the config server and downloads the new configuration, otherwise if "config" is not present it goes to its normal work by connecting to the "configured" AP.
Any other suggestion? Using it as a webserver and configure it by accessing it from a PC client?
Just remember that I can't touch it, it's inside a sealed case, so maybe running a webserver all the time for when it has to be configured is not good for the battery.

Thanks!
User avatar
By PaulRB
#42881 Hello,

Yes, sounds very much like ESP.deepSleep() is what you need to use. I am using the same for my temp/humidity sensors which connect and report every 15mins. While awake, the circuits draw around 75mA, but in deep sleep they draw less than 200uA which dramatically increases battery life (i am currently using 3 x AA or AAA NiMH cells but am also considering using Li-ion).

To wake from deep sleep, you need to connect the correct GPIO line to RST. I use WeMos D1-mini rather than the Huzzah boards, but the principle is the same. Using a wire to connect the two pins prevents uploading a sketch while the board is in deep sleep, so rather than a wire connection, i use a 500R~1K resistor instead, which allows sketch upload reset the board.

You could put all your code in setup() or some in loop() if you like, it really doesn't matter. But because of the use of deepsleep(), loop() will probably only ever run once before the board is reset, depending how you write your code. Its true for my sensors.

I have seen example code which allows multiple SSID/passwords to be used. I'll try to find it again and post a link here.

For entering SSID/passwords, can you connect the unit to a laptop via a USB cable? The unit could request & receive that data via serial. Or you could re-upload the sketch with the latest passwords hard-coded in. Another possibility is that you could store the list of required SSID/passwords in a file on the server, which the unit could download regularly. You might have to think about the security concerns of storing those passwords on a server.

Paul
User avatar
By Mattia Durli
#43235 Hello Paul, sorry but I didn't receive email notification and missed your answer, I thought no one was answering.

As you say, deep sleep would be the way to go, and I tested it, but after a certain number of cycles, it hangs.
I've searched the web and I'm definetely not the only one with this problem, for many others deep sleep is unstable, or reset is unstable, or just the Feather Huzzah or the esp8266... so I abandoned the deep sleep mode.

I connected the pin 16 to rst, and followed instructions from support:
http://forums.adafruit.com/viewtopic.php?f=57&t=91787
but still hangs after a certain number of cycles.

If it works on your WeMos D1-mini, maybe the problem is in the Feather Huzzah, I have no idea.

I'm trying light sleep now:
viewtopic.php?f=32&t=8824

thanks!