did some shit

main
thuenemann.nico@gmail.com 11 months ago
parent 9fb89c1807
commit f00cc573fb

@ -0,0 +1,33 @@
# Generated by Django 5.0.3 on 2025-01-02 20:18
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0001_initial'),
]
operations = [
migrations.RenameModel(
old_name='Clients',
new_name='Client',
),
migrations.AlterModelOptions(
name='client',
options={'ordering': ['id']},
),
migrations.AlterModelOptions(
name='moisture',
options={'ordering': ['id']},
),
migrations.AlterModelOptions(
name='temperature',
options={'ordering': ['id']},
),
migrations.AlterModelOptions(
name='waterlevel',
options={'ordering': ['id']},
),
]

@ -0,0 +1,18 @@
# Generated by Django 5.0.3 on 2025-01-02 21:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0002_rename_clients_client_alter_client_options_and_more'),
]
operations = [
migrations.AlterField(
model_name='moisture',
name='moisture',
field=models.FloatField(),
),
]

@ -26,7 +26,7 @@ class Temperature(models.Model):
class Moisture(models.Model): class Moisture(models.Model):
id = models.AutoField(primary_key=True, auto_created=True, editable=False) id = models.AutoField(primary_key=True, auto_created=True, editable=False)
moisture = models.IntegerField() moisture = models.FloatField()
created_by = models.ForeignKey(Client, on_delete=models.CASCADE) created_by = models.ForeignKey(Client, on_delete=models.CASCADE)
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)

@ -34,7 +34,7 @@ def temperature(request):
def moisture(request): def moisture(request):
client = Client.objects.get(hostname=request.data['hostname']) client = Client.objects.get(hostname=request.data['hostname'])
temp = Moisture( temp = Moisture(
moisture=request.data['moistrue'], moisture=request.data['moisture'],
created_by=client created_by=client
) )
temp.save() temp.save()

@ -26,7 +26,8 @@ SECRET_KEY = 'django-insecure-(6h_gl6)e$xf3^^ds6-iyjxa^kbgr51%tu79urm1lrl31ov%65
DEBUG = True DEBUG = True
ALLOWED_HOSTS = [ ALLOWED_HOSTS = [
'*' '192.168.178.122',
'127.0.0.1'
] ]

Binary file not shown.

@ -3,11 +3,13 @@
#include <ArduinoJson.h> #include <ArduinoJson.h>
//TemperaturSensor //TemperaturSensor
#include "DHT.h" #include <DHT.h>
#define DHT_PIN D5
#define DHT_TYPE DHT22 #define DHT_TYPE DHT22
DHT dht(DHT_PIN, DHT_TYPE);
//WaterLevelSensor //WaterLevelSensor
#define waterlevel_pin D2 #define waterlevel_pin D1
#define waterlevelread_pin A0 #define waterlevelread_pin A0
//moistureSensor //moistureSensor
@ -20,16 +22,12 @@
int val = 0; int val = 0;
int test = 0; int test = 0;
//Temperature and humidity sensor
const int DHT_PIN = D5;
DHT dht(DHT_PIN, DHT_TYPE);
//Wlan configuration //Wlan configuration
const char* ssid = "Andy"; const char* ssid = "Andy";
const char* password = "AndyNicoChiara"; const char* password = "AndyNicoChiara";
//api and host configuration //api and host configuration
const char* serverName = "http://192.168.178.45:8000/api/"; const char* serverName = "http://192.168.178.122:8000/api/";
String hostname = "ESP8266NodeTemperature1"; String hostname = "ESP8266NodeTemperature1";
@ -180,6 +178,7 @@ int postRequest(String requestBody, String api) {
urlName = serverName + api; urlName = serverName + api;
WiFiClient client; WiFiClient client;
HTTPClient http; HTTPClient http;
Serial.println(urlName);
http.begin(client, urlName); http.begin(client, urlName);
http.addHeader("Content-Type", "application/json"); http.addHeader("Content-Type", "application/json");
int httpResponseCode = http.POST(requestBody); int httpResponseCode = http.POST(requestBody);

@ -2,7 +2,7 @@
#include <DHT.h>; #include <DHT.h>;
//Constants //Constants
#define DHTPIN 2 // what pin we're connected to #define DHTPIN D2 // Sensor out
#define DHTTYPE DHT22 // DHT 22 (AM2302) #define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino

@ -1,6 +1,6 @@
// Sensor pins // Sensor pins
#define sensorPower 7 #define sensorPower D3 // Sensor D0
#define sensorPin A0 #define sensorPin A0 // Sensor A0
void setup() { void setup() {
pinMode(sensorPower, OUTPUT); pinMode(sensorPower, OUTPUT);

@ -1,5 +1,5 @@
// pump // pump
#define pump D8 #define pump D2 // Relay S
//needs some work, needs special logic board to function properly //needs some work, needs special logic board to function properly

@ -1,6 +1,6 @@
// Sensor pins // Sensor pins
#define sensorPower 7 #define sensorPower D2 // Sensor +
#define sensorPin A0 #define sensorPin A0 // Sensor S
// Value for storing water level // Value for storing water level
int val = 0; int val = 0;

Loading…
Cancel
Save