ESP8266 Node MCU Setup

ESP8266 Node MCUThe ESP8266 Node MCU

I recently bought yet another non-Raspberry Pi device in yet another spontaneous purchase that I don’t have the money or time for. I had no idea what it was, but due to the very low price I figured I would take the chance and find out later.

A couple of days later a very small package arrived with my brand new ESP8266 Node MCU, but the question remained…”what are you and how do you work?!“.

As always it was Google to the rescue, however as expected there wasn’t even a fraction of the information, documentation or tutorials that the Raspberry Pi has. From the limited snippets I did discover, I managed to set up my Node, update the firmware and even connect to WiFi.

So here’s a blog post showing you how you can do the same. I like writing these kind of posts as I tend to refer back to them myself. Let’s get Node’d!

LoLin ESP8266 Node MCU

My specific model is the LoLin ESP8266 Node MCU v0.1 (despite the rear stating v3…)

What’s a Node MCU?

The Node is an open-source IoT (Internet of Things) platform. Rather than familiar Python, it uses the Lua programming language – yep, another one to learn!

In terms of hardware, it runs an ESP8266 WiFi SoC from Espressif systems. I’m still getting to grips with the details of this chip and exactly how it works, but that seems to be the main component mentioned.

Raspberry Pi users will feel a little more comfortable when they see the pinout of the board. It comes with 10 GPIOs, and interestingly each GPIO can be used for PWM, I2C and 1-wire. It also has 3.3V pins, GND pins, RX, TX, SCLK, MISO, MOSI and so on. Add the fact that it’s powered by a 5V micro-USB port and maybe it’s not such foreign territory after all?

Node MCU pin diagram

The LoLin Node MCU pin diagram (courtesy of www.wemos.cc)

Connectivity is a strong point with built-in WiFi alongside the micro-USB port that includes a TTL serial connection (plug into your PC > get coding!).

Lastly, I get the general feeling that the Node is summarised as “a bit like an Arduino“. It’s small, cheap, has low power/capacity specs and is managed with an IDE style interface. Close enough…

Node MCU versions

There appear to be a few different versions of the Node out in the wild. These differences can be the brand that makes them, the layout of the board and even the size. There’s not a lot of difference between these versions, but it’s worth pointing out.

From what I have seen online, the latest version appears to be 1.0. This version is thinner than the previous releases, taking feedback from users as the older style was too wide to offer any usable pins on a standard breadboard!

The version I have is 0.1. This is the wider variant, but I don’t think there are many more changes over and above that.

Fakes!

I’m not an expert on Open Source, but I’m pretty sure there can’t really be such thing as a ‘fake’ unless the product attempts to use the original brand name. An image from the Node MCU Twitter account suggests otherwise:

Node MCU Fakes

Is it really a fake if the design is Open Source, and sells under a different name?

Looking at this, it would appear I have a ‘fake’ LoLin version 0.1 in my hands right now. Does it work? Yes. Is it an Open Source design? Yes. Does my board pretend to be an official product? No.

I will support Node MCU and buy an ‘official’ board as well, but I think calling out other versions as fakes is a bit strong – surely it’s just a variation of an Open Source design with a different name?

Getting Started – Firmware update

The first thing I did was upgrade the firmware. I found a few guides with different links and methods that had mixed results, and eventually found one that worked well. There isn’t really an official website with everything in one place like the Raspberry Pi, so this one’s a bit more of a challenge!

Here’s what I did:

Connect your Node

You’re going to want to connect your Node MCU to your computer initially. This will allow you to find which COM port it’s assigned to.

  • Plug in your Node to a spare USB slot. You should see a short LED flash on the board, and maybe the usual ‘installing driver’ pop up. Tip: If you don’t see any flash or interaction with your PC, try another USB cable (thanks to Steve in the comments section for this tip)
  • In Windows, go to Control Panel > Devices and Printers.
  • You’ll see a USB-SERIAL entry under ‘Unspecified’ devices. In the name you will see the COM port in brackets. Make a note of this.
Node MCU COM port

Find your Node MCU’s COM port in the Devices and Printers screen

Flashing tool

Next you’ll need flasher software to flash a new firmware version on to your Node. I’m using this one:

https://github.com/nodemcu/nodemcu-flasher

Click the ‘Download zip’ button on the right hand side. When you open the zip you’ll see folders for Win32 and Win64 (32-bit or 64-bit). Open the folder that matches your PC and the .exe program will be inside.

Firmware

Next you’re going to need to grab the latest firmware for your Node. Here’s the link you’ll need:

https://github.com/nodemcu/nodemcu-firmware/releases

Under ‘Downloads’ grab the latest version for either ‘float’ or ‘integer’. If you’re unsure what this means, it’s as simple as this:

  • Float = number with fractions/decimals. You’ll want this version if you plan on using those in your code.
  • Integer = whole numbers. If your project doesn’t need fractions or decimals, go for this.
  • The integer version is smaller in size.

