4 changed files with 67 additions and 0 deletions
@ -0,0 +1,19 @@ |
|||||
|
#include <DHT11.h> |
||||
|
|
||||
|
DHT11 dht11(2); |
||||
|
|
||||
|
void setup() { |
||||
|
Serial.begin(9600); |
||||
|
} |
||||
|
void loop() { |
||||
|
int temperature = dht11.readTemperature(); |
||||
|
|
||||
|
if (temperature != DHT11::ERROR_CHECKSUM && temperature != DHT11::ERROR_TIMEOUT){ |
||||
|
Serial.print("DHT11:"); |
||||
|
Serial.println(temperature); |
||||
|
} else{ |
||||
|
Serial.print("ERROR:"); |
||||
|
Serial.println(DHT11::getErrorString(temperature)); |
||||
|
} |
||||
|
delay(2000); |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
import serial #pip intall pyserial |
||||
|
import time |
||||
|
from datetime import datetime |
||||
|
|
||||
|
ser = serial.Serial("COM3",9600) |
||||
|
|
||||
|
while True: |
||||
|
line = ser.readline().decode("utf-8").strip() |
||||
|
|
||||
|
sensor_name, sensor_value = line.split(":") |
||||
|
|
||||
|
now = datetime.now() |
||||
|
current_time = now.strftime("%H:%M:%S") |
||||
|
print(f"Čas: {current_time}") |
||||
|
print(f"Název senzoru: {sensor_name}") |
||||
|
print(f"Hodnota senzoru: {sensor_value}") |
||||
|
print("------------------") |
||||
|
time.sleep(1) |
||||
@ -0,0 +1,18 @@ |
|||||
|
import serial |
||||
|
import matplotlib.pyplot as plt |
||||
|
|
||||
|
ser = serial.Serial("COM3",9600) |
||||
|
num_values = int(input("KOlik dat načíst?:")) |
||||
|
values = [] |
||||
|
|
||||
|
while True: |
||||
|
for i in range(num_values): |
||||
|
line = ser.readline().decode("utf-8").strip() |
||||
|
name, value = line.split(":") |
||||
|
values.append(int(value)) |
||||
|
print(i) |
||||
|
plt.plot(values) |
||||
|
plt.show() |
||||
|
values = [] |
||||
|
if input("q?").lower() == "q": |
||||
|
break |
||||
@ -0,0 +1,12 @@ |
|||||
|
#vytvoření venv |
||||
|
python -m venv .venv |
||||
|
|
||||
|
#aktivace venv |
||||
|
.venv\Scripts\activate |
||||
|
|
||||
|
#instalace knihoven |
||||
|
pip install pyserial |
||||
|
pip install matplotlib |
||||
|
|
||||
|
#výpis knihoven ve venv |
||||
|
pip list |
||||
Loading…
Reference in new issue