mirror of https://github.com/arendst/Tasmota.git
Add support for sensor DHT family using Shelly Add-On
- Fix Hass sensor discovery part 1/4 by Federico Leoni (#7582, #7548) - Add support for sensor DHT family on Shelly 1 and Shelly 1PM using Shelly Add-On adapter (#7469)
This commit is contained in:
parent
c067da6d21
commit
12f603cc59
|
@ -70,6 +70,7 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
|||
- Fix ``PowerDelta`` zero power detection (#7515)
|
||||
- Fix ``RGBWWTable`` ignored (#7572)
|
||||
- Fix PWM flickering at low levels (#7415)
|
||||
- Fix Hass sensor discovery part 1/4 by Federico Leoni (#7582, #7548)
|
||||
- Add command ``SetOption79 0/1`` to enable reset of counters at teleperiod time by Andre Thomas (#7355)
|
||||
- Add command ``SetOption82 0/1`` to limit the CT range for Alexa to 200..380
|
||||
- Add command ``SetOption84 1`` to send AWS IoT device shadow updates (alternative to retained)
|
||||
|
@ -90,3 +91,4 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
|||
- Add optional parameter <startcolor> to command ``Scheme <scheme>, <startcolor>`` to control initial start color
|
||||
- Add rule trigger on one level deeper using syntax with two ``#`` like ``on zigbeereceived#vibration_sensor#aqaracubeside=0 do ...``
|
||||
- Add support for sensor DS18x20 on Shelly 1 and Shelly 1PM using Shelly Add-On adapter (#7469)
|
||||
- Add support for sensor DHT family on Shelly 1 and Shelly 1PM using Shelly Add-On adapter (#7469)
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
### 8.1.0.6 20200205
|
||||
|
||||
- Fix Hass sensor discovery part 1/4 by Federico Leoni (#7582, #7548)
|
||||
- Add support for sensor DS18x20 on Shelly 1 and Shelly 1PM using Shelly Add-On adapter (#7469)
|
||||
- Add support for sensor DHT family on Shelly 1 and Shelly 1PM using Shelly Add-On adapter (#7469)
|
||||
|
||||
### 8.1.0.5 20200126
|
||||
|
||||
|
|
|
@ -217,6 +217,7 @@ enum UserSelectablePins {
|
|||
GPIO_GPS_RX, // GPS serial interface
|
||||
GPIO_GPS_TX, // GPS serial interface
|
||||
GPIO_DSB_OUT, // Pseudo Single wire DS18B20 or DS18S20
|
||||
GPIO_DHT11_OUT, // Pseudo Single wire DHT11, DHT21, DHT22, AM2301, AM2302, AM2321
|
||||
GPIO_SENSOR_END };
|
||||
|
||||
// Programmer selectable GPIO functionality
|
||||
|
@ -298,7 +299,7 @@ const char kSensorNames[] PROGMEM =
|
|||
D_SENSOR_SLAVE_TX "|" D_SENSOR_SLAVE_RX "|" D_SENSOR_SLAVE_RESET "|" D_SENSOR_SLAVE_RESET "i|"
|
||||
D_SENSOR_HPMA_RX "|" D_SENSOR_HPMA_TX "|"
|
||||
D_SENSOR_GPS_RX "|" D_SENSOR_GPS_TX "|"
|
||||
D_SENSOR_DS18X20 "o|"
|
||||
D_SENSOR_DS18X20 "o|" D_SENSOR_DHT11 "o|"
|
||||
;
|
||||
|
||||
const char kSensorNamesFixed[] PROGMEM =
|
||||
|
@ -561,6 +562,7 @@ const uint8_t kGpioNiceList[] PROGMEM = {
|
|||
GPIO_DHT11, // DHT11
|
||||
GPIO_DHT22, // DHT21, DHT22, AM2301, AM2302, AM2321
|
||||
GPIO_SI7021, // iTead SI7021
|
||||
GPIO_DHT11_OUT, // Pseudo Single wire DHT11, DHT21, DHT22, AM2301, AM2302, AM2321
|
||||
#endif
|
||||
#ifdef USE_DS18x20
|
||||
GPIO_DSB, // Single wire DS18B20 or DS18S20
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
uint32_t dht_max_cycles;
|
||||
uint8_t dht_data[5];
|
||||
uint8_t dht_sensors = 0;
|
||||
uint8_t dht_pin_out = 0; // Shelly GPIO00 output only
|
||||
bool dht_active = true; // DHT configured
|
||||
bool dht_dual_mode = false; // Single pin mode
|
||||
|
||||
struct DHTSTRUCT {
|
||||
uint8_t pin;
|
||||
|
@ -49,7 +51,11 @@ struct DHTSTRUCT {
|
|||
void DhtReadPrep(void)
|
||||
{
|
||||
for (uint32_t i = 0; i < dht_sensors; i++) {
|
||||
digitalWrite(Dht[i].pin, HIGH);
|
||||
if (!dht_dual_mode) {
|
||||
digitalWrite(Dht[i].pin, HIGH);
|
||||
} else {
|
||||
digitalWrite(dht_pin_out, HIGH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,11 +83,19 @@ bool DhtRead(uint8_t sensor)
|
|||
|
||||
if (Dht[sensor].lastresult > DHT_MAX_RETRY) {
|
||||
Dht[sensor].lastresult = 0;
|
||||
digitalWrite(Dht[sensor].pin, HIGH); // Retry read prep
|
||||
if (!dht_dual_mode) {
|
||||
digitalWrite(Dht[sensor].pin, HIGH); // Retry read prep
|
||||
} else {
|
||||
digitalWrite(dht_pin_out, HIGH);
|
||||
}
|
||||
delay(250);
|
||||
}
|
||||
pinMode(Dht[sensor].pin, OUTPUT);
|
||||
digitalWrite(Dht[sensor].pin, LOW);
|
||||
if (!dht_dual_mode) {
|
||||
pinMode(Dht[sensor].pin, OUTPUT);
|
||||
digitalWrite(Dht[sensor].pin, LOW);
|
||||
} else {
|
||||
digitalWrite(dht_pin_out, LOW);
|
||||
}
|
||||
|
||||
if (GPIO_SI7021 == Dht[sensor].type) {
|
||||
delayMicroseconds(500);
|
||||
|
@ -90,9 +104,14 @@ bool DhtRead(uint8_t sensor)
|
|||
}
|
||||
|
||||
noInterrupts();
|
||||
digitalWrite(Dht[sensor].pin, HIGH);
|
||||
delayMicroseconds(40);
|
||||
pinMode(Dht[sensor].pin, INPUT_PULLUP);
|
||||
if (!dht_dual_mode) {
|
||||
digitalWrite(Dht[sensor].pin, HIGH);
|
||||
delayMicroseconds(40);
|
||||
pinMode(Dht[sensor].pin, INPUT_PULLUP);
|
||||
} else {
|
||||
digitalWrite(dht_pin_out, HIGH);
|
||||
delayMicroseconds(40);
|
||||
}
|
||||
delayMicroseconds(10);
|
||||
if (-1 == DhtExpectPulse(sensor, LOW)) {
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT D_TIMEOUT_WAITING_FOR " " D_START_SIGNAL_LOW " " D_PULSE));
|
||||
|
@ -109,6 +128,7 @@ bool DhtRead(uint8_t sensor)
|
|||
}
|
||||
}
|
||||
interrupts();
|
||||
|
||||
if (error) { return false; }
|
||||
|
||||
for (uint32_t i = 0; i < 40; ++i) {
|
||||
|
@ -187,6 +207,13 @@ void DhtInit(void)
|
|||
if (dht_sensors) {
|
||||
dht_max_cycles = microsecondsToClockCycles(1000); // 1 millisecond timeout for reading pulses from DHT sensor.
|
||||
|
||||
if (pin[GPIO_DHT11_OUT] < 99) {
|
||||
dht_pin_out = pin[GPIO_DHT11_OUT];
|
||||
dht_dual_mode = true; // Dual pins mode as used by Shelly
|
||||
dht_sensors = 1; // We only support one sensor in pseudo mode
|
||||
pinMode(dht_pin_out, OUTPUT);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < dht_sensors; i++) {
|
||||
pinMode(Dht[i].pin, INPUT_PULLUP);
|
||||
Dht[i].lastreadtime = 0;
|
||||
|
@ -196,6 +223,7 @@ void DhtInit(void)
|
|||
snprintf_P(Dht[i].stype, sizeof(Dht[i].stype), PSTR("%s%c%02d"), Dht[i].stype, IndexSeparator(), Dht[i].pin);
|
||||
}
|
||||
}
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT D_SENSORS_FOUND " %d"), dht_sensors);
|
||||
} else {
|
||||
dht_active = false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue