Re: ds18b20 Temperature Sensor

Greg Troxel <[email protected]> Sat, 03 Jul 2021 06:11:07 -0400
Newsgroups gmane.os.netbsd.devel.embedded
Message-ID <[email protected]>
--=-=-=
Content-Type: text/plain


Benjamin Patterson <[email protected]> writes:

> Greg, thank you for your reply and suggestions!
>
>> > 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.
>
> "works" means that upon reboot, I get output from "gpioctl gpio0"
> indicating that 1 pin is configured.
> "does not work" means that after reboot "gpioctl gpio0" says that 0
> pins are configured.

Thanks - one could also actually look at voltage levels and see if they
could be set.

> I just want the temperature. The simpler the approach the better. It
> seems that it could be easiest to use the gpioow/owtemp/onewire
> support in the kernel since that code has already been written and
> tested. My thinking was that with either approach, I would first have
> to configure the pin. My thought was first to try to get the pin
> working for "inout" and then go from there. So far, I have not been
> able to configure the pin for bidirectional use. Should I expect to
> see the pin configured from the output of "gpioctl gpio0"?

I would think so.

> I did find and read those man pages. Per your suggestion, I just

In general, when asking for help, it's good to give such background,
even if it's only helpful for some future person coming across your
message in the archives.

> reread them and I am missing something. I run "man 4 gpioow" and I
> don't see information about "kernel config". Is the part at the top
> ("gpioow* at gpio? offset 0 mask 0x1")?

yes.  section 4 has kernel config lines. See intro(4), the section
titled "Configuring a driver into the kernel".

> I tried creating "/etc/modules.conf" and adding "owtemp" to it and
> then rebooting. I do not see a change. I also found "modstat" and
> "modload". Below is the contents of the file.
>
> # /etc/modules.conf
> # owtemp # does not show up in output from "modstat"
> onewire # this shows up in output of "modstat"

Sorry, I thought I had found an owtemp module, but apparently not.  Look
in /stand/evbarm/9.2/modules (or whatever your version is).

> Do you think this means that I need to recompile my kernel with
> support for "owtemp"?

Yes, and onewire, because you can't (I think, and it's a bad idea if you
can) compile in a driver and use a module for a dependency.

Look in sys/arch/i386/conf/GENERIC.   Apparently onewire but not owtemp
exists in amd64.   (This is a clue that it is not used much.)

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iF0EARECAB0WIQS7wyAjWilQwVHG9Vsf2nroCY7WDgUCYOA3uwAKCRAf2nroCY7W
DmPLAJ91KOHx7ZQFHtGWXfWjS56ibakmUgCeNNHPVnaGNAvJxY9yyZ7I5r9yBVw=
=ey0I
-----END PGP SIGNATURE-----
--=-=-=--