Skip to content

Sensors do not report values if interrupts is enabled  #547

Open
@j54n1n

Description

@j54n1n

Hello,

I think I found a logical error that inhibits reporting of sensor values when interrupts are enabled and a sensor with high interrupt frequency is used.

In my case it was a weather station node with some non-interrupt sensors (i.e. reporting at a given time interval) and a wind speed sensor using SensorPulseMeter with smart sleep disabled and using an RTC clock module. The wind speed was reported always, but the other sensors would report only when the wind speed was very low.

The Anemometer from Davis DW-6410 that I am using is specified to measure wind speeds up to 322km/h which translates into an interrupt frequency of about 89Hz. But nevertheless even at lower speeds greater than 1Hz I was already getting no reports from the other sensors.

So I looked at the code from Node.cpp and I found that at line 291 the else if block allows only reporting of the other sensors if no _last_interrupt_pin was recognized.
At very low speeds (i.e. less than 1Hz interrupt frequency) there is at least some chance that one of the loop cycles goes through without the interrupt pin assigned, but at higher speeds this will not occur since interrupt pin is assigned ever so more.

I think the reporting within the loop function can be arranged in the same way as before but instead of using the else if block a else block should be enough to allow both type of sensors to be reported. At least in my local version where I tested this change it seems to be working also at high interrupt frequencies. I will propose a PR that fixes this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions