pimoroni / badger2040

Examples and firmware for Badger 2040 and Badger 2040 W
MIT License
150 stars 50 forks source link

OSError: [Errno 110] ETIMEDOUT #61

Closed optio closed 10 months ago

optio commented 11 months ago

Hi,

Since recently, I receive the folllowing error, using badger2040w , pimoroni-badger2040w-v0.0.4-micropython-with-badger-os.uf2

Traceback (most recent call last): File "", line 5, in File "badger2040.py", line 58, in OSError: [Errno 110] ETIMEDOUT

The error is thrown at this line:

i2c.writeto_mem(0x51, 0x00, b'\x00') # ensure rtc is running (this should be default?)

https://github.com/pimoroni/badger2040/blob/a8552a55ad090783f9bf06aa2a07821051accf87/firmware/PIMORONI_BADGER2040W/lib/badger2040.py#L57C31-L58C88

Any idea how to solve this? I tried reflashing pimoroni-badger2040w-v0.0.4-micropython-with-badger-os.uf2 though even with the default launcher, the error is thrown.

Even when trying to import badger from the shell , the error is thrown

>>> import badger2040 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "badger2040.py", line 58, in <module> OSError: [Errno 110] ETIMEDOUT

helgibbons commented 11 months ago

Sounds like the RTC might has got into a weird state - you could try unplugging the battery and leaving it for little while to allow it to reset?

optio commented 11 months ago

I left badger2040w unplugged for 2 days , though still same error. Will try again in a week or so...

helgibbons commented 11 months ago

That should be sufficient for the RTC to reset.

You could try running this RTC example to see if it unsticks things? https://github.com/pimoroni/pimoroni-pico/blob/main/micropython/examples/pcf85063a/pico_rtc.py

You could also try clearing Badger's flash memory, as described here: https://learn.pimoroni.com/article/getting-started-with-badger-2040#troubleshooting (if you do that, you'll need to copy across the Badger MicroPython image again afterwards).

optio commented 10 months ago

I first put flash_nuke.uf2 , then after restart put pimoroni-badger2040w-v0.0.4-micropython.uf2.

When running https://github.com/pimoroni/pimoroni-pico/blob/main/micropython/examples/pcf85063a/pico_rtc.py I get:

>>> %Run -c $EDITOR_CONTENT MPY: soft reboot ` PCF85063A rtc demo! =================== initialise rtc.. `

which does not continue further, no error shown either.

When I added a print after PimoroniI2C()

PINS = {"sda": 4, "scl": 5} # i2c pins 4, 5 i2c = PimoroniI2C(**PINS) print("i2c ok")

the print 'i2c ok' does not show, thus it's already stuck on i2c = PimoroniI2C(**PINS)

Btw Inky Frame 4 connects just fine, so it's not a thonny/cable/... issue.

helgibbons commented 10 months ago

Does flashing our standard Pico W build and then re-running the RTC example help?

https://github.com/pimoroni/pimoroni-pico/releases

optio commented 10 months ago

Thanks for the help, though still no luck.

I first reflashed 'flash_nuke.uf2' , then flashed 'pimoroni-picow-v1.21.0-micropython.uf2' , though the pico_rtc.py example still failed at rtc.datetime(now) .

Initially I though the pico_rtc.py sample failed earlier, based in which print() statement did last output, though upon removing/adding line by line in , it was clear that PimoroniI2C() seems to work fine, also rtc = PCF85063A(i2c) , though hangs when calling rtc.

I tried inputting the script manually using the Thonny shell, where the shell stops responding upon rtc.datetime(now) or rtc.reset() or any call to rtc.. After a few minutes, I click the stop button , which results in Unable to connect to .... A reset makes the badger2040w responsive again.

Could it be the wrong PINS values?

>>> import machine
from pimoroni_i2c import PimoroniI2C
from pcf85063a import PCF85063A, MONDAY
import time
led = machine.Pin(22, machine.Pin.OUT)
led.high()
PINS = {"sda": 4, "scl": 5}  # i2c pins 4, 5
i2c = PimoroniI2C(**PINS)
rtc = PCF85063A(i2c)
>>> rtc
<pcf85063a>
>>> rtc.reset()
─────────────────────
Unable to connect to COM3: could not open port 'COM3': PermissionError(13, 'Access is denied.', None, 5)
If you have serial connection to the device from another program, then disconnect it there first.
Process ended with exit code 1.
helgibbons commented 10 months ago

Thanks for that - the RTC example runs as is on my Badger W so the pins should be correct.

I suspect you may have a faulty RTC if trying to initialise it hard crashes the Pico W - drop a note to support with a link to this issue and they should be able to sort you out with a replacement Badger.

optio commented 10 months ago

Thanks for the debugging support @helgibbons . A new badger2040w is shipped to me within warranty by Pimoroni.