Micro:bit ist zwar BLE tauglich, doch unter Python reichen die Ressorcen für den BLE-Stack nicht aus und es bleibt die micro:bit radio Verbindung.
Zur abgesetzten Temperaturmessung kann ein micro:bit als Sensorknoten und eine weiterer als Empfängerknoten genutzt werden. Die Message des Sensors wird hier als Broadcast versendet.
Das Python-Programm des Sensors ist:
# Measuring chip temperature on micro:bit & output to radio from microbit import * import radio # The radio won't work unless it's switched on. radio.on() while True: temp = temperature() - 3 # offset to ambient temperature display.scroll(str(temp)+" C") radio.send(str(temp)) sleep(5000)
Das Python-Programm des Empfängers ist:
# Receiving chip temperature from a micro:bit sensor node & output to console from microbit import * import os import radio uart.init() uart.write(os.uname().machine +" get chip temperature by radio connection\r\n") # The radio won't work unless it's switched on. radio.on() while True: # Read any incoming messages. temp = radio.receive() display.scroll(str(temp)+" C") uart.write("micro:bit chip temperature = "+str(temp)+" C\r\n") sleep(1000)