2024-03-11 04:46 PM - last edited on 2024-03-12 02:01 AM by Amel NASRI
I want to read a temperature sensor DS18B20 with onewire with the STM32MP135 in Python?
Does anyone know how to do this best?
I've already tried installing the onwire library from python, but that fails. I don't want to program it in C.
I'm new here, so I hope I've classified my problem correctly.
greetings
2024-03-12 02:35 AM
Hi @birnnehi
I succeeded to use DS18B20 with STM32MP157F-DK2 with the following setup
Connect sensor on:
install PyDigiTemp python module
Boot the board using "stm32mp157f-dk2-a7-examples" device tree (option 2 in U-Boot when prompted).
This define USART3 as ttySTM1 on pins listed above.
If needed to confirm the tty port used on your system, please have a look to https://wiki.st.com/stm32mpu/wiki/Trace_and_debug_scenario_-_UART_issue#Checking_the_UART_probe
Then such kind of python code should work:
from digitemp.master import UART_Adapter
from digitemp.device import TemperatureSensor
sensor = TemperatureSensor(UART_Adapter('/dev/ttySTM1'))
temperature = sensor.get_temperature()
Regards
2024-03-12 02:43 AM
If the MP1 runs linux, there is also owfs, the one-wire-filesystem.