Hands On...


NodeMCU

Introduction


By: BEEVA Research Lab

What is NodeMCU?

IoT Device
"An open-source firmware and development kit that helps you to prototype your IOT product within a few Lua script lines."

A devkit

NodeMCU pinout NodeMCU pinout
  • Based on the Espressif SoC ESP8266.
  • Low cost (under 5$).
  • WiFi!

Set up



Requirements

  • Git
  • Python2.7
  • Virtualenv


Installation


cd
mkdir projects
cd projects
git clone https://github.com/samuelmh/smh_nodemcu
cd smh_nodemcu
make install
sudo adduser $USER dialout  # Add your user to the dialout group!
						

Operative


Connect your board to the USB port and activate the environment.

cd
cd projects/venvs/smh_nodemcu
source bin/activate
						


Examples


nodemcu --help  #Print help

nodemcu terminal  #Connect to the interactive terminal
nodemcu terminal --help  #Print the help related to the "terminal" command
nodemcu terminal --file=<file>  #Send a file and connect to the terminal

nodemcu file ls  #List the files stored in the device
nodemcu file add <origin> <destination>  #Copy a file from the computer to the device
nodemcu file --help  #Print the the help related to the "file" command
						

Extras



init.lua

If you want a script to be executed just afer every bootup, name it init.lua.


Flashing the firmware

Do not asume the board comes with your desired firmware.
It is a good practice to use a familiar one.


make flash-float-4mb-all
						

Hardware



Code


  1. Configure the device
  2. Set pin to high value
  3. Wait
  4. Set pin to low value
  5. Wait
  6. Repeat!


Hardware



Code


  1. Configure the device
  2. Set the LED to the button value
  3. Wait
  4. Repeat!


INTERRUPTIONS




Call a function asynchronously when the input value of a pin changes.

  • up: rising edge
  • down: falling edge
  • both: both edges
  • low: low level
  • high: high level


Difference between edges and levels.

Code


  1. Configure the device
  2. Define the callback function
  3. Set the trigger
  4. Wait for an event!


THE END