Saturday, 11 April 2015

Internet of Things pt1a: ESP8266

Nice!!! (But not for me)

A quick write up of what I found when I read around ESP8266 firmware, I was vaguely aware of most of this but I actually sat down and had a quick play with some of the ideas...

The ESP8266 can operate without the need of a separate micro controller such as an Arduino. The easiest example I could find was to upload the Lua firmware. Everything you need is on github here:  https://github.com/nodemcu


It was relatively straight forward.  The ESP8266 needs to be booted with it's GPIO0 pin tied to ground to enter into firmware update mode.



Use the firmware flasher to upload the Lua firmware to the ESP8266.


Once this is finished, restart the ESP8266 (remembering to put GPIO0 back to being a floating pin before you restart).












So now you can write and upload a Lua program that is executed whenever the ESP8266 restarts - neato.  Here I'm just executing Lua on the ESP8266 through puTTY terminal, connecting to my home wi-fi and confirming the connection by getting the ip address of the ESP8266.  There are a few Instructables, YouTubes and blogs about this, all the ones I looked at were pretty good so I won't link to any in particular - Google is your friend.


I am not a massive fan of Lua but this would get me more interested.  I found tutorials on compiling C programs for the ESP8266.  I can now fully appreciate why this is such a popular device.

The ESP8266 I have only has two GPIO pins but the forums have hacks to extend that like this...  http://www.esp8266.com/viewtopic.php?p=3804.



I'm wanting to see how the ESP8266 fits in with my existing long term projects so adding that second micro controller is the direction I'll take....


Internet of Things pt1: ESP8266

Jumping on the IoT bandwagon

It seems I can't escape from the "Internet of Things"... at work the development tool vendors spam me with how their tools enable IoT and their wild market growth predictions; at home in my making hobby IoT articles are popping up all over.

What does a guy that has too many long term projects on the go need?  That's right... another project! So here's the start of what might turn into a full IoT project.  In any case the short term goal is to look at wi-fi and get my head around the ESP8266 device.

I have a new fish tank in my home office, so this will probably be my thing on the internet...










ESP8266

A lot has been written about this on the net by smarter people than me so this write up is just a simple run through of what I did to get mine working.  If you don't know what the ESP8266 is either have a google round or read on and I'll demo some of what it can do...

The first problem is that the 4 x 2 pin out of the chip doesn't work with a breadboard, because the rows of pins are next to each other you can't put it directly into a breadboard without shorting it out.

One guys solution to this issue is included in this video: https://www.youtube.com/watch?v=9QZkCQSHnko

My solution is to bend the pins out to be 90 degress from each other and solder on 90 degree pins to create the spacing:











Quick test that it actually works

These devices cost around £2 posted on eBay, I always expect stuff that does so much for such a small price to not work.  So the first test is to power it up and see what happens...


















Firstly...  this is a 3.3v device and the word is that it doesn't like 5v.  In the image the ESP8266 is being powered with the 3.3v out of my USB to serial board that I use to program Arduino Pro-Minis. Don't connect it to the 5v out. 

There are just 3 connections to the ESP8266 here, 3.3v, Ground and the CH_PD pin, which is the enable pin, is pulled high by a 1K resistor to 3.3v.

The velcro cable tidy is just for stress relief, holding the USB cable to the bread board. 

On the iPhone you can see the unsecured wi-fi AI-THINKER... yes! it works, just 3 connections and the ESP8266 has a wi-fi access point running, albeit not connected to anything at the moment. I notice it's not the only unsecured wi-fi near me - roll up roll up, free wi-fi over at mine...



Digging a little deeper...

Lets use the serial of the Arduino programmer to communicate with the ESP8266...  




















This is where there were a few complications, I had a few issues. rather than go into it, I'll just provide what worked for me.

The ESP8266 is a powerful device and it draws a fair amount of current in operation, you can't run it just on the 3.3v supply from the USB to Serial device. You don't need a bench power supply, but you do need a source of 3.3v that can deliver the juice when the device needs it (I read upto 400mA peak).




















So in addition to the 3 connections we started with I have added the beefier power and connected the Transmit and Receive lines of the USB to Serial to the Tx and Rx pins of the ESP8266.

So here I have the Tx and Rx being driven at 5v, I've read some say don't do this and others say it's fine.  All I can say is that trying a 5v to 3.3v level shifter didn't work for me and I've been driving the serial at 5v for a couple of hours and nothing has gone bang yet.


I installed a serial program called Termite and tried out some AT commands



























Sending a command like AT+GMR gets the ESP8266 to reply with it's version details.

AT+CWLAP gets it to list out the wi-fi networks available.

So let's try and connect...





The blacked out bits are my login details for my wi-fi, I didn't get the syntax right first time round.  the AT+CIFSR command returns the ip address, confirming I managed to connect to my local wi-fi with the ESP8266... magic.


The next step is to check the firmware version and see if I need to upgrade.  I have read about a Lua based firmware that people are recommending so I need to do some reading up...  

Monday, 16 March 2015

Blackpool LUG and Makerspace - The great give away

Attending :-
Mike, Joe, Chris, Phyllis, Kieran, Elizabeth, Jeff, Olly, and Arthur.

The great give away started today, so if you want anything, make sure you let me know soon, there is only two weeks left before I close Ripon Road for good.

Arthur left with two bags full of cdrom/dvd drives, and is coming back for more. Elizabeth took two digital cameras, several people left with  corded telephones selected from a box full of them.

Olly has requested a cisco router, and the rack mounted server (if Les does not take it).
Les has requested an apple keyboard and a small psu.
Tony has requested some compaq evo base units.
James has requested a 90 watt Dell psu.

There is an 'Alladins cave' full of stuff here, so if you want something, speak up, because once it has gone, it is not coming back.




Monday, 9 February 2015

Arduino how to: Cheap eBay OLED Screens

Introduction

I noticed keenly priced OLED screens started appearing on eBay a long while ago.  I bought a few, but at the time there wasn't much information on how to drive them.  I found a C library on a Chinese website that I was able to cajole into MikroC for the PIC microprocessors but it was never really useful as I didn't implement any fonts.  Time has moved on and now there are a few well executed drivers out there.  I have tried a couple of different ones and this is a writeup on the approach that worked for me on the Arduino.


What is it, why would I want one?

The OLED screen is a very crisp 128 x 64 pixel mono screen.  The ones I buy have 16 rows of yellow pixels at the top and 48 rows of blue pixels at the bottom.  They are really good for giving feedback about what is happening in your Arduino code and little projects like this Arduino watch:

Time / Date / Temperature and Compass module

Buying the OLED Screen

There are a variety of similar screens available from Adafruit, if you need something other than 128x64pixels or feel more comfortable dealing with a UK supplier take a look at them.  Here is a different layout of OLED i2c sceen from Adafruit through Pimoroni.


I buy them from eBay, not only are they cheap but it's very easy.  Search for 'Arduino OLED i2c'.  The cheapest price currently is £2.57 posted from China.  I have bought 10 screens this way and so far they have all arrived working.  At that price you can afford to buy one more than you need perhaps.

