mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 03:49:13 +03:00
MAX6675 @Serghei63
This commit is contained in:
@@ -293,9 +293,23 @@
|
|||||||
"round": 1
|
"round": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "22. Датчик CO2 MHZ-19 UART",
|
"name": "22. Cенсор температуры MAX6675",
|
||||||
"num": 22,
|
"num": 22,
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
|
"subtype": "Max6675t",
|
||||||
|
"id": "maxtmp",
|
||||||
|
"widget": "anydataTmp",
|
||||||
|
"page": "Сенсоры",
|
||||||
|
"descr": "MAX Температура",
|
||||||
|
"int": 15,
|
||||||
|
"DO": 12,
|
||||||
|
"CS": 13,
|
||||||
|
"CLK": 14
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "23. Датчик CO2 MHZ-19 UART",
|
||||||
|
"num": 23,
|
||||||
|
"type": "Reading",
|
||||||
"subtype": "Mhz19uart",
|
"subtype": "Mhz19uart",
|
||||||
"id": "co2uart",
|
"id": "co2uart",
|
||||||
"widget": "anydataPpm",
|
"widget": "anydataPpm",
|
||||||
@@ -312,8 +326,8 @@
|
|||||||
"ABC": 1
|
"ABC": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "23. Датчик CO2 MHZ-19 PWM",
|
"name": "24. Датчик CO2 MHZ-19 PWM",
|
||||||
"num": 23,
|
"num": 24,
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Mhz19pwm",
|
"subtype": "Mhz19pwm",
|
||||||
"id": "co2pwm",
|
"id": "co2pwm",
|
||||||
@@ -327,8 +341,8 @@
|
|||||||
"int": 300
|
"int": 300
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "24. Cенсор температуры от MHZ-19 UART",
|
"name": "25. Cенсор температуры от MHZ-19 UART",
|
||||||
"num": 24,
|
"num": 25,
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Mhz19temp",
|
"subtype": "Mhz19temp",
|
||||||
"id": "Mhz19temp",
|
"id": "Mhz19temp",
|
||||||
@@ -344,8 +358,8 @@
|
|||||||
"int": 30
|
"int": 30
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "25. Рабочий диапазон от MHZ-19 UART",
|
"name": "26. Рабочий диапазон от MHZ-19 UART",
|
||||||
"num": 25,
|
"num": 26,
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Mhz19range",
|
"subtype": "Mhz19range",
|
||||||
"id": "Mhz19range",
|
"id": "Mhz19range",
|
||||||
@@ -362,8 +376,8 @@
|
|||||||
"int": 30
|
"int": 30
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "26. Автокалибровка от MHZ-19 UART",
|
"name": "27. Автокалибровка от MHZ-19 UART",
|
||||||
"num": 26,
|
"num": 27,
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Mhz19ABC",
|
"subtype": "Mhz19ABC",
|
||||||
"id": "Mhz19ABC",
|
"id": "Mhz19ABC",
|
||||||
@@ -377,8 +391,8 @@
|
|||||||
"int": 30
|
"int": 30
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "27. Датчик пыли SDS011 PM25",
|
"name": "28. Датчик пыли SDS011 PM25",
|
||||||
"num": 27,
|
"num": 28,
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sds011_25",
|
"subtype": "Sds011_25",
|
||||||
"id": "pmuart25",
|
"id": "pmuart25",
|
||||||
@@ -395,8 +409,8 @@
|
|||||||
"period": 300
|
"period": 300
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "28. Датчик пыли SDS011 PM10",
|
"name": "29. Датчик пыли SDS011 PM10",
|
||||||
"num": 28,
|
"num": 29,
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sds011_10",
|
"subtype": "Sds011_10",
|
||||||
"id": "pmuart10",
|
"id": "pmuart10",
|
||||||
@@ -413,8 +427,8 @@
|
|||||||
"period": 300
|
"period": 300
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "29. Cенсор температуры Sht20",
|
"name": "30. Cенсор температуры Sht20",
|
||||||
"num": 29,
|
"num": 30,
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sht20t",
|
"subtype": "Sht20t",
|
||||||
"id": "tmp2",
|
"id": "tmp2",
|
||||||
@@ -425,8 +439,8 @@
|
|||||||
"round": 1
|
"round": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "30. Cенсор влажности Sht20",
|
"name": "31. Cенсор влажности Sht20",
|
||||||
"num": 30,
|
"num": 31,
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Sht20h",
|
"subtype": "Sht20h",
|
||||||
"id": "Hum2",
|
"id": "Hum2",
|
||||||
@@ -440,8 +454,8 @@
|
|||||||
"header": "Экраны"
|
"header": "Экраны"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "31. LCD экран 2004",
|
"name": "32. LCD экран 2004",
|
||||||
"num": 31,
|
"num": 32,
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Lcd2004",
|
"subtype": "Lcd2004",
|
||||||
"id": "Lcd",
|
"id": "Lcd",
|
||||||
@@ -455,8 +469,8 @@
|
|||||||
"id2show": "id датчика"
|
"id2show": "id датчика"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "32. LCD экран 1602",
|
"name": "33. LCD экран 1602",
|
||||||
"num": 32,
|
"num": 33,
|
||||||
"type": "Reading",
|
"type": "Reading",
|
||||||
"subtype": "Lcd2004",
|
"subtype": "Lcd2004",
|
||||||
"id": "Lcd",
|
"id": "Lcd",
|
||||||
|
|||||||
@@ -33,13 +33,11 @@ data_dir = data_svelte
|
|||||||
[common_env_data]
|
[common_env_data]
|
||||||
lib_deps_external =
|
lib_deps_external =
|
||||||
bblanchon/ArduinoJson @6.18.0
|
bblanchon/ArduinoJson @6.18.0
|
||||||
;me-no-dev/ESP Async WebServer
|
|
||||||
Links2004/WebSockets
|
Links2004/WebSockets
|
||||||
knolleary/PubSubClient
|
knolleary/PubSubClient
|
||||||
|
|
||||||
[env:esp8266_4mb_fromitems]
|
[env:esp8266_4mb_fromitems]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
|
|
||||||
adafruit/Adafruit MCP23017 Arduino Library@^2.0.2
|
adafruit/Adafruit MCP23017 Arduino Library@^2.0.2
|
||||||
adafruit/Adafruit ADS1X15 @ ^2.3.0
|
adafruit/Adafruit ADS1X15 @ ^2.3.0
|
||||||
Adafruit AHTX0
|
Adafruit AHTX0
|
||||||
@@ -49,13 +47,13 @@ lib_deps =
|
|||||||
milesburton/DallasTemperature@^3.9.1
|
milesburton/DallasTemperature@^3.9.1
|
||||||
https://github.com/JonasGMorsch/GY-21.git
|
https://github.com/JonasGMorsch/GY-21.git
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
|
adafruit/MAX6675 library
|
||||||
Nova Fitness Sds dust sensors library@1.5.1
|
Nova Fitness Sds dust sensors library@1.5.1
|
||||||
robtillaart/SHT2x@^0.1.1
|
robtillaart/SHT2x@^0.1.1
|
||||||
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||||
|
|
||||||
[env:esp32_4mb_fromitems]
|
[env:esp32_4mb_fromitems]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
|
|
||||||
adafruit/Adafruit MCP23017 Arduino Library@^2.0.2
|
adafruit/Adafruit MCP23017 Arduino Library@^2.0.2
|
||||||
adafruit/Adafruit ADS1X15 @ ^2.3.0
|
adafruit/Adafruit ADS1X15 @ ^2.3.0
|
||||||
Adafruit AHTX0
|
Adafruit AHTX0
|
||||||
@@ -65,6 +63,7 @@ lib_deps =
|
|||||||
milesburton/DallasTemperature@^3.9.1
|
milesburton/DallasTemperature@^3.9.1
|
||||||
https://github.com/JonasGMorsch/GY-21.git
|
https://github.com/JonasGMorsch/GY-21.git
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
|
adafruit/MAX6675 library
|
||||||
Nova Fitness Sds dust sensors library@1.5.1
|
Nova Fitness Sds dust sensors library@1.5.1
|
||||||
robtillaart/SHT2x@^0.1.1
|
robtillaart/SHT2x@^0.1.1
|
||||||
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
marcoschwartz/LiquidCrystal_I2C@^1.1.4
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ void* getAPI_Dht1122(String subtype, String params);
|
|||||||
void* getAPI_Ds18b20(String subtype, String params);
|
void* getAPI_Ds18b20(String subtype, String params);
|
||||||
void* getAPI_GY21(String subtype, String params);
|
void* getAPI_GY21(String subtype, String params);
|
||||||
void* getAPI_Hdc1080(String subtype, String params);
|
void* getAPI_Hdc1080(String subtype, String params);
|
||||||
|
void* getAPI_Max6675(String subtype, String params);
|
||||||
void* getAPI_Mhz19(String subtype, String params);
|
void* getAPI_Mhz19(String subtype, String params);
|
||||||
void* getAPI_Sds011(String subtype, String params);
|
void* getAPI_Sds011(String subtype, String params);
|
||||||
void* getAPI_Sht20(String subtype, String params);
|
void* getAPI_Sht20(String subtype, String params);
|
||||||
@@ -35,6 +36,7 @@ if ((tmpAPI = getAPI_Dht1122(subtype, params)) != nullptr) return tmpAPI;
|
|||||||
if ((tmpAPI = getAPI_Ds18b20(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Ds18b20(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_GY21(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_GY21(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Hdc1080(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Hdc1080(subtype, params)) != nullptr) return tmpAPI;
|
||||||
|
if ((tmpAPI = getAPI_Max6675(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Mhz19(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Mhz19(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Sds011(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Sds011(subtype, params)) != nullptr) return tmpAPI;
|
||||||
if ((tmpAPI = getAPI_Sht20(subtype, params)) != nullptr) return tmpAPI;
|
if ((tmpAPI = getAPI_Sht20(subtype, params)) != nullptr) return tmpAPI;
|
||||||
|
|||||||
@@ -10,60 +10,68 @@
|
|||||||
#include "classes/IoTItem.h"
|
#include "classes/IoTItem.h"
|
||||||
|
|
||||||
#include "Wire.h"
|
#include "Wire.h"
|
||||||
#include <Adafruit_ADS1X15.h> // Библиотека для работы с модулями ADS1115 и ADS1015
|
#include <Adafruit_ADS1X15.h> // Библиотека для работы с модулями ADS1115 и ADS1015
|
||||||
|
|
||||||
|
// to do убрать глобальный экземпляр
|
||||||
Adafruit_ADS1115 ads;
|
Adafruit_ADS1115 ads;
|
||||||
|
|
||||||
class Ads1115 : public IoTItem {
|
class Ads1115 : public IoTItem {
|
||||||
int _pin;
|
int _pin;
|
||||||
bool _isRaw;
|
bool _isRaw;
|
||||||
bool _isInited = false;
|
bool _isInited = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Ads1115(String parameters): IoTItem(parameters) {
|
Ads1115(String parameters) : IoTItem(parameters) {
|
||||||
String tmp;
|
String tmp;
|
||||||
jsonRead(parameters, "pin", tmp);
|
jsonRead(parameters, "pin", tmp);
|
||||||
_pin = tmp.toInt();
|
_pin = tmp.toInt();
|
||||||
|
|
||||||
jsonRead(parameters, "mode", tmp);
|
jsonRead(parameters, "mode", tmp);
|
||||||
_isRaw = tmp == "raw";
|
_isRaw = tmp == "raw";
|
||||||
|
|
||||||
if (!ads.begin()) {
|
if (!ads.begin()) {
|
||||||
Serial.println("Failed to initialize ADS.");
|
Serial.println("Failed to initialize ADS.");
|
||||||
_isInited = false;
|
_isInited = false;
|
||||||
} else _isInited = true;
|
} else
|
||||||
|
_isInited = true;
|
||||||
|
|
||||||
String gain;
|
String gain;
|
||||||
jsonRead(parameters, "gain", gain);
|
jsonRead(parameters, "gain", gain);
|
||||||
if (gain == "1x") ads.setGain(GAIN_ONE);
|
if (gain == "1x")
|
||||||
else if (gain == "2x") ads.setGain(GAIN_TWO);
|
ads.setGain(GAIN_ONE);
|
||||||
else if (gain == "4x") ads.setGain(GAIN_FOUR);
|
else if (gain == "2x")
|
||||||
else if (gain == "8x") ads.setGain(GAIN_EIGHT);
|
ads.setGain(GAIN_TWO);
|
||||||
else if (gain == "16x") ads.setGain(GAIN_SIXTEEN);
|
else if (gain == "4x")
|
||||||
else ads.setGain(GAIN_TWOTHIRDS);
|
ads.setGain(GAIN_FOUR);
|
||||||
// ВОЗМОЖНЫЕ ВАРИАНТЫ УСТАНОВКИ КУ:
|
else if (gain == "8x")
|
||||||
// ads.setGain(GAIN_TWOTHIRDS); //| 2/3х | +/-6.144V | 1bit = 0.1875mV |
|
ads.setGain(GAIN_EIGHT);
|
||||||
// ads.setGain(GAIN_ONE); //| 1х | +/-4.096V | 1bit = 0.125mV |
|
else if (gain == "16x")
|
||||||
// ads.setGain(GAIN_TWO); //| 2х | +/-2.048V | 1bit = 0.0625mV |
|
ads.setGain(GAIN_SIXTEEN);
|
||||||
// ads.setGain(GAIN_FOUR); //| 4х | +/-1.024V | 1bit = 0.03125mV |
|
else
|
||||||
// ads.setGain(GAIN_EIGHT); //| 8х | +/-0.512V | 1bit = 0.015625mV |
|
ads.setGain(GAIN_TWOTHIRDS);
|
||||||
// ads.setGain(GAIN_SIXTEEN); //| 16х | +/-0.256V | 1bit = 0.0078125mV |
|
// ВОЗМОЖНЫЕ ВАРИАНТЫ УСТАНОВКИ КУ:
|
||||||
|
// ads.setGain(GAIN_TWOTHIRDS); //| 2/3х | +/-6.144V | 1bit = 0.1875mV |
|
||||||
|
// ads.setGain(GAIN_ONE); //| 1х | +/-4.096V | 1bit = 0.125mV |
|
||||||
|
// ads.setGain(GAIN_TWO); //| 2х | +/-2.048V | 1bit = 0.0625mV |
|
||||||
|
// ads.setGain(GAIN_FOUR); //| 4х | +/-1.024V | 1bit = 0.03125mV |
|
||||||
|
// ads.setGain(GAIN_EIGHT); //| 8х | +/-0.512V | 1bit = 0.015625mV |
|
||||||
|
// ads.setGain(GAIN_SIXTEEN); //| 16х | +/-0.256V | 1bit = 0.0078125mV |
|
||||||
}
|
}
|
||||||
|
|
||||||
void doByInterval() {
|
void doByInterval() {
|
||||||
if (_isInited) {
|
if (_isInited) {
|
||||||
if (_isRaw) value.valD = ads.readADC_SingleEnded(_pin); // Чтение АЦП нулевого канала(rawdata)
|
if (_isRaw)
|
||||||
else value.valD = ads.computeVolts(ads.readADC_SingleEnded(_pin)); // Чтение АЦП нулевого канала (Вольты)
|
value.valD = ads.readADC_SingleEnded(_pin); // Чтение АЦП нулевого канала(rawdata)
|
||||||
regEvent(value.valD, "ADC1115");
|
else
|
||||||
}
|
value.valD = ads.computeVolts(ads.readADC_SingleEnded(_pin)); // Чтение АЦП нулевого канала (Вольты)
|
||||||
|
regEvent(value.valD, "ADC1115");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~Ads1115() {};
|
~Ads1115(){};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void *getAPI_Ads1115(String subtype, String param) {
|
||||||
void *getAPI_Ads1115(String subtype, String param)
|
|
||||||
{
|
|
||||||
if (subtype == F("Ads1115")) {
|
if (subtype == F("Ads1115")) {
|
||||||
return new Ads1115(param);
|
return new Ads1115(param);
|
||||||
} else {
|
} else {
|
||||||
@@ -71,25 +79,22 @@ void *getAPI_Ads1115(String subtype, String param)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// {
|
||||||
|
// "name": "26. Датчик напряжения ADS1115",
|
||||||
|
// "num": 26,
|
||||||
|
// "type": "Reading",
|
||||||
|
// "subtype": "Ads1115",
|
||||||
|
// "id": "Ads3",
|
||||||
|
// "widget": "anydataVlt",
|
||||||
|
// "page": "Сенсоры",
|
||||||
|
// "descr": "ADS_3",
|
||||||
|
|
||||||
|
// "pin": "0",
|
||||||
|
// "mode": "volt",
|
||||||
|
// "gain": "3/4x",
|
||||||
|
|
||||||
|
// "plus": 0,
|
||||||
// {
|
// "multiply": 1,
|
||||||
// "name": "26. Датчик напряжения ADS1115",
|
// "round": 100,
|
||||||
// "num": 26,
|
// "int": 10
|
||||||
// "type": "Reading",
|
// }
|
||||||
// "subtype": "Ads1115",
|
|
||||||
// "id": "Ads3",
|
|
||||||
// "widget": "anydataVlt",
|
|
||||||
// "page": "Сенсоры",
|
|
||||||
// "descr": "ADS_3",
|
|
||||||
|
|
||||||
// "pin": "0",
|
|
||||||
// "mode": "volt",
|
|
||||||
// "gain": "3/4x",
|
|
||||||
|
|
||||||
// "plus": 0,
|
|
||||||
// "multiply": 1,
|
|
||||||
// "round": 100,
|
|
||||||
// "int": 10
|
|
||||||
// }
|
|
||||||
@@ -6,55 +6,56 @@
|
|||||||
adapted for version 4 @Serghei63
|
adapted for version 4 @Serghei63
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "classes/IoTItem.h"
|
#include "classes/IoTItem.h"
|
||||||
|
|
||||||
#include "Adafruit_AHTX0.h"
|
#include "Adafruit_AHTX0.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
// to do убрать глобальный экземпляр
|
||||||
Adafruit_AHTX0 aht;
|
Adafruit_AHTX0 aht;
|
||||||
sensors_event_t temp, humidity;
|
sensors_event_t temp, humidity;
|
||||||
|
|
||||||
class Aht20t : public IoTItem {
|
class Aht20t : public IoTItem {
|
||||||
public:
|
public:
|
||||||
Aht20t(String parameters): IoTItem(parameters) { }
|
Aht20t(String parameters) : IoTItem(parameters) {}
|
||||||
|
|
||||||
void doByInterval() {
|
void doByInterval() {
|
||||||
value.valD = temp.temperature;
|
value.valD = temp.temperature;
|
||||||
if (value.valD != -200) regEvent(value.valD, "Aht20t"); // TODO: найти способ понимания ошибки получения данных
|
if (value.valD != -200)
|
||||||
else SerialPrint("E", "Sensor AHTt", "Error");
|
regEvent(value.valD, "Aht20t"); // TODO: найти способ понимания ошибки получения данных
|
||||||
|
else
|
||||||
|
SerialPrint("E", "Sensor AHTt", "Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
~Aht20t() {};
|
~Aht20t(){};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Aht20h : public IoTItem {
|
class Aht20h : public IoTItem {
|
||||||
public:
|
public:
|
||||||
Aht20h(String parameters): IoTItem(parameters) { }
|
Aht20h(String parameters) : IoTItem(parameters) {}
|
||||||
|
|
||||||
void doByInterval() {
|
void doByInterval() {
|
||||||
value.valD = humidity.relative_humidity;
|
value.valD = humidity.relative_humidity;
|
||||||
if (value.valD != -200) regEvent(value.valD, "Aht20h"); // TODO: найти способ понимания ошибки получения данных
|
if (value.valD != -200)
|
||||||
else SerialPrint("E", "Sensor AHTt", "Error");
|
regEvent(value.valD, "Aht20h"); // TODO: найти способ понимания ошибки получения данных
|
||||||
|
else
|
||||||
|
SerialPrint("E", "Sensor AHTt", "Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
~Aht20h() {};
|
~Aht20h(){};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void* getAPI_Aht20(String subtype, String param) {
|
void* getAPI_Aht20(String subtype, String param) {
|
||||||
if (subtype == F("Aht20t")) {
|
if (subtype == F("Aht20t")) {
|
||||||
aht.begin();
|
aht.begin();
|
||||||
aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
|
aht.getEvent(&humidity, &temp); // populate temp and humidity objects with fresh data
|
||||||
return new Aht20t(param);
|
return new Aht20t(param);
|
||||||
} else if (subtype == F("Aht20h")) {
|
} else if (subtype == F("Aht20h")) {
|
||||||
aht.begin();
|
aht.begin();
|
||||||
aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
|
aht.getEvent(&humidity, &temp); // populate temp and humidity objects with fresh data
|
||||||
return new Aht20h(param);
|
return new Aht20h(param);
|
||||||
} else {
|
} else {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,33 +12,37 @@
|
|||||||
#include "ClosedCube_HDC1080.h"
|
#include "ClosedCube_HDC1080.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
//создаем объект HDC1080
|
// to do убрать глобальный экземпляр
|
||||||
ClosedCube_HDC1080 hdc1080;
|
ClosedCube_HDC1080 hdc1080;
|
||||||
|
|
||||||
class Hdc1080t : public IoTItem {
|
class Hdc1080t : public IoTItem {
|
||||||
public:
|
public:
|
||||||
Hdc1080t(String parameters): IoTItem(parameters) { }
|
Hdc1080t(String parameters) : IoTItem(parameters) {}
|
||||||
|
|
||||||
void doByInterval() {
|
void doByInterval() {
|
||||||
value.valD = hdc1080.readTemperature();
|
value.valD = hdc1080.readTemperature();
|
||||||
if (value.valD < 124) regEvent(value.valD, "Hdc1080t");
|
if (value.valD < 124)
|
||||||
else SerialPrint("E", "Sensor Hdc1080t", "Error");
|
regEvent(value.valD, "Hdc1080t");
|
||||||
|
else
|
||||||
|
SerialPrint("E", "Sensor Hdc1080t", "Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
~Hdc1080t() {};
|
~Hdc1080t(){};
|
||||||
};
|
};
|
||||||
|
|
||||||
class Hdc1080h : public IoTItem {
|
class Hdc1080h : public IoTItem {
|
||||||
public:
|
public:
|
||||||
Hdc1080h(String parameters): IoTItem(parameters) { }
|
Hdc1080h(String parameters) : IoTItem(parameters) {}
|
||||||
|
|
||||||
void doByInterval() {
|
void doByInterval() {
|
||||||
value.valD = hdc1080.readHumidity();
|
value.valD = hdc1080.readHumidity();
|
||||||
if (value.valD < 99 ) regEvent(value.valD, "Hdc1080h");
|
if (value.valD < 99)
|
||||||
else SerialPrint("E", "Sensor Hdc1080h", "Error");
|
regEvent(value.valD, "Hdc1080h");
|
||||||
|
else
|
||||||
|
SerialPrint("E", "Sensor Hdc1080h", "Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
~Hdc1080h() {};
|
~Hdc1080h(){};
|
||||||
};
|
};
|
||||||
|
|
||||||
void* getAPI_Hdc1080(String subtype, String param) {
|
void* getAPI_Hdc1080(String subtype, String param) {
|
||||||
|
|||||||
45
src/modules/sensors/Max6675/Max6675.cpp
Normal file
45
src/modules/sensors/Max6675/Max6675.cpp
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/******************************************************************
|
||||||
|
Used MAX6675 Driver (temperature sensor)
|
||||||
|
Support for MAX6675
|
||||||
|
|
||||||
|
https://github.com/adafruit/MAX6675-library
|
||||||
|
|
||||||
|
adapted for version 4 @Serghei63
|
||||||
|
******************************************************************/
|
||||||
|
|
||||||
|
#include "Global.h"
|
||||||
|
#include "Classes/IoTItem.h"
|
||||||
|
|
||||||
|
#include "max6675.h"
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
MAX6675* thermocouple = nullptr;
|
||||||
|
|
||||||
|
class MAX6675t : public IoTItem {
|
||||||
|
public:
|
||||||
|
MAX6675t(String parameters) : IoTItem(parameters) {
|
||||||
|
int thermoDO = jsonReadInt(parameters, "DO");
|
||||||
|
int thermoCS = jsonReadInt(parameters, "CS");
|
||||||
|
int thermoCLK = jsonReadInt(parameters, "CLK");
|
||||||
|
thermocouple = new MAX6675(thermoCLK, thermoCS, thermoDO);
|
||||||
|
}
|
||||||
|
|
||||||
|
void doByInterval() {
|
||||||
|
value.valD = thermocouple->readCelsius();
|
||||||
|
if (String(value.valD) != "nan") {
|
||||||
|
regEvent(value.valD, "Max6675t");
|
||||||
|
} else {
|
||||||
|
SerialPrint("E", "Sensor Max6675t", "Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~MAX6675t(){};
|
||||||
|
};
|
||||||
|
|
||||||
|
void* getAPI_Max6675(String subtype, String param) {
|
||||||
|
if (subtype == F("Max6675t")) {
|
||||||
|
return new MAX6675t(param);
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/modules/sensors/Max6675/items.json
Normal file
16
src/modules/sensors/Max6675/items.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "Cенсор температуры MAX6675",
|
||||||
|
"num": 31,
|
||||||
|
"type": "Reading",
|
||||||
|
"subtype": "Max6675t",
|
||||||
|
"id": "maxtmp",
|
||||||
|
"widget": "anydataTmp",
|
||||||
|
"page": "Сенсоры",
|
||||||
|
"descr": "MAX Температура",
|
||||||
|
"int": 15,
|
||||||
|
"DO": 12,
|
||||||
|
"CS": 13,
|
||||||
|
"CLK": 14
|
||||||
|
}
|
||||||
|
]
|
||||||
8
src/modules/sensors/Max6675/platformio.ini
Normal file
8
src/modules/sensors/Max6675/platformio.ini
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[env:esp8266_4mb]
|
||||||
|
lib_deps =
|
||||||
|
adafruit/MAX6675 library
|
||||||
|
|
||||||
|
[env:esp32_4mb]
|
||||||
|
lib_deps =
|
||||||
|
adafruit/MAX6675 library
|
||||||
|
|
||||||
@@ -17,6 +17,7 @@ extern IoTGpio IoTgpio;
|
|||||||
//встроена в ядро для 8266, для 32 по этому же имени обращаемся к другой библиотеке plerup/EspSoftwareSerial
|
//встроена в ядро для 8266, для 32 по этому же имени обращаемся к другой библиотеке plerup/EspSoftwareSerial
|
||||||
#include <SoftwareSerial.h>
|
#include <SoftwareSerial.h>
|
||||||
|
|
||||||
|
// to do убрать глобальный экземпляр
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
int rxPinSDS = 13; // D7 – подключаем к Tx сенсора
|
int rxPinSDS = 13; // D7 – подключаем к Tx сенсора
|
||||||
int txPinSDS = 12; // D6 – подключаем к Rx сенсора
|
int txPinSDS = 12; // D6 – подключаем к Rx сенсора
|
||||||
|
|||||||
Reference in New Issue
Block a user