+ All Categories
Home > Technology > NodeMCU with Blynk and Firebase

NodeMCU with Blynk and Firebase

Date post: 20-Mar-2017
Category:
Upload: eueung-mulyana
View: 404 times
Download: 31 times
Share this document with a friend
43
1 / 43 Introduction - Blynk - Firebase NodeMCU Eueung Mulyana https://eueung.github.io/012017/nodemcu CodeLabs | Attribution-ShareAlike CC BY-SA
Transcript
Page 1: NodeMCU with Blynk and Firebase

1 / 43

Introduction - Blynk - Firebase

NodeMCUEueung Mulyanahttps://eueung.github.io/012017/nodemcuCodeLabs | Attribution-ShareAlike CC BY-SA

Page 2: NodeMCU with Blynk and Firebase

NodeMCU DEVKIT V1.0

Firebase Version: 3.6.4 | Blynk Library v0.4.4

Arduino IDE 1.8.1

2 / 43

Page 3: NodeMCU with Blynk and Firebase

Outline

Introduction

Using Arduino IDE

NodeMCU + Blynk

NodeMCU + Firebase

3 / 43

Page 4: NodeMCU with Blynk and Firebase

Introduction

4 / 43

Page 5: NodeMCU with Blynk and Firebase

5 / 43

Page 6: NodeMCU with Blynk and Firebase

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

Page 7: NodeMCU with Blynk and Firebase

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

Page 8: NodeMCU with Blynk and Firebase

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!

Page 9: NodeMCU with Blynk and Firebase

V1.0 Pin Map

9 / 43

Page 10: NodeMCU with Blynk and Firebase

Arduino IDE

10 / 43

Page 11: NodeMCU with Blynk and Firebase

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

Page 12: NodeMCU with Blynk and Firebase

#2 | File | Preferences12 / 43

Page 13: NodeMCU with Blynk and Firebase

#3 | File | Preferences | BM URLs13 / 43

Page 14: NodeMCU with Blynk and Firebase

#4 | Tools | Board | Boards Manager14 / 43

Page 15: NodeMCU with Blynk and Firebase

#4 | esp826615 / 43

Page 16: NodeMCU with Blynk and Firebase

#5 | Tools | Board | NodeMCU 1.016 / 43

Page 17: NodeMCU with Blynk and Firebase

Blynk

17 / 43

Page 18: NodeMCU with Blynk and Firebase

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)!

Page 19: NodeMCU with Blynk and Firebase

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

Page 20: NodeMCU with Blynk and Firebase

#2 - Check20 / 43

Page 21: NodeMCU with Blynk and Firebase

#3 - Con�gure Blynk App21 / 43

Page 22: NodeMCU with Blynk and Firebase

#3 - Con�gure Blynk App22 / 43

Page 23: NodeMCU with Blynk and Firebase

#4 - Sketch23 / 43

Page 24: NodeMCU with Blynk and Firebase

#4 - Sketch - cf. Sketch Builder24 / 43

Page 25: NodeMCU with Blynk and Firebase

#5 - Play!25 / 43

Page 26: NodeMCU with Blynk and Firebase

Firebase

26 / 43

Page 27: NodeMCU with Blynk and Firebase

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!

Page 28: NodeMCU with Blynk and Firebase

#2 - Install FirebaseArduino28 / 43

Page 29: NodeMCU with Blynk and Firebase

#2 - Check

29 / 43

Page 30: NodeMCU with Blynk and Firebase

#3 - Create Firebase Project30 / 43

Page 31: NodeMCU with Blynk and Firebase

#3 - Create Firebase Project : Host31 / 43

Page 32: NodeMCU with Blynk and Firebase

#3 - Create Firebase Project : DB Secret32 / 43

Page 33: NodeMCU with Blynk and Firebase

#4 - Example Sketch FirebaseRoom33 / 43

Page 34: NodeMCU with Blynk and Firebase

#4 - Example Sketch FirebaseRoom34 / 43

Page 35: NodeMCU with Blynk and Firebase

#5 - Prepare the Circuit35 / 43

Page 36: NodeMCU with Blynk and Firebase

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

Page 37: NodeMCU with Blynk and Firebase

#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

Page 38: NodeMCU with Blynk and Firebase

#6 - Changing the Values from Firebase38 / 43

Page 39: NodeMCU with Blynk and Firebase

#6 - Changing the States from the Circuit39 / 43

Page 40: NodeMCU with Blynk and Firebase

Refs/Resources

40 / 43

Page 41: NodeMCU with Blynk and Firebase

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

Page 42: NodeMCU with Blynk and Firebase

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

Page 43: NodeMCU with Blynk and Firebase

43 / 43

ENDEueung Mulyanahttps://eueung.github.io/012017/nodemcuCodeLabs | Attribution-ShareAlike CC BY-SA


Recommended