There are also SPI versions available, SPI and i2c are different communication standards used to communicate between electronic devices.  This write up is about i2c screens.  (Adafruit do a driver for SPI driven screens which I believe works with the SPI eBay screens but I haven't tried this.)


Wiring it up

The i2c communications uses 2 wires.  One for Data and one for a Clock.  These pins can be found on the pinout diagram for an Arduino as SDA for Data and SCL for clock.  Just add 5v power and you are ready to go.

This is the pinout for an Arduino UNO

Connect the OLED screen to your Arduino as follows:

SCL goes to SCL
SDA goes to SDA
Vcc goes to 5v
GND goes to GND

It is that simple!



Lots more information

A slightly different device but the information here is mostly applicable:  http://www.geekonfire.com/wiki/index.php?title=I2C_OLED_Panel(128x64)



Getting and installing the library

This is the best library I have found and it works very well for me.  As well as line and basic shape drawing you get two font sizes and a bitmap editor.

To download the library:

Go to the resources of the link above.  Direct link: http://www.geekonfire.com/wiki/index.php?title=I2C_OLED_Panel(128x64)#Resources

Click on the link for the Arduino library to download it.


I recommend the automatic library installation in Arduino, which is explained here:  http://arduino.cc/en/Guide/Libraries



Once you have installed the library your Arduino environment should have these menus available (I have just upgraded to Arduino 1.6.0 which came out today!).

The GOFi2cOLED Library showing as installed


GOFi2cOLED files added to the Examples


Firing it up!

The best way to start is to look at the Examples supplied. Load up an example you like the look of from the File > Examples > GOFi2cOLED menu and upload it to your Arduino.

Oh no, it didn't work!

It might not work straight away.  In i2c you can have many different devices on the communications bus and each device needs an address.  The library assumes the address of your OLED screen is 0x3D, so far all of the screens I have bought have had an address of 0x3C.

You might need to change the i2c address used, look at the void setup() section of code:

  
Change this:

  //default address is 0x3D.
  GOFoled.init(0x3D);

To this:

  //address changed to 0x3C.
  GOFoled.init(0x3C);

And re upload the code.


Success!

Animated heart sketch running on my Arduino UNO


If your screen still doesn't work, double check the wiring and try downloading a sketch that will sniff the i2c addresses and show you if the screen is correctly attached to the i2c bus and what address it is showing as.  Simply put that address into the code and you shoild be good to go.














Wednesday, 4 February 2015

Saturday 30th January

Well lots for folk at the makerspace this morning including Mike H, Mike 2, Joe, Arthur and son, Richard, Kieran, Phyllis, Les, Nathan, Sharon and a couple of folk whose names escape me, oh and me Tony.

I spent quite a bit of the morning progressing the rebuild of the 3D printer and by the end of the morning had got this far.




As you can see quite some way to go before we will be printing our first object.

The others were all doing something interesting relating to arduino coding but someone else will have to fill in on that.

Saturday, 17 January 2015

Work (re)starts on the 3D printer

Attending:- Mike, Joe, Tony, Les, Michael(2), Richard, Arthur, Elizabeth, Susan, Phyllis, Kieran


We were donated a 3D printer in need of some TLC last year. 
Details of the printer here, :-
http://blackpoollug.blogspot.co.uk/2014/10/makerspacefy1-and-3d-printer.html

Donald started the ball rolling in October by refitted the filament drive motor and also re-aligned the the other drive belt. Description of the work is here:-
http://blackpoollug.blogspot.co.uk/2014/10/makerspacefy1-robots-and-3d-printers.html

Various other small adjustment have been made since, including relocating and aligning the two vertical drive motors.

Today, Tony and Les decided that they wanted to experience building the 3D printer from scratch, this entailed dismantling the printer back down to it's component parts. Here they are discussing if they have enough boxes to put all the bits in before they start.


This is what our 3D printer looks like now.


Meanwhile, Mike continues work on his electric motor project


Arthur and Joe discuss RethinkDB


Elizabeth and Susan still trying to discover why the missing Pinterest button appears  and disappears . There is a long discussion on the mailing list about this.


Gaming talk



This event was powered by coffee and Jaffa cakes.








Saturday, 10 January 2015

2015 #1 - A Chromebook a smartwatch and a windows tablet

Attending This week: Mike, Jack, Chris, Joe, Les. Keiran, Ricky, Arthur, tony, Mark and Mike(2)

A very windy day in Blackpool today. 
Elizabeth and Susan decided not to risk the journey in the little smartcar.



Jack takes a break, Mike looks at the possibility of rewinding an electric motor for a very specific role.



Multiple and diverse discussions around the table.
 There was a lot to talk about following the Christmas / New Year break.



Chris showed off his new Chromebook, and explained how to get Ubuntu on it.



Then Chris demonstrated a smartwatch 


Arthur 'upgraded'  his windows laptop to dual boot with Linux Mint, with the help of Tony.

Les showed off a 7" windows 8 tablet obtained for the bargain price of £60
Attempts to get Linux on it are ongoing.