Introduction: IOT Base Computing Using Nodemcu and Micropython

About: I am hobbies, educator, learner, and developer in various programming languages and Electronic hardware's. I also won the Smart India Hackathon 2019 Competition organized by the Government of India. I am very…

In this tutorial I am going to use NodeMcu, micropython and Mqtt connection to connect the server.

This tutorial is using https based mqtt connect to connect from Nodemcu to Adafruit.io Server.

In this project i am using micropython programming language which is almost simillar to python.

Step 1: Components Required

Following Components are required to complete this project.

Components Required:

Step 2: Getting Starting.

Procedure:

  • Download and install espcut software for debugging .
  • Download files from this link. which is stored as github repository. All program is available in this repository..
  • Download and install the micropython firmware from this link to the NODEMCU
  • Connect IR sensor to GPIO12 and LED to GPIO 2 of Nodemcu.
  • download this webrepl software

Step 3: Adafruit IO

  • visit to io.adafruit.com and log in to go to your dashboard.

Step 4: Create Dashboard

  • Click on action and create new dashboard

Step 5: Creating Blocks

  1. Click on the Dashboard name.
  2. again click on +(plus) button to create block
  3. Now Click on Toggle and give it a name.
  4. Now click on create button
  5. Next select your block and click on next step
  6. Give name to this block and set the names of ON state and OFF state.
  7. After that click on create block.

Repeat the process from 2nd step select text and create one more block as shown in figure.

Step 6: Final Dashboard

Your Final Dashboard will look like this.

Step 7: Get Username and Key

Click on key icon on left side of screen and Copy the username and Active key

Step 8: Enable WEBREPL

  • Open the espcut software
  • send this command "import webrepl_setup"
  • read the text on console and configure the webrepl.

Step 9: Connect to Webrepl

  • Find the wifi network who's ssid starts from micropython
  • connect to that ssid with password "micropythoN"
  • you will get the screen as shown in above figure.

Step 10: Add the Code

  • extract webrepl software, open webrepl.html and click on connect
  • it will ask you to provide password
  • in my case the password is "1234567"
  • wow you are connected.
  • upload the files which was downloaded from github repository.
  • upload main.py ,mqtt.py,boot.py and data.txt using webrepl.
  • now press reset on button on your nodemcu. and check output on io.adafruit.com
  • if you want check code execution then again you have to connect to micropython wifi and login.

Step 11: Working Video

The working video of this tutorial is available here.