Quick Start: Raspberry Pi

In this guide, you will learn how to quickly get started with the aREST cloud platform & the Raspberry Pi. This guide assumes that you already created an aREST account, so if this is not done yet, you can create a free account here. The guide was made using a Raspberry Pi 4, but it would work with most Raspberry Pi versions.

 #1: Getting your aREST API Key  

The first step is to get your aREST API key. This is really simple to do as you just need to login in your aREST dashboard: 

Then, simply click on the API Key tab or follow this link: 

Your API key should be displayed on this page. You'll need it for later, so either save it somewhere or leave the tab open. 

#2: Setting up your Raspberry Pi 

The next step is to setup your Raspberry Pi so you can use it with aREST. First, if it is not done yet, make sure to install an operating system on your Raspberry Pi. I recommend using the official Raspberry Pi OS, you can find more about how to install it from this page: 

Next, you will also need to install Node.js on your Raspberry Pi. For that, open a terminal on your Raspberry Pi, and type those two commands: 

curl -sL https://deb.nodesource.com/setup_15.x | bash -
apt-get install -y nodejs

This will install Node.js on your Pi. After it's done, you can check it was correctly installed by typing:

node -v

This will show you the current installed version of Node.js, which means it was successfully installed.

#3: Connecting your Raspberry Pi to the cloud 

It's now time to configure your Raspberry Pi! For that, open the terminal on your Raspberry Pi and create a new folder. Then, inside the folder create a file called pi_cloud.js and insert the following code:

// Start
var express = require('express');
var app = express();
var piREST = require('pi-arest')(app);
// Set Raspberry Pi
piREST.setKey('your_key'); piREST.set_id('your_id'); piREST.set_mode('bcm');
// Connect to cloud.aREST.io
// Start server
var server = app.listen(80, function () {
    console.log('Listening on port %d', server.address().port);
Inside this code, you will have to put your API key that you got earlier instead of the your_key variable.

Next, in the terminal type the following command to install the required packages: 

sudo npm install express pi-arest --unsafe-perm

Once this is done, you can finally start aREST on your Raspberry Pi! For that, simply type on a terminal:

node pi_cloud.js

Your Raspberry Pi should now be connected to the aREST cloud!

#4: Checking Your Cloud Dashboard 

We now have to check that the device is actually connecting to your aREST account. 

For that, go to:

You should see a new device with the online status:

If this is not the case, make sure to check that you correctly set your API key & your WiFi credentials

Congratulations, you now have a device connected to your aREST dashboard! You can now use it to control your projects from anywhere in the world. You can now do many things with your device, for example storing measurements made by your device to the aREST cloud.