LoginSignup
0
0

More than 3 years have passed since last update.

初めてのRaspberry Pi Pico ⑬ Circuitpythonで14セグLEDに温度を表示 その2

Last updated at Posted at 2021-02-11

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)

 実行中のMuの画面です。この温度が本当なら、すごくクールなCPUだといえます。
c201.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0