2019-04-16

Arduino / ESP8266 / ESP-01 / ESP-12F

I never really got in to Arduino, which is kind of surprising given my history. I have been playing around with micro processors for a long time. 30 years ago I had a door entry system running on a home made wire-wrapped 6502. I have coded things from tote betting ticket machines to mobile phones, and much more. I did loads on the PIC16C84 which was amazing when it came out, but somehow the Arduino passed me by.

Of course, these days, there are the Raspberry Pi boards, which are similar in size and price to Arduino but powerful enough to run linux. I have used a lot of those. At the office we have loads running display screens, and doing things like network printers, and even the door entry and alarm system. Very powerful, but used generally as small network computers rather than hobby electronics with I/O. Even the alarm system uses the Galaxy RIO boards to do the I/O.

Arduino is stupidly easy

The Arduino eco system - the desktop environment - is really very simple and quite impressive. So much so that someone like my friend Simon, who knows bugger all about coding in C, is able to create working Arduino applications. It is impressive. The standard "Hello world" program is: (a) plug in the board, (b) click on arduino app, (c) type Serial.println("Hello World"); in the on screen setup() function, (d) click the arrow to flash... Done. In a few seconds you have a computer sending Hello World via a serial port. Making I/O pins do things is similarly simple.

The coding is actually C++, which I have never been that happy with - but I am coping :-)

What is very impressive is the community of hobbyists that has built up. There are libraries for everything, so if you want, say, to use a Dallas DS18B20 temperature sensor, you will find a library to do that and examples, and instructions how to wire it up. Indeed, even the Tasmota code I am using on my light switches has that built in so I can literally solder a temperature sensor on the the pads and click a few config settings on the web page to set it up.

The libraries and examples mean that even Simon has been doing some impressive things, but he is not really a programmer, and so thought I might like a break(!) and spend a long weekend at his place.

In some ways this is actually a slight problem - I found there are many competing libraries for lots of things and it is not always obvious which you should pick. Of course, I am making some apps and libraries to add to that!

Hobby hardware

Back in the days of a PIC16C84 you could get chips with actual legs on and solder wires to them! These days that is impossible - the chips and components are just too small. What is interesting is that there are now common "modules" that have such chips, with extra passive components, all in place on tiny PCBs with headers. As always the headers are 0.1" (2.54mm) pitch so you can use molex style pins and plugs (or even wire-wrap).

I would always have bought parts from RS or Farnell but I was shocked at what you can get from Amazon. I mean, seriously, it is mental. And unlike RS I can get stuff same day or on a Sunday (which was handy during this long weekend). Seriously, it is like finding your corner shop sells electronic components next to the sweets counter, I can't get over it!

Sensors everywhere! What is impressive is the hobby electronic devices you can get, on PCBs with 0.1" headers, it is mental. If I was asked to list possible types of sensor, I would not come up with nearly as many as you can get, and get on Amazon Prime even! Here are just a few.



3.3V and 5V

One of the things that takes some getting used to is that everything is 3.3V now. When I were a lad it was all TTL (5V). But even now it is not that simple as some things are 5V still, so you need level convertors. That said, some things are 5V only and will not work on 3.3V, some are 3.3V only and are damaged by 5V, and some things are designed to work at 3.3V or 5V.

Interestingly the ESP8266 (see below) is 3.3V, but rumours are that the input pins tolerate 5V. Apparently the CEO of the company that makes them said so on facebook, and people say it works. What does not work is powering the ESP-01, or similar, from 5V as the flash chip gets fried. The right thing to do is read the data sheet and use level convertors as necessary. The good news is that 5V to 3.3V and 3.3V to 5V power regulators are now small and cheap and so are level convertors, so easy enough to do it right.

Power

Another issue is powering things - I have always had to use a power supply in the past, a plug-top and lead of some sort. But of course there are USB 5V connectors everywhere now. That said, the regulators for such things are tiny now. The Sonoff devices work of mains with a simple on-PCB power supply so for many things you could use one of those as the processor! Powering off 12V, or 5V, is simple and a small PCB with regulator. Even powering off 1.5V or 3V is simple as well. It never used to be this easy, cheap or tiny! Apparently you can make apps that will run off a battery for years if you try hard.

