Sensor Polling interval in Tasmota and sending over MQTT

9,329 views
Skip to first unread message

Dimitar Tsvetkov

unread,
Feb 23, 2021, 5:30:06 AM2/23/21
to TasmotaUsers
Hi,
I am using a lot of sensors for temperature, humidity, light, dust particles, etc... I use Arduino IDE to program ESP 8266. I am considering moving to Tasmota, but can not find in the documentation if I can control how often a certain sensor will be read and sent over MQTT.
Is is possible to control how often particular sensor will be read. Fro example to read the temperature sensor every  5 min and to read the Nova Dust particle sensor every 15 min and send it over MQTT to Home Assistant(both sensors are connected to the same ESP).
Can you point me to the documentation where I can read more on this topic ?
Thanks,

sfromis

unread,
Feb 23, 2021, 6:17:45 AM2/23/21
to TasmotaUsers
Reporting over MQTT is by the TelePeriod command/setting, which is not by sensor. Unless drivers have special handling, sensors are read continuously (about every second). For the "Nova Fitness SDS011 dust sensor", the command Sensor20 controls the "number of seconds before TelePeriod to poll the sensor", implying that it is "only" polled once per TelePeriod. Since most other sensors are polled continuously, it would be possible to have TelePeriod set to the slowest interval, and have rules to report selected sensor values at other intervals.

Philip Knowles

unread,
Feb 23, 2021, 6:24:18 AM2/23/21
to Dimitar Tsvetkov, TasmotaUsers

Yes and no. If you set the Teleperiod to 900 (15 minutes) then all the sensors would send the information every 15 minutes. See

Commands - Tasmota

To get other sensors to send the information every 5 minutes you would need to use a Rule

A combination of a trigger of Time#Minute|5 and this Rule

Rules - Tasmota

Should do it.

 

Regards

 

Phil K

 

 

Sent from Mail for Windows 10

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/d1e81694-1994-4e73-a1a2-712ef7667e38n%40googlegroups.com.

 

Dimitar Tsvetkov

unread,
Feb 23, 2021, 8:34:35 AM2/23/21
to TasmotaUsers
Many thanks for the answers !!!

So if I understood correctly, generally sensors are read almost second and there is no parameter to control this. Probably this is controlled by the driver for each sensor and is not exposed for configuration. I can control only how often Tasman publishes sensor state over MQTT by using TelePeriod command.

Also I see that Sensor20 parameter is up from 0 to 255 seconds, which is less than 5 min.
Problem comes with the Nova SDS011, since it has limited life. If the fan works constantly, the life of the sensor will be around 6 months. In order to extend the life of the sensor, I start it for 30 sec to calibrate, take the measurement and than put the SDS in sleep mode for 14-15 min. After this I wake it again, calibrate for 30 sec and again take measurement. This is  efficient, since dust particles don't change so often and extends the sensor life to several years.
Is it possible for me to implement such logic by extending the Tasmota  functionality somehow ? I see similar topics mentioned also by other users, but did not understand what is the proffered approach to address it.

Thanks !

benjam...@t-online.de

unread,
Feb 23, 2021, 8:59:06 AM2/23/21
to TasmotaUsers
Interesting discussion. This raises the question regarding what webrefreh does. If I set webrefresh to 10 seconds, is the sensor read 10 times and only ervery 10th result is published on the webinterface, or is just read once in 10 seconds?
I had experimented with this parameter on a BME280, which shows excessive self-heating when read every second. I had the impression setting webrefreh to 10 seconds improves the behavior. 
Second question: does this depend on the values being read via webinterface? That means, no browser open to read values, no sensor read, browser open, sensor read in the interval defined by webrefresh?

Philip Knowles

unread,
Feb 23, 2021, 11:00:26 AM2/23/21
to benjam...@t-online.de, TasmotaUsers

AFAIK webrefresh only affect the UI updates to reduce the load on the processor and doesn’t affect the reading rates which are set in the driver(s).

 

As for Sensor20 the setting is the time BEFORE the next Teleperiod that it will poll the sensor so in the use case described Sensor20 35 would poll the sensor 35 seconds before the Teleperiod to get the reading for the next MQTT output. I don’t know if it switches the device on but, if it doesn’t,  you could power the sensor from a GPIO and power up, say, 1 minute before Teleperiod.

 

Regards

 

Phil K

 

Sent from Mail for Windows 10

 

Dimitar Tsvetkov

unread,
Feb 23, 2021, 11:21:39 AM2/23/21
to TasmotaUsers
Thanks Phil,
I have missed the "BEFORE" statement in the documentation.
From the docs, for me seems that Teleperiod is applicable mainly for the MQTT. Still I am trying to understand what is the mechanism Tasmota uses to poll the sensors and update the status of each sensor- is it based on time interval - every 1 or 5 seconds for example - and is it possible to be controlled somehow. Can you point me to some documentation or source code on this topic ?

Thanks,

Philip Knowles

unread,
Feb 23, 2021, 11:55:20 AM2/23/21
to Dimitar Tsvetkov, TasmotaUsers

Most of the drivers are on GitHub and have an associated readme or just an .ino which explain how the sensor driver works.

For the BME280 (mentioned in the thread) the advanced settings.ino has the following

/*    

    // humidity sensing

    Serial.println("-- Humidity Sensing Scenario --");

    Serial.println("forced mode, 1x temperature / 1x humidity / 0x pressure oversampling");

    Serial.println("= pressure off, filter off");

    bme.setSampling(Adafruit_BME280::MODE_FORCED,

                    Adafruit_BME280::SAMPLING_X1,   // temperature

                    Adafruit_BME280::SAMPLING_NONE, // pressure

                    Adafruit_BME280::SAMPLING_X1,   // humidity

                    Adafruit_BME280::FILTER_OFF );

                      

    // suggested rate is 1Hz (1s)

    delayTime = 1000;  // in milliseconds

*/

So humidity sensing is read once a second.

sfromis

unread,
Feb 23, 2021, 12:23:19 PM2/23/21
to TasmotaUsers
My BME280 devices show **no** self-heating when read every second. I've verified using a thermal camera. You should not use 5v, even for modules supporting that, as the voltage regulator for that may generate heat when burning to the lower voltage.

There is no standard mechanism for regulating how often sensors are polled. Unless specific drivers (like for PM sensors with "special needs") have provisions for slower polling, you do not have the option.

Reply all
Reply to author
Forward
0 new messages