This example collects telemetry and battery data from a BlueMaestro sensor beacon to log data in a file and print the data to the Node-RED debug panel.
The Vesta Gateways will need permissions set so that the Node-RED palette has permission to install node modules. Follow the article "Adding Node-RED Nodes to the Managed Palette".
All necessary files for this example are available for download at the bottom of this article.
Download the "node-red-contrib-ble-uart" from the palette. The palette is accessible through the Node-RED hamburger menu. Use the install tab to search for the node. Wait for the install to complete.
SSH into the Vesta Gateway using the serial number:
Replace the file
/var/node-red/node_modules/node-red-contrib-ble-uart/ble-uart.js with the ble-uart.js file attached here.
Import the flow through the clipboard.
Copy and paste the code in flow.json in the available field and select "Import"
Make sure to select "Deploy".
Either reboot the Vesta Gateway or run the following series of commands to make sure Node-RED has installed the change to the node:
- /etc/init.d/node-red stop
- /etc/init.d/bluetooth restart
- /etc/init.d/node-red start
How Does the Example Work?
The example will display the "ble uart" node as "Scanning..." until it detects the BlueMaestro sensor. The node will change to "Device ready" once a device has been detected.
The debug panel in Node-RED will show a similar output when the "Tell" button is pressed.
The debug panel in Node-RED will show a similar output when the "Battery" button is pressed.
By default, the output file will be kept at
 Note: node-red-contrib-ble-uart has been submitted to Node_RED to support BLE devices using the UART profile from Nordic Semiconductor. The attached ble-uart.js file has been altered by Rigado so that the node does not scan for a specific device name, and it scans again once a device is disconnected.