Raspberry Pi Asked by Alexandre A. on February 10, 2021
I’m new to the Raspberry Pi ecosystem so pardon me if I’m talking nonsense.
I want to read the temperature data from the connected DS18B20 sensors using C/C++.
I followed this schema to connect them:
There are a lot of examples how to do it in different languages including C/C++ like:
But most of them seem to use a legacy way of doing things according to linux kernel docs.
Official Raspberry Pi documentation says that Programming with GPIO can be done using standard kernel interface via libgpiod. But I have a hard time to find any useful tutorials about how to do that.
So my question is how to read the DS18B20 temperature sensors in a non-legacy (modern) way ?
Can someone point me in the right direction ?
I believe the methods presented in those examples are still relevant.
libgpiod is the replacement for the sysfs method of directly talking to the GPIO as a Linux user. I.e. it replaces user functions to read and write individual GPIO and to be told about individual GPIO level changes.
It is not a replacement for all the kernel modules which currently talk to various buses over the GPIO.
E.g. talking on the I2C bus still uses the same kernel driver, talking on the SPI bus still uses the same kernel driver, and talking on the 1-wire bus still uses the same kernel driver.
In your case the DS18B20 uses the 1-wire bus and the deprecation of the sysfs interface to the GPIO is irrelevant.
Answered by joan on February 10, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP