Skip to content
Snippets Groups Projects
Commit f6a58f54 authored by David Huss's avatar David Huss :speech_balloon:
Browse files

Initial commit

parents
Branches
No related tags found
No related merge requests found
%% Cell type:code id:c44042ce-0838-4bde-a521-72c7e7d196d6 tags:
``` python
import csv
data = []
with open('data/open-meteo-53.53N9.98E11m (3) (2).csv') as csvfile:
reader = csv.DictReader(csvfile, delimiter=',')
for row in reader:
datum = row['rain_sum']
data.append(float(datum))
```
%% Cell type:code id:c70207fe-f427-4e92-813c-698cf94855b6 tags:
``` python
maximum = max(data)
normalized_data = [d/maximum for d in data]
with open("data.h", "w") as file:
file.write("#pragma once\n\n")
file.write(f"#define DATA_LENGTH {len(normalized_data)}\n\n")
file.write(f"float data[{len(normalized_data)}] = {{\n")
for d in normalized_data:
file.write(f" {d},\n")
file.write("};\n")
```
%% Cell type:code id:1fa46b19-0698-47bb-9f6d-e45ab7f2c96f tags:
``` python
from datetime import timedelta, datetime
t = 9.48 * 3
duration = timedelta(seconds=(len(normalized_data)*t))
print(duration)
```
%% Output
3 days, 0:00:02.160000
%% Cell type:code id:20be4f8c-56b4-45c4-a7f5-8885a1345ea1 tags:
``` python
t
```
%% Output
28.44
%% Cell type:code id:35be51de-976f-4f2a-a707-5dca0e213e18 tags:
``` python
```
{"data":{"layout-restorer:data":{"main":{"dock":{"type":"tab-area","currentIndex":0,"widgets":[]}},"down":{"size":0,"widgets":[]},"left":{"collapsed":false,"visible":true,"current":"filebrowser","widgets":["filebrowser","running-sessions","@jupyterlab/toc:plugin","extensionmanager.main-view"],"widgetStates":{"jp-running-sessions":{"sizes":[0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666],"expansionStates":[false,false,false,false,false,false]},"extensionmanager.main-view":{"sizes":[0.3333333333333333,0.3333333333333333,0.3333333333333333],"expansionStates":[false,false,false]}}},"right":{"collapsed":true,"visible":true,"widgets":["jp-property-inspector","debugger-sidebar"],"widgetStates":{"jp-debugger-sidebar":{"sizes":[0.2,0.2,0.2,0.2,0.2],"expansionStates":[false,false,false,false,false]}}},"relativeSizes":[0.26227795193312436,0.7377220480668757,0],"top":{"simpleVisibility":true}},"docmanager:recents":{"opened":[{"path":"","contentType":"directory","root":"~/Arduino/precipitationctl"},{"path":"Untitled.ipynb","contentType":"notebook","factory":"Notebook","root":"~/Arduino/precipitationctl"}],"closed":[{"path":"Untitled.ipynb","contentType":"notebook","factory":"Notebook","root":"~/Arduino/precipitationctl"}]}},"metadata":{"id":"default"}}
\ No newline at end of file
ESP32-DEV-KIT-DevKitC-v4-pinout-mischianti.jpg

248 KiB

%% Cell type:code id:c44042ce-0838-4bde-a521-72c7e7d196d6 tags:
``` python
import csv
data = []
with open('data/open-meteo-53.53N9.98E11m (3) (2).csv') as csvfile:
reader = csv.DictReader(csvfile, delimiter=',')
for row in reader:
datum = row['rain_sum']
data.append(float(datum))
```
%% Cell type:code id:c70207fe-f427-4e92-813c-698cf94855b6 tags:
``` python
maximum = max(data)
normalized_data = [d/maximum for d in data]
with open("data.h", "w") as file:
file.write("#pragma once\n\n")
file.write(f"#define DATA_LENGTH {len(normalized_data)}\n\n")
file.write(f"float data[{len(normalized_data)}] = {{\n")
for d in normalized_data:
file.write(f" {d},\n")
file.write("};\n")
```
%% Cell type:code id:1fa46b19-0698-47bb-9f6d-e45ab7f2c96f tags:
``` python
from datetime import timedelta, datetime
t = 9.48 * 3
duration = timedelta(seconds=(len(normalized_data)*t))
print(duration)
```
%% Output
3 days, 0:00:02.160000
%% Cell type:code id:20be4f8c-56b4-45c4-a7f5-8885a1345ea1 tags:
``` python
t
```
%% Output
28.44
%% Cell type:code id:35be51de-976f-4f2a-a707-5dca0e213e18 tags:
``` python
```
data.h 0 → 100644
This diff is collapsed.
This diff is collapsed.
#include "data.h"
#define SERVO_MIN 30
#define SERVO_MAX 480
int servoPin = 23;
int pos = SERVO_MIN;
int data_index = 0;
void setServoNormalized(float pos) {
pos = min(1.0f, max(0.0f, pos));
int span = SERVO_MAX - SERVO_MIN;
int servo_pos = SERVO_MIN + span * pos;
analogWrite(servoPin, servo_pos);
}
void setup() {
Serial.begin(115200);
// put your setup code here, to run once:
pinMode(servoPin, OUTPUT);
analogWriteFrequency(servoPin, 50);
analogWriteResolution(servoPin, 12);
}
void loop() {
// put your main code here, to run repeatedly:
float datum = data[data_index];
setServoNormalized(datum);
Serial.print("Aktueller Wert ");
Serial.print(datum * 67.2);
Serial.print(" mm --> ");
Serial.println(datum);
data_index++;
if ( data_index >= DATA_LENGTH) {
data_index = 0;
Serial.println("Die daten sind durch, wir fangen wieder vorne an...");
}
delay(28.44*1000);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment