Sign inSign up

aneisch/train-sensor

By aneisch

•Updated over 6 years ago

Detect passing locomotives end of train device (EOTD) and publish messages to MQTT

Image
0

1.8K

aneisch/train-sensor repository overview

⁠Train Sensor

Buy Me A Coffee

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⁠

⁠Usage

⁠Example docker-compose:
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
⁠Example 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.

⁠Environmental Variables

You only need to specify the environmental variables in docker run or your docker-compose file that you want/need to override:

variabledefaultdescription
DEVICE_INDEX0SDR device index
FREQUENCY452.9375MQTT server address
SQUELCH120Squelch level
MQTT_HOST10.0.1.22MQTT server address/hostname
MQTT_PORT1883MQTT server port (non-ssl)
MQTT_TOPICsensor/trainTopic where train detection will be published. Publishes 1 when detected.
HOLDOFF_TIME600Time in seconds to prevent trigger after a detection

Tag summary

Content type

Image

Digest

Size

3.7 MB

Last updated

over 6 years ago

docker pull aneisch/train-sensor