This repo contains scripts and Fritzing sketch for using the AJ-SR04M Ultrasonic Ranging Module on the ArduSub's Companion Computer, as an altimeter.
The altimeter.py
program reads distance values from AJ-SR04M ultrasonic sensor and sends to QGC using the Pymavlink module.
Is intented to run on an ArduSub's Companion Computer (tested on Raspberry Pi 3 model B with the Companion Software installed).
- placed in companion's
/home/pi/altimeter/
directory SONAR_MIN
andSONAR_MAX
variables set to 0 (depth hold mode)
A service is created (systemd), so the altimeter provides continuous data to the QGC.
- copy altimeter.py in
/home/pi/altimeter
directory and make it executable:
chmod +x /home/pi/altimeter/altimeter.py
- copy altimeter.service unit file in
/etc/systemd/system/
directory and start the service:
sudo chown root:root /etc/systemd/system/altimeter.service
sudo chmod 644 /etc/systemd/system/altimeter.service
sudo systemctl daemon-reload
sudo systemctl enable altimeter.service
sudo systemctl start altimeter.service
- use functions in python code
- perform GPIO cleanup when the service is stopped
- print service's log into systemd journal logs
- MAVLink parameters RNGFND_MIN and RNGFND_MAX should not be used for depth hold mode
- evaluate sensor's (AJ-SR04M) underwater accuracy (temperature ?)
- Ultrasonic Distance Measurement Using Python – Part 1
- Raspberry Pi Computing: Ultrasonic Distance Measurement by Malcolm Maclean
- Measuring distance with JSN-SR04T and Raspberry
- What is the difference between BOARD and BCM for GPIO pin numbering?
- HC-SR04 Ultrasonic Ranging Sensor Module
- AJ-SR04M Integration Ultrasonic Ranging Module
- Understanding Systemd Units and Unit Files
- How to run a script as a service in Raspberry Pi - Raspbian Jessie
- How to exit a python daemon cleanly?
- systemd.kill — Process killing procedure configuration
- Notes on Underwater Ranging
- Design of a Low-Cost, Underwater Acoustic Modem for Short-Range Sensor Networks
- MAVLink Step by Step by Pedro Albuquerque on Ardupilot forums
License: GNU GPLv3