0

there is a raspberry pi pico that I want to configure as a temperature sensor, and output data to zabbix

raspberry pi pico I have, connected to a computer with ubuntu 22.04 via usb, I have a code for reading the temperature, which I run in thonny and get the temperature, but the problem is that this temperature is output either to the thonny terminal or to .txt in the pico file system.

I could not find information on how to write a file.the txt file with the temperature directly to the computer or any other ways to output from raspbery Pi from pico to Zabbix

code for getting the temperature:

import machine
import time
 
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)
    time.sleep(1)

thank you very much!

1
  • Do not use Thonny. You will need a program to communicate with the Pico (serial over USB would seem to be easiest) which does the logging.
    – Milliways
    Commented Jul 13, 2023 at 23:45

2 Answers 2

0

I have been able to do this by using a Pi Pico W and connecting to the wireless. I am using a DHT11 for temperature and 2 x INA219 to read dual voltages. One for batteries and one for site power. I have it setup to respond to a web browser with a page that displays the values. I then setup Zabbix to pull the HTML and then parse the values using JavaScript and save as a floating number so that I can look at it on a graph and write alerts.

I eventually would like to connect an Ethernet hat to a regular Pi Pico so that I do not need to worry about the wireless. Maybe even add SNMP support for polling but alas there is no time.

If you are still interested let me know and I can post some details.

2
  • I need to run an snmp agent on raspberrypi pico (w) with micropython or C/C++ Commented May 8 at 5:12
  • Is there any library that you suggest for this matter? Thank you in advance. Commented May 8 at 5:15
0

The most straightforward way is for you to get a Pi Pico W with WiFi, so that you can connect via WiFi to any webservice.

I made Arduino code for ESP32 to publish on Thingspeak (not Zabbix at this time): https://fritzenlab.net/2024/04/19/esp32-s2-publishing-in-the-cloud-thingspeak/ . You can use the same code for testing if you program the Pi Pico with Arduino.

There are ways to transmit data to a computer from the Pi Pico, ideas here: https://www.instructables.com/How-to-Transfer-DataFiles-From-Raspberry-Pi-Pico-t/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.