Crashing after a couple of hours

  • Hi I'm setting up a temperature sensor using the gPy device. My idea was to have it in deepsleep for ~30 minutes and then perform a measurement and go back to sleep.

    I've created a that looks like this:

    from machine import Pin
    import time
    from onewire import DS18X20, OneWire
    print("Booted into application at {}".format(time.time()))
    def get_temperature():
        """Get temperature from OneWire sensor."""
        ow = OneWire(Pin('P10'))
        temp = DS18X20(ow)
        for _ in range(10):
            temperature = temp.read_temp_async()
            if temperature:
        return temperature
    def publish_to_web(temperature):
        print('Publishing a temperature of {}'.format(temperature))
        pybytes.send_signal(0, temperature)
    temperature = get_temperature()
    print("Going to sleep")
    pybytes.deepsleep(30*60*1000) # 30 Minutes

    And this works for some time but after 5-8 hours samples stop coming in and when looking at my computer I see that the Atom shell is trying to connect to the serial port but failing.

    Disconnecting / reconnecting then shows a SyntaxError message. Resetting the device resumes the operation.

    Has anyone seen anything similar to this? Any ideas how to make it more robust? Could I setup a watchdog in the and then feed / disable it in my would it help or is it likely that the issue occurs earlier.

    I've now connected it to an usb-charger in case there's something my computer does.

    Any help / insights would be appreciated!

  • Having it plugged to an usb-charger instead of the computer's usb has kept it stable since I sent above message so maybe it was the USB port on my computer or possibly Atom causing the issue.

Log in to reply

Pycom on Twitter