Connect tracker to Node RED
This will be the final step to have our GPRS tracker running in our system
We already have this path clear, next, we will have node-red to catch the data, then do some data processing.
Let me explain this in more detail.
Processing data at Node RED
If you carefully look at the code, our code only design to provide 3 data, that will be device ID, GPS location data in HEX (this is a data format), and battery level. Before I send It to server, I reformat the data into JSON file, as you can see title, data, also curly bracket, that is why the data is so small, and good for MQTT low latency transmission.
But the problem is Owntracks needs different format about GPS, it needs Latitude and Longitude in coordinate format, so we need shift the data back. Real time data is not provided by low level device like our board, so it must be added from Node-Red, and _Type, and Location is the necessary identifier for Owntracks too. That is why node-red fit in and do this job.
Therefore, I decided to let the device data to be delivered on this temporary channel -- owntracks/frrut/gps1 , the data is not well formatted, so it would not interfere our location points on the map, then I would deliver to actual howard channel, as user howard, and device name gprs_gps.
Then I also have a node to receive all data from Owntracks topic, for debug purpose.
Let me move to Node-Red for setup.
MQTT Input to receive data from Owntracks Mosquitto broker.
Configure Input MQTT credentials.
Receive data from topic : owntracks/frrut/gps1
Function to convert payload to owntracks data format by node-red, then push to MQTT broker
MQTT Output to send data to Owntracks Mosquitto broker.
Change Topic Owntracks/(User Name)/(Device Name)