Hands on NodeMCU (ESP8266) – Setup

If you have a hobby IoT project like me and if all you need is WiFi connection and some pins to connect your sensors, NodeMCU is way to go.
NodeMCU is an open source LUA based firmware developed for ESP8266 wifi chip. By exploring functionality with ESP8266 chip, NodeMCU firmware comes with ESP8266 Development board. NodeMCU board consist of ESP8266 wifi enabled chip. The ESP8266 is a low-cost Wi-Fi chip developed by Espressif Systems with TCP/IP protocol.
This machine has integrated wifi module and it can be bought for 2$ from China, or around 5$ in local markets. Isn’t it amazing?!
Only downside might be that it is working with 3.3V and there are times you might need 5V. But for me it was working with a lot of sensors I had chance to try.


First we need to install usb driver. Go to Silabs and download & install the driver suitable for your operating system. 
Now as an IDE (Integrated development environment) you have couple of options. You can go with ESPlorer or Arduino IDE but I decided to use PlatformIO IDE with Atom integration.
If you decide to go with my way, first install Atom text editor. When you are ready, go to Settings/Preferences -> Install and type platformio. Then install the ones you see in below screenshot.

I think you also need Python, if it is not installed by default with your OS, install python. After you installed PlatformIO, you will see this home page:

We are good to go! Now click on + New Project and fill the necessary fields. Although my board was NodeMCU 1.0, choosing NodeMCU 0.9 as the board also worked fine for me.

Click finish and you will see your project explorer on the left side. Open src/main.cpp and do your hackings! This tutorial is not development but more like environment setup tutorial. I will show couple code examples in upcoming tutorial. 
After you finish coding you need to build it. Click ✓ sign on left bar which says PlatformIO: Build when you hover over. After build is successful we need to upload it to our development board. Click → sign on left bar which says PlatformIO: Upload when you hover over.

Of course at this stage, I assume you connected your board to the computer with usb cable. When you click upload, you will see built-in blue led on the board will start blinking till upload is done. You can also see the progress on your screen. When the upload is done, your code will start running on ESP8266. You can read the Serial output of the board from PlatformIO as well!
On the same left bar you can see a plug symbol at the bottom which says Serial Monitor. Click on it and choose the correct port, now you can read the Serial output of ESP8266.

You can unplug your board from the computer and plug it to power source or battery, and it will automatically start working. Your application can also be configured with OTA to send the updates over the air. If you do the OTA setup, you don’t need to connect the device to your computer every time you want to change the code, you can simply do the updates over the air. But this topic is beyond the scope of this document, you can find examples online. 

Thanks for reading so far, and I hope it was useful. See you next time!

If you liked the content please share it!

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.