How and what to monitore for RS485 and RS 232 devices ?

Teltonika offers reliable and simple products to connect your assets. In this article, we’re focusing on two gateways: the TRB 145 (https://teltonika-networks.com/products/gateways/trb145) et the TRB 142 (https://teltonika-networks.com/products/gateways/trb142).
Découvrir le cas en détails

First of all, what is a gateway used for? It’s simply a device that can provide an Internet connection to an asset or a group of assets not connected to the Internet.

This is what offers the TRB 145 and 142 from Teltonika:

What do we like about those two:

How to use those gateways? If you want to push data from an automata, it’s quite simple:

  1. connect the TRB to the serial (485 or 232)
  2. configure the serial port in read mode
  3. read the data
  4. send the data to BAG·Tower
  5. go back to step 1 for continuous monitoring

Here is a code sample that reads the RS 485 or 232 serial port and sends the data to BAG·Tower.


#!/bin/sh

API_KEY=__ASSET_API_KEY__

# Set serial port parameters
SERIAL_PORT="/dev/ttyRS485-0"
BAUD_RATE="9600"
TIMEOUT="10"

# Configure the serial port
stty -F $SERIAL_PORT $BAUD_RATE cs8 -cstopb -parenb

# Send the command to the RS-485 device (replace 'YOUR_COMMAND_HERE' with your actual command)
echo -n "YOUR_COMMAND_HERE" > $SERIAL_PORT

# Capture the response into a string
read_value=$(timeout $TIMEOUT cat $SERIAL_PORT)

# Send the captured data to an API using curl
curl -s -X POST "https://api.bagtower.bag-era.fr/v2/logs" -H "Content-Type: application/json" -H "x-api-key: $API_KEY"  -d "data=$read_value"

echo "Data sent to the BAG·Tower!"

 

To continuously send the data, you can put this script in a crontab


crontab -e
 

Here is the crontab to send the data every 10 minutes


*/10 * * * * /usr/bin/sh /bin/sh /root/push_bagtower.sh
 

Need an easy and fast solution ?

Try BAGTOWER and see how easy it is
September 19, 2023

In summary, the synergy between Teltonika's TRB145 and TRB142 gateways and BAG·Tower's monitoring capabilities exemplifies the power of collaboration. As an esteemed partner of Teltonika, BAG·Tower remains committed to delivering seamless integration and unparalleled monitoring experiences for our users.

Autres articles qui pourraient vous intéreser :

Ready to bring your asset monitoring solution to the next level ?

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
You have more questions ?
Contact us directly.
We can discuss your strategy together.