ESP32 First Steps

ESP32I said I would not touch the ESP32 until the price came down and true to form, I just received my first ESP32 from AliExpress. Still a little more expensive than I’d like at £5.35 (inc postage came to £6.67) but I felt it was time to make a start. Bear in mind that a similar-looking ESP8266 board is half this price.

The ESP32-S board is as you would expect from a Node-MCU-type board, a simple USB plug in job with 0.1” centre holes along with reset (EN) and programming  buttons.  Unlike the ESP8266, you can see the start-up messages coming up at 115k baud and when in programming mode the board says “waiting to download” – which is very civilised.

What I will quickly gripe about on these boards is lack of LEDS. There is one RED LED which comes up with power and does nothing else. So when you are blowing the chip – there is no visual indication that anything is going on. It isn’t as if LEDs are expensive and there is room on the board!

I’m waiting to hear back from the Mongoose people as I had no success getting this board to work with their Javascript software but in the meanwhile I thought I’d give the Arduino IDE a go.

As far as I can tell there is no board level install for the Arduino IDE and ESP32 yet but I found that the Sparkfun guide worked well on my existing Arduino 1.69 IDE.   I had to install GIT on Windows to make this work – but that took mere seconds, all in all an utterly painless experience.

Despite mentioning the reset and programming buttons, you don’t need to touch any of those with the IDE – just load in your program and press the UPLOAD button on the IDE and you’re all set.

I took the more or less standard Blink example and changed the port to pin 5.

int ledPin = 5;

void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
}

void loop()
{
Serial.println(“Hello, world!”);
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
}

You don’t get any simpler than this – I checked which ports were available on the IDE then plugged in the ESP32 board  and tried again – COM6 appeared out of nowhere so I selected that. I also selected the board “Node32s” which appeared in the Arduino IDE once I’d done the Sparkfun install.

And that, ladies and gents, was it. I plugged a LED+resistor to ground and GPIO5 and it flashed reliably while putting out the serial message “Hello, world!”.

Now, the novice might say “so – I can do that with an ESP8266…  but I always like to try something really simple first to prove that the board and software were both working.

ESP32[6]I borrowed this diagram for my board from the excellent free book by Neil Kolban “Kolban-ESP32”. So, why look at the ESP32 when the ESP8266 is such a great board? Well, how about this… 34 GPIO lines, 7A/D convertor inputs, WiFi AND Bluetooth, 520K RAM and 3 UARTs – that good enough for starters? Oh and 3x SPI and 2x I2c.  The ESP32 is also capable of running in deep sleep at 20uA.

Of course all of this sounds good but whether all of that is easy to use is another matter – remember the ESP8266 has I2c but it doesn’t work so you have to use a software version!

In the IDE, ESP32-specific examples were, well, almost non-existent – so I tried one of my ESP8266 examples with WIFI and MQTT. Hey – there’s nothing like going in at the deep end and I absolutely did not expect results!!!

My code is a work in progress and not shown here – but it is a first stab for the ESP8266 at getting my normal WIFI+MQTT+various commands software running in the Arduino environment – a half-hearted project I’ve been working on in the background and includes OTA.  To be honest I was just wasting time trying this out because of the differences between the ESP8266 and the ESP32.  I set the compile going and of course, it did not know about the ESP8266 WIFI or the ESP8266 OTA code. I looked at an example in the Sparkfun page referenced above and they used “#include WiFi.h” – so I changed my include to that – and commented out the OTA stuff.

Well, blow me, it compiled – and better – when I pressed upload in the IDE – the next thing I saw on the serial monitor was it connecting to my WIFI and then to my MQTT broker!!! I had no real commands in the code yet but if I fired a dummy message out to MQTT it is supposed to come back with “Did not understand” which means WIFI and both MQTT publish and subscribe work.

Well, it worked – and sent the message back, with no modifications  – I’m impressed. Within a couple of minutes I had my usual {out5:1} working and from there, well, the sky is the limit.

As far as I can tell (someone tell me if I’m wrong) we’re still stuck with a maximum of 1 MB of FLASH for programs and that little demo used 40% of it – I’m assuming most of that is libraries. RAM on the other hand – well, there’s TONS of that. Unlike the Arduino IDE when using ESP8266 which give you lots of options for FLASH, I could find no options for the ESP32 – which might account for the 1MB limit. I’ll keep looking.

Assuming the price continues to drop I can see a great future for this little device.

