ESP8266 running on batteries

If you haven’t yet heard about the ESP8266 then it’s time for you to wake up and get serious! This little beauty is a seriously low-cost WiFi chip with a full TCP/IP stack and microcontroller made by ExpressIf. It sports 16 GPIO pins, SPI, I2C, UART, and even has a 10-bit ADC for good measure. And the price? Less than $2 on AliExpress! It is the size of a coin, and supports b/g/n wireless protocols. What’s not to love about this thing?

Wemos D1 mini ESP8266 Board Supports Shields with a Temperature ...

The device isn’t particularly heavy on electricity to start with, but it can pull as much as 200mA when it’s transmitting over WiFi, and generally around 75mA just being awake.

If you plan on running it on batteries, you’ll soon find that they only last a few days before the thing dies down!

 

Enter Deep Sleep Mode

Luckily, there is a very nice way to help on this. You see, the device has a hibernation mode (among other modes, see the full list here) that allows it to drop to as low as 60 microAmpere, and it is really easy to do it. Here are the relevant bits of code to make it happen (using Arduino Sketch or Visual Studio with VisualMicro extension:

extern "C" {
#include "user_interface.h"
}

void setup()
{
    initSerial();
    initWifi();
    initSensors();
}

void loop()
{
    // Gather sensor data
    // Transmit sensor data over wifi somewhere

    Serial.println("Entering deep sleep mode");

    auto fiveMinutes = 5 * 60 * 1000000;

    system_deep_sleep(fiveMinutes);
}

At the top, we’re referencing a C-library, which is why it is wrapped in the extern scope. Fail to do this, and it won’t compile due to types being different and other woodoo.

The ESP8266 enters a state where everything is shut off except for the realtime clock to hit the 60µA. After the clock fires up again, the device essencially reboots, running setup() again before entering loop().

NOTE
This does NOT work unless you create a short circuit between GPIO pin 16 and the RESET pin on the device. The clock needs this wire in order to wake itself up after the timer ends. So remember, there is a hardware change included in getting this right!

Diagram

Conclusion

Setting the ESP8266 in deep-sleep mode means that you can start to make battery driven solutions that will last for months instead of days. At an average of 75mA in normal mode, a 2450ma Eneloop would last around 32 hours or less on battery power, but on the same battery, you should be able to expect months (depending on how hard you drive the WIFI and sensor power consumption ofc.) Also remember that the power converters from battery to 3.3v aren’t perfect, giving you at best 85% of stated battery capacity, but all in all, it’s a good and handy thing to know about!

Woha, slow down there!!

During the recent days, I’ve been blown away over how much google has expanded since the days when I thought nothing more of it than a search engine. For some reason, unknown to mankind, I had a co-worker send me an invitation to obtain a new google email address(most likely due to the spamming problems I’ve had lately).

Opening up a new gmail account…

…is like installing a complete suite of “all you’ll ever need to use your office-like tools among friends and family. I’ve NEVER had such an organized personal life. I’ve created a budget for 2007 using a google spreadsheet. I can have Bergfrid collaborate with me over http, alter the values within the spreadsheet, and discuss the changes in a chat window as we create the budget together. We have organized our “spare time” in google calendar, making it alot easier to avoid setting plans that don’t fit. Our friends are able to see when we’re busy, and when we’re not.. Better yet, google alerts me with a text message directly onto my cellphone of important events in the calendar! MS Office has never done that for me!!

In addition,

I tried out picasa for shits & giggles, after all, I am employed in a company that writes similar software.. but what picasa has to offer, is integration ! It was SO easy to share a couple of images onto a brand new google album that it is simply scary! When stuff gets this easy to use, you don’t want to be using anything else.!

I was going to say “soon” but I think I’ll rather say “now”.. because, now, today, all you need, really for your typical chat, email, document, spreadsheet, calendar, and image needs, at least as a private person (and perhaps some simple offices) is google.. I’ve been googlified, and I’m loving it.

V for violet

From time to time, I get the urge to sit down and holler at the world and stir up a cascade of accusations and complaints about something that is less than trivial to begin with. Now is one of those times, I’m about to take upon me the role of the pixel peeper, never satisfied with less than perfection. It turns out that my Nikon D200 is completely and utterly unable to display violets! Someone, with a great deal of spare time on his hands, and nothing else to spend it on, have found that if you take your every-day primary school prism, and arrange it so that it will show you the colors of the rainbow, and then take a photography of said phenomenon, the violets will be completely gone – missing, astray, you name it, they won’t be there. Instead, a slight blue-ish shade will be there in it’s stead. Additionally, colors that are seamless in their transition between primaries (red, green, blue), are amazingly not so at all once shot onto digital chip. These facts, in the proper forums, spawn such large debates and outbreaks of sheer panic that I often wonder why I frequent those places to begin with. New looks for Bergfrid
Sadly, they’re also the best spots to be among fellow digital photographers that have a tendency for taking more images than the yearly family portrait in front of the Christmas tree.

Speaking of which, Bergfrid had her hair done the other day, and came home looking so fine that I had to rig up the stuff to freeze her hairstyle in time. Her hairdresser had some spare time on her hands, and did some fancy handwork. This image shows you how smart she looked. I was going for a couple of full figure images as well, but that grey backdrop just wasn’t big enough to serve as a full figure backdrop, so I dropped it (ooh, I’m rambling now!!)
Today’s last note would have to be mentioning the free vs. closed source debate that never seems to end. I’m torn between two camps and really not sure which one to go with – in one hand, I’m employed at, and make a living of closed source code. Our income is based on selling licenses for using patented software. This is bad, according to the open source community that believes that my money should be made of customizing that source instead, to make me share the code of the software I wrote with others, and then compete with them for making a living off of it. I hear them, I just can’t get myself to understanding them..
See you next time!