Slide 1

Slide 1 text

1 / 43 Introduction - Blynk - Firebase NodeMCU Eueung Mulyana https://eueung.github.io/012017/nodemcu CodeLabs | Attribution-ShareAlike CC BY-SA

Slide 2

Slide 2 text

NodeMCU DEVKIT V1.0 Firebase Version: 3.6.4 | Blynk Library v0.4.4 Arduino IDE 1.8.1 2 / 43

Slide 3

Slide 3 text

Outline Introduction Using Arduino IDE NodeMCU + Blynk NodeMCU + Firebase 3 / 43

Slide 4

Slide 4 text

Introduction 4 / 43

Slide 5

Slide 5 text

5 / 43

Slide 6

Slide 6 text

6 / 43 NodeMCU NodeMCU is a LUA based interactive rmware for Expressif ESP8622 Wi-Fi SoC, as well as an open source hardware board that includes a (CP2102/CH340/..) TTL to USB chip for programming and debugging, is breadboard-friendly, and can simply be powered via its micro USB port. Ref: cnx-software

Slide 7

Slide 7 text

7 / 43 NodeMCU Firmware + DevKits NodeMCU is an eLua based rmware for the ESP8266 WiFi SOC from Espressif. The rmware is based on the Espressif NON-OS SDK and uses a le system based on spi s. The NodeMCU rmware is a companion project to the popular NodeMCU DevKits, ready-made open-source development boards with ESP8266-12E chips. The NodeMCU programming model is similar to that of Node.js, only in Lua. It is asynchronous and event-driven. Many functions, therefore, have parameters for callback functions. Ref: NodeMCU Documentation

Slide 8

Slide 8 text

8 / 43 NodeMCU DevKit v1.0 1. ESP-12E WiFi Module (16 GPIOs) 2. 4 MB (32 Mb) Flash Storage 3. 128 KB Memory 4. Micro USB (5V Power, Program, Debug) 5. 2x15-Pin Headers (GPIOs, SPI, UART, ADC, Power) Notes: Pins still at 3.3V!

Slide 9

Slide 9 text

V1.0 Pin Map 9 / 43

Slide 10

Slide 10 text

Arduino IDE 10 / 43

Slide 11

Slide 11 text

http://arduino.esp8266.com/stable/package_esp8266com_index.json 11 / 43 Using Arduino IDE Develop Sketches and Flash NodeMCU with Arduino IDE (C-Style)! Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. 1. Install Arduino IDE 2. Start Arduino and open Preferences window 3. Enter board URL into Additional BM URLs 4. Open Boards Manager and install esp8266 5. Select your NodeMCU board

Slide 12

Slide 12 text

#2 | File | Preferences 12 / 43

Slide 13

Slide 13 text

#3 | File | Preferences | BM URLs 13 / 43

Slide 14

Slide 14 text

#4 | Tools | Board | Boards Manager 14 / 43

Slide 15

Slide 15 text

#4 | esp8266 15 / 43

Slide 16

Slide 16 text

#5 | Tools | Board | NodeMCU 1.0 16 / 43

Slide 17

Slide 17 text

Blynk 17 / 43

Slide 18

Slide 18 text

18 / 43 NodeMCU & Blynk Using Arduino IDE 1. Con gure Arduino IDE for NodeMCU (as before) 2. Install Blynk Library 3. Prepare/Con gure Blynk App 4. Prepare the Board, Create the Sketch & Flash 5. Play the Project (Blynk App)!

Slide 19

Slide 19 text

19 / 43 #2 Install 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

Slide 20

Slide 20 text

#2 - Check 20 / 43

Slide 21

Slide 21 text

#3 - Con gure Blynk App 21 / 43

Slide 22

Slide 22 text

#3 - Con gure Blynk App 22 / 43

Slide 23

Slide 23 text

#4 - Sketch 23 / 43

Slide 24

Slide 24 text

#4 - Sketch - cf. Sketch Builder 24 / 43

Slide 25

Slide 25 text

#5 - Play! 25 / 43

Slide 26

Slide 26 text

Firebase 26 / 43

Slide 27

Slide 27 text

27 / 43 NodeMCU & Firebase Using Arduino IDE 1. Con gure Arduino IDE for NodeMCU (as before) 2. Install FirebaseArduino Library 3. Create a Firebase Project 4. Use Example Sketch FirebaseRoom_ESP8266 5. Prepare the Circuit & Flash 6. Play!

Slide 28

Slide 28 text

#2 - Install FirebaseArduino 28 / 43

Slide 29

Slide 29 text

#2 - Check 29 / 43

Slide 30

Slide 30 text

#3 - Create Firebase Project 30 / 43

Slide 31

Slide 31 text

#3 - Create Firebase Project : Host 31 / 43

Slide 32

Slide 32 text

#3 - Create Firebase Project : DB Secret 32 / 43

Slide 33

Slide 33 text

#4 - Example Sketch FirebaseRoom 33 / 43

Slide 34

Slide 34 text

#4 - Example Sketch FirebaseRoom 34 / 43

Slide 35

Slide 35 text

#5 - Prepare the Circuit 35 / 43

Slide 36

Slide 36 text

36 / 43 #5 Prepare the Circuit Vibration Motor (brrr): pin 5 (D1) - Blue LED Light Sensor (sunlight): pin A0 - Potentio Red LED (redlight): pin 12 (D6) Button (pushbutton): pin 14 (D5) Mini Fan (cooldown): pin 13 (D7) - Orange LED

Slide 37

Slide 37 text

#include #include // 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

Slide 38

Slide 38 text

#6 - Changing the Values from Firebase 38 / 43

Slide 39

Slide 39 text

#6 - Changing the States from the Circuit 39 / 43

Slide 40

Slide 40 text

Refs/Resources 40 / 43

Slide 41

Slide 41 text

Refs/Resources 1. NodeMcu - An open-source rmware based on ESP8266 wi -soc 2. nodemcu/nodemcu-devkit-v1.0 3. NodeMCU Documentation 4. esp8266/Arduino: ESP8266 core for Arduino 5. Getting Started - Blynk 6. Simple Led Control With Blynk and NodeMCU Esp8266 12E 7. FirebaseDemo_ESP8266 - rebase/ rebase-arduino 8. NodeMCU is both a Breadboard-Friendly ESP8266 Wi-Fi Board and a LUA based Firmware 9. NodeMCU - Wikipedia 41 / 43

Slide 42

Slide 42 text

More Refs/Resources nodemcu/nodemcu- rmware: lua based interactive rmware for mcu like esp8266 NodeMCU custom builds marcelstoer/nodemcu-build - Docker Hub Comparison of ESP8266 NodeMCU development boards Comparison of tools and IDEs for NodeMCU 42 / 43

Slide 43

Slide 43 text

43 / 43 END Eueung Mulyana https://eueung.github.io/012017/nodemcu CodeLabs | Attribution-ShareAlike CC BY-SA