ESP8266, Programming, Python, Tech

MicroPython on NodeMCU V3 / ESP8266

I’m a big fan of Python. It’s easy to use and quite powerful. When I heard that there is Python firmware for microcontrollers I had to try it.

The NodeMCU V3 board I used looks like this:


Here are instructions to flashing the MicroPython firmware:

NOTE: The following instructions are to be executed on Linux. I used a Ubuntu virtual machine to do this.

1. Open a Bash terminal

2. Create a new folder “esp” and go inside it

3. Download the new firmware from under the section titled “Firmware for ESP8266 boards”. Click on the file that looks like “esp8266-20190125-v1.10.bin”.

4. Install the “esptool” firmware flashing tool:

sudo pip install esptool

5. Connect the ESP board to your computer

6. Check which port the board is connected by executing “dmesg” and you should see something like this:Capture1

Look at the line which says “…now attached to…” and note that device name, eg ttyUSB0.

7. Execute the command to erase the flash memory. Remember to change the device name to whatever it is on your computer

sudo --port /dev/ttyUSB0 erase_flash

You should see this:


8. Execute the command to flash the new firmware --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect -fm dio 0 esp8266-20170108-v1.8.7.bin

You should see this:


9. That’s it!

Here are the instructions to check the new firmware:

1. Install picocom

sudo apt install picocom

2. Run picocom

sudo picocom /dev/ttyUSB0 -b115200

You should see this:

3. That’s it!

NOTE: Hit Ctrl + A + X to exit picocom.

Woo hoo! Good luck 🙂

Linux, OpenCV, Programming, Raspberry Pi

OpenCV 3.4.3 + Raspberry Pi 3B+

Follow these steps to install OpenCV 3.4.3 on a Raspberry Pi 3B+:

1) Install these dependencies:

$ sudo apt-get install build-essential cmake pkg-config
$ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
$ sudo apt-get install libxvidcore-dev libx264-dev
$ sudo apt-get install libgtk2.0-dev libgtk-3-dev
$ sudo apt-get install libatlas-base-dev gfortran
$ sudo apt-get install python2.7-dev python3-dev

2) Get OpenCV

$ wget
$ unzip
$ rm
$ wget
$ unzip

3) Build & Install OpenCV
NOTE 1: In the cmake line there is a path to the opencv_contrib modules folder, please replace this path with the correct one for your system.

NOTE 2: The make step will take like 8-10 hours and it will crash several times due to low virtual memory. Luckily it can resume from where it crashes so I kept repeating the make command until it finished.

sudo apt-get install python-pip
pip install numpy
$ cd ~/opencv-3.4.3/
$ mkdir build
$ cd build
$ make -j4
$ sudo make install
$ sudo ldconfig

4) Confirm OpenCV installation

$ python
>>> import cv2
>>> cv2.__version__

5) Voila!

Arduino, NodeMCU, Programming

Serial Comms between NodeMCU & Arduino Nano

Here’s how to set up serial comms between a NodeMCU V1 (ESP-12E) and Arduino Nano. Note, you could replace the Nano with any Arduino board but I have only tested with a Nano.

Here are parts required:

Here’s the diagram:

circuitAnd the source code is available here:

Good luck! 🙂


Android, Kotlin, Programming

HTTP GET using Volley

I was making an Android app using Android Studio (3.1.3) which sends a HTTP GET request. The code was very similar to this:

String serverURL = "";
URL url = new URL(serverURL);
HttpURLConnection connection = null;
try {
    connection = (HttpURLConnection) url.openConnection();
    BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
    //Do something with this InputStream
    // handle the response
    int status = connection.getResponseCode();
    // If response is not success
    if (status != 200) {
        throw new IOException("Post failed with error code " + status);
} catch (Exception e) {
} finally {
     if(connection != null)

The request was never sent. I tried everything but I just couldn’t make it work. However!

I found a solution using Volley ( This code is in Kotlin but as you can see it is very simple and mostly importantly it works!

val queue = Volley.newRequestQueue(this)
val url = ""
val stringRequest = StringRequest(Request.Method.GET, url, null, null)

Don’t forget to add these lines to the AndroidManifest.xml file:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


Arduino, ESP8266, NodeMCU, Programming

NodeMCU ESP8266 CP1202 Programming (Blink)

This is the tutorial for programming the NodeMCU CP1202 board using the Arduino IDE. The code that will be used is the Blink example. And the board that I’m using looks like this.

Image result for cp1202 nodemcu

Here are the steps I followed:

  1. Install the drivers from
  2. Download the ESP8266 board information for Arduino
    1. Open the Arduino IDE
    2. Click on the File menu and then Preferences
    3. In the Additional Boards Manager URLs, enter this:
    4. Click Ok
    5. Click on the Tools menu, click Boards and then click Boards Manager
    6. Wait for it to download the new boards information
    7. Search for ESP8266 and install it
  3. From the Tools menu, select the following:
    1. Board: NodeMCU 1.0 (ESP-12E Module)
    2. Flash Size: 4M (3M SPIFFS)
    3. CPU Frequency: 80MHz
    4. Upload Speed: 115200
    5. Port: (whichever COM port it is)
    6. Erase Flash: Sketch Only
  4. From the File menu, click Examples, click ESP8266 and then click Blink
  5. Compile and download
  6. Voila! 🙂