Getting Started with NodeMCU Board Powered by ESP8266 WiSoC

Since ESP8266 is now so popular, I’ve recently bought a NodeMCU board to try it. I selected this board because the latest version of the board is breadboard-friendly, integrates a USB to serial chip, and it can be powered by a simple USB to micro USB cable. I also noticed a ESP8266 tutorial with NodeMCU firmware by SwitchDoc Labs the other day (using ESP-12 and Adafruit Huzzah), which I applied to my NodeMCU board, but since I encountered a few issues, I decided to report my findings, and write my own little getting started guide to switch on/off LED and GPIOs using a web interface.

NodeMCU v0.9 and NodeMCU v1.0

If you are going to purchase a NodeMCU board it’s important to know there are two official versions:

  • NodeMCU v0.9 with ESP-12 module
  • NodeMCU v1.0 with ESP-12E module
NodeMCU_v0.9_vs_NodeMCU_v1.0
NodeMCU v0.9 vs NodeMCU v1.0 (Click to Enlarge)

The main complain about NodeMCU v0.9 is that while it fits on the breadboard, you can’t use as it takes the full width of the board, while NodeMCU v1.0 is really breadboard-friendly as you can see on the right part of the picture above.

I’ve bought mine for just above $6 on eBay advertised as “NEW Version NodeMcu Lua ESP8266 WIFI Internet Development Board Latest Firmware”. The image was still v0.9, but since there are only two version, I was sort of expecting to receive NodeMCU v1.0. I was wrong…

Other differences are that NodeMCU v1.0 has some extra GPIOs. Please find the pinout for both versions below. We’ll use these a little later in this tutorial.

NodeMCU v1.0 Pinout (Click to Enlarge)
NodeMCU v1.0 Pinout
NodeMCU v0.9 Pinout (Click to Enlarge)
NodeMCU v0.9 Pinout (Click to Enlarge)

Using NodeMCU v0.9 with a Breadboard

If you are lucky (or smart) enough to have purchased a NodeMCU v1.0 board, you can skip this section, but if you are stuck with NodeMCU v0.9 this may be useful.

The first way is to connect the board to the breadboard using female to male Dupont cables.

Female to Male Dupont Cables
Female to Male Dupont Cables

This works, but it’s not quite a neat as the solution provided on lucstechblog, that is making an adapter board with four female headers allowing to insert NodeMCU v0.9 board, and connecting male Dupont cables to the breadboard.

NodeMCU_v0.9_breadboardLuc uses a stripboard, which makes it quite easier to solder than the perfboard I used, and it took me a little while to get rid of some shortcuts I did during soldering. So I should get myself some stripboards too, as they may be useful in the future.

NodeMCU Adapter Board with Stripboard and Perfboard
NodeMCU Adapter Board with Stripboard and Perfboard

Installing Firmware and Accessing the Console on NodeMCU

Now that we have taken care of the hardware part, let’s check how to actually use the board. I was expecting some easy to follow documentation, but the documentation on NodeMCU.com is not really that useful to get started, and after searching further I eventually ended up on NodeMCU Firmware Wiki on github which provides more details.

However, after connecting the board to my computer via a micro USB to USB cable, while I could see new open ESSID “AI-THINKER_F52E3F” to which I could connect, I had no access to any webserver or the console. So I used minicom in Ubuntu to access the serial program (Putty can be used instead Windows), but again I had nothing. My default settings is 115200 8N1, so I tried 19200 and 38400, and 56700 without any luck.

The I decided to flash the latest NodeMCU firmware with  esptool as explained on that guide. I did so in a terminal in an Ubuntu computer, with the board connected via USB.

  1. Download the latest firmware @ https://github.com/nodemcu/nodemcu-firmware/releases. There are both float and integer versions, but since I just wanted to toggle GPIOs, I downloaded the integer version:
  2. Install esptool from Github
  3. Flash the firmware

    and once it is successful:

So I tried again to connect to the serial console via minicom, and no luck. I could still see the AI-THINKER_XXXXXX ESSID though, so it’s likely the board already came with the right firmware. Finally, I found that the serial console may be connected at 9600 baud on Electrodragon Wiki, so I changed the serial in minicom to 9600 8N1, and I had success with the Hello World test:

Controlling ModeMCU’s GPIOs via a Web Interface

Now that we know the board it working, we can run a small web server to control some GPIOs and LEDs. To do so, I created init.lua file with the code I found in SwitchDoc Labs’ tutorial:


You’ll just need to change the second line replacing ROUTER_ESSID and WIFI_PASSWORD by your own credentials to have NodeMCU connect to your WiFi router. The code is set to modify the status for GPIO 0 and GPIO 2 (D3 and D4 pind on NodeMCU board as show in the pinout diagram), so you may also want to modify the code to control the GPIOs required by your project. If you want to clearly understand LUA language, you may want to check out that PDF file provinding details about Lua Language 5.1.

We’ll also need another Python script (luatool) to push the file to the board:


The first time I tried it the connection failed:


So I tried again an it went through:


So for some reasons, the connection between the baord and my computer is not very stable, and I had another aborted connection when I tried again later. The important point is that you need to check the command went through without errors.

We can check the IP address in LUA console:


Now open a web browser (I used Firefox) and point it to the IP address (192.168.0.106 in my case).

NodeMCU_Web_ServerNow you can click on the On / Off button to change the GPIO levels, and with GPIO 2 it will also turn on and off the blue LED on ESP-12 module with OFF (low) = LED on and ON (high) = LED off. The URL will also change accordingly, for example GPIO 2 OFF will show the URL http://192.168.0.106/?pin=OFF2.

Finally, after some small challenges, NodeMCU is not that difficult to setup after all. Hopefully, this will help a few people getting started faster.

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

Radxa Orion O6 Armv9 mini-ITX motherboard
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
26 Comments
oldest
newest
Roel
Roel
9 years ago

Does somebody know if you can get this dupont cables for connectors of 0.5mm?

sk
sk
9 years ago
sk
sk
9 years ago

Oops! 🙂
Yes, that’s right. Though I actually saw it here:
http://www.instructables.com/id/Get-Started-with-ESP8266-Using-AT-Commands-NodeMCU/?ALLSTEPS

Jon Smirl
9 years ago

@Roel

Why do you want 0.5mm Dupont cables? Smallest I have seen is 2mm, most are 0.1in (2.54mm). 0.5mm is extremely small, so small I have difficulty soldering it.

Johny007
Johny007
9 years ago

I think the problem is with your code. You set the AP settings wifi.sta.config(“ROUTER_ESSID”,”WIFI_PASSWORD”) which is immediately followed by this print(wifi.sta.getip()) . This procedural attitude is not right with this board. You should hook up a function with wifi.sta.eventMonReg(wifi.STA_GOTIP, yourFunction()) before you make server socket etc. Hope this helps.

John S.
John S.
9 years ago

Very cool, I went through much the same with my doit.am V1.0-clone board (~$10 from banggood), though now I’m just using it as a fancy UART adapter running ESP-Link from JeeLabs. One difference with the V1.0 is it uses a SiLabs cp2102 for the serial chip instead of a ch340, I don’t know if that would have any effect on your intermittent comms problems, though. I’ve been using picocom lately, and it has a very handy CTRL-A menu that lets you quickly “step” the baudrate up and down, so it’s pretty fast to cycle through various bauds to try them… Read more »

Andrew
Andrew
9 years ago

Not to poop at your party or anything, but MXChip now has a competitor to the NodeMCU in a similar form factor, using their EMW3165 module. ARM Cortex M4 & Wifi. Same price point as this board. The ARM core opens up a bunch of possibilities, since the ESP uses the far less common Xtensa core. Search for “WifiMCU”, and you’ll find it. But … this module/board is new enough on the market that the community has not implemented all the wonderful stuff that it generally does, not yet. Plans are to have the Lua interpreter, and the Espruino software,… Read more »

Roel
Roel
9 years ago

@Jon Smirl
Jon,

I’m trying to debug a router. It’s a main-board with a daughterboard. The connectors are 0.5 mm. I want to break it out to find the serial console.

John S.
John S.
9 years ago

Are you measuring the pitch of the header? The distance from the center of one pin to the center of the next? A 0.5mm-pitch pin header is unbelievably small. The pins themselves would have to be so thin (0.15mm, maybe?) that I don’t think you’d be able to plug them into anything without the pins just bending instead of going in. It sounds incredibly exotic and expensive and impractical (because there’s already cheaper, smaller, more common, and more robust non-pin-header connectors widely available as an alternative), and it’s really unlikely to even exist. If your measurement is the width of… Read more »

roel
roel
9 years ago

@John S.
John,

thanks for the answer, you made me a lot smarter. i did indeed measure the pin, not the pitch. The connector is more like a ide connector of a 2,5 inch harddrive but smaller. I don’t have the device with me this weekend, but monday i got it back. Probably the pitch will be 2mm.

John S.
John S.
9 years ago

@Jon Smirl, @roel:

There are also 2mm to 2.54mm dupont cables available (I got mine at ElectroDragon). That’s handy if you want to be able to connect the other end to something with 0.1″ headers, like a usb-serial device or a breadboard. You’d also need long male-to-male 0.1″ pin headers to convert the female 0.1″ connectors into male connectors for using with a breadboard.

Or I assume the 0.1″ ends are handy; I haven’t actually tried plugging a 2mm female dupont connector onto a 0.1″ square pin — would it fit?

Marcel
9 years ago

I advise you to not use any of the outdated releases from https://github.com/nodemcu/nodemcu-firmware/releases. They’re old, unmaintained, suffer from memory issues and contain modules that you probably won’t need (but still eat memory. Use http://nodemcu-build.com/ or the Docker image at https://hub.docker.com/r/marcelstoer/nodemcu-build/ to build your own custom firmware from the NodeMCU dev branch. Disclaimer: both services are from yours truly.

zmemw16
zmemw16
8 years ago

for the 0.9 dev kit, span it over two of the power supply strips, for the 1.0 use a single power strip.

Ville
8 years ago

Hey, thanks for this great article. If only I had found this yesterday when I got my NodeMCU, would have saved me couple of hours :D. Documentation is indeed pretty hard to find compared to Arduino stuff.

SC
SC
8 years ago

Thank you for the guide! It help!!

Meet
Meet
8 years ago

Can we do serial communication between NodeMCU and Arduino using usb cable?

has
has
7 years ago

Hello
Thanks for the tuto, but when I disconnect the pc to put it elsewhere by feeding with an external battery it does not work.
Thank you for your help

BrianD
BrianD
7 years ago

For v0.9 boards You can take two breadboards and connect them side by side, and it works fine.

(and thanks for pinouts!!)

nemo
nemo
6 years ago

You are closing the connection directly after sending. This is not working for me, because the connection is closed too early. Its better to set a callback, so the connection is closed when the transfer is finished.
This is done by replacing the line

client:close();

by

conn:on(“sent”,function(conn) conn:close() end);

Maybe it depends on the firmware version.

Thanks for your helpful posting.

Boardcon Rockchip RK3588S SBC with 8K, WiFI 6, 4G LTE, NVME SSD, HDMI 2.1...