# Fatigue sensor

Syrus can communicate with fatigue sensor accessories which help monitor driver's fatigue. Fatigue sensors work as a standalone solution by alerting when a driver is closing his/her eyes, together with Syrus you can get notified whenever one of these fatigue alarms are triggered and view the captured photos associated which each fatigue event.

General Overview

  • The way it works is that you instruct the Syrus to use it's RS232 RX & TX cables to work in fatigue_sensor mode
  • Connect one of the compatible fatigue sensors to the Syrus
  • Use the apx-serial tool or Syruslang to capture photos

# Installation

Syrus 4 Datasheet with Pinout

For this example we'll connect Caredrive MR688B fatigue sensor to the Syrus.

Caredrive MR688B

Serial Wiring Pinout (found in 14-pin molex)

Fatigue Sensor Wires Signal Description Syrus Signal Syrus Wires
Blue RX Fatigue sensor RX (MR688B 232 data receiver), connect to the Syrus orange data transmitter cable. RS232_TX Orange
Green TX Fatigue sensor TX (MR688B 232 data transmission), connect to the Syrus blue data receiver cable. RS232_RX Blue
Red PWR Power for the Fatigue sensor accessory, use the same power source as the Syrus +12-24V DC.
Black GND Fatigue sensor's ground, connect to the Syrus 4 electrical ground cable. GND Brown

# Configuration

Once you have the Fatigue Sensor accessory connected to the Syrus you can configure the serial port to fatigue_sensor mode with the apx-serial tool.

$ sudo apx-serial mode fatigue_sensor

To test the communication with the accessory, you can use the capture command.

$ sudo apx-serial fatigue_sensor capture

a photo is captured and automatically uploaded to the default directory: /data/users/syrus4g/fatigue_sensor.

Before your first drive it's important to change the default settings, here's some recommended apx commands you can use to program the camera for 'normal' operation.

# Set sensitivity to 2.9 seconds
$ sudo apx-serial fatigue_sensor sensitivity 3

# Set minimum speed to 30kph
$ sudo apx-serial fatigue_sensor min_speed 30

# Set speeding alarm threshold to 135kph
$ sudo apx-serial fatigue_sensor speeding 135

# Set the speaker volume to low
$ sudo apx-serial fatigue_sensor speaker_volume 1

Ensure the changes are saved by turning the fatigue sensor off and back on.

Note that some fatigue sensors include dip switches on the back of the camera that override these settings. Follow the recommended settings in the manual of the fatigue sensor

Caredrive MR688B Dip Switches

# FTP configuration

The images that are saved automatically to the default directory can be uploaded via ftp using lftp

An event generated will have a reference to the image:

    "fatigue_sensor": {
        "state": "connected",
        "sensitivity": 3,
        "speaker_volume": 2,
        "min_speed": 10,
        "speeding": 50,
        "max_photos": 50,
        "nbr_photos": 24,
        "latest_photo": "1616442180-photo.jpeg"

On the remote FTP server we recommend creating subdirectories using each device IMEI, followed by a subfolder for images. Example: ftp://ftp.mysite.com/867698041103030/images

With the above in place you can upload it like this

# upload photo
lftp -u username,password -p 4455 -e 'put /data/users/syrus4g/fatigue_sensor/1616442180-photo.jpeg -o 867698041103030/images/1616442180-photo.jpeg; bye' ftp://ftp.mysite.com

lftp includes a command for mirroring the contents of a source folder with the remote server, make sure to add a -c option to continue the file transfer in case there's an interruption.

# reverse mirror contents from source into destination directory
lftp -u username,password -p 4455 -e 'mirror -c --reverse /data/users/syrus4g/fatigue_sensor/ 867698041103030/images/; bye' ftp://ftp.mysite.com

once mirrored you can use the -n option to upload only newer files

# upload new images only
lftp -u username,password -p 4455 -e 'mirror -n --reverse /data/users/syrus4g/fatigue_sensor/ 867698041103030/images/; bye' ftp://ftp.mysite.com

another useful option is to force ssl, which refuses to send the password in clear when the remote server does not support ssl

# force ssl connection to remote server
lftp -u username,password -p 4455 -e 'set ftp:ssl-force=true put /data/users/syrus4g/fatigue_sensor/1616442180-photo.jpeg 867698041103030/images/1616442180-photo.jpeg; bye' ftp://ftp.mysite.com

# Redis Interaction

Connection Status

To notify the connection status, the serial application publishes

serial/notification/fatigue_s/state connected

when connected, or

serial/notification/fatigue_s/state disconnected

when disconnected.

Fatigue Alarm

To notify a fatigue alarm, the serial application publishes

serial/notification/fatigue_s/photo 1615813683-fatigue_remind.jpeg

serial/notification/fatigue_s/photo 1615813683-fatigue_alarm.jpeg

serial/notification/fatigue_s/photo 1615813683-fatigue_warning.jpeg

Driver Not Detected

To notify when a driver is not detected, the serial application publishes

serial/notification/fatigue_s/photo 1615813683-no_portrait.jpeg

Driver Distracted

To notify when a driver is distracted, the serial application publishes

serial/notification/fatigue_s/photo 1615813683-distraction.jpeg

Manual Photo Captured

To notify when a photo is taken with the captured command, the serial application publishes

serial/notification/fatigue_s/photo 1615813683-photo.jpeg

# Tips

Take note of the amount of space occupied by the photos in the /data/users/syrus4g/fatigue_sensor folder.

Once your application has received a photo you may want to delete them based on the epoch

$ rm 16158136*

If you lower the buffer size it will delete the oldest photos over the new size limit.

Last Updated: 3/31/2021, 8:12:02 AM