i read this wiki page (https://www.domoticz.com/wiki/ESP8266_WiFi_module) and i want know how put the domoticz username and password for login in this code ?
Code: Select all
#include <Wire.h>
#include <SparkFun_Si7021_Breakout_Library.h> //https://github.com/sparkfun/Si7021_Breakout/blob/master/Libraries/Arduino/Si7021/src/SparkFun_Si7021_Breakout_Library.h
#include <ESP8266WiFi.h>
// int status = WL_IDLE_STATUS; // the Wifi radio's status
WiFiClient client;
// domoticz
const char * domoticz_server = "192.168.1.10"; //Domoticz port
int port = 8080; //Domoticz port
int idx = 5; //IDX for this virtual sensor, found in Setup -> Devices
float humidity = 0;
float temp = 0;
// Create Instance of HTU21D or SI7021 temp and humidity sensor and MPL3115A2 barrometric sensor
Weather sensor;
void setup()
{
// Initialize the I2C sensors and ping them
sensor.begin();
}
void loop()
{
// Get readings from all sensors
getWeather();
printInfo();
delay(60000); // Wait 60 seconds
}
void getWeather()
{
// Measure Relative Humidity from the HTU21D or Si7021
humidity = sensor.getRH();
// Measure Temperature from the HTU21D or Si7021
temp = sensor.getTemp();
// Temperature is measured every time RH is requested. It is faster, therefore, to read it from previous RH measurement with getTemp() instead with readTemp()
}
void printInfo()
{
// Domoticz format /json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=TEMP;HUM;HUM_STAT
if (client.connect(domoticz_server,port)) {
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();
}
}