Skip to content

Sporadic resets - not entirely clear why #118

@gmrza

Description

@gmrza

I am using mqtt_as on a Raspberry Pi Pico W to report on a BME280 (temperature, pressure and humidity) sensor and a flow meter, which uses a Hall Effect sensor.
I originally wrote a micropython script which directly wrote to an influxdb db, but I am busy migrating to using MQTT (using Mosquitto as the broker) and mqtt_as as the client.
In my test setup, I am running into issues that the controller is sporadically resetting. I am not seeing any exceptions generated before the reset, and when I interrogate machine.reset_cause() during restart, it always gives a value of 1 (machine.PWRON_RESET). Just to check that the value was being changed, I caused a watchdog timer reset before starting my script (setting the reset_cause() to 3 before my script started).
The Hall Effect sensor is being read using a hard IRQ, and my IRQ handler is as simple as I can make it:
`def irq_handler(pin):
global pulses, maxpulses

pulses = ( pulses + 1 ) % maxpulses`

"maxpulses" is currently set up so that my "pulses" counter acts as a 24 bit circular counter.

I do have the emergency exception buffer set up as well.
At this point I can't specifically tell what is causing the resets, but I have only seen this behaviour since using mqtt_as.

I'd be open to suggestions on how to diagnose. I have also tried using a soft IRQ, but I have also seen the resets occur at times when there are no IRQs occurring - I use 2 test setups, where I use a second Pi Pico to generate pulses rather than the Hall Effect sensor - one where I pulse the input continuously at up to 200Hz, and one where I pulse for a while and then have a gap. In the second test I seem to even be getting resets when there are no IRQs. I will eliminate the I2C access as a further test to see if that is having an effect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions