This shows you the differences between two versions of the page.
iothings:proiecte:2022sric:smart-garden [2023/06/02 05:51] laura_aida.dinca [Software] |
iothings:proiecte:2022sric:smart-garden [2023/06/02 06:23] (current) laura_aida.dinca [Software] |
||
---|---|---|---|
Line 28: | Line 28: | ||
{{:iothings:proiecte:2022sric:schema.jpeg?700|}} | {{:iothings:proiecte:2022sric:schema.jpeg?700|}} | ||
+ | To ensure the control of the motor (the solenoid valve), we need a driver (H-bridge) with the role of providing the voltage and current necessary for good operation. Thus, a driver acts as a connection interface. The motors require a high level of current, while the rest of the circuit, a lower one, so it is recommended to isolate the power supply of the motors from the rest of the components. | ||
+ | |||
+ | To maintain the data line HIGH and ensure good communication between the sensor and the ESP32, I added a 10K pull-up resistor between VCC and the data line. | ||
===== Software ===== | ===== Software ===== | ||
Line 77: | 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 116: | 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 136: | 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 218: | 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]] | ||