Microcontroller Basics Internet of Things

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

MICROCONTROLLER BASICS

Embedded systems for mortals


INTERNET OF THINGS
• ”IoT is a network of physical objects with embedded electronics that collect
and share data”

COMPONENTS FOR IoT


• ESP8266 module
• NodeMCU 1.0
• Arduino UNO wifi Shield
• OTA WeMos D1

1. ESP8266 MODULE
• We are using this today
• Can be programmed by itself but
usually connected to Arduino
• Price: 2 – 5 €

ESP8266 MODULE PINOUT


2. 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!

NodeMCU 1.0 PINOUT

3. 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 . . .

4. 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)
• 9 - 24 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!
OTA WeMos D1 PINOUT

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

HOW TO CONNECT?
• Cloud
– NearBus?
• Ready made
– Blynk
• Server
– DIY?

INSTALLING BLYNK LIBRARIES


1. http://www.blynk.cc/getting-started /
2. https://github.com/blynkkk/blynk-library/releases/tag/v0.3.1
3. Download the Blynk_v0.3.1.zip in the bottom of the page
EXTRACTING LIBRARIES
4. Extract the 4 folders inside the .zip to: C:\Program Files
(x86)\Arduino\libraries
5. Done!
BLYNK FOR PHONE
• Download the app for your phone
• You will get a project code to your e-mail
– You need to copy paste it to your Arduino Code
HOW TO CONNECT ARDUINO?

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
http://allaboutee.com/2015/01/02/esp8266-arduino-led-control-from-
webpage/ 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:
https://nurdspace.nl/ESP8266#AT_Commands

CODES
#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);
delay(10);
Blynk.begin(auth, wifi, "ssid", "password"); // enter wifi name and password to it
timer.setInterval(1000L, sendTemperature);
}
// 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;
}

ARTICLE III : BILL OF RIGHTS


Section 9. Private property shall not be taken for public use without just compensation.
Section 10. No law impairing the obligation of contracts shall be passed.
Section 17. No person shall be compelled to be a witness against himself.
Section 20. No person shall be imprisoned for debt or non-payment of a poll tax.
Section 22. No ex post facto law or bill of attainder shall be enacted.

You might also like