Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Pysense MPL3115A2 hangs rather quickly and consistently. #46

@stroobandt

Description

@stroobandt

This Pysense MPL3115A2 bug has been confirmed independently by two forum users, myself included.

Within a minute or two (it varies) below script hangs without any error message.

Serial communication also breaks down and a power cycle is required to regain communication with the LoPy Pysense combo.

import pycom
import pysense
import machine
from MPL3115A2 import MPL3115A2, PRESSURE
import utime
import sys

class Device:

    def __init__(self):
        self.iteration = 0
        self.sense(self)
        self.timer = machine.Timer.Alarm(self.sense, 3, periodic=True)

    def sense(self, device):
        # barometer mode, not raw, oversampling 128, minimum time 512 ms
        self.p = MPL3115A2(board, mode=PRESSURE).pressure()    # in Pa 
        self.iteration += 1
        print('%f Pa | iteration %d' % (self.p, self.iteration))
        pycom.rgbled(0x002200)
        utime.sleep(0.1)
        pycom.rgbled(0x000000)

pycom.wifi_on_boot(False)
pycom.heartbeat(False)
board = pysense.Pysense()
device = Device()

try:
    while True:
        pass
except KeyboardInterrupt:
    device.timer.cancel()
    sys.exit()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions