Day 6: Johnny-Five, NodeMCU

Today was the first day of my hands-on experience for these modules, chips and wirings. It was an exciting day!

Johnny Five

I love love love JavaScript. This love started from front end development. When NodeJS came out, it was a no brainer to me. How come a scripting language like PHP or Ruby could serve back end dynamic pages, and JavaScript could not? Johnny Five, yeah, makes the powerful language run on the top IoT devices. That’s awesome.

After playing with several starter examples (pulsing LEDs, RGB LED module, 7 segment LEDs, etc.) using Arduino language, which helped me get familiar with the development environment and its IDE, I switched to use Johnny Five.

Johnny-Five is an Open Source, Firmata Protocol based, IoT and Robotics programming framework, developed at Bocoup. Johnny-Five programs can be written for Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, pcDuino3, Raspberry Pi, Spark/Particle Core, TI Launchpad and more!

I think, after this point, it would be super hard for me to switch back, since I’m so familiar with JavaScript. I built a simple thing, with Arduino reading a temperature sensor LM35 and displaying the ambient temperature in the room. It successfully showed our room temperature at that moment was between 26 and 27 celsius.

I went on and wanted to get a 4-digit 7-segment LED module to show the temperature on the display . I think I got all the wirings correct, but there was one segment always showing the wrong state. I may need to revisit this part later.

Flashing NodeMCU

I bought this NodeMcu Lua WIFI Development Board For ESP8266 Module from Banggood, and it does not provide much documentation as Banggood states on that product detail page. It makes a beginner like me a little hard to sort it out. After googling it and youtubing it, I finally got this little magic chip to work. One thing I have learned is that, this chip can be only for prototyping but for production, given that the documentation is so limited.

There is no website that records the steps that I took to make this chip to work. I took several references, and got this to work. So I’m writing them down, in case other people may need it. I’m using Mac OSX Yosemite.

Install Driver

  1. Download the driver from here, and install it on your Mac
  2. Run this command line only for Yosemite
    sudo nvram boot-args=”kext-dev-mode=1"
  3. Reboot the computer
  4. Go to terminal, and type:
    ls /dev/tty*

You should be able to find out the new serial port. Mine says: /dev/tty.wchusbserial620

Flash the latest firmware

  1. Download the latest firmware from
    https://github.com/nodemcu/nodemcu-firmware/releases
  2. Download the flash tool esptool.py by clone the git:
    git clone https://github.com/themadinventor/esptool.git
  3. Hold the flash button on the NodeMCU board, and run
    ./esptool.py — port=/dev/ttyUSB0 write_flash 0x00000 nodemcu_latest.bin

4. Download and install ESPlorer, and start to code! Then you can actually follow the YouTube video for the fun part.

At the end of day, I got the WiFi scanning working on the NodeMCU using the language Lua. You can find the source code here.

The WiFi scanning result

One thing that I’m not clear about is that, how NodeMCU works with Arduino. NodeMCU uses Lua, a JavaScript like language, while Arduino uses its language or JavaScript. I need to find out how to connect the dots here.