Detect passing locomotives end of train device (EOTD) and publish messages to MQTT
1.8K
Uses RTL_FM and SDR to detect passing locomotives end of train device (EOTD) and publish messages to
MQTT. Monitors head of train at 452.9375MHz by default. You can tune to 457.9375MHz for end of train detection.
Optimum squelch value will vary greatly based on antenna, distance from locomotive, etc. Once the container is running, for the initial squelch tuning I recommend using docker exec -it tcontainer_name /bin/bash, executing pkill rtl_fm inside the container and manually running rtl_fm -f $FREQUENCY -M fm -l $SQUELCH. Lower the squelch value until you begin picking up noise, and then raise it slightly to suppress the noise again. This will be a good starting point!
https://hub.docker.com/r/aneisch/train-sensor
version: '3.2'
services:
train-sensor:
container_name: train-sensor
image: aneisch/train-sensor
restart: 'on-failure'
devices:
- '/dev/rtl_sdr:/dev/bus/usb/001/005'
environment:
- SQUELCH=90
docker run:docker run -d --name train-sensor --device='/dev/rtl_sdr:/dev/bus/usb/001/005' \
-e SQUELCH=90 aneisch/train-sensor
Note: The rtl_fm process will run as an unprivileged user. Ensure you grant access to your SDR dongle.
You only need to specify the environmental variables in docker run or your docker-compose file that you want/need to override:
| variable | default | description |
|---|---|---|
DEVICE_INDEX | 0 | SDR device index |
FREQUENCY | 452.9375 | MQTT server address |
SQUELCH | 120 | Squelch level |
MQTT_HOST | 10.0.1.22 | MQTT server address/hostname |
MQTT_PORT | 1883 | MQTT server port (non-ssl) |
MQTT_TOPIC | sensor/train | Topic where train detection will be published. Publishes 1 when detected. |
HOLDOFF_TIME | 600 | Time in seconds to prevent trigger after a detection |
Content type
Image
Digest
Size
3.7 MB
Last updated
over 6 years ago
docker pull aneisch/train-sensor