Skip to content

jonathanlindahl/dt-ultrasonic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ultrasonic

Linux device driver for ultrasonic sensor HC-SR04 using device tree

The module works by triggering an ultrasonic pulse, the echo from which then causes an interrupt. Time between the trigger and echo is measured and is used to calculate distance in the following way: uS / 58

Future improvements:

  • Trigger and read measurements through a userspace application.
  • Another userspace application could be used to regularly trigger measurements and only output when the distance changes from the last reading, resulting in a simple motion sensor.

Raspberry pi pinout can be found here: https://pinout.xyz/

Datasheet for the sensor can be found here: https://www.alldatasheet.com/datasheet-pdf/pdf/1132203/ETC2/HC-SR04.html

TODO: Add diagram

Build using make.

Insert the module with: sudo insmod dt_ultrasonic.ko

Check that the module has been inserted: sudo lsmod | grep dt_ultrasonic

To trigger a measurement use: echo "1" | sudo tee /dev/usnc_device

To read the result of the measurement use: dmesg | grep dt_ultrasonic

To remove the module use: sudo rmmod dt_ultrasonic

About

Linux device driver for ultrasonic sensor HC-SR04, updated for newer kernel versions and using device tree

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors