flyte / mqtt-io

Expose GPIO modules (Raspberry Pi, Beaglebone, PCF8754, PiFace2 etc.) and digital sensors (LM75 etc.) to an MQTT server for remote control and monitoring.
MIT License
464 stars 157 forks source link

Sensor polling interval not working #67

Closed SkySails closed 1 year ago

SkySails commented 5 years ago

The polling interval as set in the configuration is not reflected on the update intervals of the sensors when the server is running. The actual interval is sporadic and unnecessary high.

Configuration

sensor_modules:
  - name: dht22
    module: dht22
    type: dht11 # can be  DHT11, DHT22 or AM2302
    pin: 4

sensor_inputs:
  - name: temperature
    module: dht22
    interval: 10 #interval in seconds, that a value is read from the sensor and a update is published
    digits: 4 # number of digits to be round
    type: temperature

  - name: humidity
    module: dht22
    interval: 10 #interval in seconds, that a value is read from the sensor and a update is published
    digits: 4 # number of digits to be round
    type: humidity

Logs

2019-06-14 14:46:02,422 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'humidity' value 42.0
2019-06-14 14:46:09,354 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'temperature' value 28.0
2019-06-14 14:46:12,422 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'humidity' value 42.0
2019-06-14 14:46:19,356 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'temperature' value 28.0
2019-06-14 14:46:22,424 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'humidity' value 40.0
2019-06-14 14:46:29,349 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'temperature' value 28.0
2019-06-14 14:46:32,417 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'humidity' value 40.0
2019-06-14 14:46:39,350 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'temperature' value 28.0
2019-06-14 14:46:42,420 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'humidity' value 40.0
2019-06-14 14:46:49,353 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'temperature' value 28.0
2019-06-14 14:46:52,421 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'humidity' value 40.0
2019-06-14 14:46:59,353 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'temperature' value 28.0
2019-06-14 14:47:02,423 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'humidity' value 40.0
2019-06-14 14:47:09,349 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'temperature' value 28.0
2019-06-14 14:47:14,945 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'humidity' value 40.0
2019-06-14 14:47:24,410 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'temperature' value 28.0
2019-06-14 14:47:27,480 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'humidity' value 40.0
2019-06-14 14:47:29,349 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'temperature' value 28.0
2019-06-14 14:47:37,482 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'humidity' value 40.0
2019-06-14 14:47:39,349 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'temperature' value 28.0
2019-06-14 14:47:44,944 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'humidity' value 40.0
2019-06-14 14:47:56,942 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'temperature' value 28.0
2019-06-14 14:48:00,011 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'humidity' value 40.0
2019-06-14 14:48:03,081 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'temperature' value 28.0
2019-06-14 14:48:06,152 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'humidity' value 39.0
2019-06-14 14:48:09,348 mqtt_gpio (INFO): sensor_timer_thread: reading sensor 'temperature' value 28.0
flyte commented 5 years ago

Thanks for the report.

Could you also provide the relevant sections of your config, if you're setting the interval there?

SkySails commented 5 years ago

I edited the original post to include the wanted information.

flyte commented 5 years ago

What I think might be happening is that it takes a non-trivial amount of time to read the sensor, so it skews the timing when it's set to short intervals. Can you try setting it to 30 or 60 seconds and see if it outputs the values more punctually?

BenjiU commented 1 year ago

should be fixed with the async integration. Please create a new issue, if the problem is still there.