Step-by-Step Guide to Deploying Node-RED with FlowFuse in balenaCloud
Fleet management made easier with FlowFuse and balena.
In a recent webinar with balena, we explored the dynamic capabilities of deploying FlowFuse to a fleet of devices using balenaCloud. This blog post serves as a practical guide to replicate that process, specifically tailored for those aiming to streamline their deployment of FlowFuse in an efficient and user-friendly manner.
# How to Implement FlowFuse with balenaCloud on a Fleet of devices
# Preparation Steps
Before diving into the deployment process, it's crucial to familiarize yourself with key resources. We recommend reviewing our previous blog post on deploying the FlowFuse Device Agent via balena. This post contains a vital link to the GitHub repository, essential for deploying FlowFuse with balena, laying the groundwork for the steps ahead.
# Creating a New Fleet in balenaCloud
- Navigate to the FlowFuse git repository. Click on the Deploy with balena button.
- Name your fleet.
- Select your default device.
- Click Create and Deploy.
# Adding Devices to the Fleet
Once your fleet is created, the next step is to add devices. To add a device to your fleet, follow these instructions.
# Setting Up FlowFuse
Setting up FlowFuse correctly is essential for seamless operation:
- Create a new instance within FlowFuse or use an existing one if you prefer. Follow these instructions to create a new instance.
- Create a Device Provisioning Token by following these instructions.
- Ensure you add the FlowFuse Node-RED application you want the devices to provision. If left at default, devices will need to be manually added to applications.
# Using the Device Provisioning Token
- First, convert the contents of the Device Provisioning Token to base64. Follow these instructions to convert the file to base64.
- Once converted, import this string into balena as a Fleet level variable, not a device level variable. Follow these instructions to import the Fleet level variable with the Name
FF_DEVICE_YML
. - This action will provision any new device added to the fleet with the yaml file configuration, automatically adding the device to a FlowFuse instance.
# Deploying and Testing the FlowFuse Instance
Deploying the FlowFuse instance brings everything together:
- Navigate to your FlowFuse application created earlier.
- Go to your devices and you should now see your newly provisioned devices from balena.
- If this is your first time setting up your fleet, the device will not have a snapshot. You will need to deploy a snapshot. Follow these instructions to do so. Ensure that you select Set Target Snapshot.
- Once complete, the FlowFuse instance will deploy to your device(s).
# Integrating InfluxDB (Optional)
Integrating InfluxDB enables effective data storage and management:
- Similar to the previous steps, navigate to this Github repository and click Deploy with balena.
- This time, instead of creating a new fleet, select Use an existing fleet instead.
- Choose your fleet for deployment and select Deploy to fleet.
# Data Generation and Management
For testing, we have created a flow to get you started. Follow this link and import it. There are four sets of flows for you to begin with. The first is for data generation. The second is a manual data generation flow. The third is key as it initiates the creation of a database, in this case, mydb. The last flow is a simple query that pulls data from InfluxDB.
- Import the flows into your FlowFuse instance of Node-RED and deploy. Follow these instructions for importing and exporting.
- Return to Flowfuse, go to your instance, and create another snapshot.
- Ensure that you Set Target Snapshot.
# Finalizing and Testing the Setup
The final steps ensure that your setup is fully operational:
- Once deployed, navigate to the device.
- Enable Developer Mode.
- Next, click the newly revealed button, Open Editor, to access the deployed Flow.
# Conclusion
Implementing FlowFuse with balenaCloud significantly enhances your device management and data processing capabilities. This guide provides a foundational approach, but don't hesitate to delve deeper into each step to tailor the setup to your specific needs.
Written By:
Published on:
Related Articles:
- Capture Data from edge devices with Node-RED
- Import a File into Node-RED with Dashboard 2.0
- Send a File to Node-RED
- Run Node-RED as a service on Windows
- Running the FlowFuse Device Agent as a service on a Raspberry Pi