ESP8266

The breakthrough for me really is the ESP8266 processor. It turns a small(ish) Arduino board with Ethernet and a plug top power supply in to some thing truly tiny, cheap, and interesting. The ESP8266 is a small processor which includes WiFi (albeit only 2.4GHz). This is amazing. It is sold in various packages, but the interesting ones seem to be the ESP-01 and ESP-12F. It is this processor that is in the Sonoff light switches. There seems to be good support for them under the Arduino IDE.

ESP-01

The ESP-01 is the basic entry level package for the ESP8266. It seems some were sold with ½MB flash but now they are 1MB flash (there are two chips on the module, the ESP8266 and the flash).



They are tiny, and have an 8 pin header. There are a whole load of boards designed just to work with the ESP-01, such as relay boards which have an 8 pin socket on the board (and come with an ESP-01). They cost 50p or so if buying from China, but are around £2.75 on Amazon. So easy to use.

For programming there is a nice UART / USB board you can get, which has the 8 ping socket for an ESP-01. The trick is to modify it to have a button on GPIO0, which has to be pulled low as you reset to put in programming mode. Simply hold the button as you plug it in...


ESP-12F

There are a range of modules from ESP-01, ESP-02, and so on. The ESP-12 series is interesting, and they have taken a different approach in some of these later modules - instead of 0.1" headers they have solder tags on the edge so the module can be soldered on to a parent board.

The ESP-12E and ESP-12F are the same apart from the antennae, and include 4MB of flash (which is nice). The ESP-12S is quite new it seems and slightly smaller and does not have some otherwise useless pins on the end (used for external flash). They also have a metal can for EMC, and claim FCC and CE approvals, which is nice too. There are, of course, nice breakout boards that provide the 0.1" headers. The main advantage (apart from CE marking, and 4MB flash) are that more of the ESP8266 pins are available, including the ADC input.


For programming you just need to connect the pins from the small UART board (GND, 3.3V, RX, TX, and the GND via a button for GPIO0).

I'll blog on some of the projects I am making later in the week.

8 comments:

  1. The ESP-07 is another module to consider as it has a socket for an external antenna.

    ReplyDelete
  2. It's worth looking at PlatformIO too.. that looks quite nice compared to the arduino IDE although I've not used it in anger yet.

    ReplyDelete
  3. I don't particularly like those breakout boards. They are excessively wide and don't leave much space on a breadboard.

    My favourite is the Wemos D1 Mini Pro.
    Entirely self contained so you only need plug in a micro USB lead to program.
    16M Flash.
    Socket for an optional external antenna.

    ReplyDelete
  4. +1 for the Wemos D1 Mini. Much nicer to use than those breakout boards and also an ESP8266-12E.

    That said if you are amazed by the Arduino and the ESP8266 wait until you find the ESP32! Only a pound or two more than the ESP8266 and has 2x240MHz cores, a ULP core, WiFi, Bluetooth and BLE, 2xADCs, a DAC and an I2S sound interface, built in touch sensor support and the physical pins can be assigned to which ever peripheral you wish!

    ReplyDelete
  5. What I would love, is one of these ESP units (at a similar price point) with wired ethernet instead of WiFi. I guess it's always going to be difficult due to physical components needed - but wireless still just isn't as robust, in my head at least, anyway.
    Something like OrangePi came closest in terms of price point last time I looked, but that's a different product altogether of course (and still 4x the price of ESP8266)..
    -JMH

    ReplyDelete
    Replies
    1. Adding wired Ethernet support to the esp range is really easy...

      Delete
  6. 3.3v?? dinosaur... 1.8v is where it's at :)

    ReplyDelete

Comments are moderated purely to filter out obvious spam, but it means they may not show immediately.

Breaking my heart

One of the things I suffer from is tachycardia. My first memory of this was in secondary school, when I got a flat tyre cycling to school an...