From owner-freebsd-arm@FreeBSD.ORG Fri Aug 29 18:07:20 2014 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 47D0BCB7 for ; Fri, 29 Aug 2014 18:07:20 +0000 (UTC) Received: from mail-wg0-x231.google.com (mail-wg0-x231.google.com [IPv6:2a00:1450:400c:c00::231]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C80D81FAC for ; Fri, 29 Aug 2014 18:07:19 +0000 (UTC) Received: by mail-wg0-f49.google.com with SMTP id y10so2532886wgg.32 for ; Fri, 29 Aug 2014 11:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=s5R/5/0WZd6PSqzc9bEWa80joLTwG6EvHdzxR7zePig=; b=TuQIzI+gopXM64QxhWl4mPiv2CEwpd8aHEMlTm6mTG1vk5P1FIPiZvcZOd7KdCcQma 38RIjm0RJGOpbanIPyjHnvC5fJK+s+KtRxvHfI4+p/gB6K7EEsJEZ+NqkJab1Y3wAuoU 42D5EPaadTRUXtHZ5WW5mPtx0pq/jBpEG4tluZJny5oORLKBoiz4L9gLjJZB9HPb8HPM rMgAx1mOi53bDkLcU0r5A2XFkftYMWsBQI+602d9d2oVHzNMOUfSdwtmLz5dNLPuxw9o nQ1SEzb8XbEngg+2F8qzG0RIW/R8QN046GMow+J1zgC8mu79uypvSf1hgCf/i2X5XgIM 8Eog== MIME-Version: 1.0 X-Received: by 10.194.82.106 with SMTP id h10mr15196400wjy.37.1409335638013; Fri, 29 Aug 2014 11:07:18 -0700 (PDT) Received: by 10.216.199.70 with HTTP; Fri, 29 Aug 2014 11:07:17 -0700 (PDT) In-Reply-To: <411C643B-BC46-494E-919B-39098FB87EEA@freebsdbrasil.com.br> References: <5D802942-2D0F-4324-8212-C2871EEB6327@FreeBSD.org> <01562FB1-32C6-45AF-AB77-5BB80526E18C@FreeBSD.org> <53F8FED8.6030409@freebsdbrasil.com.br> <3949AF9C-B5BD-44E8-A049-21F26B8B6B9A@freebsdbrasil.com.br> <411C643B-BC46-494E-919B-39098FB87EEA@freebsdbrasil.com.br> Date: Fri, 29 Aug 2014 15:07:17 -0300 Message-ID: Subject: Re: HC-SR04 and FreeBSD From: Luiz Otavio O Souza To: Patrick Tracanelli Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: "freebsd-arm@freebsd.org" , Rui Paulo X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2014 18:07:20 -0000 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