Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard lock when using 2ed core with DHT22 sensor #23

Open
GM-Script-Writer-62850 opened this issue Aug 24, 2023 · 1 comment
Open

Hard lock when using 2ed core with DHT22 sensor #23

GM-Script-Writer-62850 opened this issue Aug 24, 2023 · 1 comment

Comments

@GM-Script-Writer-62850
Copy link

GM-Script-Writer-62850 commented Aug 24, 2023

I suspect this is a clock de-sync issue

Hardware: W5500_EVB_PICO
Firmware: rp2_w5500_20221111_v2.0.0.uf2

When this happens everything freezes and no errors are reported in Thonny and a power cycle is required on the PICO
note that rp2_w5500_20221111_v2.0.0.uf2 will run just fine for usually weeks (my record with production code is 2-3 months with a minimum of a few days) while the W5500_EVB_PICO-20230426-v1.20.0.uf2 will run for maybe hours at most

This is all it takes:

from machine import Pin,SPI
from time import sleep,time
import network
import _thread
import dht # example hardware wiring: https://microcontrollerslab.com/wp-content/uploads/2022/02/Raspberry-Pi-Pico-with-DHT22-connection-diagram.jpg

def read_sensor():
    dev=dht.DHT22(Pin(6))
    dev.measure()
    print("Temperature:",dev.temperature()," C; Humidity:",dev.humidity())

def enable_NIC():
    spi=SPI(0,2_000_000, mosi=Pin(19),miso=Pin(16),sck=Pin(18))
    nic = network.WIZNET5K(spi,Pin(17),Pin(20)) #spi,cs,reset pin
    nic.active(True)
    return nic

nic=enable_NIC()
    
_thread.start_new_thread(read_sensor,())

while True:
	print('heartbeat',time())
	sleep(3)

Even if you nic.active(False) before _thread is started then nic.active(True) it when _thread is completed it will still hard lock

Here is my upsteam report: micropython/micropython#10448

At this time i am using W5500_EVB_PICO-20230426-v1.20.0.uf2 and have everything running using uasyncio on core 0, i would prefer to have my sensors read using core 1 but that make it unstable, this production code does not work on rp2_w5500_20221111_v2.0.0.uf2 due to issue #14 (this also affects using uasyncio urequests)

I have no issues doing this same thing using a PICO W having the second core deal with the sensors works all day every day

@GM-Script-Writer-62850
Copy link
Author

Seems to be resolved upstream in micropython 1.3, i suspect 1.22 fixed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant