Hi!
I am using Domoticz for house-automation.
From a webbrowser I can control Domoticz e.g. with:
192.168.2.13:8080 /json.htm?type=command¶m=switchlight&idx=770&switchcmd=Off
192.168.2.13 is IP of Domoticz
Now I likt to send same Json using Arduino.
I used next code but it does not work.
My Arduino UNO gets an IP# and gets connected with Domoticz but furthermore nothing happens.
Any suggestion?
Note that is quit new for me so maybe beginners fault?
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x7D, 0x54 };
char domoticz_server[] = "84.84.64.129";
EthernetClient domoticz_client;
String data= "";
char c="";
void setup(void)
{
Serial.begin(9600);
Serial.println("zet hier iets leuks..");
// start the Ethernet connection and the server:
Serial.println("Trying to get an IP address using DHCP");
if (Ethernet.begin(mac) == 0)
{
Serial.println("Failed to configure Ethernet using DHCP");
while (true) ;
}
Serial.println();
// start listening for clients
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
void loop(void)
{
data = "GET /json.htm?type=command¶m=switchlight&idx=770&switchcmd=Off";
Serial.println(data);
Serial.println();
domoticz_client.stop() ;
if (domoticz_client.connect(domoticz_server,8080));
{
Serial.println("connected");
}
domoticz_client.println(data);
while (domoticz_client.available())
{
c = domoticz_client.read();
Serial.print(c);
domoticz_client.println();
}
domoticz_client.println("Connection: close");
domoticz_client.println();
delay(10000);
}