Living on the Edge – How to Use Edge Computing with CloudRail

 In CloudRail

In this blog post, we will talk about Edge Computing using CloudRails’ native Edge Computing functionality. Compared to AWS Greengrass CloudRail Edge Functions works cloud provider agnostic. This means you can use Edge Computing for any of our supported cloud platforms and not only AWS. Moreover, it is possible to use the same function for devices that are connected to different cloud platforms in parallel. Another differentiator to AWS Greengrass is simplicity. While AWS Greengrass is perfect for complex algorithms or even machine learning, CloudRail Edge Functions allow you to do very simple tasks like building sums, averages or do simple calculations like described in this tutorial. But first, let’s talk about Edge Computing in general.

What is Edge Computing?

 

edge computing overview

Source – Alibaba Cloud

Well in short terms by definition edge computing is “A distributed computing approach that attributes data processing to edge devices”. Still unclear right😒?

Let’s quickly jump into that. To illustrate what is what, imagine the cloud services we use daily in our IoT solutions, such as AWS, Alibaba, Azure or IBM. Those services help us (between lots of other things) to send and receive data/commands/instructions to our devices (also with the help of the CloudRail.Box 👍), in this scenario our devices represent … guess what … exactly! Edge devices!

With that background in mind, we can say in more simple terms that edge computing is when those “edge devices” analyze and process that data before sending it to the cloud, as close as possible to the collecting source. Do you want more? Alibaba Cloud has an interesting text about this topic.

Why Edge Computing?

I guess you can already imagine infinite advantages that could bring, among them we can enumerate:

  • Latency Optimization;
  • Lessen the load on the server and the network. (Less processing, cheaper bills 💰);
  • Distributed computation;

 

How to Use Edge Computing with CloudRail?

Edge Computing? Yes, we can! Using our solution and with a little help from our cloud platform to configure the devices on the go, we can easily achieve our edge computing over the CloudRail.Box.

  • Scenario: We have set up our CloudRail basic environment and we currently have a temperature sensor attached to it. (let’s call it MrKelvin)
  • Objective: Using CloudRail Edge Computing functionality lets make our temperature sensor (MrKelvin) witch currently displays values only in Celsius and Fahrenheit to display the temperature only in … well… Kelvin. 👨‍🔬

Talk is cheap, show me the code!

Before going through the following text you might want to give a look in the video we have prepared for this blog post to make it even easier for you.

Step 1: Setup CloudRail Environment

To use Amazon Web Services (AWS) with the CloudRail Device Management Cloud, you must have an AWS account and subscribe to the AWS IoT Core service. You can actually choose any cloud service supported by our platform, but for the sake of simplicity we will use AWS in this tutorial. For in detail instructions check our documentation page.

 

Link your cloud service with your CloudRail account using our Credentials Manager. You can find the credentials link in the homepage after the login at https://devices.cloudrail.com 

 

Step 3: Create a temperature device.

In the Boxes page (https://devices.cloudrail.com/modules), click in the “New Device” button to initiate the process;

 

Select the temperature device and configure it to read the data as you wish. Then, it is possible to select either on a periodic interval or “on change”. For this article, we will use the “interval” configuration.

.      

 

Step 4: Create our Edge function “CelciusToKelvin”

The edge functions in CloudRail are not dependant on any device or CloudRail.Box, this means that you can reuse the functions among different devices and boxes (even if you delete the device). So first let’s go to our Edge Functions page (devices.cloudrail.com/functions).

Now lets actually add our edge function. We here have two options, either we upload a JS/ZIP file containing the code or we can quickly type in the Code Editor Embbed on the page, let’s go for the last one. Ok now we need to type a code that actually makes MrKelvin send us ONLY the temperature in Kelvin, should be:

Code snippet:

 

Step 5: Attach the function to the temperature device.

After creating the function we need to attach it to a created sensor, we can do that either on the Edge Functions page or in the Device Details page:

 

 

Done!

Now our CloudRail.Box is already doing the edge computing to provide us with the temperature in Kelvin and also getting rid of the burden data that was being sent before. You can check in the selected cloud services the messages that the device is sending to the MQTT broker, in our case you can go to the “Test” and just subscribe to the devices MQTT publish topic. That is it for Edge computing! For more information check our Documentation page and our videos! Now MrKelvin can finally be worthy of thy name.

Recent Posts