Page 1 of 1

How to give data to domoticz

Posted: Sunday 23 October 2016 16:26
by a3vd
I have a cactus micro (with esp8266) which i can succesfully upload the data from a DHT11 to api.thingspeak.com

How can i put the data on my domoticz system ?

I have tried to put the json command in which should be something like this :

http://192.168.1.80:8080/json.htm?type= ... ue=21;42;0

Here under is the code i use for thingspeak , what do i have to change for domoticz ?



dht11 DHT;
ESP esp(&Serial1, &Serial, PIN_ENABLE_ESP);

REST rest(&esp);

boolean wifiConnected = false;

void wifiCb(void* response)
{
uint32_t status;
RESPONSE res(response);

if(res.getArgc() == 1) {
res.popArgs((uint8_t*)&status, 4);
if(status == STATION_GOT_IP) {
Serial.println("WIFI CONNECTED");

wifiConnected = true;
} else {
wifiConnected = false;
}
}
}

void setup() {
Serial1.begin(19200);
Serial.begin(19200);
pinMode(4,OUTPUT);
pinMode(3,INPUT);
digitalWrite(4,HIGH);

esp.enable();
delay(500);
esp.reset();
delay(500);
while(!esp.ready());
Serial.println("ARDUINO: setup rest client");
if(!rest.begin("api.thingspeak.com")) {
Serial.println("ARDUINO: failed to setup rest client");
while(1);
}
/*setup wifi*/
Serial.println("ARDUINO: setup wifi");
esp.wifiCb.attach(&wifiCb);

esp.wifiConnect(SSID, PASS);
Serial.println("ARDUINO: system started");
}

void loop() {
char response[266];
esp.process();
if(wifiConnected) {
int chk = DHT.read(3);

if(chk == DHTLIB_OK){
char buff[64];
char str_hum[6], str_temp[6];
dtostrf(DHT.humidity, 4, 2, str_hum);
dtostrf(DHT.temperature, 4, 2, str_temp);
sprintf(buff, "/update?api_key=MYOWNKEY&field1=%s&field2=%s", str_hum, str_temp);
Serial.println(buff);

rest.get((const char*)buff);
Serial.println("ARDUINO: send get");

if(rest.getResponse(response, 266) == HTTP_STATUS_OK){
Serial.println("Cactus Micro: GET successful");
Serial.println(response);
}
delay(30000);

} else {
Serial.print("error,\r\n");
}
}

}

Re: How to give data to domoticz

Posted: Friday 28 October 2016 20:44
by domoticzag
Try using the ESPeasy firmware, you can easily setup Domoticz, and intergrate a DHT11, its supported stock in ESPEasy

https://www.domoticz.com/wiki/ESP8266_WiFi_module