Blink LED using Flutter mobile app, NodeMCU

Blink LED using Flutter mobile app, NodeMCU

We are going to just blink an Led on NodeMCU board remotely from a Flutter dart app. So I decided to get this board and see what it was all about.

NodeMCU is an open source IoT platform It includes firmware which runs on the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on the ESP-12 module.[6][7] The term “NodeMCU” by default refers to the firmware rather than the development kits. The firmware uses the Lua scripting language. It is based on the eLua project, and built on the Espressif Non-OS SDK for ESP8266. It uses many open source projects, such as lua-cjson, and spiffs.

See also:

 

Note: This is not a tutorial on mobile app development.

what you will be needing:

  • Intellij IDE or any other IDE or editor like webstorm or vscode
  • LED ( i just used the bultin LED)
  • NodeMCU esp8266-12E
  • USB cable
  • Mobile phone
  • PC
  • Flutter SDK

Setup

To setup Arduino IDE for NodeMCU, go to file –> Preferences –> settings tab. On the additional boards Manager URL field, enter this url: http://arduino.esp8266.com/stable/package_esp8266com_index.json.

 

Open tools –> boards –> boards manager: type esp8266 in the search field and install.

To use intellij IDE to  develop flutter apps, install the dart and flutter plugin first, create a new Project. We will walk with the default generated program, edit your lib/main.dart file to include a raised button:

 

lines 2 and 4 imports async and http packages which is essential to make http requests. The function from line 45 makes the http request and the response is used to update the button text inside the setState function. line 77 creates a new raised button and the ledRequest function is passed to its onPressed handler.

 

The NodeMCU code written with Arduino IDE:

Arduino part is pretty straightforward. You can test the address: http://192.168.4.1/steinacoz/led to see how it works on both browser and app. Connect all devices to the access point created by NodeMCU.

 

Feel free to drop your comments and follow our social media channels for more posts like these.

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *