first commit
This commit is contained in:
119
ESP8266_DOMOTICZ_BMP180/ESP8266_DOMOTICZ_BMP180.ino
Executable file
119
ESP8266_DOMOTICZ_BMP180/ESP8266_DOMOTICZ_BMP180.ino
Executable file
@@ -0,0 +1,119 @@
|
||||
//extern "C" {
|
||||
//#include "user_interface.h"
|
||||
//}
|
||||
|
||||
// Need for getVcc
|
||||
ADC_MODE(ADC_VCC);
|
||||
|
||||
/////////////////////
|
||||
// Domoticz Classe
|
||||
/////////////////////
|
||||
|
||||
#include "Domoticz.h"
|
||||
|
||||
Domoticz domo("192.168.1.3", "81", "Livebox-37cc", "8A6060920A8A86896F770F2C47");
|
||||
#include "Modules.h"
|
||||
Modules modules;
|
||||
Params * params;
|
||||
|
||||
|
||||
IPAddress gateway(192, 168, 1, 1);
|
||||
IPAddress subnet(255, 255, 0, 0);
|
||||
IPAddress DNS(192, 168, 1, 1);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// pinMode(PIN_ALIM_DS, OUTPUT);
|
||||
// digitalWrite(PIN_ALIM_DS, HIGH);
|
||||
//Wire.begin(SDA, SCL);
|
||||
|
||||
Serial.begin(9600);
|
||||
//delay(200);
|
||||
String macId = domo.generateKey();
|
||||
IPAddress ip = domo.getIP(macId);
|
||||
|
||||
// Conversion d'objet en pointeur
|
||||
Params p;
|
||||
params = &p;
|
||||
domo.initWifiStatic(ip, gateway, subnet, DNS);
|
||||
//domo.initWifi();
|
||||
domo.getIdFromDomoticz(macId, params);
|
||||
|
||||
modules.barometre();
|
||||
|
||||
// modules.readLuminosite();
|
||||
|
||||
// digitalWrite(PIN_ALIM_DS,LOW);
|
||||
|
||||
printInfo();
|
||||
|
||||
modules.sleep(params->sleepTime);
|
||||
//delay(5000);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void printInfo()
|
||||
{
|
||||
// Domoticz format /json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=TEMP;HUM;HUM_STAT;BAR;BAR_FOR
|
||||
|
||||
Serial.println("Dans printInfo " + params->esp8266_id);
|
||||
|
||||
boolean connected = domo.connect();
|
||||
|
||||
if (connected && modules.temp > 0 && params->esp8266_id != "" ) {
|
||||
Serial.println("Dans set temperature");
|
||||
String svalue = String(modules.temp)
|
||||
+ ";" + String(modules.humidity)
|
||||
+ ";0;" + String(modules.pression)
|
||||
+ ";" + String(modules.pressionHg);
|
||||
Serial.println(svalue);
|
||||
domo.executeJson("/json.htm?type=command¶m=udevice&idx=" + params->esp8266_id, svalue, "0");
|
||||
|
||||
// delay(200);
|
||||
// Serial.println("Response: ");
|
||||
//
|
||||
// domo.readResponse();
|
||||
domo._client.stop();
|
||||
|
||||
delay(200);
|
||||
|
||||
}
|
||||
|
||||
connected = domo.connect();
|
||||
if (connected && params->esp8266_id_Vcc != "") {
|
||||
Serial.print(" Envoi tension ");
|
||||
Serial.print(params->esp8266_id_Vcc);
|
||||
Serial.print(" ");
|
||||
String vcc = domo.readVcc();
|
||||
Serial.println(vcc);
|
||||
|
||||
// domo._client.print("GET /json.htm?type=command¶m=udevice&idx=");
|
||||
domo.executeJson("/json.htm?type=command¶m=udevice&idx=" + params->esp8266_id_Vcc, vcc, "0");
|
||||
|
||||
domo._client.stop();
|
||||
}
|
||||
|
||||
// Serial.print("Luminosite ");
|
||||
// Serial.println(modules.lum);
|
||||
//
|
||||
// connected = domo.connect();
|
||||
// if (connected && params->esp8266_id_lum != "") {
|
||||
// Serial.print(" Envoi luminosite ");
|
||||
// Serial.print(params->esp8266_id_lum);
|
||||
// Serial.print(" ");
|
||||
// Serial.println(modules.lum);
|
||||
//
|
||||
// // domo._client.print("GET /json.htm?type=command¶m=udevice&idx=");
|
||||
// domo.executeJson("/json.htm?type=command¶m=udevice&idx=" + params->esp8266_id_lum, String(modules.lum), "0");
|
||||
// domo._client.stop();
|
||||
// }
|
||||
|
||||
Serial.print("Time = ");
|
||||
Serial.println(millis());
|
||||
|
||||
delay(200);
|
||||
}
|
||||
Reference in New Issue
Block a user