What is Grandeur and Why Grandeur?
(Pain Point)
Since IoT is the new world order, sooner or later there will be a huge need for developers in this field. It is a time-consuming task, and very difficult for a developer to work on an IoT-based project alone. For working on such projects many resources and several engineers and people are required.
Grandeur is the solution to all such problems. Here developers get a complete package by which they can make their products easily in a short time. You get a full-stack package with a backend that handles all the functions of your app and hardware, a frontend for your app, and some WIFI module, all you have to do is to integrate your product with it.
Since there are two things a backend and a frontend so there are two components of grandeur:
The Arduino SDK and Canvas.
Following are the steps to get a quick start with grandeur:
- Sign in to grandeur at https://canvas.grandeur.tech
- Sign in to grandeur at https://canvas.grandeur.tech
Click on get access to signup or to create a new account.
Fill in all the required fields and click submit.
You would have received a one-time password(OTP) on the number you added in the previous step, copy that here and click Submit.
- Create a New Project
The moment you see this screen, consider your account created. Now you are in Grandeurโs World, you are free to do the magic here. For a start, create a new project by clicking on the button shown.
Fill in the name and description of the project you are working on and click the button, Create Project.
So, your project is created and this is your dashboard.
- Register your device
Click on the DEVICES tab in the menu, located on the left side of your dashboard.
Now click Add, to add your device.
****Note: the device will be your WIFI Module, that you are working with to get your product connected to the internet.
To register your device (WIFI Module), you first need to register its data model. You are free to name the device whatever you want, but in the schema field, you have to be vigilant, while passing a variable with its value.
Suppose we are running a blink function on the WIFI Module, so we can name the data model as โledโ, for instance, and we will write it this way:
{"led": 0}
Here 0
is the initial state of the Led.
After filling all both fields click Add and it will add your model.
Then click Add, in the Devices section.
Click on anywhere on this row.
Select the model that you created in the last step, give the device a machine-descriptive product ID.
You added the ID, now click Register.
Now here you have got a device ID and a device token. You will have to copy-paste them somewhere else, like your notepad, so you can use them afterwards, in the sketch where you will need them to connect your device and WIFI module.
So, your device is registered.
- Register a New User
To control the device from the app, you need a user account. Click on the Accounts tab from the left menu,
and click on the Add Account button.
After filling in all the necessary details, click Add.
An account can only see and control the devices paired with it. So go to the Devices tab, and in the Actions column of the device you created in the previous steps, click on the Pair button.
Select your user account and done.
As you can see, your device has been paired to the user account.
Making a drag-and-drop app with CanvasBy clicking on the Canvas tab in the left menu, you will see this screen.
Click on the Add widgets button, and then add any widget you want, in this case, a buttonโs widget has been selected.
Click on the widget you added, the button, for instance, then click Configure.
Edit the widget configurations, including its title, variable we want to control (since here we are trying to control the LED with this switch button, we choose the led
variable), ON state value, and OFF state value. Then click Save.
The widget is ready now. Clicking on Run button will run our newly created App. Select the device you want to control,
and done.
- Set up the WIFI module
You can use a WIFI library corresponding to your microcontroller to handle your device's WIFI. Here are some popular ones:
- ESP8266: https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WiFi
- ESP32: https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFi
- Arduino WIFI Shield: https://www.arduino.cc/en/Reference/WiFi
Here we illustrate how to handle your ESP8266's WIFI.
#include "recipes/WiFi.h"
#include <Grandeur.h>
// Pin 2 is attached to the ESP's builtin LED.
int ledPin = 2;
// Grandeur credentials.
**const char* apiKey = YOUR_API_KEY;
const char* deviceID = YOUR_DEVICE_ID;
const char* token = YOUR_DEVICE_TOKEN;**
Grandeur::Project project;
Grandeur::Project::Device device;
// Function that runs when the LED is toggled from the Internet.
void updateLED(const char* path, const char* update);
void setup() {
Serial.begin(9600);
// Connecting to WiFi.
**connectWiFi(WIFI_SSID, WIFI_PASSPHRASE);**
// Initializing.
project = grandeur.init(apiKey, token);
device = project.device(deviceID);
// Schedule the updateLED function for the update in "led" variable.
device.data().on("led", updateLED);
}
void loop() {
// Synchronizing the ESP with the Cloud.
project.loop();
}
void updateLED(const char* path, const char* update) {
// "update" contains the updated value of the "led" variable. If it's toggled,
// we toggle the ledPin.
if(strcmp(update, "0") == 0) digitalWrite(ledPin, 1);
else if(strcmp(update, "1") == 0) digitalWrite(ledPin, 0);
}
All you have to do is to replace the API key and token, with the one you copied at the end of step 3. Then add the WIFI credentials, and done.
Now just run the code and with the command grandeur run, your WIFI module will be connected to your device and you can test it by running it by changing the states of the device through the canvas.
You can have a look at the complete tutorial here:
Comments
Please log in or sign up to comment.