Seluxit CEO, Daniel Lux, has been nominated for PWC Denmark’s Owner-Manager Award 2020.
Go to wappsto.com, register and log in.
It's free up to generous usage limits [pricing]
Click the Store in the menu on the left side. In Store, find the "Seluxit IoT Creator" wapp and install it.
Click "Open last installed" button.
Here is the IoT Model we will have in this guide and the steps we will go through to create it.
We will describe each step below.
Please note that if you create your own names, you will have to change the code examples in this tutorial accordingly, so watch out for that!
You will now create a so-called Network in Wappsto. We are calling ours "Light" in this example.
Click on the network you have just created, then click the "Add device" to create the device.
We're calling our device "Bulb". Please use caution about naming.
When you create a device, you'll be prompted to fill out a form. Answer the questions meaningfully, as it makes sense to you. But don't sweat the small stuff - this is just a hello world after all. In the image below we have used examples for each field.
In this case, our "Bulb" device only has one value - "on" or "off" / "1" or "0".
To create a "Value", expand "Bulb" panel and click "Add value".
In this tutorial, we're calling our Value "LED". Please note the caution with naming mentioned in previous steps.
Here it is important that you fill out following form fields correctly to make a working example.
When you've finished modeling your Network > Device > Value, click download and save the zip-file containing the certificates, example values, generics as well as a JSON file. Experienced programmers will recognize here that you could write a program in any given programming language on any device that supports these certificates to connect to the Seluxit IoT Platform.
Connect the wires and components as shown below. It is important that you place the LED correctly, as otherwise it will not light up. The "long leg" should be placed at the red wire, in this example connected to pin 11 (GPIO17).
We are using WinSCP to upload the code in this example. Connect to your Pi. Extract the downloaded folder and move it to the Pi as shown.
This description is written for Windows users, if you are using Linux or Mac you can use a terminal to do ssh and scp, instead of using Winscp and Putty.
You can test the connection (see section 8 in this guide) by monitoring the text output in a console, but to get the led to work you will need to modify the "main.py".
Before you continue, please ensure that you have these 2 parts installed:
sudo apt-get install rpi.gpio
sudo pip3 install wappsto
This link https://github.com/Wappsto/IoT_RapidPrototyping/blob/master/example_code/led/led_on_off.py contains the 3 chunks of code you must copy into "main.py".
Now we will connect to the Raspberry Pi using PuTTY. After you log in and start the command line type "cd" and the name of your folder to enter it.
Tip: you can start writing the directory name and press "Tab" to autocomplete.
Once you have entered the directory type in the code:
sudo python3 main.py
Now the IOT model/Pi is connected to Wappsto.
Go to the pre-installed wapp, "My Data", and locate the Network that you've just added to Wappsto and the "Bulb" device with the "LED" value. Navigate to value and toggle the on/off switch. Your LED should respond.
Under the menu point "Installed Apps" find the "Wapp Creator" wapp which will open in a new tab. Click create new and give the wapp a name, e.g. "LED wapp".
In "Wapp Creator", hover on newly created wapp and click "Edit code". You'll have a blank canvas now. What you need to add is 3 files with the following names and code. After you create files and copy paste the code, press "Save" and you will see the UI loading in the canvas on the right side.
Once you save this code a popup will be prompted asking you to accept the permission to control your LED. This is required because by default wapps are not allowed to retrieve any user data. Accept it and try switching your LED "on" and "off" using the buttons in your wapp. (Blinking part is handled in the next step).
Create the following files under the "Background" section the same way you did in the "Foreground" and press "Save".
All the background tasks are constantly running in the cloud. To stop it from running, you can uninstall the wapp or remove the code.
Once you have Saved your files in the "Background" you can go back to the "Foreground" and press "Reload". Try turning your LED "on","off" or to "blink" or "stop blinking", your LED should respond.
How can flashing a LED still be so satisfying?
Try to make you own modifications, and play around.
Please make sure you shut down the Raspberry Pi before unplugging the power cable!
To shut down the Pi, in PuTTY command prompt stop the program by using the keybord command "Ctr+c" twice.
Then enter the following command:
sudo shutdown -h now
The small green light on your Pi should stop blinking, meaning its safe to unplug.