ESP8266 Arduino NetIO Server Demo

MIT

This week as regular readers know I was far away from our little home in Spain – in fact I was at MIT (Massachusetts Institute of Technology)  in Boston, helping promote ESP8266 technology (why? because I could).

IvanAlong the way I met up with Ivan Grokhotkov who as some of you know has done a lot of work to bring the Arduino environment to the ESP8266 community.  As part of what we were doing at MIT, Ivan and I decided to put together a simple demonstration – this would use NETIO (my favourite IOS/Android visual interface) and ESP8266-Arduino to help an ESP board drive a servo via wireless control. 

As it happens any old ESP board would do – an ESP-01 would be just as easy, however both there in America and here in Spain I just happen to have the NodeMCU boards handy and so this short blog will show this in action using pin D5 on the NodeMCU – but there is nothing clever about these boards – if you have something different, use it.

NETIO – so firstly what is NETIO? It is a very inexpensive APP for IOS/Android with a free visual web interface – I’ve discussed it before in here with examples. Essentially you create a free account at http://netio.davideickhoff.de/en/ and having logged in, you go to the online design editor and put together your dream interface. In this case a simple slider to control a solenoid will do – but more of that in a moment. You then sync your phone to the account and the control page becomes available to your device. The point being it is just SO easy to make pretty interfaces.

ESP8266/Arduino – this is a free add-in for the Arduino environment (which in turn is also free) to allow you to compile C++ code for the ESP8266 chips – just as easily as if you were using an Arduino. Indeed with the nodeMCU board you simply plug it into USB, fire up the environment, fire up an example – and you are up and running. I believe the forthcoming (Kickstarter) node.IT boards will be similarly easy to use.

In my case I firstly downloaded the standard Arduino 1.6.5 environment to my Windows PC – I then followed the instructions on Ivan’s GitHub page – everything you need to know is included in his readme file so I’ll just take you straight there. github.com/esp8266/Arduino

The example Ivan put together to control a servo is here. https://gist.github.com/igrr/9ef4d5c74355503e3b1f

The only thing you have to do to run this sketch is to put in the name and password of your router. Running the program and using the Arduino serial monitor yielded (in my case) this…

Image635745760775013702

As you can see the little board immediately connected to my router which gave it the address of 192.168.1.24 – this actual address will vary from system to system.

The demo program sets up a trivial web server which will work as follows: In a browser I typed http://192.168.1.24 and here’s what appeared in the browser…

browser

Check out the example code and you’ll see where this comes from.  The next step is to add an argument to that URL – so let’s try http://192.168.1.24/servo?value=120 (remember you likely won’t get that actual address)

browser2

You can see that the value has been extracted and passed back to the browser – meanwhile in the serial window…

debug

What you don’t see is that on pin D5 of the ESP8266, a constant pulse is being sent out and this pulse WIDTH has been altered. Values 0-180 work and turn the servo from 0-180 degrees.

It REALLY is that simple to drive a servo – in my case the 3-wire DIRT CHEAP servo is a Turnigy TG9e with 3 wires – ground, power (3v3 in my case) and signal (D5 – but doesn’t have to be that pin).

So by firing the argument (value 0-179) as above to that address I can control the servo – how about doing this remotely via a mobile – for now we’ll assume internal addresses so this would only work within the area covered by the router… but I’m sure you’ve already considered world-wide servo domination.

The image below pretty much covers it – in the web browser I dropped a slider into the NETIO main screen.

netio

The only thing missing here is the code for the slider. Click on the slider and…

netio2

(I’m pretty sure I should have made that max value 179 but whatever… it works) So I have set the slider to emit code /servo?value={value} where {value} gets replaced by the actual slider position as you run the app and move the slider around – add that to the address in the main panel and you have exactly the same result as we saw higher up this blog entering the value into a browser manually. Hence… here I am moving the slider around on my Android phone – the result in the debug serial window is:

slider

And as this happens the actual servo is rotating back and forth up to 180 degrees. Whether this powers a piece of paper or a ton of concrete is down to the servo!!!

This is of course trivial – the same APP could control a whole HOST of sliders and the ESP8266 code could perform all sorts of transforms on that data – an ESP8266 spider could be fun (I got that idea from the giant cockroach which appeared on the floor while we were experimenting at MIT)! A nice addition to that code might be a timing arrangement to smooth the value change as moving your finger across a phone tends to produce slightly jerky results.  If you were using this for a window opener or other visual toy…..

When I get a minute I’ll do a video of this for YouTube – in terms of development, if you have everything to hand you could have this all running from scratch within 10 minutes, it is that easy.

My thanks to Ivan for bringing the ESP8266-Arduino environment to my attention – I talked about this ages ago when it was new but at the time was not that impressed – today – hell yes this is a very easy way to get quick results with ESP8266. If you have any code issues, Ivan is really approachable.

 

servo

That’s it for now. Just back from the states to our little village and I’m thinking a pint is in order..

Facebooktwittergoogle_pluspinterestlinkedin

6 thoughts on “ESP8266 Arduino NetIO Server Demo

  1. Hi,
    Tried the ESP board add in for Arduino IDE but I get an error during compiling, it looks like I need Windows 64 bit, is that true?

    Phil

    1. Can you paste up the error message ? (Presumably you've changed the "Board Type" in the IDE Tools menu to be an ESP8266 based board ?)

      1. Figured it out, I had an 'Hardware' folder in my sketch folder in my dropbox folder with some old ESP files inside, I deleted this folder an all works OK now.

        Thanks

  2. Hi Peter

    I see you were using NodeMCU devices.
    I have just received mine in the form of ESP12E Devkit.

    I was trawling the net to find information on it and found this User Manual http://www.gitbook.com/book/smartarduino/user-manual-for-esp-12e-devkit/details

    Hopefully this will be of use to your 'readers'.

    The info is not complete, it does give a full list of pinouts, but it does give info on what I hope is the external power input.
    The other thing missing is what LEDs are on which output (if any!). Can anybody can point to this info?

Comments are closed.