d2r2 / go-dht

Golang library to interact with DHT11/DHT22/DHT12 temperature and humidity sensors from Raspberry PI.
MIT License
133 stars 52 forks source link

Beaglebone question #2

Closed Gonzih closed 7 years ago

Gonzih commented 7 years ago

Hi, I made small temperature service for my own use on beaglebone https://github.com/Gonzih/temperature-service. Originaly i wanted ot use your library but it did not work. I looked at Adafruit labrary https://github.com/adafruit/Adafruit_Python_DHT and main difference that I saw is /dev/gpiomem usage instead of /dev/mem on beaglebone. Do you think it is possible to adjust this labriary in a way that it will work on Beaglebone also? Their implementation should work on beaglebone black, but also works on my beaglebone white board.

Thanks!

d2r2 commented 7 years ago

Hi Gonzih,

Miss your letter, so want to apologize for late response.

Huh, first, I never work with beaglebone device (this software tested with few models of RaspberryPI, as well as BananaPI), so not ready to talk what could be a reason, why this library not working with beaglebone hardware. Second, this software use standard Linux GPIO subsystem to work with external devices via binary logic input/output pins. So, your device should have /sys/class/gpio/ directory structure used here as interface to interact with sensor (you may find this in dht.go.h). I do not use devices such /dev/gpiomem or /dev/mem, as you describe in your mail. Could you check, that directory /sys/class/gpio/ is present on your device?

If you have more specific information about issue (including error output), let me know - perhaps I can find root cause of an issue.

Regards, Denis

Gonzih commented 7 years ago

Hi Denis, thanks for your reply.

Yeah beaglebone gpio system is similar to pi one, but is also different a bit. I suspect main differente can be seing in those files from adafruit library. https://github.com/adafruit/Adafruit_Python_DHT/blob/master/source/Beaglebone_Black/bbb_mmio.c https://github.com/adafruit/Adafruit_Python_DHT/blob/master/source/Raspberry_Pi_2/pi_2_mmio.c

I will poke around trying to port your codebase to beaglebone, but for now I just shell out to python script to read data.

d2r2 commented 7 years ago

Hi Gonzih,

As I know there are two approach how we can work with GPIO in linux. In the code provided by your GPIO handled via "memory mapped" device (/dev/mem), which better in respect of speed, but worse for compatibility between various RPI clones (Raspberry, Bananian, Orange, BeagleBone and so on). As I remember, almost each RPI clone has their own registers (memory addresses) not equals to other clone (that is why, for instance, for popular python GPIO library exists separate version for BananaPi: https://github.com/LeMaker/RPi.GPIO_BP; if you try to use regular python lib "import RPi.GPIO" for BananaPI - it will not work).

In my Golang DHT (c code) I use "device tree" approach, where all GPIO pins mapped to /sys/class/gpio/... virtual file system files. It slower, but better compatible between RPI clones.

It's pity, that I have no BeagleBone system near me, because perhaps BeagleBone have some issue with "device tree" GPIO, and I have not possibility to check if there is some problem there...

UPDATE: It seems there are some challenges with GPIO device tree config on BeagleBone system, starting from 3.8 kernel. Watch the video: https://www.youtube.com/watch?v=wui_wU1AeQc

Gonzih commented 7 years ago

@d2r2 thanks a lot for the explanation, now it is clear to me what is going on! Thanks a lot again, sorry for wasting your time like that :)

d2r2 commented 7 years ago

@Gonzih, thank you for paying attention to my project! When I will have free time, I will fork and adapt your temperature-service project back to dht library ;)