Microbit Temperature:温度传感器
The Microbit_Temperature
sensor provides App Inventor users with the ability to configure the BBC micro:bit’s on-board temperature sensor and receive one or more temperature samples via the appropriate methods.
The temperature sensor’s reportrate, or period, determines how frequently data will be sent to App Inventor.
More links:<ul><li>Download a sample project for the micro:bit temperature sensor.</li><li>View the how to instructions for the micro:bit temperature sensor.</li></ul>
Properties
Methods
ReadTemperature
– Read a single sample of temperature data from the micro:bit. On successful read, theTemperatureDataReceived
event will be run.
ReadTemperaturePeriod
– Read the current report rate for the micro:bit’s temperature sensor. After the period is read, it will be received by theTemperaturePeriodReceived
event.
RequestTemperatureUpdates
– Request notifications of changes in the micro:bit’s temperature sensor. Changes in the temperature will be reported at a rate determined by the last period value set by a call toWriteTemperaturePeriod
. Temperature data will be reported through theTemperatureDataReceived
event.
StopTemperatureUpdates
– Stop receiving updates from the micro:bit’s temperature sensor. Note that there may be pending messages from the device that will still be reported through theTemperatureDataReceived
event.
WriteTemperaturePeriod
– Use theWriteTemperaturePeriod
method to change how frequently the micro:bit sends temperature data to App Inventor. The period is measured in milliseconds.
Parameters:
* <code>temperature_period_value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/math.html#number">_number_</a>) —
The new reporting period for the micro:bit's temperature sensor.
Events
TemperaturePeriodReceived
– TheTemperaturePeriodReceived
event is run after the micro:bit’s temperature reporting period is read from the device.
Parameters:
* <code>temperature_period_value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/math.html#number">_number_</a>) —
The current reporting interval for the micro:bit's temperature sensor.
TemperatureReceived
– TheTemperatureReceived
event is run whenever temperature samples are received from the micro:bit. This is usually a result of performing a read or request updates operation. The temperature value is measured in degrees Celsius.
Parameters:
* <code>temperature_value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/math.html#number">_number_</a>) —
The temperature measured by the micro:bit, in degrees Celsius
WroteTemperaturePeriod
– TheWroteTemperaturePeriod
event is run after the micro:bit’s temperature reporting period is written to the device.
Parameters:
* <code>temperature_period_value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/math.html#number">_number_</a>) —
The new reporting interval for the micro:bit's temperature sensor.