Monthly Archives: August 2015

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

Node.IT

Node.ITMany of you have asked me about the devices I called ESP-210. I’d planned to take a boatload of early production boards with me to Boston this coming week – donated by Pontus Oldberg – but the couriers let us down (there’s a surprise).  So – I don’t know how long this link will remain live – I’ll fix this blog entry when it changes – but for now – feast your eyes on this..

https://www.kickstarter.com/projects/sweetpeas/579580872?token=d171d9a9

Facebooktwittergoogle_pluspinterestlinkedin

FAB11–Boston

This coming Monday/Tuesday/Wednesday I’ll be working with Espressif CEO Swee-Ann TeoJeroen Domburg, Ivan Grokkhotkov and others at FAB11 in Boston – demonstrating how to use the ESP8266 chips in home control and other applications.Heading off from Alicante first thing in the morning tomorrow (Sunday) and arriving late afternoon in Boston. Should be quite an adventure.

As well as talking about the technology and helping others I’m hoping to learn a lot more myself about these chips and of course I’ll be spending time armed with camera, checking out the many seminars and exhibitions at FAB11.  For pics and info…. I’ll be updating this blog occasionally – tweeting at @scargill (#fab11) and on the Facebook page esp8266wifi

Facebooktwittergoogle_pluspinterestlinkedin