Download presentation
1
Microcontroller basics
Embedded systems for mortals
2
Lesson 5 What is IoT? Prototyping electronics for IoT How to connect?
IoT with Blynk and ESP8266
3
Internet of Things ”IoT is a network of physical objects with embedded electronics that collect and share data”
5
Components for IoT ESP8266 module NodeMCU 1.0 Arduino UNO wifi Shield
OTA WeMos D1
6
ESP8266 module We are using this today
Can be programmed by itself but usually connected to Arduino Price: 2 – 5 €
7
ESP8266 module pinout
8
NodeMCU 1.0 Built-in ESP8266, ”ESPduino”
Works with Arduino IDE, not officially though 12 V regulator for input voltage Price: 5 – 10 € 13 GPIO, only one PWM and ADC (0-1 V) Pins work with 0 - 3,3 V! Good tutorial:
9
NodeMCU 1.0 Pinout
10
Arduino UNO wifi shield
Nothing special Even the original as poor documentation Price Fake 10 € Original up to 70 €, can be cheaper Has micro SD card slot . . .
11
OTA WeMos D1 ESP8266 Embedded Works with Arduino IDE Price 10 €
11 Digital I/O pins 10 have PWM/Interrupt 1 Analog pin (max 3v3) V input to power jack All pins use 0 – 3.3 V No experience of this yet There is also a miniversion which is good!
12
OTA WeMos D1 pinout Pin Function ESP-8266 Pin TX TXD TXD RX RXD RXD A0 Analog input, max 3.3V input A0 D0 IO GPIO16 D1 IO, SCL GPIO5 D2 IO, SDA GPIO4 D3 IO,Pull-up GPIO0 D4 IO,pull-up, BUILTIN_LED GPIO2 D5 IO, SCK GPIO14 D6 IO, MISO GPIO12 D7 IO, MOSI GPIO13 D8 IO,pull-down, SS GPIO15 G Gound GND 5V 5V - 3V3 3.3V 3.3V RST Reset RST *All IO have interrupt/pwm/I2C/one-wire supported(except D0)
13
Logic level converter Logic shifter 3v3 <-> 5 V if you want to use NodeMCU or OTA WeMoes D1 Price: Sparkfun 2,5 € Bi-directional, works both ways
14
How to connect? Cloud NearBus? Ready made Blynk Server DIY?
15
Installing Blynk libraries
Download the Blynk_v0.3.1.zip in the bottom of the page
16
Extracting libraries Extract the 4 folders inside the .zip to: C:\Program Files (x86)\Arduino\libraries Done!
17
Blynk for phone Download the app for your phone
You will get a project code to your You need to copy paste it to your Arduino Code
18
How to connect Arduino?
19
Code for Arduino In the end of the presentation there is the code in text format
20
ESP8266 after Blynk Using the ESP8266 without an app like Blynk requires some coding skills, although lots of ready-made code can be found on the internet. You can connect with the module directly within its range or anywhere through internet. For internet connection you’ll need a website to which the module sends data or where you can send data to the module. A good basic example project can be found here In this example you have a webpage with buttons that control LEDs connected to an Arduino with an ESP module. The module acts as a serial device, and you speak to it through AT commands. For example AT+CWLAP gives a list of the available access points (Wi-Fi networks). A list of commands can be found here:
21
Resources • Google & Youtube - search for projects, solutions to occurring problems and data sheets for components • - Homepage of the Blynk software, getting started, community forums • - Everything on ESP8266, wiki • - Learning materials, guides, example projects, forums, store • - Largest code host, lots of projects and sample code • - good ESP8266 tutorials • - ESP8266 info and basic list of AT commands
22
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266_SoftSer.h> #include <BlynkSimpleShieldEsp8266_SoftSer.h> #include <SimpleTimer.h> // Set ESP8266 Serial object #include <SoftwareSerial.h> SoftwareSerial EspSerial(2, 3); // RX, TX ESP8266 wifi(EspSerial); // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "your_auth_token"; float temp; int tempPin = 1; //analog pin 1 int reading; float voltage; SimpleTimer timer; void setup() { // Set console baud rate Serial.begin(9600); delay(10); // Set ESP8266 baud rate // 9600 is recommended for Software Serial EspSerial.begin(9600); Blynk.begin(auth, wifi, "ssid", "password"); // enter wifi name and password to it timer.setInterval(1000L, sendTemperature); }
23
// This function sends the value of "temp" every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means // that you define how often to send data to Blynk App. This function is used (instead of // sending data in the loop function) to avoid over-loading the Blynk servers. void sendTemperature() { // You can send any value at any time. // Please don't send more that 10 values per second as this will cause a flood error. Blynk.virtualWrite(V5, temp); } void loop() Blynk.run(); // Initiates Blynk timer.run(); // Initiates SimpleTimer // This changes the analog pin reading to Celsius degrees, // which is then sent to Blynk in the SendTemperature function. reading = analogRead(tempPin); voltage = reading * 5; voltage /= 1024; temp = (voltage-0.5)*100;
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.