HTTP POST to cloud database using MODBUS data

Hello

I need to make this POST to my web IoT platform

POST --data “{“temperature”: 12, “Status_OK”:true, “pressure”: 1013}” https://demo.thingsboard.io/api/v1/$ACCESS_TOKEN/attributes --header “Content-Type:application/json”

The three data are collected from a modbus RTU communication at three different address (of course)

My question is : how can build the previous POST with specific data name (temperature, pressure, …) and the collected values in the specific modbus registers.

@MichalPankau , it seems you did it, could you send me some hints to do it ?

Thanks,

Hugues

Hi Hugues,

I have written my own service in shell for OpenWrt, which runs in background each x minutes/seconds and then sends data via mqtt.
My script is for sending just one value at a time, but most of a job is aligned with your needs.

Script is called by service at startup of gateway, then reads config file for modbus settings and required data (adresses, registers, etc), then one by one it calls all required data and if modbus call is success sends data via mqtt.

Are you interested in this kind of solution ?
Regards,
Michal

Hello,
Thanks for your prompt reply !
It seems to be interesting :slight_smile:
However, I am certainly not experienced enough in IT to set up this approach. Let me know your opinion…
Bye,
Hugues

Hi Hugues,

my setup for thingsboard looks like it
device → TRB145 (modbusRTU) / TRB140 (modbusTCP) → mqtt (mosquitto) → EMQ broker → Thingsboard
I think you don’t need to make service like me, but just use Teltonika WebUI.
Do you need to send all data at once ?

Hi,
No special need to send all of them simultaneously. Upto now, I tried to avoid MQTT broker (mosquitto and others) and to simply send the data using HTTP POST.
Anyway, if it is easier to configure, I will do.
Where mosquitto is installed ? Within the TRB module ?
Thanks so much for the discussion and your advice.
Hugues

Yes, with mqtt in gateway TRB140 MQTT - Teltonika Networks Wiki you can configure your json payload easily, then send to thingsboard directly (i think there is simple mqtt broker) or use Data to Server via http TRB140 Data to Server - Teltonika Networks Wiki

Hello. I will try in this way. One additional question : what would you use in the $THINGSBOARD_HOST_NAME ?
Sorry for the basic questions but I am really lost in this field :wink: (I am coming from HW and FW dev side)
Thanks,
H