Posts | Comments

Planet Arduino

Archive for the ‘web server’ Category

Arduino has a library for quickly and easily setting up a simple web server on an ESP8622-based board, and [Tomaž] found that power consumption on an ESP-01 can be reduced a considerable amount by simply inserting a 1 ms delay in the right place. The reason this works isn’t because of some strange bug or oddball feature — it’s really just a side effect of how the hardware operates under the hood.

[Tomaž] uses the “hello world” example from ESP8266WebServer to explain. In it, the main loop essentially consists of calling server.handleClient() forever. That process checks for incoming HTTP connections, handles them, sends responses, exits — and then does it all over again. A simple web server like this one spends most of its time waiting.

A far more efficient way to handle things would be to launch server.handleClient() only when an incoming network connection calls for it, and put the hardware to sleep whenever that is not happening. However, that level of control just isn’t possible in the context of the Arduino’s ESP8266WebServer library.

So what’s to be done? The next best thing turns out to be a simple delay(1) statement right after each server.handleClient() call in the main loop.

Why does this work? Adding delay(1) actually causes the CPU to spend the vast majority of its time in that one millisecond loop. And counting microseconds turns out to be a far less demanding task, power-wise, than checking for incoming network requests about a hundred thousand times per second. In [Tomaž]’s tests, that one millisecond delay reduced idle power consumption at 3.3 V from roughly 230 mW to around 70 mW — about 60% — while only delaying the web server’s response times by 6-8 milliseconds.

For simple web server applications, this is is for sure a good trick to keep in mind. There are also much more advanced techniques for saving power on ESP8266-based boards; from boards that barely sip a single microamp while sleeping, to coin-cell powered boards that go so far as to modify the TCP/IP stack to help squeeze every bit of power savings possible.

In the movie Wall-E, future humans live in floating chairs and have everything done for them. Today, we grumble if we have to go to physically find a light switch or a remote control. How far away can floating chairs with screens be? T2, the Tea Bot, gets us one step closer to that. Using a laser-cut frame, an ESP8266, and a servo motor, the T2 brews your tea for exactly the right amount of time.

We were kind of hoping the robot would at least dunk the tea bag in and out, but it does provide a web interface that lets you select the brew. Of course, the code is available, so you could make modifications — maybe turn on a hotplate underneath the cup.

While this isn’t particularly practical for most people, it is a nice short example of how to provide a web interface and do something with an ESP8266. Maybe you want to lock a desk drawer or put a marshmallow into a flame, for those tasks you could use very similar code.

Since a servo takes a pulse width and draws very little current, you could probably drive a bunch of them and parallel process a lot of teacups if you were serving a crowd. Naturally, this isn’t the first automated brewer we’ve seen. It isn’t even the only one with a servo.

Nov
17

wJsonduino

ajax, gallery, Json, web server Comments Off on wJsonduino 

Is a web server page that show the Arduino’s analog and digital input pin status, the status of the pin is transmitted with json, the page detect connection problems with the Arduino device and alert the user.
All refresh code run in browser and is write in javascript and ajax.

You can find it on the [webpage] coded by [bigjohnson].



  • Newsletter

    Sign up for the PlanetArduino Newsletter, which delivers the most popular articles via e-mail to your inbox every week. Just fill in the information below and submit.

  • Like Us on Facebook