Added LDR

This commit is contained in:
Kevin Veen-Birkenbach 2020-05-12 11:58:36 +02:00
parent e2a19fdc76
commit d89cac59cb

View File

@ -29,6 +29,7 @@ const int pin_pir = 14;
const int pin_tmp = 12; const int pin_tmp = 12;
const uint16_t pin_ir_reciever = 2; const uint16_t pin_ir_reciever = 2;
const uint16_t pin_ir_send = 4; const uint16_t pin_ir_send = 4;
const uint16_t pin_ldr = A0;
const unsigned long ritter_group_address = 13043702; const unsigned long ritter_group_address = 13043702;
const char* parameter_plug_id="plug_id"; const char* parameter_plug_id="plug_id";
const char* parameter_plug_status="plug_status"; const char* parameter_plug_status="plug_status";
@ -135,19 +136,23 @@ void controller(void){
String getJsonDht(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){ String getJsonPir(void){
return "{\"motion\":\""+String(digitalRead(pin_pir))+"\"}"; return "{\"motion\":\""+String(digitalRead(pin_pir))+"\"}";
} }
String getJsonLdr(void){
return "{\"relative\":\""+String(analogRead (pin_ldr))+"\"}";
}
String getJsonIrLastRecieved(void){ String getJsonIrLastRecieved(void){
return "{\"last_recieved\":{\"bits\":\""+String(last_recieved_ir_bits)+"\",\"type\":\""+String(last_recieved_ir_type)+"\",\"data\":\""+String(last_recieved_ir_data)+"\"}}"; return "{\"last_recieved\":{\"bits\":\""+String(last_recieved_ir_bits)+"\",\"type\":\""+String(last_recieved_ir_type)+"\",\"data\":\""+String(last_recieved_ir_data)+"\"}}";
} }
String getJson(void){ 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" #include "homepage_template.h"