8297 questions

9760 answers

15547 comments

13864 members

0 votes
37 views 0 comments
by
Hello

My task -> using TRB142 to send data from sensor with serial interface to Azure IoTHub using MQTT. TRB142 Configuration part for MQTT and  Azure is clear for me. But how to configure serial interface?

1 Answer

0 votes
by

Hello,

TRB142 do not have a feature which would allow it to send serial data over MQTT. This would require additional development.

But you could try making a custom scripts which for example would log serial data to file, and then another script would take that info and with the help of mosquitto package you could try and send that data over MQTT.

Here are some ideas how those scripts could potentially look like:

- Logging serial data:

#!/bin/ash
microcom /dev/rs232 > /tmp/serialtomqtt.txt

- Sending data over MQTT:

#!/bin/ash
while true
do
if [ -s /tmp/serialtomqtt.txt ]
then
mosquitto_pub -h 192.168.1.244 -p 8800 -m "$(cat /tmp/serialtomqtt.txt)" -t testas
echo -n "" > /tmp/serialtomqtt.txt
else
mosquitto_pub -h 192.168.1.244 -p 8800 -t testas -m Nothning_Received
fi
sleep 10
done

You might need to install mosquitto package via opkg.

Please, keep in mind this is only a theory and we are not sure if this solution will work, so please test with "pinch of salt".

Best regards,