Version 8 (modified by hek, 11 years ago) (diff) |
---|
Distance sensor (HC-SR04)
Software
You can download the Arduino sketch here:
http://code.mios.com/git_public/mios/arduino-sensor.git/tree/HEAD:/VeraArduino/Arduino/libraries/Vera/examples/DistanceSensor?js=1
Adjust the measure interval by updating SLEEP_TIME define at the top of the sketch file.
This sensor requires you to upload the following device files to Vera as well.
http://code.mios.com/git_public/mios/arduino-sensor.git/tree/HEAD:/VeraArduino/Vera/distance?js=1
D_DistanceSensor1.xml
D_DistanceSensor1.json
S_DistanceSensor1.xml
Wire things up
Follow the instructions in ConnectingRadioModule to connect radio module.
The HC-SR04 sends out short ultrasonic pulses and registers when the sound echo comes back. By knowing the speed of sound you can easily calculate the distance.
To connect the HC-SR04 sensor to the Arduino board follow these instructions:
Connect VCC of the HC-SR04 sensor to +5V
Connect Echo to digital pin 5 of the Arduino board
Connect Trig to digital pin 6 of the Arduino board
Connect GND to Arduino ground
Hardware - Purchase guide
To build this sensor you'll need one arduino + radio specified in the base kit found here:
http://code.mios.com/trac/mios_arduino-sensor/wiki/WikiStart#Buyingguide
With the following additional parts:
1x Distance Sensor HC-SR04
http://www.aliexpress.com/item/Free-shipping-2pcs-Ultrasonic-Module-HC-SR04-Distance-Measuring-Transducer-Sensor-for-Arduino-Samples-Best-prices/690139020.html
TOTAL SENSOR PRICE: $7.6 (arduino + radio) + $2.42 (HC-SR04) = $10
Attachments
- tmeasure.png (5.9 KB) - added by hek 11 years ago.
- distVera.png (23.1 KB) - added by hek 11 years ago.
- dist.jpg (1.7 MB) - added by hek 11 years ago.