0% found this document useful (0 votes)
0 views

66d4523741098e13a4c290f7_WiFi_Module_ESP8266

This document outlines a project to connect an Arduino to the internet using an ESP8266 WiFi module to control an LED and display temperature data via a web/mobile app called Blynk. It includes a list of required hardware, circuit diagrams, and sample code for programming the Arduino. Additionally, it provides steps for setting up the necessary software and libraries to facilitate the project.

Uploaded by

namnhnse172135
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

66d4523741098e13a4c290f7_WiFi_Module_ESP8266

This document outlines a project to connect an Arduino to the internet using an ESP8266 WiFi module to control an LED and display temperature data via a web/mobile app called Blynk. It includes a list of required hardware, circuit diagrams, and sample code for programming the Arduino. Additionally, it provides steps for setting up the necessary software and libraries to facilitate the project.

Uploaded by

namnhnse172135
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Wifi communications

- Connect Arduino to internet.


- Control LED on/off from web/mobile phone.
- Display temperature value on web/mobile phone.

Hardware Required
 Arduino or Genuino Board
 ESP8266 Wifi module
 Breadboard
 LED
 Wires
 Pushbutton
 Resistor

Theory
The Arduino Uno WiFi is an Arduino Uno with an integrated WiFi
module. The board is based on the ATmega328P with an
ESP8266WiFi Module integrated. The ESP8266WiFi Module is a self
contained SoC with integrated TCP/IP protocol stack that can give
access to your WiFi network (or the device can act as an access
point). One useful feature of Uno WiFi is support for OTA (over-the-
air) programming, either for transfer of Arduino sketches or WiFi
firmware.

The Arduino Uno WiFi is programmed using the Arduino Software


(IDE), our Integrated Development Environment common to all our
boards and running both online and offline.

In this project, we are going to connect our device to the internet in


order to upload data from a temperature sensor and control the LED
light. With the support of Blynk, an app that specially designed for
IoT, which provides cloud data storage and others useful tools.
Circuit
(Block diagram and Circuit diagram shows the wire connection).

ESP8266 Breadboard LED1(trái) TMP


TX
RX
3V V
G(phải) cathode
D2 anode
G(trái) GND(trêni) GND
VIN
A0 AnalogOutput

Code
Board NodeMCU 1.0(ESP-12E Module)
1. #define BLYNK_PRINT Serial
2. #include <ESP8266WiFi.h>
3. #include <BlynkSimpleEsp8266.h>
4. #include <SoftwareSerial.h>
5. #include <SimpleTimer.h>
6.
7. #define BLYNK_TEMPLATE_ID "..."
8. #define BLYNK_TEMPLATE_NAME "..."
9.
10. #define led D2
11.
12. char auth[] = "Blynk auth code";
13. char ssid[] = "WiFi Name"
14. char pass[] = "WiFi Password";
15.
16. SimpleTimer timer;
17.
18. //Truyền dữ liệu sensor
19. void myTimerEvent()
20. {
21. Blynk.virtualWrite(V1, millis() / 1000);
22.
23. int analogValue = analogRead(A0);
24. float millivolts = (analogValue/ 1024.0) *3300;
25. float celsius = millivolts/10; //Tính toán dữ liệu
26. Blynk.virtualWrite(V2, celsius);
27. }
28. //Bật tắt LED
29. BLYNK_WRITE(V10){
30. int pinvalue = param.asInt();
31. if (pinvalue == 0) {
32. digitalWrite(led, LOW);
33. } else {
34. digitalWrite(led, HIGH);}
35. }
36.
37.
38.
39.
40.
41. void setup()
42. {
43. Serial.begin(9600);
44. Blynk.begin(auth, ssid, pass);
45. pinMode(led, OUTPUT);
46. timer.setInterval(1000L, myTimerEvent);
47. }
48.
49. void loop()
50. {
51. if (Serial.available() == 0 )
52. {
53. Blynk.run();
54. timer.run(); // Initiates BlynkTimer
55. }
56. }

Demonstrations
(Demonstrations with photos of experiments)

Before coding the project, we need to be able to connect 2 devices to Arduino IDE in order to
upload codes on the devices.

1. We need to install CH340 driver in order to connect to ESP8266. Then download ESP8266 board
(Tools -> Board -> Boards manager -> Search for “esp8266” by ESP8266 community)
2. We use Blynk to support our project. So that we have to install Blynk library (Sketch -> Include
library -> Manage library -> Search for “Blynk” by Volodymyr Shymanskyy) .
3. Adding crucial library:
 SimpleTimer.h(Sketch -> Include library -> ADD .ZIP library...)
 ESP8266WiFi.h (File -> Preferences -> Additional Boards Manager URLs: -> add this link)

4. Create Blynk account


5. Create device

6. Get these code by


going to Device Info
7. Start coding
8. Wiring

References
https://docs.arduino.cc/retired/getting-started-guides/
ArduinoUnoWiFi
https://www.youtube.com/watch?v=lp93f4tFqh4&t=924s
https://www.youtube.com/watch?v=MM9Fj6bwHLk
https://www.youtube.com/watch?v=vDm1zhqS-wE

You might also like