Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Aug 2014 15:07:17 -0300
From:      Luiz Otavio O Souza <lists.br@gmail.com>
To:        Patrick Tracanelli <eksffa@freebsdbrasil.com.br>
Cc:        "freebsd-arm@freebsd.org" <freebsd-arm@freebsd.org>, Rui Paulo <rpaulo@felyko.com>
Subject:   Re: HC-SR04 and FreeBSD
Message-ID:  <CAB=2f8w8vYr_zrN21nBhyR=Q4yUUw1Pa=_7zOZ3khS_NU9CEVQ@mail.gmail.com>
In-Reply-To: <411C643B-BC46-494E-919B-39098FB87EEA@freebsdbrasil.com.br>
References:  <CAG4HiT6wwbmSA_KWsgHOqdeZVOCUsdhRxDhMubvkG1tEwVH5Sw@mail.gmail.com> <5D802942-2D0F-4324-8212-C2871EEB6327@FreeBSD.org> <CAG4HiT6fiqVXMoqcJra1Yh8aFVbOcezP8rRqst6WC8aHuaF_rA@mail.gmail.com> <01562FB1-32C6-45AF-AB77-5BB80526E18C@FreeBSD.org> <CAG4HiT4kKz18iauXfuF0Dpv-USghunssUvwkTF7bDx_gE_VS2w@mail.gmail.com> <CCD5AEE5-798D-4EAC-BAE7-A086DE55B5D2@FreeBSD.org> <CAG4HiT6YUBCxXrK_KyRW6zTthPa-wDe=A9=CmMHQf-Gh54s7QA@mail.gmail.com> <EA5A973C-960A-4B0F-A690-8AA9BF66244A@felyko.com> <CAG4HiT4EbX=Lar_o8YZc5B51Yao1-B=Ebck0vQajyzoZwesWwQ@mail.gmail.com> <CAB=2f8zBDTVkQd15C_icZpOMC14XxFycW_ZR2Sa--updv=dX2w@mail.gmail.com> <53F8FED8.6030409@freebsdbrasil.com.br> <CAG4HiT4RXsUyGfjDDTTJPoeB8bqpY39z6C-_f0S3Zmka0C8gNQ@mail.gmail.com> <3949AF9C-B5BD-44E8-A049-21F26B8B6B9A@freebsdbrasil.com.br> <CAB=2f8xyu1EwL3zft8E%2BSXRL66vdYSjgcSuhF7Kva9zDatGtXA@mail.gmail.com> <411C643B-BC46-494E-919B-39098FB87EEA@freebsdbrasil.com.br>

next in thread | previous in thread | raw e-mail | index | archive | help
Okay, so i got my hands on one HC-SR04 and got it working quite
easily. Two consecutive GPIO readings takes from 15 to 30 usec which
gives a good precision for this case (readings above 116 usec).

I written a simple C program to program the GPIO pins, trigger the
sensor and read back the duration of echo pulse, it give me good
readings using the datasheet formula, so i'm happy with it. Build it
with: cc -o hc-sr04 hc-sr04.c

I'm using the wiring suggested at (voltage divisor on echo pin):
https://www.modmypi.com/blog/hc-sr04-ultrasonic-range-sensor-on-the-raspberry-pi

The trigger and echo pin is connected to pins 2 and 3 respectively.
The module is powered from DGND and VDD_5V.

This maybe a good candidate to be on Wiki.

Luiz



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAB=2f8w8vYr_zrN21nBhyR=Q4yUUw1Pa=_7zOZ3khS_NU9CEVQ>