renetec-io / pyxis-apps

API reference documentation and application examples for Pyxis
BSD 3-Clause "New" or "Revised" License
4 stars 2 forks source link

Analog pin GPIO reading? #2

Open ASK472k opened 3 years ago

ASK472k commented 3 years ago

Is it possible? Would love to read temperature in pin 4 with a DS18B20.

Also curious if the pyxis-gpio daemon in your repo is required for Pi3+

shtig commented 3 years ago

Thank you for your interest. DS18B20 has 1-wire interface. We don't have a specific API for 1-wire yet, but it is totally possible to read the temperature and use it in an application. You can use FIFO API and file operations for getting data from another process. You will need to make a Python script that reads temperature from the sensor and writes it into a file in /tmp/pyxis-fifo/. You can then start this script as a systemd service on every boot. I hope that is helpful.

ASK472k commented 3 years ago

Thank you. I did end up using a scripted service to output a temporary file, only I needed to output it as an html file in the app's directory instead of /tmp. This is the only way I know to be able to read it from the web app's index.html file using periodic AJAX requests, under the pyxis architecture.

shtig commented 3 years ago

Glad you found a solution! Still FIFO pipes may be a more optimal way to accomplish that. I was thinking about making a blog post with a simple example, since DS18B20 is a popular temperature sensor. I will share a link in this thread once I do.