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!
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?
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.
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:
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.
Next you’ll need flasher software to flash a new firmware version on to your Node. I’m using this one:
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.
Next you’re going to need to grab the latest firmware for your Node. Here’s the link you’ll need:
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):
Now go to the Config tab, which initially should contain the following text in the first line:
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:
Now go back to the Operation tab and hit ‘Flash’. One of two things should happen:
- 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.
- 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.
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).
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:
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).
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:
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:
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:
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).
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…