Skip to main content
Visitor II
March 11, 2024
Question

Wie kann man onewire auf dem STM32MP135 mit python nutzen?

  • March 11, 2024
  • 2 replies
  • 1029 views

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

    This topic has been closed for replies.

    2 replies

    Technical Moderator
    March 12, 2024

    Hi @birnnehi 

     

    I succeeded to use DS18B20 with STM32MP157F-DK2 with the following setup

    Connect sensor on:

    • CN2 pin 8 and pin 10 shorted together (USART3_TX and USART3_RX): sensor data (usually yellow wire)
    • CN2 pin 6 (VSS) : sensor ground (usually black wire)
    • CN2 pin 4 (+5V): sensor supply (usually red wire)

    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

     

     

     

    Graduate II
    March 12, 2024

    If the MP1 runs linux, there is also owfs, the one-wire-filesystem.