diff --git a/csv_wr/.idea/.gitignore b/csv_wr/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/csv_wr/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/csv_wr/.idea/csv_wr.iml b/csv_wr/.idea/csv_wr.iml
new file mode 100644
index 0000000..2c80e12
--- /dev/null
+++ b/csv_wr/.idea/csv_wr.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/csv_wr/.idea/inspectionProfiles/profiles_settings.xml b/csv_wr/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/csv_wr/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/csv_wr/.idea/misc.xml b/csv_wr/.idea/misc.xml
new file mode 100644
index 0000000..1317860
--- /dev/null
+++ b/csv_wr/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/csv_wr/.idea/modules.xml b/csv_wr/.idea/modules.xml
new file mode 100644
index 0000000..baba56c
--- /dev/null
+++ b/csv_wr/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/csv_wr/data.csv b/csv_wr/data.csv
new file mode 100644
index 0000000..a46c7aa
--- /dev/null
+++ b/csv_wr/data.csv
@@ -0,0 +1,61 @@
+Datum a cas,DHT11 vlhkost,DHT11 teplota,HC-SR04 vzdalenost
+2024-04-08 14:40:46,39,27,199
+2024-04-08 14:40:47,37,24,105
+2024-04-08 14:40:48,49,26,113
+2024-04-08 14:40:49,72,25,175
+2024-04-08 14:40:50,32,20,182
+2024-04-08 14:40:51,34,27,108
+2024-04-08 14:40:52,54,25,63
+2024-04-08 14:40:53,48,28,115
+2024-04-08 14:40:54,58,20,50
+2024-04-08 14:40:55,71,28,171
+2024-04-08 14:40:56,56,28,65
+2024-04-08 14:40:57,50,23,134
+2024-04-08 14:40:58,53,24,72
+2024-04-08 14:40:59,40,27,105
+2024-04-08 14:41:00,33,27,113
+2024-04-08 14:41:01,59,28,175
+2024-04-08 14:41:02,40,20,56
+2024-04-08 14:41:03,59,23,27
+2024-04-08 14:41:04,45,26,124
+2024-04-08 14:41:05,31,26,143
+2024-04-08 14:41:06,58,26,27
+2024-04-08 14:41:07,73,25,65
+2024-04-08 14:41:08,41,25,55
+2024-04-08 14:41:09,64,20,148
+2024-04-08 14:41:10,68,24,112
+2024-04-08 14:41:11,48,22,37
+2024-04-08 14:41:12,65,22,77
+2024-04-08 14:41:13,78,26,57
+2024-04-08 14:41:14,68,26,59
+2024-04-08 14:41:15,46,28,133
+2024-04-08 14:49:30,75,27,49
+2024-04-08 14:49:31,65,27,190
+2024-04-08 14:49:32,52,27,26
+2024-04-08 14:49:33,79,24,182
+2024-04-08 14:49:34,43,27,185
+2024-04-08 14:49:35,73,20,188
+2024-04-08 14:49:36,63,26,149
+2024-04-08 14:49:37,76,20,66
+2024-04-08 14:49:38,63,27,180
+2024-04-08 14:49:39,31,23,168
+2024-04-08 14:49:40,69,26,127
+2024-04-08 14:49:41,76,21,134
+2024-04-08 14:49:42,54,23,45
+2024-04-08 14:49:43,53,20,179
+2024-04-08 14:49:44,51,26,30
+2024-04-08 14:49:45,80,26,116
+2024-04-08 14:49:46,39,25,148
+2024-04-08 14:49:47,76,28,41
+2024-04-08 14:49:48,46,22,163
+2024-04-08 14:49:49,30,22,183
+2024-04-08 14:49:50,37,23,163
+2024-04-08 14:49:51,53,20,164
+2024-04-08 14:49:52,35,26,89
+2024-04-08 14:49:53,54,25,197
+2024-04-08 14:49:54,55,20,44
+2024-04-08 14:49:55,53,21,67
+2024-04-08 14:49:56,31,28,92
+2024-04-08 14:49:57,72,27,27
+2024-04-08 14:49:58,47,23,60
+2024-04-08 14:49:59,43,26,103
diff --git a/csv_wr/main.py b/csv_wr/main.py
new file mode 100644
index 0000000..08884ce
--- /dev/null
+++ b/csv_wr/main.py
@@ -0,0 +1,21 @@
+import csv
+import datetime
+import random
+
+#definice senzrorů
+senzory = [ "DHT11 vlhkost","DHT11 teplota", "HC-SR04 vzdalenost"]
+
+#otevření souboru
+with open("data.csv", "a", newline="") as csvfile:
+ writer = csv.writer(csvfile) #zapisovatel
+ now = datetime.datetime.now() #aktualní datum a čas
+ if csvfile.tell() == 0: #zajistit hlavičku souboru
+ writer.writerow(["Datum a cas"] + [senzor for senzor in senzory])
+
+ hodnoty = [ #simulatce dat
+ random.randint(30,80), #vlhkost
+ random.randint(20,28), #teplota
+ random.randint(20,200) #vzdalenost
+ ]
+ #zapis dat
+ writer.writerow([now.strftime("%Y-%m-%d %H:%M:%S")] + hodnoty)
diff --git a/csv_wr/reader.py b/csv_wr/reader.py
new file mode 100644
index 0000000..1e7b708
--- /dev/null
+++ b/csv_wr/reader.py
@@ -0,0 +1,48 @@
+import csv
+import matplotlib.pyplot as plt
+import datetime
+
+with open("data.csv", "r") as csvfile:
+ reader = csv.reader(csvfile)
+
+ next(reader,None)
+
+ data_cas = []
+ data_vlhkost = []
+ data_teplota = []
+ data_vzdalenost = []
+
+ for row in reader:
+ datum_cas = row[0]
+
+ try:
+ datetime_object = datetime.datetime.strptime(datum_cas, "%Y-%m-%d %H:%M:%S")
+ except ValueError:
+ print(f"Chybní format data a času: {datum_cas}")
+
+ data_cas.append(datetime_object)
+ data_vlhkost.append(float(row[1]))
+ data_teplota.append(float(row[2]))
+ data_vzdalenost.append(float(row[3]))
+
+#print(data_vlhkost) #test
+
+plt.subplot(311) # 3 řádky, 1 sloupec, 1. graf
+plt.plot(data_cas, data_vlhkost, label="Vlkost")
+plt.legend()
+plt.xticks(visible=False)
+plt.title("Vlhkost")
+
+plt.subplot(312) # 3 řádky, 1 sloupec, 2. graf
+plt.plot(data_cas, data_teplota, label="teplota")
+plt.legend()
+plt.xticks(visible=False)
+
+plt.title("teplota")
+
+plt.subplot(313) # 3 řádky, 1 sloupec, 3. graf
+plt.plot(data_cas, data_vzdalenost, label="vzdalenost")
+plt.legend()
+plt.title("vzdalenost")
+
+plt.show()
\ No newline at end of file
diff --git a/csv_wr/writer_loop.py b/csv_wr/writer_loop.py
new file mode 100644
index 0000000..a14f3f9
--- /dev/null
+++ b/csv_wr/writer_loop.py
@@ -0,0 +1,26 @@
+import csv
+import datetime
+import random
+import time
+
+#definice senzrorů
+senzory = [ "DHT11 vlhkost","DHT11 teplota", "HC-SR04 vzdalenost"]
+
+#otevření souboru
+with open("data.csv", "a", newline="") as csvfile:
+ writer = csv.writer(csvfile) #zapisovatel
+
+ if csvfile.tell() == 0: # zajistit hlavičku souboru
+ writer.writerow(["Datum a cas"] + [senzor for senzor in senzory])
+
+ for i in range(30):
+ now = datetime.datetime.now() #aktualní datum a čas
+ hodnoty = [ #simulatce dat
+ random.randint(30,80), #vlhkost
+ random.randint(20,28), #teplota
+ random.randint(20,200) #vzdalenost
+ ]
+ #zapis dat
+ writer.writerow([now.strftime("%Y-%m-%d %H:%M:%S")] + hodnoty)
+ print(f"{i+1}/30")
+ time.sleep(1)