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):
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_at = models.DateTimeField(auto_now_add=True)

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

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

Binary file not shown.

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

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

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

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

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

Loading…
Cancel
Save