Benjamin Patterson <bpbenpatterson%gmail.com@localhost> writes: > Has anyone had success using a ds18b20 temperature sensor in NetBSD? No :-) Not that you asked, and not that this is what you want, but I have used i2c parts on ESP8266 and sent the data to NetSBD via MQTT. I have read a simple input via GPIO (on a RPI3) just fine. > I am trying to find the simplest way to read a ds18b20 temperature sensor. This is a one-wire protocol part. (I know you know that, but not sure everybody does.) > I am using NetBSD 9.2 on Raspberry Pi Zero W. > > I connected the sensor supply to 3.3V supply, ground to ground, and > data to GPIO4, > > I set gpio=yes in /etc/rc.conf. > > Here is what I have tried in my /etc/gpio.conf. > #gpio0 4 set inout #does not work > #gpio0 4 set in #works > #gpio0 4 set out #works > #gpio0 4 set inout #does not work > #gpio0 4 set gpioow # does not work > #gpio0 attach gpioow 4 0x01 #does not work You say "does not work" and "works", but I think you mean something like "{error, no error} at config time". Please try to be much more specific. > I think to have "userland" (I think this is the correct term) access > to the temperature sensor, I need "inout" since it is a bidirectional > interface. But this configuration does not seem to work based on > running "gpioctl gpio0" after boot. lines in gpio.conf are simply passed to gpioctl. See /etc/rc.d/gpio. You did not say which you are trying to do: use the gpioow support in the kernel use some program in user space to access the gpio pin and speak the onewire protocol. (and if so, you didn't say if you are writing it, or using some existing program and which one) Read the man pages for gpio(4), gpioctl(8), gpioow(4), onewire(4), and owtemp(4). Luckily, you are trying to do something that has been done before. In gpioow(4), there are kernel config lines. It seems obvious that the first is for hard-wiring a gpio pin in the kernel, and the second for having a gpioow device that is not connected at boot, that you can connect with gpioctl commands. However, the commands are going to fail if the device is not compiled into the kernel. A quick egrep of the kenrel configs shows that onewire is not compiled into the evbarm GENERIC, used on RPI. However there is a modules, so you can proably add owtemp to /etc/modules.conf and reboot.
Attachment:
signature.asc
Description: PGP signature