6 files changed
+216
No files matched your search
@@ -21,6 +21,13 @@ You will receive the HTU21 sensor readings every TimeBetweenReadinghtu21 (set in
|
|||||||
|
|
||||||
If you don't want to resend values that haven't changed you can set htu21_always = false in config_HTU21.h
|
If you don't want to resend values that haven't changed you can set htu21_always = false in config_HTU21.h
|
||||||
|
|
||||||
|
### AHTx0 (AHT10 and AHT20)
|
||||||
|
You will receive the AHT sensor readings every TimeBetweenReadingAHTx0 (set into config_AHTx0.h) (30s by default).
|
||||||
|
|
||||||
|
`home/OpenMQTTGateway/CLIMAtoMQTT/aht { "tempc": 27.48108, "tempf": 81.46594, "hum": 48.90614 }`
|
||||||
|
|
||||||
|
If you don't want to resend values that haven't changed you can set AHTx0_always = false in config_AHTx0.h
|
||||||
|
|
||||||
### DS18x20
|
### DS18x20
|
||||||
You will receive the DS18x20 sensor readings every DS1820_INTERVAL_SEC (set into config_DS1820.h) (60s by default).
|
You will receive the DS18x20 sensor readings every DS1820_INTERVAL_SEC (set into config_DS1820.h) (60s by default).
|
||||||
Each sensor will be published under the following topic using each sensors' address.
|
Each sensor will be published under the following topic using each sensors' address.
|
||||||
|
|||||||
@@ -186,6 +186,26 @@ void pubMqttDiscovery() {
|
|||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# ifdef ZsensorAHTx0
|
||||||
|
# define AHTparametersCount 3
|
||||||
|
Log.trace(F("AHTx0Discovery" CR));
|
||||||
|
char* AHTsensor[AHTparametersCount][8] = {
|
||||||
|
{"sensor", "tempc", "aht", "temperature", jsonTemp, "", "", "°C"},
|
||||||
|
{"sensor", "tempf", "aht", "temperature", jsonTempf, "", "", "°F"},
|
||||||
|
{"sensor", "hum", "aht", "humidity", jsonHum, "", "", "%"}
|
||||||
|
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < AHTparametersCount; i++) {
|
||||||
|
Log.trace(F("CreateDiscoverySensor" CR));
|
||||||
|
createDiscovery(AHTsensor[i][0],
|
||||||
|
AHTTOPIC, AHTsensor[i][1], (char*)getUniqueId(AHTsensor[i][1], AHTsensor[i][2]).c_str(),
|
||||||
|
will_Topic, AHTsensor[i][3], AHTsensor[i][4],
|
||||||
|
AHTsensor[i][5], AHTsensor[i][6], AHTsensor[i][7],
|
||||||
|
0, "", "", true, "");
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
# ifdef ZsensorDHT
|
# ifdef ZsensorDHT
|
||||||
# define DHTparametersCount 2
|
# define DHTparametersCount 2
|
||||||
Log.trace(F("DHTDiscovery" CR));
|
Log.trace(F("DHTDiscovery" CR));
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
OpenMQTTGateway Addon - ESP8266 or Arduino program for home automation
|
||||||
|
|
||||||
|
Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
|
||||||
|
Send and receiving command by MQTT
|
||||||
|
|
||||||
|
This is the Climate Addon:
|
||||||
|
- Measures Temperature, Humidity
|
||||||
|
- Generates Values for: Temperature in degrees C and F, Humidity in %
|
||||||
|
- Required Hardware Module: AHTX0 (AHT10 & AHT20)
|
||||||
|
- Required Library: Adafruit AHTX0 by Adafruit
|
||||||
|
|
||||||
|
Connection Schemata:
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
AHT10 ------> Arduino Uno ----------> ESP8266
|
||||||
|
==============================================
|
||||||
|
Vcc ---------> 5V -------------------> 3v3 (3V)
|
||||||
|
GND ---------> GND ------------------> GND
|
||||||
|
SCL ---------> Pin A5 ---------------> D1
|
||||||
|
SDA ---------> Pin A4 ---------------> D2
|
||||||
|
|
||||||
|
This file is part of OpenMQTTGateway.
|
||||||
|
|
||||||
|
OpenMQTTGateway is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenMQTTGateway is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include "User_config.h"
|
||||||
|
|
||||||
|
#ifdef ZsensorAHTx0
|
||||||
|
# include <stdint.h>
|
||||||
|
|
||||||
|
# include "Adafruit_AHTX0.h"
|
||||||
|
# include "Wire.h" // Library for communication with I2C / TWI devices
|
||||||
|
# include "config_AHTx0.h"
|
||||||
|
|
||||||
|
//Time used to wait for an interval before resending measured values
|
||||||
|
unsigned long timeAHTx0 = 0;
|
||||||
|
|
||||||
|
//Global sensor object
|
||||||
|
Adafruit_AHTX0 ahtSensor;
|
||||||
|
|
||||||
|
void setupZsensorAHTx0() {
|
||||||
|
delay(10); // Gives the Sensor enough time to turn on
|
||||||
|
Log.notice(F("AHTx0 Initialized - begin()" CR));
|
||||||
|
|
||||||
|
# if defined(ESP32)
|
||||||
|
Wire.begin(AHT_I2C_SDA, AHT_I2C_SCL);
|
||||||
|
ahtSensor.begin(&Wire);
|
||||||
|
# else
|
||||||
|
ahtSensor.begin();
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void MeasureAHTTempHum() {
|
||||||
|
if (millis() > (timeAHTx0 + TimeBetweenReadingAHTx0)) {
|
||||||
|
Log.trace(F("Read AHTx0 Sensor" CR));
|
||||||
|
|
||||||
|
timeAHTx0 = millis();
|
||||||
|
static float persisted_aht_tempc;
|
||||||
|
static float persisted_aht_hum;
|
||||||
|
|
||||||
|
sensors_event_t ahtTempC, ahtHum;
|
||||||
|
ahtSensor.getEvent(&ahtHum, &ahtTempC); // get sensor data
|
||||||
|
|
||||||
|
if (ahtTempC.temperature >= 998 || ahtHum.relative_humidity >= 998) {
|
||||||
|
Log.error(F("Failed to read from sensor AHTx0!" CR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if reads failed and exit early (to try again).
|
||||||
|
if (isnan(ahtTempC.temperature) || isnan(ahtHum.relative_humidity)) {
|
||||||
|
Log.error(F("Failed to read from sensor AHTx0!" CR));
|
||||||
|
} else {
|
||||||
|
Log.notice(F("Creating AHTx0 buffer" CR));
|
||||||
|
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
|
||||||
|
JsonObject& AHTx0data = jsonBuffer.createObject();
|
||||||
|
// Generate Temperature in degrees C
|
||||||
|
if (ahtTempC.temperature != persisted_aht_tempc || AHTx0_always) {
|
||||||
|
float ahtTempF = (ahtTempC.temperature * 1.8) + 32;
|
||||||
|
AHTx0data.set("tempc", (float)ahtTempC.temperature);
|
||||||
|
AHTx0data.set("tempf", (float)ahtTempF);
|
||||||
|
} else {
|
||||||
|
Log.notice(F("Same Temp. Don't send it" CR));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate Humidity in percent
|
||||||
|
if (ahtHum.relative_humidity != persisted_aht_hum || AHTx0_always) {
|
||||||
|
AHTx0data.set("hum", (float)ahtHum.relative_humidity);
|
||||||
|
} else {
|
||||||
|
Log.notice(F("Same Humidity. Don't send it" CR));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AHTx0data.size() > 0)
|
||||||
|
pub(AHTTOPIC, AHTx0data);
|
||||||
|
}
|
||||||
|
persisted_aht_tempc = ahtTempC.temperature;
|
||||||
|
persisted_aht_hum = ahtHum.relative_humidity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
OpenMQTTGateway Addon - ESP8266 or Arduino program for home automation
|
||||||
|
|
||||||
|
Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
|
||||||
|
Send and receiving command by MQTT
|
||||||
|
|
||||||
|
This is the Climate Addon:
|
||||||
|
- Measures Temperature, Humidity
|
||||||
|
- Generates Values for: Temperature in degrees C and F, Humidity in %
|
||||||
|
- Required Hardware Module: AHTX0 (AHT10 & AHT20)
|
||||||
|
- Required Library: Adafruit AHTX0 by Adafruit
|
||||||
|
|
||||||
|
Connection Schemata:
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
AHT10 ------> Arduino Uno ----------> ESP8266
|
||||||
|
==============================================
|
||||||
|
Vcc ---------> 5V -------------------> 3v3 (3V)
|
||||||
|
GND ---------> GND ------------------> GND
|
||||||
|
SCL ---------> Pin A5 ---------------> D1
|
||||||
|
SDA ---------> Pin A4 ---------------> D2
|
||||||
|
|
||||||
|
This file is part of OpenMQTTGateway.
|
||||||
|
|
||||||
|
OpenMQTTGateway is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenMQTTGateway is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef config_AHTx0_h
|
||||||
|
#define config_AHTx0_h
|
||||||
|
|
||||||
|
extern void setupAHTx0();
|
||||||
|
extern void AHTx0toMQTT();
|
||||||
|
|
||||||
|
#define AHTx0_always true // if false when the current value of the parameter is the same as previous one don't send it by MQTT
|
||||||
|
#define TimeBetweenReadingAHTx0 30000
|
||||||
|
|
||||||
|
/*----------------------------USER PARAMETERS-----------------------------*/
|
||||||
|
/*-------------DEFINE YOUR MQTT PARAMETERS BELOW----------------*/
|
||||||
|
#define AHTTOPIC "/CLIMAtoMQTT/aht"
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
# if !defined(AHT_I2C_SDA) || !defined(AHT_I2C_SCL)
|
||||||
|
# define AHT_I2C_SDA 16
|
||||||
|
# define AHT_I2C_SCL 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -88,6 +88,9 @@ unsigned long ReceivedSignal[array_size][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}};
|
|||||||
#ifdef ZsensorHTU21
|
#ifdef ZsensorHTU21
|
||||||
# include "config_HTU21.h"
|
# include "config_HTU21.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ZsensorAHTx0
|
||||||
|
# include "config_AHTx0.h"
|
||||||
|
#endif
|
||||||
#ifdef ZsensorHCSR04
|
#ifdef ZsensorHCSR04
|
||||||
# include "config_HCSR04.h"
|
# include "config_HCSR04.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -542,6 +545,9 @@ void setup() {
|
|||||||
#ifdef ZsensorHTU21
|
#ifdef ZsensorHTU21
|
||||||
setupZsensorHTU21();
|
setupZsensorHTU21();
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ZsensorAHTx0
|
||||||
|
setupZsensorAHTx0();
|
||||||
|
#endif
|
||||||
#ifdef ZsensorBH1750
|
#ifdef ZsensorBH1750
|
||||||
setupZsensorBH1750();
|
setupZsensorBH1750();
|
||||||
#endif
|
#endif
|
||||||
@@ -1076,6 +1082,9 @@ void loop() {
|
|||||||
#ifdef ZsensorHTU21
|
#ifdef ZsensorHTU21
|
||||||
MeasureTempHum(); //Addon to measure Temperature, Humidity, of a HTU21 sensor
|
MeasureTempHum(); //Addon to measure Temperature, Humidity, of a HTU21 sensor
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ZsensorAHTx0
|
||||||
|
MeasureAHTTempHum(); //Addon to measure Temperature, Humidity, of an 'AHTx0' sensor
|
||||||
|
#endif
|
||||||
#ifdef ZsensorHCSR04
|
#ifdef ZsensorHCSR04
|
||||||
MeasureDistance(); //Addon to measure distance with a HC-SR04
|
MeasureDistance(); //Addon to measure distance with a HC-SR04
|
||||||
#endif
|
#endif
|
||||||
@@ -1196,6 +1205,9 @@ void stateMeasures() {
|
|||||||
# ifdef ZsensorHTU21
|
# ifdef ZsensorHTU21
|
||||||
modules = modules + ZsensorHTU21;
|
modules = modules + ZsensorHTU21;
|
||||||
# endif
|
# endif
|
||||||
|
# ifdef ZsensorAHTx0
|
||||||
|
modules = modules + ZsensorAHTx0;
|
||||||
|
# endif
|
||||||
# ifdef ZsensorHCSR04
|
# ifdef ZsensorHCSR04
|
||||||
modules = modules + ZsensorHCSR04;
|
modules = modules + ZsensorHCSR04;
|
||||||
# endif
|
# endif
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ tsl2561 = Adafruit TSL2561@1.0.3
|
|||||||
bme280 = SparkFun BME280@2.0.4
|
bme280 = SparkFun BME280@2.0.4
|
||||||
bmp180 = BMP180@efac46bd8d
|
bmp180 = BMP180@efac46bd8d
|
||||||
htu21 = SparkFun HTU21D Humidity and Temperature Sensor Br@1.1.3
|
htu21 = SparkFun HTU21D Humidity and Temperature Sensor Br@1.1.3
|
||||||
|
ahtx0 = Adafruit AHTX0
|
||||||
ina226 = jarzebski/Arduino-INA226#968a684
|
ina226 = jarzebski/Arduino-INA226#968a684
|
||||||
a6lib = 1technophile/A6lib
|
a6lib = 1technophile/A6lib
|
||||||
wifimanager = tzapu/WiFiManager#c3ff582
|
wifimanager = tzapu/WiFiManager#c3ff582
|
||||||
@@ -173,6 +174,7 @@ lib_deps =
|
|||||||
${libraries.bme280}
|
${libraries.bme280}
|
||||||
${libraries.bmp180}
|
${libraries.bmp180}
|
||||||
${libraries.htu21}
|
${libraries.htu21}
|
||||||
|
${libraries.ahtx0}
|
||||||
${libraries.unifiedsensor}
|
${libraries.unifiedsensor}
|
||||||
${libraries.dht}
|
${libraries.dht}
|
||||||
${libraries.tsl2561}
|
${libraries.tsl2561}
|
||||||
@@ -196,6 +198,7 @@ build_flags =
|
|||||||
'-DZsensorBH1750="BH1750"'
|
'-DZsensorBH1750="BH1750"'
|
||||||
'-DZsensorBME280="BME280"'
|
'-DZsensorBME280="BME280"'
|
||||||
'-DZsensorHTU21="HTU21"'
|
'-DZsensorHTU21="HTU21"'
|
||||||
|
'-DZsensorAHTx0="AHTx0"'
|
||||||
'-DZsensorTSL2561="TSL2561"'
|
'-DZsensorTSL2561="TSL2561"'
|
||||||
'-DZsensorDHT="DHT"'
|
'-DZsensorDHT="DHT"'
|
||||||
'-DZsensorDS1820="DS1820"'
|
'-DZsensorDS1820="DS1820"'
|
||||||
@@ -365,6 +368,7 @@ lib_deps =
|
|||||||
${libraries.bme280}
|
${libraries.bme280}
|
||||||
${libraries.bmp180}
|
${libraries.bmp180}
|
||||||
${libraries.htu21}
|
${libraries.htu21}
|
||||||
|
${libraries.ahtx0}
|
||||||
${libraries.unifiedsensor}
|
${libraries.unifiedsensor}
|
||||||
${libraries.dht}
|
${libraries.dht}
|
||||||
${libraries.tsl2561}
|
${libraries.tsl2561}
|
||||||
@@ -391,6 +395,7 @@ build_flags =
|
|||||||
'-DZsensorBH1750="BH1750"'
|
'-DZsensorBH1750="BH1750"'
|
||||||
'-DZsensorBME280="BME280"'
|
'-DZsensorBME280="BME280"'
|
||||||
'-DZsensorHTU21="HTU21"'
|
'-DZsensorHTU21="HTU21"'
|
||||||
|
'-DZsensorAHTx0="AHTx0"'
|
||||||
'-DZsensorTSL2561="TSL2561"'
|
'-DZsensorTSL2561="TSL2561"'
|
||||||
'-DZsensorDHT="DHT"'
|
'-DZsensorDHT="DHT"'
|
||||||
'-DZsensorDS1820="DS1820"'
|
'-DZsensorDS1820="DS1820"'
|
||||||
@@ -596,6 +601,7 @@ lib_deps =
|
|||||||
${libraries.bme280}
|
${libraries.bme280}
|
||||||
${libraries.bmp180}
|
${libraries.bmp180}
|
||||||
${libraries.htu21}
|
${libraries.htu21}
|
||||||
|
${libraries.ahtx0}
|
||||||
${libraries.unifiedsensor}
|
${libraries.unifiedsensor}
|
||||||
${libraries.dht}
|
${libraries.dht}
|
||||||
${libraries.tsl2561}
|
${libraries.tsl2561}
|
||||||
@@ -620,6 +626,7 @@ build_flags =
|
|||||||
'-DZsensorBH1750="BH1750"'
|
'-DZsensorBH1750="BH1750"'
|
||||||
'-DZsensorBME280="BME280"'
|
'-DZsensorBME280="BME280"'
|
||||||
'-DZsensorHTU21="HTU21"'
|
'-DZsensorHTU21="HTU21"'
|
||||||
|
'-DZsensorAHTx0="AHTx0"'
|
||||||
'-DZsensorTSL2561="TSL2561"'
|
'-DZsensorTSL2561="TSL2561"'
|
||||||
'-DZsensorDHT="DHT"'
|
'-DZsensorDHT="DHT"'
|
||||||
'-DZsensorDS1820="DS1820"'
|
'-DZsensorDS1820="DS1820"'
|
||||||
|
|||||||
Reference in new issue
Block a user