How to give data to domoticz

Everything about esp8266 and more.

Moderator: leecollings

Post Reply
User avatar
a3vd
Posts: 22
Joined: Tuesday 25 February 2014 14:02
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Noordwijk, The Netherlands
Contact:

How to give data to domoticz

Post 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");
}
}

}
Raspberry 3+ / 4
P1 smartcable / RFXtrx433 FW 182 / Several 1 wire Temp Sensors /DHT12/Conbee2 (zigbee)
Several Kaku switches/ Weather Underground / Hue
domoticzag
Posts: 24
Joined: Tuesday 13 September 2016 19:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to give data to domoticz

Post 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
RPi 3
Domoticz Béta
RFLink Gateway dipool antenna
Many kaku devices
P1 smart meter
Custom made ESP8266 devices
Hue lights / Milight ligts and strips
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest