This shows you the differences between two versions of the page.
iothings:proiecte:2021:flood-detection [2022/01/27 23:49] alexandru.ionascu |
iothings:proiecte:2021:flood-detection [2022/01/28 08:41] (current) alexandru.ionascu |
||
---|---|---|---|
Line 1: | Line 1: | ||
==== Flood Detecton System ==== | ==== Flood Detecton System ==== | ||
<sub>Alexandru Ionascu - AAC 2021</sub> \\ | <sub>Alexandru Ionascu - AAC 2021</sub> \\ | ||
+ | <sub>[[https://youtu.be/t9QbCft8HMM | [Project Video]]]</sub> | ||
=== 1. Project Objective === | === 1. Project Objective === | ||
Line 7: | Line 8: | ||
=== 2. Project Description === | === 2. Project Description === | ||
- | #TODO | + | The system consists in two main components: **ESP32 board** and **HC-SR04 ultrasonic sensor**. \\ |
+ | ***ESP32** is the main component and has the following roles: | ||
+ | * to establish Wi-Fi connection that will allow to perform HTTP requests; | ||
+ | * to send POST requests to the Pushover API to trigger push notifications; | ||
+ | * to determine the distance to the floor based on received input from the ultrasonic sensor; \\ | ||
+ | ***HC-SR04** serves as the proximity sensor and has the following roles: \\ | ||
+ | * to provide informations about the distance to the floor; | ||
=== 3. Hardware Description === | === 3. Hardware Description === | ||
Line 27: | Line 34: | ||
=== 4. Software Description === | === 4. Software Description === | ||
- | The code consists of two main functions: setup and loop. In the setup function, we will set the echo and trigger pins and we will connect to the local Wi-Fi network to perform further HTTP requests. Once the connection is established, in the loop function, we will measure the distance to the floor in centimeters by sending ulstrasonic impulses and if this is less than 2 centimeters, we will perform a POST request to the Pushover API. | + | The code consists of two main functions: **setup** and **loop**. In the setup function, we will set the echo and trigger pins and we will connect to the local Wi-Fi network to perform further HTTP requests. Once the connection is established, in the loop function, we will measure the distance to the floor in centimeters by sending ulstrasonic impulses and if this is less than 2 centimeters, we will perform a POST request to the Pushover API. There will also be a 2s delay between requests to make avoid unnecessary push notifications. |
The source code is listed below: | The source code is listed below: | ||
Line 87: | Line 94: | ||
http.addHeader("Content-Type", "application/x-www-form-urlencoded"); | http.addHeader("Content-Type", "application/x-www-form-urlencoded"); | ||
- | String form = "device=device&user=ukszyvbax7eob3goo9h159xs75ixvw&title=IoT - ESP32&message=Flood!!&token=atq3xjuehksriumq9s23hcyw5b3f7g"; | + | String form = "device=device&user=********&title=IoT - ESP32&message=Flood!!&token=********"; |
int httpCode = http.POST(form); | int httpCode = http.POST(form); | ||
Line 100: | Line 107: | ||
http.end(); | http.end(); | ||
- | delay(10000); | + | delay(2000); |
} else { | } else { | ||
Serial.println("Error on HTTP request"); | Serial.println("Error on HTTP request"); | ||
Line 110: | Line 117: | ||
=== 5. Issues and Solutions === | === 5. Issues and Solutions === | ||
- | #TODO | + | This project had some initial issues with getting the source code up on the board, but for some reasons it got fixed once we switched from MacOS to Linux. |
+ | Another problem would be testing this application in a real life case scenario because it won't be that easy to simulate flood home. | ||
- | === 6.Conclusions === | + | === 6. Resources and Documentation === |
- | #TODO | + | |
+ | [[https://techtutorialsx.com/2017/04/24/esp32-connecting-to-a-wifi-network/ | ESP32: Connecting to a WiFi network ]] \\ | ||
+ | [[https://techtutorialsx.com/2017/05/20/esp32-http-post-requests | ESP32: HTTP POST Requests ]] \\ | ||
+ | [[https://randomnerdtutorials.com/esp32-hc-sr04-ultrasonic-arduino | ESP32 with HC-SR04 Ultrasonic Sensor with Arduino IDE ]] \\ | ||