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

Description
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()