Page 1 of 1

Arduino Variables to domoticz via http GET json, help:-)

Posted: Monday 25 January 2016 21:20
by ngc981
Hallo

I am new with domoticz i like move from emoncms graphs to my domoticz server PI, please can someone help how to, Where to find , what to do to

To get these graphs in domoticz

I like to have one graph with the HR,Cloud,Light one graph with T,IR-TEMP,Dew and a traffic light based on cloudy, dewing, frizzing where 0 is red and 1 is green ore something like that

Below the arduino code i send to emoncms ;-) This arduino is connected to mijn network based on the s5100 shield

if (client.connect(server, 80)) {
Serial.print("sendData Connecting...to emoncms ");
Serial.println(loopcount);
// send the HTTP PUT request:
client.print("GET http://myserver/input/post.json?node=1& ... 8008&json={");
client.print("\"T\":\"");
client.print(T);
client.print("\",\"Clouds\":\"");
client.print(Clouds);
client.print(",IR:");
client.print(IR);
client.print(",HR:");
client.print(HR);
client.print(",dew:");
client.print(Dew);
client.print(",light:");
client.print(light);
client.print(",Clouds:");
client.print(Clouds);
client.print(",skyT:");
client.print(skyT);
client.print(",cloudy:");
client.print(cloudy);
client.print(",dewing:");
client.print(dewing);
client.print(",frezzing:");
client.print(frezzing);

client.println("\"}");
lastConnectionTime = millis();
client.stop();
}

I hope some can help me to get this running

The Idea is based on this automated things

Thanks on forhand

Chris

Re: Arduino Variables to domoticz via http GET json, help

Posted: Saturday 30 January 2016 11:49
by ngc981
Still having trouble to add my temperature values via Arduino to Domoticz
Adding via url in the browser work my dummy device gets update
translating it to code on the arduino it doesn't work

Please can some help me, what is going wrong
server is defined

char server[] = "192.168.178.42";

It connects because iam in the loop

void sendData(float T) {
// if there's a successful connection:
loopcount++;
if (client.connect(server,8080)) {
Serial.println(server);
// url to use http://192.168.178.42:8080/json.htm?typ ... &svalue=15"
String datastring="/json.htm?type=command&param=udevice&idx=1&nvalue=0&svalue=";
String datainput = datastring+T;
Serial.println(datainput);
client.println("GET "+datainput+" HTTP/1.1");
client.println("Host: 192.168.178.42");
client.println( "Connection: close");
//lastConnectionTime = millis();
delay(1000);
client.stop();
}
else {
// if you couldn't make a connection:
Serial.println("sendData Connection failed");
Serial.println("sendData Disconnecting...");
client.stop();
}
delay(1000);
Serial.println("sendData Connection...done");
}


De result of the serial is

sendData Connecting...to Domoticz 192.168.178.42
/json.htm?type=command&param=udevice&idx=1&nvalue=0&svalue=23.10


Thanks on forehand

Chris

Re: Arduino Variables to domoticz via http GET json, help:-)

Posted: Saturday 30 January 2016 12:43
by paulvha
Could it have to do with the authorization as indicated on http://www.domoticz.com/wiki/Domoticz_API/JSON_URL's

"When using some method other than a browser to connect to Domoticz it may be necessary to do Authorization differently.

Re: Arduino Variables to domoticz via http GET json, help:-)

Posted: Saturday 30 January 2016 17:03
by alfred_j_kwak
Maybe port number?

Re: Arduino Variables to domoticz via http GET json, help:-)

Posted: Sunday 31 January 2016 11:24
by ngc981
Paulvha, i checked the most of the code on this forum but most don't use any of authorisation. Mijn domoticz us plain SD install on a Pi, i am this will be the first thing to add

@Alfred the port used is 8080, which port can be used also for this?


Chris

Re: Arduino Variables to domoticz via http GET json, help:-)

Posted: Sunday 31 January 2016 12:11
by paulvha
on authorization : I agree. I use Python and can update, but was not sure what happens on libraries underneath. I add my svalue as a string to the URL. are you added as a float ?

SOLVED: Arduino Variables to domoticz via http GET json, help:-)

Posted: Sunday 31 January 2016 13:16
by ngc981
Paul

Yes i did and its working with de code above, i did reinstall of domoticz on the SD now its working ik think i messed something up :-(
Any way thanks for your help and your reaction i appreciate that.


Chris