CONTROLLINO is an amazingly simple yet powerful, industry ready PLC, based on Arduino Open Source Software Technology and it can serve all your controlling and automation needs in both commercial and industrial applications. 

This incredible Arduino-PLC device currently offers 3 sizes of its devices: MINI, MAXI (Standard & Automation) and MEGA. All of them with multitude of analog and digital inputs and outputs. For more information and a list of features for the CONTROLLINO, check out their website.

Connecting your Controllino

With your device in hand and this guide to assist you, in no time you can have your own CONTROLLINO driven and Ubidots powered application.

PRO TIP: If your a building an Industrial IoT application, we recommend you take a look of the article below to see all the features that Ubidots can brings to their users into the different licenses:

Requirements

Step 1. Setup the Arduino IDE with your device 

To start this tutorial, we will begin by connecting your CONTROLLINO to the Arduino IDE. To do this we have to setup the CONTROLLINO boards and install the libraries required.

1.- Download the Arduino IDE if you have not already. Open the Arduino IDE, select Files -> Preferences:

In the following window enter the URL below into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas, if needed:

https://raw.githubusercontent.com/CONTROLLINO-PLC/CONTROLLINO_Library/master/Boards/package_ControllinoHardware_index.json

2.- Open Boards Manager from Tools -> Board -> Boards Manager and install the CONTROLLINO boards. 

Pro Tip: To simply find the correct device, search CONTROLLINO within the search bar.

3.- Select your CONTROLLINO MAXI from Tools > Board menu.

4.- Thanks to the libraries, the CONTROLLINO and Ubidots team makes connecting things easier for you, in order to start in as easily and quickly as possible. 

Installing the Ubidots Library 

a) Go to the library repository to download the Ubidots Arduino Ethernet library. To download the library clicking the green button called "Clone or download" and select "Download ZIP".

b) Now back in the Arduino IDE, click on Sketch -> Include Library -> Add .ZIP Library

c) Select the .ZIP file of UbidotsArduinoEthernet and then “Accept” or “Choose

If successful you will receive the message below in the Arduino IDE:

Installing CONTROLLINO library

a) Go to Sketch/Program -> Include Library -> Library Manager and install the CONTROLLINO library. 

To simply find the correct library, search CONTROLLINO within the search bar. 

Make sure to install the last version of the library, in order to verify that everthing is updated. 

 

IMPORTANT NOTE: Once you've finish all the steps above, close and restart the Arduino IDE.

Step 2. Setup the CONTROLLINO 

1. To start, take the CONTROLLINO device and connect it to the 12/24 power supply.

2. Once the device is properly powered, you have to establish the connection with your computer to be able to program it and with a router to access the internet. Connect your Controlino to the computer with your USB cable (the same one that comes with the Arduino) and to an router with an Ethernet cable.

3. To verify the connection and check the IP address assigned to the device, go to the Arduino IDE and open the following example from Arduino > Examples > Ethernet > DhcpAddressPrinter. To verify that everything is ok with the example, press the Check Mark icon in the top-left corner of our Arduino IDE:

Next, your have to upload the code into your CONTROLLINO. To do this, choose the right-arrow icon beside the check mark icon. 

To visualize the IP address assigned to the device open the Serial Monitor of the Arduino IDE using the "magnifying glass" icon found in the top-right corner of your IDE display.

You will see the message below from the Serial Monitor:

If you are not able to visualize the IP address, verify if the device is properly connected and has powered. Also verify the Ethernet connection.

4. Now that you've verify that your device is properly connected, it is time to start with Ubidots.

a) Open your Ubidots account and go to the Device section and select add a new device. To create the device, just press "Add Device" and assign "controllino" as the name.

Once the device is created, you will see something like this:  

b) Now with the device is created, it is time to create the variables needed to control the device. To create the variable, simply press "Add Variable" from your device screen.

Assign the name desired by you, in this case I decided to called ours "control". It's is important to mention that if you assign any other name to the variable, you have to change the API Label assigned in the code below; if not, your device will be not able to communicate with Ubidots. 

5. It's time to start coding! 

a) Copy and paste the code below into the Arduino IDE. Once the code is pasted assign your Ubidots token where is indicated. If you don't how locate your Ubidots TOKEN, please reference this article below. Also, assign the IP address assigned to the device in the previously example "DhcpAddressPrinter" where indicated in the code below.

#include <Controllino.h>
#include <Ethernet.h>
#include <SPI.h>
#include <UbidotsEthernet.h>

#define TOKEN  "Assign_your_Ubidots_token"  // Put here your Ubidots TOKEN
#define DEVICE_LABEL  "controllino"  // Put here your Ubidots variable ID
#define VARIABLE_LABEL_POST  "sensor" // Put here your Ubidots variable label to POST data
#define VARIABLE_LABEL_GET  "control"  // Put here your Ubidots  variable label to GET data
                                                          // This variable have to be created before in Ubidots


// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(10, 42, 0, 121);

Ubidots client(TOKEN);

void setup(){
   
    pinMode(CONTROLLINO_R0, OUTPUT);
    pinMode(CONTROLLINO_A0, INPUT);
   
    Serial.begin(9600);
    // start the Ethernet connection:
    if (Ethernet.begin(mac) == 0) {
      Serial.println("Failed to configure Ethernet using DHCP");
      // try to congifure using IP address instead of DHCP:
      Ethernet.begin(mac, ip);
    }
    // give the Ethernet shield a second to initialize:
    delay(1000);
}
void loop(){
    /* Reading the sensor */
    float value = analogRead(CONTROLLINO_A0);
    /* Posting the variables to Ubidots*/
    client.add(VARIABLE_LABEL_POST, value);
    client.sendAll();

    /* Getting the values from Ubidots */
    float control_status =  client.getValue(DEVICE_LABEL,VARIABLE_LABEL_GET);
    /* Write a the value received from Ubidots (HIGH or LOW) to the Digital Pin*/
    digitalWrite(CONTROLLINO_R0, control_status);
}


b) Verify
and upload the code into the device following the same process mentioned in the point 3 of the step 2.  

c) Once the code is properly uploaded, you will see a new variable created in the device previously. 

d) In order to control a variable, you have to create a control widget. Go to the Dashboard section, and press the "+" icon from the top right of the page to add the Widget.

To create the control widget click Control > Switch > controllino > control > finish.

Once your widget is created you should see something similar to the below visual on your dashboard:

Now you are able to control your CONTROLLINO from Ubidots!

Result

In just only a few minutes you've built an industrial ready IoT application using a robust and versatile IoT device, letting you send data and control assets. 

Reference to the Ubidots Help Center for any doubt, and as always, don't forget the Ubidots support team is here to help as best we can with your Ubidots setup and integration questions.

Happy Hacking! :)

Did this answer your question?