time.sleep(0.2)
        pycom.rgbled(0xBBBBBB)
        time.sleep(0.2)
        pycom.rgbled(0x999999)
        time.sleep(0.2)
        pycom.rgbled(0x777777)
        time.sleep(0.2)
        pycom.rgbled(0x555555)
        time.sleep(0.2)
        pycom.rgbled(0x333333)
        time.sleep(0.2)
        pycom.rgbled(0x111111)
        time.sleep(0.2)

    # going to sleep
    py.go_to_sleep()


# ==============================================================================
# settings deep sleep mode
py.setup_int_pin_wake_up(True)
py.setup_int_wake_up(True, True)
py.setup_sleep(60 * 30)  # deep sleep for 2 minutes

# enable sensor to wake up
acc = LIS2HH12()
acc.enable_activity_interrupt(500, 200)

# Send data and go to deep sleep
_thread.start_new_thread(mainTread, ())
Beispiel #2
0
py = Pysense()

# display the reset reason code and the sleep remaining in seconds
# possible values of wakeup reason are:
# WAKE_REASON_ACCELEROMETER = 1
# WAKE_REASON_PUSH_BUTTON = 2
# WAKE_REASON_TIMER = 4
# WAKE_REASON_INT_PIN = 8
print("Wakeup reason: " + str(py.get_wake_reason()) +
      "; Approximate sleep remaining: " + str(py.get_sleep_remaining()) +
      " sec")
time.sleep(0.5)

# enable wakeup source from INT pin
py.setup_int_pin_wake_up(False)

# enable activity and also inactivity interrupts, using the default callback handler
py.setup_int_wake_up(True, True)

acc = LIS2HH12()
mp = MPL3115A2(
    py, mode=ALTITUDE
)  # Returns height in meters. Mode may also be set to PRESSURE, returning a value in Pascals
mpp = MPL3115A2(
    py, mode=PRESSURE
)  # Returns pressure in Pa. Mode may also be set to ALTITUDE, returning a value in meters
si = SI7006A20(py)
lt = LTR329ALS01(py)
# enable the activity/inactivity interrupts
# set the acceleration threshold to 2000mG (2G) and the min duration to 200ms