/ circuitpython / example.py
example.py
 1  from bm_serial import BristlemouthSerial
 2  import board
 3  import digitalio
 4  import time
 5  
 6  led = digitalio.DigitalInOut(board.LED)
 7  led.direction = digitalio.Direction.OUTPUT
 8  bm = BristlemouthSerial()
 9  last_send = time.time()
10  
11  while True:
12      now = time.time()
13      if now - last_send > 60:
14          led.value = True
15          last_send = now
16          print("publishing", now)
17          bm.spotter_tx(b"sensor1: 1234.56, binary_ok_too: \x00\x01\x02\x03\xff\xfe\xfd")
18          bm.spotter_log(
19              "any_file_name.log",
20              "Sensor 1: 1234.56. More detailed human-readable info for the SD card logs.",
21          )
22          led.value = False