38 thoughts on “ESP32 First Steps

  1. Personally I’ve been down the 433Mhz radio route.. spend countless months working on that and other frequency radios using Arduino and various network software… NRF240L01 radios at 2.4Ghz come to mind, possibly the worst radios in the world… no thanks – too many horrific memories of success rapidly followed by failure. I’ll stick with WIFI 🙂

    About the only thing I use 433Mhz for now is the odd sensor – and rarely ever get the range one would expect – got a stone cottage!

      1. honestly, i’ve seen these videos from Andreas Spiess where he explains everything, but as i didn’t need it for now, never studied LoRa, for now 🙂
        so, i don’t know if that 433 is standard or there are better option or anything else… just reported a board that is AIO, and i see many others are out there these days… but the full architecture requires gateways and many more stuff, so, it’s just a link in waiting for easier configurations, and actual needs, of course 🙂







  2. i scaled both versions available on banggood till the esp32 chip was exactly same size, then i put the black one on top of the red one, to evaluate the differences… and put 2 more reds on the sides, trying to align most of the pins… as you see, the red ones have 10 more pins than the black ones, 5 per side…

    p.s.: repost here, to let post survive the eventual deletion of the banggood temporary blog article…

  3. just received a second board, and while quite similar to the first one, as you can see the nodemcu marked one has 10 pins more than the doit one… consider this when buying…

  4. Just an update I can access following pins as outputs Was a soldering issue
    2,4, 5,12,13,14,15,16,17,18,19,21,22,23,27,26,25,33,32

  5. Just a note… I buy stuff through Bangood. The Geekcreit units I have bought landed cost was $NZ9 about $US5

  6. Yes, Ive watched most of his videos, the spreadsheet is great. The issue I have is not being able to address all of the available GPIO on my boards using standard Arduino commands… Reluctant to learn Expressife IDE ,, too many programs in my head

  7. Hi Peter
    Have you worked out in Arduino IDE which IO can actually be used as inputs and outputs? For argument sake the board I have an IO27 but I cant get it to function as an output

    1. I’ve not done that thorough testing yet as my second ESP32 board only just turned up (I’ve been waiting for price drops)…. someone else in here may however know…

    1. That one doesn’t ship to Spain either – what on earth these guys are thinking about only selling in the one country….. anyway – the Chinese will usually sell to anyone – mine came to Spain.

  8. If I recall correctly, one big advantage of the ESP32 is two CPU cores, with one being dedicated to communication (ie WiFi) which makes things nicer as your code isn’t blocked so much waiting for communication to happen.

    1. Hi

      I have MQTT working but I’ve not used SSL as this is for internal use. There’s no reason the broker can’t talk on an SSL connection to the outside world.

      1. ha, yes – “no reason”… but SSL on such tiny devices can be a challenge. I’ve spent a ton of time trying to get SSL to work with ESP8266 & AWS; No success to date. I think the mongoose folks had something that I’ve been meaning to try…. I had also considered some sort of internal MQTT relay to an RPi, but alas one more point of failure.

  9. Interesting and tempting though ESP-12F modules still suit my needs for the moment. I’ll see how the ESP32 progresses – I may have one particular use for one.

    Another minor edit for your post “…you can see the startup messages coming up at 115k board…” – that should be 115K baud I think.

    1. Not my day for writing blog entries, Brian 🙂 I’ve fixed that typo thanks. Oh, don’t get me wrong – I think the ESP12F is the bees knees – I’ve just ordered some of those WEMO boards which use them as general purpose boards but I thought I’d better take the time and effort to play with an ESP32 – as far as I can tell the information about it is way more spread about – and with far fewer examples – but there’s enough compatibility as far as I can see to make them immediately useful – one has to think about it – for slightly more you can get a NEO which is in a different league – so price really is important. Good fun learning though…

  10. “we’re still stuck with a maximum of 1 GB of FLASH”
    I think you mean 1MB and no that’s just the way the partition is set up in arduino.

    1. Yes sorry I did mean 1MB (blog updated.. I’m too used to working with various PI boards)… Right – so is that FIXED in the Arduino setup or is there a way to alter it etc? I’m reasonably familiar with both the Arduino IDE + Arduino plus using it with ESP8266 but this is my first stab at using the ESP32.

        1. Hi Peter – on the ESP8266 setup you have a range of options – all with a maximum of 1MB for programs – the rest can be used for OTA and for storing data. Those options don’t appear to be there on the IDE for the ESP32 – I’m guessing it’s just a matter of time before they appear.

  11. Hi Pete,

    There are some useful examples in the library folder https://github.com/espressif/arduino-esp32/tree/master/libraries

    Please try the touch capabilities, there are a great option and works fine with touchInterupt() and touchRead() – there are examples in the library folder also.

    You don’t have to install git (which is horrible under windows), just download the https://github.com/espressif/arduino-esp32 from github, put them in the right folder and the run get.exe and everything will work fine.

    There is a nice board for testing the esp32’s features but quite expensive https://www.olimex.com/Products/IoT/ESP32-EVB/open-source-hardware

Comments are closed.