The Internet of Things is kinda the buzz now. But is it still possible to do IoT without the need for an Arduino-compatible wifi/ethernet shield or the ESP8266 wifi module at the least? Fret no more, because it is!
You will need the following:
- Arduino board (I will use an Arduino Uno compatible board)
- Three (3) LEDs
- Three (2) 220-ohm resistors (which we will use to control via the Internet)
- A breadboard
- Some jumper wires
- and lastly, a computer with Internet connection. This will be the gateway of the Arduino and the devices connected to it, to the Internet.
The schematics for this activity is as follows:
The first thing to do is (well of course, register for a FREE account at Cayenne Sign Up. Log on to your account after having set it up successfully:
After successfully logging on to your Cayenne account, we need to add a new device:
After clicking Device/Widget under Add New combo box, you will be shown options to choose from. Select Arduino under Microcontrollers:
Next, you will be shown a screen that will guide you on how to set your Arduino board Arduino IDE, and the libraries. We already covered this in our previous tutorial. Click the Next button afterwards:
Clicking the Next button will prompt you to the next step which will as you what type of board you are going to use. But in this activity, that will be irrelevant. We will only focus on the AUTH TOKEN FOR THIS DEVICE. The value here will be used in the sketch you will be uploading to your board. Take note of the Auth Token value. Here, it is 5lre2s21xd. But you need to replace this with the actual token you will be receiving:
At this stage, Cayenne IoT platform in your account will be waiting for the board to be connected to it. Follow the next steps carefully.
Open you Arduino IDE. Be sure that all Cayenne libraries are installed correctly. Will be opening up a sketch which we will be using for this project.
Go to File > Examples > Cayenne > Internet Connections > Serial USB Connection:
A sketch will be shown. We will use this sketch for your activity. Now, you need to change the value of the token array variable and assign it with the Auth Token found in your set up:
After changing it, we are now ready to upload the sketch to your Arduino board (Arduino Uno in my case). After successfully uploading the sketch, we need one more thing to do. In the comment section of the sketch, you will see:
In order for this to work you must run the connection script on the machine the Arduino is connected to. The scripts are located under the extras\scripts folder in the main library folder. This redirects the traffic from the Arduino to the Cayenne server. Steps: 1. Set the token variable to match the Arduino token from the Dashboard. 2. Compile and upload this sketch. 3. Launch the connection script as described below for Windows or Linux/OSX. Windows: 1. Open the Windows command line (cmd.exe) 2. Navigate to the scripts folder by typing "cd [path]", e.g. "cd C:\Users\[YourUserName]\Documents\Arduino\libraries\Cayenne\extras\scripts" 3. Run the script by typing "cayenne-ser.bat -c COM4" (where COM4 is port with your Arduino) and hitting Enter
I am using Windows, so I will focus on the steps needed for Windows.
Open the Command Line as an Administrator:
Go to the Cayenne scripts folder. The highlighted text below (in red) will be different and will be your actual username in your local machine:
Now, type the command to run the script. My Arduino is connected to COM3 on may laptop, so yours might be connected to a different one.
After pressing Enter, you will see something like this. This script will actually establish connection between your Arduino board and Cayenne:
Now, go back to your Cayenne account. The page has changed, and at the left side portion of the page is the list of configured device (Arduino board), including the new one. The icon is currently NOT grayed out, meaning it is online now:
At this point we will now be adding the three (3) LEDs to the board.
Go to Add New… then click Device/Wdiget:
Scroll down, and find Actuators. Select Light:
Select Light Switch:
Now, lets configure the first LED. This is connected to Digital 13 on Arduino Uno. For the device, select the newly added board (Arduino in our case):
Click Add Actuator. There’s no need for Step 1, since we already have the sketch. You will now see the new widget being added:
Follow the same steps for the rest of the LEDs (Blue and Green). Blue LED is connected to Digital Pin 12 of the Arduino Uno, Green LED to Digital Pin 11 of the same board. The final widgets will be similar to the one below:
We are now done. You may now click the buttons to turn the LEDs on or off. Image below shows the actual set up of my components:
I hope this helps those beginners like me. This article will also serve as a documentation for myself. I might need this in the future if I will be trying to re-create the project.
Thank you very much.