代写辅导接单-Homework 1 Overview ECE 56800

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top

Homework 1 Overview

ECE 56800

Embedded Systems

Spring 2024

https://purdue.brightspace.com/d2l/home/949499

Lab 2: Wi-Fi Networking and a simple HTTP-based IoT Application Due: Monday, April 8th 11:59pm

This assignment deals with connecting your ESP32 board to the Internet over WiFi and writing a simple program. You will also be using the RTC module and the on-board touch sensor in this lab. The hardware and software implementation details for this assignment are described in the following sections.

2 Lab Exercise

2.1 Hardware Interfacing

Interface the following components to the board:

• •

Two external LEDs (red and green) as GPIO outputs.

– The red LED should indicate if the board is awake (ON) or in sleep mode (OFF).

– The green LED should be controlled by touch-based input (see Table 1).

One external push button as a GPIO input to use as a wake-up source.

One external Male-Male jumper wire connected to a Touch-enabled pin. Insert the wire into the header on the board. This page gives information about the Touch-enabled pins. You can select any of the 10 capacitive-touch enabled pins on the board with the following caveat. The pins indicated on the webpage above are for the ESP32 microcontroller itself. On your board however, only 6 out of the 10 touch-enabled pins are available for use. You can figure out the 6 pins by trial and error. (You will get a ‘ValueError’ if you try to assign an unavailable pin as a TouchPad input.)

Software Implementation (main.py)

Your program should implement the following functionality.

2.2.1 Connect to the Internet over WiFi

• TheprogramshouldusethenetworkmoduleinMicroPythontoconnectyourESP32toaWiFinetworkusingthe ‘SSID’ and ‘Password’ for that network. You can create a WiFi hotspot on your mobile/laptop and connect your ESP32 to the hotspot. Refer to the example given in the MicroPython documentation for the network module [1].

• e.g.,ifyourmobilehotspothasanSSID:‘Lenovo-SSID’andPassword:‘12345678’,thenusethisSSIDandpassword for connecting the ESP32 to the Internet.

• NOTE: You can also connect to any other WiFi network which works directly with an SSID and password. How- ever, be aware that enterprise networks such as PAL3.0 which require SSID, username, password, certificates, etc., are unfortunately not supported in MicroPython.

• Each time the board successfully connects to Wi-Fi, the program should print the SSID it has connected to and the interface’s IP address.

     Connected to Lenovo-SSID

     IP Address: 192.168.0.107

2.2

  page 1 of 4

 

Purdue ECE 56800: Embedded Systems March 18, 2024

 2.2.2 Display Current Date and Time using Network Time Protocol (NTP)

• Get the current time from the Internet using NTP. The program should fetch the current date and time from the NTP server ‘pool.ntp.org’ and use it to set the RTC (real time clock).

• HINT: check module ntptime. Then, manually adjust the RTC to convert UTC (Coordinated Universal Time) to the current local time zone (e.g., West Lafayette).

• Initialize a hardware timer and display the current date and time every 15 seconds. Do not use time.sleep(). Instead, use the RTC and Timer interrupt/callback. Format the date and time as shown in the example below:

     Date: 09/29/2021

     Time: 10:00:00 HRS

2.2.3 Green LED Control by Touch Input

• InitializetheTouchpad-enabledpinconnectedtothejumperwireandcalibrateitbyobservinghowthetouchpad pin values change when you physically touch the jumper wire.

• Initialize a second hardware timer and read the touch pin values every 50 milliseconds using a Timer interrup- t/callback and implement the following pattern. Use calibrated values to detect whether the wire is touched or not.

– Touch Pin not touched: Green Led should be OFF – Touch Pin touched: Green Led should be ON

2.2.4 Red LED, Deep Sleep and Different Wake Up Sources

• The red LED should be ON whenever the ESP32 is awake and OFF when it is in sleep mode.

• Use a third hardware timer to put the ESP32 into deep sleep every 30 seconds for a duration of 1 minute. Print out a message on the terminal before going to sleep like:

     I am going to sleep for 1 minute.

• AWAKE duration: 30 seconds (this will be the duration of the third hardware timer)

• SLEEP duration: 1 minute (do not need a timer for this, check this link for details on deep sleep.)

• Youwillbeusingtwodifferentsourcesofwakingupfromdeepsleep.Yourprogramshouldcheckforbothsources and the board should be able to wake up from either source.

– TimerWakeUp:WakeuptheESP32afterthepredefinedsleepduration(1minute)andprintthatit’satimer wake-up.

– External Wake Up Mode 0: Configure the switch as an external wake-up source. Pressing the switch within the 1-minute sleep duration should wake up the board and print out it’s an EXT0 wake-up. If one-minute passes and no touch is detected, then your board should wake up due to the Timer Wake Up above.

    page 2 of 4

 

Purdue ECE 56800: Embedded Systems March 18, 2024

 2.3 Overall Program Flow and Sample Output

The board is powered on for the first time. It connects to the Wi-Fi network, fetches the current time from NTP server, displays them after 15s, and turns on the green led whenever the touch pin wire is touched. It again displays the date and time at 30s and then goes to deep sleep. The program now checks for the push button wake-up signal. If you press the switch or if 1 minute expires, the board wakes up and starts the overall process again. Table 1 shows the LED status functionality. A sample output is also provided here for your understanding. For this sample, we assume that the program started at 10:00:00 hrs. EST.

 Mode Sleep Sleep Awake Awake

Table 1: Sleep and Wake Up Program Flow Switch

Touch Pin

Not Pressed: No Effect

Pressed: No Effect

Not Pressed: Green LED off Pressed: Green LED on

Not Pressed: No Effect Pressed: Wake-Up Not Pressed: No Effect Pressed: No Effect

Red Led Off

Off

On

On

Green Led Off

Off

Off

On

      This is a sample output:

 I (200) wifi: wifi driver task: 3ffe2c34, prio:23, stack:3584, core=0

...

...

...

I (22233) network: CONNECTED

I (22883) event: sta ip: 192.168.0.107, mask: 255.255.255.0, gw: 192.168.0.1

I (22883) network: GOT_IP

Connected to Lenovo-SSID

IP Address: 192.168.0.107

Date: 03/18/2024

Time: 10:00:15 HRS

Date: 03/18/2024

Time: 10:00:30 HRS

I am going to sleep for 1 minute.

ets Jun 8 2016 00:22:57

rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

configsip: 0, SPIWP:0xee...

...

...

I (0) cpu_start: Starting scheduler on APP CPU.

Woke up due to EXT0 wakeup.

I (200) wifi: wifi driver task: 3ffe2c34, prio:23, stack:3584, core=0

///continues

 page 3 of 4

 

Purdue ECE 56800: Embedded Systems March 18, 2024

 Collaboration

This is an individual assignment. Do not collaborate with others. If you have any questions, please post on Piazza. You can post clarification questions, but you are not allowed to ask for answers or post answers. See the Brightspace page for instructor office hours.

Bonus Point

You will receive 5% bonus credit on the lab for creating a short video that shows you demonstrating your working solution (explain your hardware connections briefly before demonstrating the working solution). Please do not upload video files directly on Brightspace. Instead, upload the video to YouTube (or other such video hosting platform) as a private video and include the link to the video in your README file.

Submission

Make sure you follow these instructions precisely. You need to turn in your code on Brightspace. Please create a directory named username_lab2, where username is your CAREER account login ID. This directory should contain only the following files, i.e., no executables, no temporary files, etc.

• main.py: your program (2.2)

• A README file named username_lab2_README.txt that contains a description of your hardware connec-

tions (which pins you used, exactly what they were connected to, etc.).

Zip the directory and name it as username_lab2.zip and upload the .zip file to Brightspace. A 10% late penalty will apply per 12 hours.

Grading

We will use a combination of automatic grading scripts and manual code inspection for evaluation. If your code is unusually complex or different from expected solutions, you may be asked to attend an office hour and explain your code.

References

• Getting started with MicroPython on the ESP32

• ESP32 WROOM-32 Datasheet

• ESP32 Technical Reference Manual

• Adafruit HUZZAH32 – ESP32 Feather Online Manual • Adafruit ESP32 Feather Schematics

• MicroPython GitHub • REPL

• Thonny IDE

• Rshell GitHub

• Sleep Modes API in C

• Touch Sensor API in C

• ESP32 specific functionalities in MicroPython

page 4 of 4

 

 

51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468