初めてのRaspberry Pi Pico ⑬ Circuitpythonで14セグLEDに温度を表示 その2
CPU内部の温度
Raspberry Pi Pico Python SDKやRaspberry Pi Pico C/C++ SDKを読むと、A4端子は内部の温度計の出力につながれていると説明されています。
CircuitPython(6.2.0-beta.2)で次のように記述しました。
analog_in = AnalogIn(board.A4)
エラーになりました。GitHubで質問したら、現時点では、microcontrollerライブラリを使ってくれるようにとのことでした。
温度を取得するプログラム
前回のTMP117を使ったプログラムに、CPU内蔵温度計の値を追加して表示するように変更しました。
(2021/02/15)マニュアルには、onboard temperature sensorと書かれているので、CPU内蔵とは異なるかもしれません。
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
# Author: Tony DiCola
import time
import board
import busio
from adafruit_ht16k33 import segments
import adafruit_tmp117
import microcontroller
# Create the I2C interface.
i2c = busio.I2C(board.GP27, board.GP26)
# Create the LED segment class.
display = segments.Seg14x4(i2c)
tmp117 = adafruit_tmp117.TMP117(i2c)
# Clear the display.
display.fill(0)
while 1:
print('Temperature: {:.1f}C CPU: {:.1f}C'.format(tmp117.temperature, microcontroller.cpu.temperature))
display.print('{:.1f}c'.format(tmp117.temperature))
time.sleep(1)
display.print('{:.1f}c'.format(microcontroller.cpu.temperature))
display.show()
time.sleep(1)
Author And Source
この問題について(初めてのRaspberry Pi Pico ⑬ Circuitpythonで14セグLEDに温度を表示 その2), 我々は、より多くの情報をここで見つけました https://qiita.com/jamjam/items/77fb73a2d179acad922d著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .