树莓派pico温度读取并输出到zabbix

问题描述 投票:0回答:1

有一个树莓派pico,我想配置为温度传感器,并将数据输出到zabbix

我有raspberry pi pico,通过usb连接到带有ubuntu 22.04的计算机,我有一个读取温度的代码,我在thonny中运行并获取温度,但问题是这个温度要么输出到thonny终端或 pico 文件系统中的 .txt。

我找不到有关如何写入文件的信息。将带有温度的txt文件直接传输到计算机或任何其他方式从树莓派从pico输出到Zabbix

获取温度代码:

import machine
import utime
 
sensor_temp = machine.ADC(4)
conversion_factor = 3.3 / (65535)

temp = ()

while True:
    reading = sensor_temp.read_u16() * conversion_factor 
    temperature = 27 - (reading - 0.706)/0.001721
#    print(f'Температура: {temperature}°C')
    temp = temperature
    print(temp)
    utime.sleep(1)

非常感谢!

python zabbix micropython raspberry-pi-pico
1个回答
0
投票

如果是带WiFi的Pico,请在RaspberryPi上安装Zabbix Agent添加用户参数启动

python temperature.py

© www.soinside.com 2019 - 2024. All rights reserved.