From d89cac59cbabd32e31a999b038c7e34b05ba64be Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Tue, 12 May 2020 11:58:36 +0200 Subject: [PATCH] Added LDR --- main/main.ino | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main/main.ino b/main/main.ino index 669ac52..2e5faa5 100644 --- a/main/main.ino +++ b/main/main.ino @@ -29,6 +29,7 @@ const int pin_pir = 14; const int pin_tmp = 12; const uint16_t pin_ir_reciever = 2; const uint16_t pin_ir_send = 4; +const uint16_t pin_ldr = A0; const unsigned long ritter_group_address = 13043702; const char* parameter_plug_id="plug_id"; const char* parameter_plug_status="plug_status"; @@ -135,19 +136,23 @@ void controller(void){ String getJsonDht(void){ - return "{\"temperature\":\""+String(dht.readTemperature())+"\",\"humidity\":\""+String(dht.readHumidity())+"\"}"; + return "{\"temperature_celcius\":\""+String(dht.readTemperature())+"\",\"humidity\":\""+String(dht.readHumidity())+"\"}"; } String getJsonPir(void){ return "{\"motion\":\""+String(digitalRead(pin_pir))+"\"}"; } +String getJsonLdr(void){ + return "{\"relative\":\""+String(analogRead (pin_ldr))+"\"}"; +} + String getJsonIrLastRecieved(void){ return "{\"last_recieved\":{\"bits\":\""+String(last_recieved_ir_bits)+"\",\"type\":\""+String(last_recieved_ir_type)+"\",\"data\":\""+String(last_recieved_ir_data)+"\"}}"; } String getJson(void){ - return "{\"DHT\":"+String(getJsonDht())+",\"PIR\":"+String(getJsonPir())+",\"IR\":"+String(getJsonIrLastRecieved())+"}"; + return "{\"LDR\":"+String(getJsonLdr())+",\"DHT\":"+String(getJsonDht())+",\"PIR\":"+String(getJsonPir())+",\"IR\":"+String(getJsonIrLastRecieved())+"}"; } #include "homepage_template.h"