FreeBSD driver 1-wire over GPIO and sapmles.

For free use without warranty.


kernel module for 1-wire.
kernel module for Single wire for dht11 dht22 am2302.
path for /sys/arm/broadcom/bcm2835/bcm2835_gpio.c.
Lib and sample for 1-wire ( ds1820, ds18b20, ds2438, ds2408, ds2417).

You need to download the kernel source code, apply the path and rebuild the kernel.
Next, build the kernel module and load it.
Next, build examples and test the functionality.

GPIO pin for use set in hints. Add "hint.gpio_ow.0.pin=22" to loader.conf - for 1-wire driver.
"hint.gpio_sw.0.pin=24" - for Single wire driver.
Default pin: 22 - for 1-wire driver, 24 - for Single wire driver.
Pin need pullup resistor 4.7 kOm to 3.3V.
Tested only on Raspberry Pi FreeBSD-10 -current.



----------- Apr 16 17:50:54 2014 ----------------
Hello,

First many thanks for your work, it's so cool to have such a piece of software and that allow to run Freebsd on rasberry. (which is better than raspbian :-) ).

I'm trying to get temperature from DHT22 with your driver, but I've got some issue.

The driver load properly :

root@rasp-1:~ # kldstat
Id Refs Address Size Name
1 28 0xc0100000 5bf488 kernel
2 1 0xc06c0000 2026c if_run.ko
3 3 0xc06e1000 ae48 firmware.ko
4 5 0xc06ec000 5b51c wlan.ko
5 1 0xc0748000 ac34 runfw.ko
6 1 0xc295a000 a000 wlan_wep.ko
7 1 0xc2968000 b000 wlan_tkip.ko
8 1 0xc2973000 e000 wlan_ccmp.ko
9 1 0xc2ae8000 10000 uftdi.ko
10 1 0xc2af8000 d000 ucom.ko
11 1 0xc2c81000 a000 gpio_ow.ko
12 1 0xc2c8f000 a000 gpio_sw.ko


Apr 16 08:14:25 rasp-1 kernel: device_identify() start ...
Apr 16 08:14:25 rasp-1 kernel: devclass_find(gpio_ow) - success.
Apr 16 08:14:25 rasp-1 kernel: devclass_get_device() - fail.
Apr 16 08:14:25 rasp-1 kernel: device_add_child() - success.
Apr 16 08:14:25 rasp-1 kernel: device_probe() start ...
Apr 16 08:14:25 rasp-1 kernel: gpio_ow0: on gpio0
Apr 16 08:14:25 rasp-1 kernel: device_attach() start ...
Apr 16 08:14:25 rasp-1 kernel: OneWire over GPIO pin=22
Apr 16 08:14:25 rasp-1 kernel: Created ow0
Apr 16 08:14:25 rasp-1 kernel: shutdown_final() - registered on PIN=23.
Apr 16 08:14:25 rasp-1 kernel: device_attach() - done.
Apr 16 08:14:28 rasp-1 kernel: devclass_find() - success.
Apr 16 08:14:28 rasp-1 kernel: devclass_get_device() - fail.
Apr 16 08:14:28 rasp-1 kernel: device_add_child() - success.
Apr 16 08:14:28 rasp-1 kernel: gpio_sw0: on gpio0
Apr 16 08:14:28 rasp-1 kernel: SingleWire over GPIO pin=24
Apr 16 08:14:28 rasp-1 kernel: Created sw0

root@rasp-1:~ # more /boot/loader.conf
if_run_load="YES"
runfw_load="YES"
hint.gpio_ow.0.pin=22


I've done the same wiring that this URL
http://1.bp.blogspot.com/-tHGPCZwLwYE/UdU8tkknGoI/AAAAAAAAGRc/CdxmH7RQltE/s952/cablage+DHT22+raspberry+pi.png

But when I launch test, this is what I get :

root@rasp-1:/usr/home/tom/gpio_sw # ./test
error read, errno=5 Input/output error

Could you advise ? Is that a question of wrong PIn number ?

Many thanks

Regards

Thomas



----------- Apr 16 22:01:12 2014 ----------------
In your sample add to "hint.gpio_sw.0.pin=4" to loader.conf
Apply path for /sys/arm/broadcom/bcm2835/bcm2835_gpio.c and rebuild kernel.
Regards,
Alexander.
----------- Jan 2 21:02:53 2016 ----------------
у кого получилось, пожалуйста отпишитесь, хочется ds18b20 по gpio заюзать, HELP!
----------- Jan 14 16:47:31 2017 ----------------
Thank you, module works very well for me. I did some minimal changes and using it on the FreeBSD11 with RPi
----------- Jan 14 17:27:00 2017 ----------------
I did a blog post about it, see https://smallhacks.wordpress.com/2017/01/14/reading-dht11-temperature-sensor-on-raspberry-pi-under-freebsd/