1 / 43
Introduction - Blynk - Firebase
NodeMCUEueung Mulyanahttps://eueung.github.io/012017/nodemcuCodeLabs | Attribution-ShareAlike CC BY-SA
NodeMCU DEVKIT V1.0
Firebase Version: 3.6.4 | Blynk Library v0.4.4
Arduino IDE 1.8.1
2 / 43
Outline
Introduction
Using Arduino IDE
NodeMCU + Blynk
NodeMCU + Firebase
3 / 43
Introduction
4 / 43
5 / 43
6 / 43
NodeMCU
NodeMCU is a LUA based interactive�rmware for Expressif ESP8622 Wi-Fi SoC,as well as an open source hardware boardthat includes a (CP2102/CH340/..) TTL toUSB chip for programming and debugging,is breadboard-friendly, and can simply bepowered via its micro USB port.
Ref: cnx-software
7 / 43
NodeMCUFirmware + DevKits
NodeMCU is an eLua based �rmware for the ESP8266 WiFi SOCfrom Espressif. The �rmware is based on the Espressif NON-OSSDK and uses a �le system based on spi�s.
The NodeMCU �rmware is a companion project to the popularNodeMCU DevKits, ready-made open-source developmentboards with ESP8266-12E chips.
The NodeMCU programming model is similar to that ofNode.js, only in Lua. It is asynchronous and event-driven. Manyfunctions, therefore, have parameters for callback functions.
Ref: NodeMCU Documentation
8 / 43
NodeMCUDevKit v1.0
1. ESP-12E WiFi Module (16 GPIOs)2. 4 MB (32 Mb) Flash Storage3. 128 KB Memory4. Micro USB (5V Power, Program, Debug)5. 2x15-Pin Headers (GPIOs, SPI, UART,
ADC, Power)
Notes: Pins still at 3.3V!
V1.0 Pin Map
9 / 43
Arduino IDE
10 / 43
http://arduino.esp8266.com/stable/package_esp8266com_index.json
11 / 43
Using ArduinoIDE
Develop Sketches and FlashNodeMCU with Arduino IDE
(C-Style)!Starting with 1.6.4, Arduino allows installation of
third-party platform packages using Boards Manager.
1. Install Arduino IDE2. Start Arduino and open Preferences window3. Enter board URL into Additional BM URLs4. Open Boards Manager and install esp82665. Select your NodeMCU board
#2 | File | Preferences12 / 43
#3 | File | Preferences | BM URLs13 / 43
#4 | Tools | Board | Boards Manager14 / 43
#4 | esp826615 / 43
#5 | Tools | Board | NodeMCU 1.016 / 43
Blynk
17 / 43
18 / 43
NodeMCU &Blynk
Using Arduino IDE
1. Con�gure Arduino IDE for NodeMCU (as before)2. Install Blynk Library3. Prepare/Con�gure Blynk App4. Prepare the Board, Create the Sketch & Flash5. Play the Project (Blynk App)!
19 / 43
#2Install Blynk Library
~/Arduino$ tree.|-- blank| |-- blank.ino|-- libraries |-- readme.txt
2 directories, 2 files
#---------------------
~/Arduino$ tree -L 2.|-- blank| |-- blank.ino|-- libraries| |-- readme.txt| |-- Adafruit_NeoPixel| |-- Blynk| |-- BlynkESP8266_Lib| |-- SimpleTimer| |-- Time| |-- TinyGSM|-- tools |-- BlynkUpdater |-- BlynkUsbScript
11 directories, 2 files
URL: blynkkk/blynk-library
#2 - Check20 / 43
#3 - Con�gure Blynk App21 / 43
#3 - Con�gure Blynk App22 / 43
#4 - Sketch23 / 43
#5 - Play!25 / 43
Firebase
26 / 43
27 / 43
NodeMCU &Firebase
Using Arduino IDE
1. Con�gure Arduino IDE for NodeMCU (as before)2. Install FirebaseArduino Library3. Create a Firebase Project4. Use Example Sketch FirebaseRoom_ESP82665. Prepare the Circuit & Flash6. Play!
#2 - Install FirebaseArduino28 / 43
#2 - Check
29 / 43
#3 - Create Firebase Project30 / 43
#3 - Create Firebase Project : Host31 / 43
#3 - Create Firebase Project : DB Secret32 / 43
#4 - Example Sketch FirebaseRoom33 / 43
#4 - Example Sketch FirebaseRoom34 / 43
#5 - Prepare the Circuit35 / 43
36 / 43
#5Prepare the Circuit
Vibration Motor (brrr): pin 5 (D1) - Blue LEDLight Sensor (sunlight): pin A0 - PotentioRed LED (redlight): pin 12 (D6)Button (pushbutton): pin 14 (D5)Mini Fan (cooldown): pin 13 (D7) - Orange LED
#include <ESP8266WiFi.h>#include <FirebaseArduino.h>
// Set these to run example.#define FIREBASE_HOST "fbase-nodemcu.firebaseio.com"#define FIREBASE_AUTH "g3mvizMBfpXpoSa446BXxPiiBduXFRhZUhgzMjDL"#define WIFI_SSID "lk8fm"#define WIFI_PASSWORD "1234567890"
const int grovePowerPin = 15;const int vibratorPin = 5;const int lightSensorPin = A0;const int ledPin = 12;const int buttonPin = 14;const int fanPin = 13;
void setup() { Serial.begin(115200);
pinMode(grovePowerPin, OUTPUT); digitalWrite(grovePowerPin, HIGH);
pinMode(vibratorPin, OUTPUT); pinMode(lightSensorPin, INPUT); pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT); pinMode(fanPin, OUTPUT);
// connect to wifi. WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.print("connecting"); while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); } Serial.println(); Serial.print("connected: "); Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); Firebase.set("pushbutton", 0); Firebase.set("sunlight", 0); Firebase.set("redlight", 0); 37 / 43
FirebaseRoom_ESP8266
#6 - Changing the Values from Firebase38 / 43
#6 - Changing the States from the Circuit39 / 43
Refs/Resources
40 / 43
Refs/Resources1. NodeMcu - An open-source �rmware based on ESP8266 wi�-soc2. nodemcu/nodemcu-devkit-v1.03. NodeMCU Documentation4. esp8266/Arduino: ESP8266 core for Arduino5. Getting Started - Blynk6. Simple Led Control With Blynk and NodeMCU Esp8266 12E7. FirebaseDemo_ESP8266 - �rebase/�rebase-arduino8. NodeMCU is both a Breadboard-Friendly ESP8266 Wi-Fi Board and a LUA based Firmware9. NodeMCU - Wikipedia
41 / 43
More Refs/Resourcesnodemcu/nodemcu-�rmware: lua based interactive �rmware for mcu like esp8266NodeMCU custom buildsmarcelstoer/nodemcu-build - Docker HubComparison of ESP8266 NodeMCU development boardsComparison of tools and IDEs for NodeMCU
42 / 43
43 / 43
ENDEueung Mulyanahttps://eueung.github.io/012017/nodemcuCodeLabs | Attribution-ShareAlike CC BY-SA