/ardusub_altimeter_aj-sr04m

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

ArduSub Altimeter using the AJ-SR04M Ultrasonic Ranging Module

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 and SONAR_MAX variables set to 0 (depth hold mode)

A service is created (systemd), so the altimeter provides continuous data to the QGC.

Use

  • 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

TODO

  • 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 ?)

Based on

  1. Ultrasonic Distance Measurement Using Python – Part 1
  2. Raspberry Pi Computing: Ultrasonic Distance Measurement by Malcolm Maclean
  3. Measuring distance with JSN-SR04T and Raspberry
  4. What is the difference between BOARD and BCM for GPIO pin numbering?
  5. HC-SR04 Ultrasonic Ranging Sensor Module
  6. AJ-SR04M Integration Ultrasonic Ranging Module
  7. Understanding Systemd Units and Unit Files
  8. How to run a script as a service in Raspberry Pi - Raspbian Jessie
  9. How to exit a python daemon cleanly?
  10. systemd.kill — Process killing procedure configuration

ArduSub GitBook references

  1. Altimeters
  2. Pymavlink
  3. ArduSub Parameters

General notes on MAVLink, Underwater Ranging and Acoustics

  1. Notes on Underwater Ranging
  2. Design of a Low-Cost, Underwater Acoustic Modem for Short-Range Sensor Networks
  3. MAVLink Step by Step by Pedro Albuquerque on Ardupilot forums

License: GNU GPLv3 Logo GNU GPLv3