Flash new firmware

We now have the flashing software and some shiny new firmware, so let’s use them to update your Node.

Open up the flashing tool and you should be presented with this screen, which should automatically have the correct COM port that you found earlier (unless you have other devices connected using COM ports):

Node MCU Flasher tool

The flasher tool should look like this when you first open it, possibly with a different COM port

Now go to the Config tab, which initially should contain the following text in the first line:

INTERNAL://NODEMCU

This is the firmware that comes with the flashing tool, but as this may not always be the latest version we of course downloaded our own. To use the firmware we downloaded earlier, just click the little gear icon next to that line and locate your downloaded firmware .bin file.

Some guides on the internet suggest changing the numbers to the right of this line, but I kept mine at 0x00000. Also make sure all other lines are empty and un-ticked, like this:

Node MCU Flash Firmware

Add your own firmware using the gear icon to find the .bin file

Now go back to the Operation tab and hit ‘Flash’. One of two things should happen:

  1. The software will identify and display the MAC addresses, show a little QR code and flash your firmware. It’s only completed once the little green tick shows in the bottom left corner.
  2. The flasher will hold with no MAC addresses or QR code. The button will change to ‘Stop’ but nothing will happen. If this happens, press ‘Stop’, unplug your Node then plug it back in again and try once more.
Node MCU Firmware Update success

Don’t disconnect your Node until you see the green tick in the bottom left corner.

Once that’s done, pull the power once again, then plug it back in.

That’s it, firmware upgraded!

Getting Started – IDE

I said earlier that the Node is a bit like an Arduino, and this is true in that it uses an IDE style environment. That’s the comparison I’m making at least!

This part confused me a bit as I found there were lots of different environments to use. Here are a few:

I kicked of with LuaLoader, as it looked simple and had an option to quickly add WiFi without any coding (great for a beginner like me).

LuaLoader

Download LuaLoader and run the .exe program.

You will initially be greeted with a screen like this – disconnected from your Node, which is highlighted by the red colour in the top-right corner:

LuaLoader Interface

The initial LuaLoader interface. Notice the red corner indicating no connection.

Connecting your Node is a bit clunky, but simple when you know how.

First you need to make sure it has detected the correct COM port. You can do this by simply clicking on the ‘Settings’ option in the menu bar – the first item should say ‘Open COM2’ (or whatever your Node’s COM is).

LuaLoader COM check

Click the ‘settings’ menu item to see which COM port the software is looking at

If this isn’t the right COM port, look further down the menu for ‘Comm Port Settings’. Inside that option is a drop-down to select any of the detected COM ports available:

serial settings

Use the serial settings to change the COM port selected

Once you’re happy that you have the right COM port, click ‘Connect’ to the right of the menu bar.

This should connect you – to a point – but I find that every time I start up LuaLoader I don’t get any response from buttons until I click the reset (RST) button on my Node:

LuaLoader Connected

If your screen looks like this, your Node is connected…but you can’t do anything yet!

The screenshot below is what it looks like after I click the reset button on the Node. Notice the build number – I find that as a good indicator that my Node is connected, and also gives you confirmation that your firmware update was successful:

LuaLoader build number

Once you reset your Node and it connects properly, the build number will show

 

WiFi Set up

Might as well cover this whilst I’m at it. WiFi set up is super simple when using LuaLoader. Just enter your SSID (your network name – ‘BT-HomeHub12345’ for example) and router password in the boxes to the right of the screen, and click ‘Set AP’. That’s it!

Now try the ‘Get IP’ button now and you should see something like this:

> = wifi.sta.getip()
192.168.1.12 255.255.255.0 192.168.1.1
>

There are other cool features on LuaLoader like GPIO control buttons, but I still need to have a look at those – it’s early days!

If you want to check it’s definitely connected, either log in to your router or use a free app like Fing to see all the devices on your network. My Node showed up with the name ‘Expressif’ (the maker of the ESP8266).

Summary

I hope that helps you get started with the Node MCU. I spent a few hours reading about the board and trying different ways of setting it up. I’ve flashed mine twice now and this method works perfectly for me.

I guess I should caveat all of this with the fact that I’m using a LoLin Node MCU v0.1 – there are a lot of different Node boards out there so I can’t guarantee this will work for your specific version.

I’ll post another blog up soon showing how to do some simple stuff like flash LEDs connected to the Node’s GPIO, so get subscribed to be notified of any new posts (mostly Raspberry Pi but I dabble with other boards like Arduino and the Node).

Until next time…

25 Comments on "ESP8266 Node MCU Setup"

  1. Neil Manuel | 11/11/2015 at 20:53 | Reply

    I too was suckered-in by the RyanTech sale and purchased one of these and, when it arrived wondered what the heck I’d just thrown a fiver at. It didn’t appear to be working at first but, following your ‘enlightened path’, I can see it now works (after a fashion). Still got to figure out what its for yet – looking forward to your next battle with this new toy so I can learn something too. Cheers … Neil

    • Yes it was all too tempting at half a tenner!

      I’ve managed to get some LEDs going – standard GPIO on/off like the Raspberry Pi. It was good to see GPIO working in a familiar way, but I’m sure this device is more aimed towards IoT – will have to work on that!

  2. Now install MicroPython and you are good to go, if you are more familiar to Python then C

  3. HI Richard 🙂 Can I suggest moving the bit up about setting your AP details before hitting the ‘Get ip’ button ? You explain how to do it well (once I had read it!) but only after I had sat there hitting get ip for a bit. (Yes, i’m slow)
    Might also be worth suggesting if this doesn’t work t all, try using a different USB lead..I thought my MCU was dead until changing to a different cable.

    • Hi Steve

      Thanks for the tip – I’ve added the USB cable check in the steps. I’ve also changed the ‘get IP’ part – I see what you mean about it being confusing!

      Have you managed to do much with it yet?

  4. meltwater | 01/12/2015 at 20:41 | Reply

    Thanks for the excellent guide, has been perfect for getting that initial spark of life into it. It has been travelling in my bag for months waiting to be tickled into action.

    Now to see if it can play with the PiStop…(LED Flash)

  5. Hi.A time ago I had buy V3 too. Your guide help my start with. I made a sipmle blink. And functioned. Have you more skech for beginer?

    • Hi Marbri. I haven’t done anything else apart from a bit of LED GPIO – I want to work out the IoT side of it first. Watch this space.

  6. Thank You from Norway!
    I have lately read about 8266 and its posssibilities, ended up ordering Lolin version of it without really knowing…, and will soon get it and start exploring…
    Reading your article is very helpful to understand and believing I can get it working.
    Thanks again and happy Christmas!

  7. Lasse Berntzen | 10/03/2016 at 23:39 | Reply

    Thank you. I managed to get my unit up and running in a few minutes.Now connected to Internet. Will now go on and add some sensors etc.

  8. Thanks for your tutorial
    But if the project is open source the generic is’nt a fake !!!! if the firm don’t use NodeMcu name !!!! I buy Lolin product is very stable , but it’s normal it the same component but just usb ch340

    • My thoughts exactly. I’m happy enough with the LoLin version, works just fine. I need to do some more stuff with it actually, it’s sitting in my maker drawer gathering dust.

  9. Sayak Brahmachari | 09/04/2016 at 17:06 | Reply

    Thanks from India, I saw a NodeMCU on Amazon at around $5 and bought it. I had no idea to do with it at first but this post/article has given me some inspiration. I first thought that my Node was dead as I somewhat expected a ‘Blink Sketch’ from Arduino or something similar.

  10. Aaron Schmiedel | 27/04/2016 at 18:28 | Reply

    Brilliant! This worked great. Dunno what I’m gonna do with the two I bought, but something will come out of it!

  11. I can’t believe all the posts along the lines of “I bought an ESP8266 and can’t work out what to do with it”

    An IOT-capable microprocessor costing pennies that for a few more pennies you can add a screen to, and you can’t work out what to do with it? Sheesh!

    • May have mis-read your comment but…we weren’t all born as seasoned programmers. I can just about use Python without Google these days, so how could someone like me possibly just jump straight into a new device, with a new language, just because “it’s an IOT-capable microprocessor costing pennies that for a few more pennies you can add a screen to”.

      You might do this as a day job but for us ‘weekend coders’ it’s a struggle at the best of times.

  12. Hi, Natural curiosity wi-fi iot…. Why do we need a destination? … It’s the fun of the journey. Thank you, it’s great to find a helping hand on the trail. Still haven’t the foggiest where this little beasty will take me, just used the arduino ide and a sketch that tells me it’s talking to the router! And I get such a sense of achievement! So much fun for a fiver … Can’t be legal! Keep up the great work.

  13. Instead of Lua, you may want to use the Arduino ide and program in C like Arduino. In this ide are libraries for a lot of things like esp8266, wifi, etc.
    This module is merely for experimenting with esp8266 because it has everything on board, including usb interface. After designing your project and testing it with this module, you might buy an esp8266N (there are different versions) to get rid of the usb adapter and to make your project smaller.
    Main use for me is a small controller with wifi for wireless iot things.

  14. anil sharma | 09/07/2017 at 09:24 | Reply

    Hello,
    I don’t find the .bin in the firmware link you have provided. So, can you please suggest how to generate .bin file??

Leave a comment

Your email address will not be published.


*