Connect an Arduino or Controllino

In this tutorial, we will learn how to connect an Arduino-based device with Ethernet to Controllino Cloud.

What this tutorial covers #

  • Installing the Controllino Cloud Library for Arduino IDE
  • Adding a new device to Controllino Cloud
  • Creating a sketch that sends data over to Controllino Cloud

Download & install the library #

Please click on the button below to download the Controllino Cloud library to your computer.

Now, open up the Arduino IDE and use the Library Manager to install it. To get into Library Manager, click on the “Sketch” menu on the top and then go to Include Library > Add .ZIP Library

You will be prompted to select the library you would like to add. Navigate to the location of your ZIP file and open it.

Revisit the “Sketch” menu on the top again and choose Include Library. Here, you will now see the Controllino Cloud library at the bottom of the drop-down.

We are now ready to check out the examples of the library, but first let’s visit Controllino Cloud and add a device.

Add a new Device to Controllino Cloud #

Create a Device Group #

In the left-side menu, click on DEVICES. After that, you will see the round “+” icon on the right-bottom of your screen. Click on it to add an entity group.

Now, you probably wonder… “What the heck is an entity group? I want to add devices!” Let’s explain this topic before we continue:

An entity group in that case is basically just a group of devices. Let’s assume you have a building with several rooms, then you could group your devices by room. This forces you to organize your devices from the beginning and will make the management of them way easier in the future.

Now that you know what en entity group is, give it a name and a description.

After that, you can already save the entity group or share it with other users within your cloud. For now, we will just save it.

Add a Device to the Device Group #

Open up your device group and klick on the + icon on the top-right.

We will add a device to the cloud. A new window will open up. Here, you will be prompted to give your device a name, a description and some other settings. For the sake of simplicity, we will ignore the other options for now and just give it a name.

Click on “Next: Credentials” and give your device some random access token. Think of it as a password for your device, so make sure to keep this as random as possible. This token will later be used in the Arduino code, so please copy it somewhere. Note: If you don’t provide a token at this step, it will be automatically generated.

Click on “Add”.
That’s it! You have successfully created a new device.

Create a Sketch and upload it #

Next, we will use one of the example sketches provided. Let’s go to “File” > “Examples” > “CONTROLLINO_Cloud-main” and pick the last of the 4 examples.

Note: depending on if you want to send attributes or telemetry data to Controllino Cloud, you would pick either the SingleAttributes or the SingleTelemetry sketch. If you don’t know which one to pick, read the Platform Overview guide first. We will use the SingleTelemetry example in this tutorial, as we’d like to send over some temperature data.

Now, you will see the example sketch. Let’s go through the sketch and see what we need to change in order to send some data over to the cloud.

byte mac[] = {  0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };

Here, we would usually change the MAC address of your Ethernet shield or module. Please add 6 random bytes here. If your desired MAC address would be AA:BB:CC:DD:EE:FF, you would enter:

byte mac[] = {  0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };

Note: Please use a unique MAC address that nobody else has on your network to avoid conflicts.

The next thing we will set is the access token we generated before. Please add your token in the following line of code (here, we have already added our own token):

const char * token = "f83828f0e634ead837";

The last important piece of code is the function sendTelemetries() – you can find it at the very bottom of the example sketch.

void sendTelemetries(void) 
{
  // Sending telemetries in a serial way one after another. 
  cc.sendTelemetry("temperature", 42);
  cc.sendTelemetry("active", true);
}

Here’s where the magic happens. If you want to send over some data (remember, we are sending key-value-pairs), then you would do it here.

When sending data, give your data piece a name (= key) and a value. In our case, we are sending temperature data with value 42 and a status check called active with the value true. Of course, you can not just enter static data here, but use any variable of your choice. For the sake of simplicity, we will leave everything like it is in the example sketch and don’t upload dynamic data.

Now, upload your sketch to your board and make sure the device is connected to the Internet over an Ethernet cable.

View your data in Controllino Cloud #

On Controllino Cloud, open up the Device Group you created before and then open up the Device by clicking on the row.

A new window will appear. Let’s switch to the “Latest telemetry” tab and see if our device sends data…

If you see your values here – awesome, you did it! Your device is now sending telemetry data to the cloud, and we can start working with it.

The next thing you’d probably like to do is to visualize your data in a nice Dashboard with some Widgets. For that, get some coffee and start reading through the following articles to learn more how to work with Dashboards and Widgets: