This shows you the differences between two versions of the page.
iothings:proiecte:2022sric:smart-garden [2023/06/02 06:06] laura_aida.dinca [Hardware] |
iothings:proiecte:2022sric:smart-garden [2023/06/02 06:23] (current) laura_aida.dinca [Software] |
||
---|---|---|---|
Line 80: | Line 80: | ||
</html> | </html> | ||
</code> | </code> | ||
+ | |||
+ | Result: | ||
{{:iothings:proiecte:2022sric:html_page.png?700|}} | {{:iothings:proiecte:2022sric:html_page.png?700|}} | ||
+ | We will insert sensor data into the database when receiving a POST request. The second endpoint is for GET request and will display the latest data from the database. | ||
<code python> | <code python> | ||
from flask import Flask, send_file, request, render_template | from flask import Flask, send_file, request, render_template | ||
Line 119: | Line 122: | ||
cursor = conn.cursor() | cursor = conn.cursor() | ||
- | # Retrieve the image from the database based on the image_id | ||
cursor.execute("SELECT temperature, humidity FROM sensorData WHERE id = (SELECT MAX(id) from sensorData)") | cursor.execute("SELECT temperature, humidity FROM sensorData WHERE id = (SELECT MAX(id) from sensorData)") | ||
result = cursor.fetchone() | result = cursor.fetchone() | ||
Line 139: | Line 141: | ||
=== ESP32 environment === | === ESP32 environment === | ||
- | Initializing the pin connections and DHT sensor, including the necessary libraries and the variables for connecting to the network (both ESP32 and Raspberry pi be connected to the same WI-FI): | + | Initializing the pin connections and DHT sensor, including the necessary libraries and the variables for connecting to the network (both ESP32 and Raspberry pi must be connected to the same WI-FI): |
<code c> | <code c> | ||
#include <WiFi.h> | #include <WiFi.h> | ||
Line 221: | Line 223: | ||
} | } | ||
</code> | </code> | ||
+ | |||
+ | |||
+ | ===== References: ===== | ||
+ | |||
+ | - [[https://www.hackster.io/mafzal/temperature-monitoring-with-dht22-arduino-15b013|DHT22]] | ||
+ | - [[https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf|ESP32 Datasheet]] | ||
+ | - [[https://randomnerdtutorials.com/esp32-web-server-gauges/|ESP32 Web Server]] | ||
+ | - [[https://www.sqlite.org/docs.html|SQLlite]] | ||