mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 11:16:34 +00:00
Merge branch 'development' into pre-release-12.3
This commit is contained in:
commit
1e86a9a8cf
@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file.
|
||||
- TasmotaSerial ``read(buffer, size)`` regression from v9.3.0
|
||||
- RCSwitch exception 0/6 on some protocols (#17285)
|
||||
- ESP32 exception 28 when RtcNtpServer is enabled on restart (#17338)
|
||||
- Analog MQ exception 28 on restart (#17271)
|
||||
|
||||
## [12.2.0.5] 20221129
|
||||
### Added
|
||||
|
@ -165,6 +165,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
|
||||
- ModbusBridge buffer overflow [#16979](https://github.com/arendst/Tasmota/issues/16979)
|
||||
- ModbusBridge baudrates over 76500 baud [#17106](https://github.com/arendst/Tasmota/issues/17106)
|
||||
- SenseAir S8 module detection [#17033](https://github.com/arendst/Tasmota/issues/17033)
|
||||
- Analog MQ exception 28 on restart [#17271](https://github.com/arendst/Tasmota/issues/17271)
|
||||
- RCSwitch exception 0/6 on some protocols [#17285](https://github.com/arendst/Tasmota/issues/17285)
|
||||
- ESP32 exception 28 when RtcNtpServer is enabled on restart [#17338](https://github.com/arendst/Tasmota/issues/17338)
|
||||
|
||||
|
@ -463,6 +463,7 @@ size_t TasmotaSerial::write(uint8_t b) {
|
||||
size = 1;
|
||||
}
|
||||
if (m_tx_enable_valid) {
|
||||
delay(1);
|
||||
digitalWrite(m_tx_enable_pin, LOW);
|
||||
}
|
||||
return size;
|
||||
|
@ -27,7 +27,7 @@ enum LoggingLevels {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_D
|
||||
|
||||
//#define TASMOTAMODBUSDEBUG
|
||||
|
||||
TasmotaModbus::TasmotaModbus(int receive_pin, int transmit_pin, int tx_enable_pin) : TasmotaSerial(receive_pin, transmit_pin, 1)
|
||||
TasmotaModbus::TasmotaModbus(int receive_pin, int transmit_pin, int tx_enable_pin) : TasmotaSerial(receive_pin, transmit_pin, 2)
|
||||
{
|
||||
setTransmitEnablePin(tx_enable_pin);
|
||||
mb_address = 0;
|
||||
|
@ -316,7 +316,7 @@ autoconf_module.init = def (m)
|
||||
var line = f.readline() # read each line, can contain a terminal '\n', empty if end of file
|
||||
if size(line) == 0 break end # end of file
|
||||
|
||||
if line[-1] == "\n" line = line[0..-2] end # remove any trailing '\n'
|
||||
while (size(line) > 0 && (line[-1] == "\n" || line[-1] == "\r")) line = line[0..-2] end # remove any trailing '\n' or '\r'
|
||||
if size(line) > 0
|
||||
tasmota.cmd(line) # run the command
|
||||
end
|
||||
|
@ -362,31 +362,32 @@ be_local_closure(Autoconf_run_bat, /* name */
|
||||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[10]) { /* constants */
|
||||
( &(const bvalue[11]) { /* constants */
|
||||
/* K0 */ be_nested_str(string),
|
||||
/* K1 */ be_nested_str(r),
|
||||
/* K2 */ be_nested_str(readline),
|
||||
/* K3 */ be_const_int(0),
|
||||
/* K4 */ be_nested_str(_X0A),
|
||||
/* K5 */ be_nested_str(tasmota),
|
||||
/* K6 */ be_nested_str(cmd),
|
||||
/* K7 */ be_nested_str(close),
|
||||
/* K8 */ be_nested_str(format),
|
||||
/* K9 */ be_nested_str(CFG_X3A_X20could_X20not_X20run_X20_X25s_X20_X28_X25s_X20_X2D_X20_X25s_X29),
|
||||
/* K5 */ be_nested_str(_X0D),
|
||||
/* K6 */ be_nested_str(tasmota),
|
||||
/* K7 */ be_nested_str(cmd),
|
||||
/* K8 */ be_nested_str(close),
|
||||
/* K9 */ be_nested_str(format),
|
||||
/* K10 */ be_nested_str(CFG_X3A_X20could_X20not_X20run_X20_X25s_X20_X28_X25s_X20_X2D_X20_X25s_X29),
|
||||
}),
|
||||
&be_const_str_run_bat,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[54]) { /* code */
|
||||
( &(const binstruction[64]) { /* code */
|
||||
0xA40A0000, // 0000 IMPORT R2 K0
|
||||
0x4C0C0000, // 0001 LDNIL R3
|
||||
0xA8020023, // 0002 EXBLK 0 #0027
|
||||
0xA802002D, // 0002 EXBLK 0 #0031
|
||||
0x60100011, // 0003 GETGBL R4 G17
|
||||
0x5C140200, // 0004 MOVE R5 R1
|
||||
0x58180001, // 0005 LDCONST R6 K1
|
||||
0x7C100400, // 0006 CALL R4 2
|
||||
0x5C0C0800, // 0007 MOVE R3 R4
|
||||
0x50100200, // 0008 LDBOOL R4 1 0
|
||||
0x78120018, // 0009 JMPF R4 #0023
|
||||
0x78120022, // 0009 JMPF R4 #002D
|
||||
0x8C100702, // 000A GETMET R4 R3 K2
|
||||
0x7C100200, // 000B CALL R4 1
|
||||
0x6014000C, // 000C GETGBL R5 G12
|
||||
@ -394,43 +395,53 @@ be_local_closure(Autoconf_run_bat, /* name */
|
||||
0x7C140200, // 000E CALL R5 1
|
||||
0x1C140B03, // 000F EQ R5 R5 K3
|
||||
0x78160000, // 0010 JMPF R5 #0012
|
||||
0x70020010, // 0011 JMP #0023
|
||||
0x5415FFFE, // 0012 LDINT R5 -1
|
||||
0x94140805, // 0013 GETIDX R5 R4 R5
|
||||
0x1C140B04, // 0014 EQ R5 R5 K4
|
||||
0x78160002, // 0015 JMPF R5 #0019
|
||||
0x5415FFFD, // 0016 LDINT R5 -2
|
||||
0x40160605, // 0017 CONNECT R5 K3 R5
|
||||
0x94100805, // 0018 GETIDX R4 R4 R5
|
||||
0x6014000C, // 0019 GETGBL R5 G12
|
||||
0x5C180800, // 001A MOVE R6 R4
|
||||
0x7C140200, // 001B CALL R5 1
|
||||
0x24140B03, // 001C GT R5 R5 K3
|
||||
0x78160003, // 001D JMPF R5 #0022
|
||||
0xB8160A00, // 001E GETNGBL R5 K5
|
||||
0x8C140B06, // 001F GETMET R5 R5 K6
|
||||
0x5C1C0800, // 0020 MOVE R7 R4
|
||||
0x7C140400, // 0021 CALL R5 2
|
||||
0x7001FFE4, // 0022 JMP #0008
|
||||
0x8C100707, // 0023 GETMET R4 R3 K7
|
||||
0x7C100200, // 0024 CALL R4 1
|
||||
0xA8040001, // 0025 EXBLK 1 1
|
||||
0x7002000D, // 0026 JMP #0035
|
||||
0xAC100002, // 0027 CATCH R4 0 2
|
||||
0x7002000A, // 0028 JMP #0034
|
||||
0x60180001, // 0029 GETGBL R6 G1
|
||||
0x8C1C0508, // 002A GETMET R7 R2 K8
|
||||
0x58240009, // 002B LDCONST R9 K9
|
||||
0x5C280200, // 002C MOVE R10 R1
|
||||
0x5C2C0800, // 002D MOVE R11 R4
|
||||
0x5C300A00, // 002E MOVE R12 R5
|
||||
0x7C1C0A00, // 002F CALL R7 5
|
||||
0x7C180200, // 0030 CALL R6 1
|
||||
0x8C180707, // 0031 GETMET R6 R3 K7
|
||||
0x7C180200, // 0032 CALL R6 1
|
||||
0x70020000, // 0033 JMP #0035
|
||||
0xB0080000, // 0034 RAISE 2 R0 R0
|
||||
0x80000000, // 0035 RET 0
|
||||
0x7002001A, // 0011 JMP #002D
|
||||
0x6014000C, // 0012 GETGBL R5 G12
|
||||
0x5C180800, // 0013 MOVE R6 R4
|
||||
0x7C140200, // 0014 CALL R5 1
|
||||
0x24140B03, // 0015 GT R5 R5 K3
|
||||
0x7816000B, // 0016 JMPF R5 #0023
|
||||
0x5415FFFE, // 0017 LDINT R5 -1
|
||||
0x94140805, // 0018 GETIDX R5 R4 R5
|
||||
0x1C140B04, // 0019 EQ R5 R5 K4
|
||||
0x74160003, // 001A JMPT R5 #001F
|
||||
0x5415FFFE, // 001B LDINT R5 -1
|
||||
0x94140805, // 001C GETIDX R5 R4 R5
|
||||
0x1C140B05, // 001D EQ R5 R5 K5
|
||||
0x78160003, // 001E JMPF R5 #0023
|
||||
0x5415FFFD, // 001F LDINT R5 -2
|
||||
0x40160605, // 0020 CONNECT R5 K3 R5
|
||||
0x94100805, // 0021 GETIDX R4 R4 R5
|
||||
0x7001FFEE, // 0022 JMP #0012
|
||||
0x6014000C, // 0023 GETGBL R5 G12
|
||||
0x5C180800, // 0024 MOVE R6 R4
|
||||
0x7C140200, // 0025 CALL R5 1
|
||||
0x24140B03, // 0026 GT R5 R5 K3
|
||||
0x78160003, // 0027 JMPF R5 #002C
|
||||
0xB8160C00, // 0028 GETNGBL R5 K6
|
||||
0x8C140B07, // 0029 GETMET R5 R5 K7
|
||||
0x5C1C0800, // 002A MOVE R7 R4
|
||||
0x7C140400, // 002B CALL R5 2
|
||||
0x7001FFDA, // 002C JMP #0008
|
||||
0x8C100708, // 002D GETMET R4 R3 K8
|
||||
0x7C100200, // 002E CALL R4 1
|
||||
0xA8040001, // 002F EXBLK 1 1
|
||||
0x7002000D, // 0030 JMP #003F
|
||||
0xAC100002, // 0031 CATCH R4 0 2
|
||||
0x7002000A, // 0032 JMP #003E
|
||||
0x60180001, // 0033 GETGBL R6 G1
|
||||
0x8C1C0509, // 0034 GETMET R7 R2 K9
|
||||
0x5824000A, // 0035 LDCONST R9 K10
|
||||
0x5C280200, // 0036 MOVE R10 R1
|
||||
0x5C2C0800, // 0037 MOVE R11 R4
|
||||
0x5C300A00, // 0038 MOVE R12 R5
|
||||
0x7C1C0A00, // 0039 CALL R7 5
|
||||
0x7C180200, // 003A CALL R6 1
|
||||
0x8C180708, // 003B GETMET R6 R3 K8
|
||||
0x7C180200, // 003C CALL R6 1
|
||||
0x70020000, // 003D JMP #003F
|
||||
0xB0080000, // 003E RAISE 2 R0 R0
|
||||
0x80000000, // 003F RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
|
@ -893,6 +893,7 @@ bool WifiHostByName(const char* aHostname, IPAddress& aResult) {
|
||||
}
|
||||
#else
|
||||
// DnsClient can't do one-shot mDNS queries so use WiFi.hostByName() for *.local
|
||||
aResult = (uint32_t) 0x00000000L; // indirectly force to be IPv4, since the client touches the binary format later
|
||||
size_t hostname_len = strlen(aHostname);
|
||||
if (strstr_P(aHostname, PSTR(".local")) == &aHostname[hostname_len] - 6) {
|
||||
if (WiFi.hostByName(aHostname, aResult)) {
|
||||
|
@ -386,46 +386,55 @@ uint16_t AdcGetLux(uint32_t idx) {
|
||||
}
|
||||
|
||||
void AddSampleMq(uint32_t idx){
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Adding sample for mq-sensor"));
|
||||
// AddLog(LOG_LEVEL_DEBUG, PSTR("ADC: Adding sample for mq-sensor"));
|
||||
|
||||
int _adc = AdcRead(Adc[idx].pin, 2);
|
||||
// init af array at same value
|
||||
if (Adc[idx].indexOfPointer==-1)
|
||||
{
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Init samples for mq-sensor"));
|
||||
for (int i = 0; i < ANALOG_MQ_SAMPLES; i ++)
|
||||
if (Adc[idx].indexOfPointer==-1) {
|
||||
|
||||
// AddLog(LOG_LEVEL_DEBUG, PSTR("ADC: Init samples for mq-sensor"));
|
||||
|
||||
for (int i = 0; i < ANALOG_MQ_SAMPLES; i ++) {
|
||||
Adc[idx].mq_samples[i] = _adc;
|
||||
}
|
||||
else
|
||||
}
|
||||
} else {
|
||||
Adc[idx].mq_samples[Adc[idx].indexOfPointer] = _adc;
|
||||
}
|
||||
Adc[idx].indexOfPointer++;
|
||||
if (Adc[idx].indexOfPointer==ANALOG_MQ_SAMPLES)
|
||||
if (Adc[idx].indexOfPointer==ANALOG_MQ_SAMPLES) {
|
||||
Adc[idx].indexOfPointer=0;
|
||||
}
|
||||
}
|
||||
|
||||
float AdcGetMq(uint32_t idx) {
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Getting value for mq-sensor"));
|
||||
// AddLog(LOG_LEVEL_DEBUG, PSTR("ADC: Getting value for mq-sensor"));
|
||||
|
||||
float avg = 0.0;
|
||||
float _RL = 10; //Value in KiloOhms
|
||||
float _R0 = 10;
|
||||
for (int i = 0; i < ANALOG_MQ_SAMPLES; i ++)
|
||||
for (int i = 0; i < ANALOG_MQ_SAMPLES; i ++) {
|
||||
avg += Adc[idx].mq_samples[i];
|
||||
}
|
||||
float voltage = (avg / ANALOG_MQ_SAMPLES) * ANALOG_V33 / ANALOG_RANGE;
|
||||
|
||||
float _RS_Calc = ((ANALOG_V33 * _RL) / voltage) -_RL; //Get value of RS in a gas
|
||||
if (_RS_Calc < 0) _RS_Calc = 0; //No negative values accepted.
|
||||
float _ratio = _RS_Calc / _R0; // Get ratio RS_gas/RS_air
|
||||
float ppm= Adc[idx].param2/ANALOG_MQ_DECIMAL_MULTIPLIER*FastPrecisePow(_ratio, Adc[idx].param3/ANALOG_MQ_DECIMAL_MULTIPLIER); // <- Source excel analisis https://github.com/miguel5612/MQSensorsLib_Docs/tree/master/Internal_design_documents
|
||||
if(ppm < 0) ppm = 0; //No negative values accepted or upper datasheet recomendation.
|
||||
char ppm_chr[6];
|
||||
dtostrfd(ppm, 2, ppm_chr);
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Ppm read. ADC-RAW: %2_f, ppm: %s,"), &voltage, ppm_chr);
|
||||
float _RL = 10; // Value in KiloOhms
|
||||
float _RS_Calc = ((ANALOG_V33 * _RL) / voltage) -_RL; // Get value of RS in a gas
|
||||
if (_RS_Calc < 0) {
|
||||
_RS_Calc = 0; // No negative values accepted.
|
||||
}
|
||||
|
||||
float _R0 = 10;
|
||||
float _ratio = _RS_Calc / _R0; // Get ratio RS_gas/RS_air
|
||||
float ppm = Adc[idx].param2 / ANALOG_MQ_DECIMAL_MULTIPLIER * FastPrecisePow(_ratio, Adc[idx].param3 / ANALOG_MQ_DECIMAL_MULTIPLIER); // Source excel analisis https://github.com/miguel5612/MQSensorsLib_Docs/tree/master/Internal_design_documents
|
||||
if (ppm < 0) { ppm = 0; } // No negative values accepted or upper datasheet recomendation.
|
||||
if (ppm > 100000) { ppm = 100000; }
|
||||
|
||||
// AddLog(LOG_LEVEL_DEBUG, PSTR("ADC: Ppm read. ADC-RAW: %2_f, ppm: %2_f"), &voltage, &ppm);
|
||||
|
||||
return ppm;
|
||||
}
|
||||
|
||||
float AdcGetPh(uint32_t idx) {
|
||||
int adc = AdcRead(Adc[idx].pin, 2);
|
||||
|
||||
|
||||
float y1 = (float)Adc[idx].param1 / ANALOG_PH_DECIMAL_MULTIPLIER;
|
||||
int32_t x1 = Adc[idx].param2;
|
||||
float y2 = (float)Adc[idx].param3 / ANALOG_PH_DECIMAL_MULTIPLIER;
|
||||
@ -434,12 +443,7 @@ float AdcGetPh(uint32_t idx) {
|
||||
float m = (y2 - y1) / (float)(x2 - x1);
|
||||
float ph = m * (float)(adc - x1) + y1;
|
||||
|
||||
|
||||
char phLow_chr[6];
|
||||
char phHigh_chr[6];
|
||||
dtostrfd(y1, 2, phLow_chr);
|
||||
dtostrfd(y2, 2, phHigh_chr);
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Analog pH read. ADC-RAW: %d, cal-low(pH=ADC): %s=%d, cal-high(pH=ADC): %s=%d"), adc, phLow_chr, x1, phHigh_chr,x2);
|
||||
// AddLog(LOG_LEVEL_DEBUG, PSTR("ADC: Analog pH read. ADC-RAW: %d, cal-low(pH=ADC): %2_f = %d, cal-high(pH=ADC): %2_f = %d"), adc, &y1, x1, &y2, x2);
|
||||
|
||||
return ph;
|
||||
}
|
||||
@ -666,10 +670,9 @@ void AdcShow(bool json) {
|
||||
}
|
||||
case ADC_PH: {
|
||||
float ph = AdcGetPh(idx);
|
||||
char ph_chr[6];
|
||||
char ph_chr[FLOATSZ];
|
||||
dtostrfd(ph, 2, ph_chr);
|
||||
|
||||
|
||||
if (json) {
|
||||
AdcShowContinuation(&jsonflg);
|
||||
ResponseAppend_P(PSTR("\"pH%d\":%s"), idx + offset, ph_chr);
|
||||
@ -682,11 +685,11 @@ void AdcShow(bool json) {
|
||||
}
|
||||
case ADC_MQ: {
|
||||
float mq = AdcGetMq(idx);
|
||||
char mq_chr[6];
|
||||
char mq_chr[FLOATSZ];
|
||||
dtostrfd(mq, 2, mq_chr);
|
||||
|
||||
float mqnumber =Adc[idx].param1;
|
||||
char mqnumber_chr[6];
|
||||
char mqnumber_chr[FLOATSZ];
|
||||
dtostrfd(mqnumber, 0, mqnumber_chr);
|
||||
|
||||
if (json) {
|
||||
@ -754,8 +757,8 @@ void CmndAdcParam(void) {
|
||||
Adc[idx].param2 = strtol(ArgV(argument, 3), nullptr, 10);
|
||||
Adc[idx].param3 = phHigh * ANALOG_PH_DECIMAL_MULTIPLIER;
|
||||
Adc[idx].param4 = strtol(ArgV(argument, 5), nullptr, 10);
|
||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Analog pH probe calibrated. cal-low(pH=ADC) %2_f=%d, cal-high(pH=ADC) %2_f=%d"),
|
||||
&phLow, Adc[idx].param2, &phHigh, Adc[idx].param4);
|
||||
|
||||
// AddLog(LOG_LEVEL_INFO, PSTR("ADC: Analog pH probe calibrated. cal-low(pH=ADC) %2_f = %d, cal-high(pH=ADC) %2_f = %d"), &phLow, Adc[idx].param2, &phHigh, Adc[idx].param4);
|
||||
}
|
||||
if (ADC_CT_POWER == XdrvMailbox.payload) {
|
||||
if (((1 == Adc[idx].param1) & CT_FLAG_ENERGY_RESET) > 0) {
|
||||
@ -796,11 +799,11 @@ void CmndAdcParam(void) {
|
||||
ratioMQCleanAir=15;
|
||||
}
|
||||
}
|
||||
Adc[idx].param2 = (int)(a * ANALOG_MQ_DECIMAL_MULTIPLIER); // Exponential regression
|
||||
Adc[idx].param3 = (int)(b * ANALOG_MQ_DECIMAL_MULTIPLIER); // Exponential regression
|
||||
Adc[idx].param4 = (int)(ratioMQCleanAir * ANALOG_MQ_DECIMAL_MULTIPLIER); // Exponential regression
|
||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Analog MQ reset: mq%d, a=%2_f, b=%2_f, ratioMQCleanAir=%2_f"),
|
||||
Adc[idx].param1, &a, &b, &ratioMQCleanAir);
|
||||
Adc[idx].param2 = (int)(a * ANALOG_MQ_DECIMAL_MULTIPLIER); // Exponential regression
|
||||
Adc[idx].param3 = (int)(b * ANALOG_MQ_DECIMAL_MULTIPLIER); // Exponential regression
|
||||
Adc[idx].param4 = (int)(ratioMQCleanAir * ANALOG_MQ_DECIMAL_MULTIPLIER); // Exponential regression
|
||||
|
||||
// AddLog(LOG_LEVEL_INFO, PSTR("ADC: MQ reset mq%d, a = %2_f, b = %2_f, ratioMQCleanAir = %2_f"), Adc[idx].param1, &a, &b, &ratioMQCleanAir);
|
||||
}
|
||||
} else { // Set default values based on current adc type
|
||||
// AdcParam 2
|
||||
@ -829,7 +832,7 @@ void CmndAdcParam(void) {
|
||||
if (value % 10) { break; }
|
||||
value /= 10;
|
||||
}
|
||||
char param3[33];
|
||||
char param3[FLOATSZ];
|
||||
dtostrfd(((double)Adc[idx].param3)/10000, precision, param3);
|
||||
ResponseAppend_P(PSTR(",%s,%d"), param3, Adc[idx].param4);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user