#include <UIPEthernet.h> // Used for Ethernet
// **** ETHERNET SETTING ****
// Arduino Uno pins: 10 = CS, 11 = MOSI, 12 = MISO, 13 = SCK
// Ethernet MAC address - must be unique on your network - MAC Reads T4A001 in hex (unique in your network)
byte mac[] = { 0x54, 0x34, 0x41, 0x30, 0x30, 0x31 };
// For the rest we use DHCP (IP address and such)
//Domoticz
const char * domoticz_server = "192.168.2.30"; // IP Adres (or name) of server to dump Domoticz data to
int port = 8080; //Domoticz port
int idx = 3; //IDX for this virtual sensor, found in Setup -> Devices
float humidity = 96;
float temp = 22.5;
EthernetClient client;
int interval = 10000; // Wait between dumps
void setup() {
Serial.begin(115200);
Ethernet.begin(mac);
Serial.println("Tweaking4All.com - Temperature Drone - v2.0");
Serial.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
Serial.print("IP Address : ");
Serial.println(Ethernet.localIP());
Serial.print("Subnet Mask : ");
Serial.println(Ethernet.subnetMask());
Serial.print("Default Gateway IP: ");
Serial.println(Ethernet.gatewayIP());
Serial.print("DNS Server IP : ");
Serial.println(Ethernet.dnsServerIP());
}
void loop() {
// if you get a connection, report back via serial:
if (client.connect(domoticz_server, port)) {
Serial.println("-> Connected");
// Make a HTTP request:
client.print("GET /json.htm?type=command¶m=udevice&idx=");
client.print(idx);
client.print("&nvalue=0&svalue=");
client.print(temp);
client.print(";");
client.print(humidity);
client.print(";0"); //Value for HUM_STAT. Can be one of: 0=Normal, 1=Comfortable, 2=Dry, 3=Wet
client.println(" HTTP/1.1");
client.print("Host: ");
client.print(domoticz_server);
client.print(":");
client.println(port);
client.println("User-Agent: Arduino-ethernet");
client.println("Connection: close");
client.println();
client.stop();
} else {
Serial.println("--> connection failed/n"); // you didn't get a connection to the server:
}
delay(interval);
}