2019 lea iot esp8266 presentationscience.concordiashanghai.org/home/wp-content/uploads/... ·...

33

Upload: others

Post on 17-Jun-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased
Page 2: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Control the LED Remotely!

Connect to the RGB_Klammer WiFiNetwork

Open any web browser to 192.168.1.1

Tap on any color and take control of the LED!

Page 3: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

What is the “Internet of Things”?

It seems that almost every modern electronic device that we use today involves an aspect of communication with other devices.

The Internet of Things (IoT) is actually a pretty simple concept, it means taking any and all electronic devices and connecting them to the internet.

When something is connected to the internet, that means that it can (1) send information, (2) receive information, or (3) both. This ability to send and/or receive information makes things smart, and smart is good! J

Page 4: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

According to the U.S. Department of Education, US students rank 17th in science and 25th in mathematics among industrialized nations

STEM allows our students to have authentic project-based learning experiences across a variety of disciplines (Art, Music, Community service, Science)

“For we are God’s handiwork, created in Christ Jesus to do good works, which God prepared in advance for us to do.” Eph 2:10

Page 5: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Our school is in a fairly polluted city(Shanghai). We have an Air Quality Indexmachine for outdoors, but our OperationsDepartment wanted real-time air qualitydata for all of the classrooms. A group of ourstudents designed sensors and an ESP8266that updates data from each room to acentral database every 5 minutes. They alsodesigned a web interface for Operations.

Page 6: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

This week a volunteer group is installing twosolar-powered freezers on South Bougainvillein the Solomon Island chain. They asked ourstudents to design a data logging systemthat would allow remote data access to thepower output of the solar array, batteryvoltage, and freezer temperatures. Ourstudents are building an inexpensive systembased on the ESP8266 to help the group.

Page 7: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

The ESP8266 Module is an inexpensive controller that can be purchased for around $4 (Amazon). It has an 80-MHz 32-bit microcontroller, 512 KB of program storage space with built-in WiFi

The firmware on it is Arduino-compatible so all of your favorite Arduino code, libraries, and most sensors work. The Arduino is an 8-bit microcontroller that runs at 16 MHz with 32 KB of RAM. The ESP8266 is 5-10X faster, has 16X more memory, includes WiFi, and it is cheaper too!

Page 8: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Today we’ll do project 01, project 04, and if there is time, project 02.

You have the parts for the other projects in your kit

Page 9: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Use the micro USB cable to connect the ESP8266 chip to any of the USB ports on the laptop

Page 10: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Start up the “Arduino” IDE program using the icon on the desktop. Go to the ”Tools” menu and ensure that the Port is /dev/ttyUSBO

Page 11: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

GPIO16 = Onboard LED

INPUTOUTPUT INPUT_PULLUP

HIGHLOW

milliseconds

Enter the code shown above

Page 12: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

When you are finished typing the code, click on the “Upload” button

Page 13: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Give your program an appropriate name like “Blink” and choose “Save” program.

Page 14: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Check the bottom of the screen. If your code was correct andthe upload was successful, you should see “Done uploading” atthe bottom of the screen and “Hard resetting via RTS pin…” inred in the status window. If not, check your code for errors.

Page 15: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

GPIO16 = Onboard LED

Page 16: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

RGB LED Control via a Webpage

Page 17: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

RGB LED Control via a Webpage

Page 18: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

longest lead

RGB LED Control via a Webpage

Page 19: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Connect the R lead through a 330Ω resistor to the D3pin on your ESP8266

Resistor

Wire

330Ω resistor (direction does not matter)

RGB LED Control via a Webpage

Page 20: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Connect the G lead through a 330Ω resistor to the D2pin on your ESP8266

Resistor

Wire

330Ω resistor (direction does not matter)

RGB LED Control via a Webpage

Page 21: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Connect the B lead through a 330Ω resistor to the D1pin on your ESP8266

Resistor

Wire330Ω resistor

(direction does not matter)

RGB LED Control via a Webpage

Page 22: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Finally, connect the (-) lead through a wire (no resistor) to any GND pin on your ESP8266

Wire

RGB LED Control via a Webpage

Page 23: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

http://bit.ly/lea_iot

Project 04: RGB LED Control via Web page.

RGB LED Control via a Webpage

Page 24: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Copy the code shown (it is long!) and paste it into a new window in the Arduino program.

Please remember to change the line const char *ssid = "RGB_Klammer"; remove Klammer and put your favorite name there!

Then hit the ‘Upload’ button, save your code, and if successful, you should see the LED flash red, green, blue and then switch off.

Page 25: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Use your favorite phone, tablet, or laptopand search for a new WiFi network with the name RGB_yourfavoritename. Connect to it (ignore any warnings about it not being connected to the Internet).

Open any browser on the device and enter the address 192.168.1.1 You should see the screen similar to the right. Click on anycolor and the LED should match the color that you choose. Have fun!

Page 26: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

How does it work? The ESP8266 chip isacting as a WiFi router and webpageserver. It creates a webpage at theaddress 192.168.1.1 and displays a basiccolor wheel. When you click on the colors,the webpage sends the red, green, andblue values (each between 0 à 255) forthat color. The chip then outputs aproportional output for each of the threeLEDs built into the RGB LED

RGB LED Control via a Webpage

Page 27: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Temperature and Humidity Webpage

Our final project today will use the DHT(Digital Humidity and Temperature) sensor shown above. Please remove the previous circuit and place the DHT sensor as shown on your Experimenter Board. (Please note that your sensor only has 3 leads instead of 4)

Page 28: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Temperature and Humidity Webpage

The DHT22 sensor is a highlyaccurate temperature andhumidity sensor that sends dataserially using one data wire. Withthe white sensor facing you,connect the left-most (+) pin toone of the 3V3 outputs on theESP8266, connect the middle(data) pin to D6, and therightmost (-) pin to one of theGND outputs on your board.

Page 29: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

http://bit.ly/lea_iot

Project 02: Temperature and Humidity Webpage.

Temperature and Humidity Webpage

Page 30: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Copy the code shown (it is long!) and paste it into a new window in the Arduino program.

Click on the Serial Monitorbutton at the upper-right corner of thescreen. At the bottom of the Serial Monitor ensure that the “Baud Rate” is set to 115200

Page 31: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Then hit the ‘Upload’ button, save your code, and if successful, you should see the IP address of your board in the Serial Monitor

Page 32: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

http://your IP address

Temperature and Humidity Webpage

Page 33: 2019 LEA IoT ESP8266 Presentationscience.concordiashanghai.org/home/wp-content/uploads/... · 2019-10-16 · The ESP8266 Module is an inexpensive controller that can be purchased

Need ideas, help, advice, or parts?

Link to Projects: http://bit.ly/lea_iot/Email: [email protected]: joel.klammer