Getting Started with Raspberry Pi 4

This guide teaches you how to get started using the Raspberry Pi 4 single-board computer with Atmosphere. This includes creating your first project, putting the project’s firmware app image into your Raspberry Pi, getting the computer registered to Atmosphere, and having its data displayed on a dashboard.

This guide demonstrates how to build a simple project that reads the computer’s CPU temperature and sends the data to the cloud.

Prerequisite: You should already have an Atmosphere account.

If you'd like to see the complete demo before attempting this guide, the project created here is available in Atmosphere Studio's Demo Projects section as the Raspberry Pi CPU Temperature Demo. Simply open the project to check it out and get started.

Hardware Requirements

  • Raspberry Pi 4

The Raspberry Pi can be operated however you choose, be it with a standard desktop setup or headless. Either setup will work without issue with Atmosphere.

Users are expected to have a moderate understanding of working with a Raspbery Pi and embedded Linux systems prior to use with Atmosphere.

Software Requirements

  • None

Step 1 of 6: Create a New Project

Navigate to Atmosphere Studio from the side menu. When you visit Studio for the first time in a session, you are brought to the Studio Projects screen.

  1. Click the New Project button. This displays a New Project window.
  2. Select the Raspberry Pi 4 project type and give the project a name, then click Create.
    • The project type for the Raspberry Pi 4 is specifically for the Raspberry Pi 4 (model B). Earlier generations of the computer are currently not supported in Atmosphere, and aren’t compatible with this project type.

This opens a new project in Studio.

This guide walks through the step-by-step process to perform actions in Studio, but doesn't cover the in-depth aspects of Studio itself. To learn more about using Studio, its areas and features, and Studio elements, visit the Atmosphere Studio section.

Step 2 of 6: Create the Project’s Embedded Firmware

The first aspect of building this sample project is adding elements to the Embedded tab to create the project’s embedded firmware. This involves setting an interval to read embedded data, and to tell the interval to read the computer’s CPU temperature.

  1. Add the following elements to the canvas by clicking them in the Element Toolbox:
    • Interval Element Interval element: The interval element sets the project to run at the time set in the element’s properties, which by default is set to once per second (1000 ms).
    • Counter Element CPU temperature element: The CPU temperature element reads the temperature of the Raspberry Pi’s CPU.

    Each of these elements will work as intended by default, so none of their properties need to be changed.

  2. Connect the interval element to the CPU temperature element. This creates an event between them, which can be seen in either the interval element’s properties, or by clicking the connector’s Configuration Button button. The event added is within the Interval trigger. In the Ability field within the event, set the ability to Read Temperature (°C). This means that when the interval element is triggered (which is every second), it will read the temperature of the Raspberry Pi’s CPU.

That wraps up the first aspect of the project within the Embedded tab. To this point, an interval has been set that will run every second, and when run will read the Raspberry Pi’s CPU temperature.

The Embedded tab canvas should resemble the following image:

Raspberry Pi Embedded Tab

Step 3 of 6: Enable the Project’s Cloud Connectivity

The second and last aspect of building this sample project is enabling it for cloud connectivity. This is done on both the Embedded and Cloud tabs.

  1. While still in the Embedded tab, add a Cloud Event Element cloud event element to the canvas. The cloud event element is a coupled element between the Embedded and Cloud tabs that enables a project’s data to be sent to Atmosphere.
  2. Connect the CPU temperature element to the cloud event element. In the connector’s properties between the two elements, select the Temperature Read trigger, then add an event with the ability Send Event. This sends the value to Atmosphere when the CPU temperature is read.
  3. Click the Cloud tab to move to the cloud area of the project. Notice how the Element Toolbox has changed, and that the coupled cloud event element is displayed on the canvas.
  4. Add a Cloud Storage Element cloud storage element to the canvas, and connect the existing cloud event element to it. By default, this creates an event using the Add Data ability within the cloud event’s Event Received trigger, which allows Atmosphere to add (and store) data sent to it from the cloud event element.
  5. Within the Add Data event, modify the event’s Value field to {"Temperature": value}, which will label the incrementing value dataset as “Temperature” when displayed in the cloud.

That’s all for creating the project! With the added cloud connectivity, the project will send the temperature value from the Embedded tab to the Cloud tab through a cloud event element, where it’s connected to a cloud storage element to store the data on Atmosphere.

The final canvas for each tab should resemble the following images:

Embedded Cloud
Raspberry Pi Embedded Tab Raspberry Pi Cloud Tab

Step 4 of 6: Put Firmware onto the Raspberry Pi

With the project complete, your Raspberry Pi 4 is ready to have the project firmware put onto it. This involves putting a project’s app image file onto the Raspberry Pi and running the file as an executable application.

Prior to putting an app image onto a Raspberry Pi 4, ensure you have the following setup configuration:

  • The Raspberry Pi 4 is powered on.
  • An Internet connection is maintained.
  • You have a method for putting the app image onto the Raspberry Pi 4, either while directly on the computer itself or through remote access.

With setup complete, you can program the Raspberry Pi 4:

  1. Click the Compile button in the project options menu on the top-right of the screen. You’ll see a loading message on the screen indicating compiling has started, and will be notified when the project is compiled. This readies the entire project’s source code for deployment.
  2. While the Embedded tab is active, click the Program Firmware button from the tab’s toolbar. This downloads an Atmosphere_Project.AppImage file containing the project’s compiled firmware.
  3. Put the app image onto the Raspberry Pi 4. This process may vary based on how you’re running the computer.
    • If running the Raspberry Pi 4 with a standard desktop setup (display, keyboard, mouse, etc.), the app image can be downloaded into the Downloads folder and run from there.
    • If running in headless mode, use the remote access method (SSH, VNC, etc.) and associated software of your choice to put the app image onto the Raspberry Pi 4.

Once the download/transfer is complete, the Raspberry Pi 4 has the project app image on it, but can’t yet be run. Steps to run the application are included below as part of registering the Raspberry Pi 4.

Step 5 of 6: Register the Raspberry Pi to Atmosphere

Connecting a Raspberry Pi 4 to Atmosphere involves generating an API token in Atmosphere, and providing that token in a terminal when the project application is run. Once the token is provided, the Raspberry Pi 4 will register to Atmosphere automatically as long as the Internet connection is maintained.

To run an Atmosphere application and register the Raspberry Pi 4:

  1. While in Atmosphere open the account menu from the navigation bar and click Security.
  2. In the Security section’s Authentication Tokens area, click the Generate Token button to make a new API token. This will be the token you use to provide the Raspberry Pi with the credentials to connect to Atmosphere. Raspberry Pi API Token

Once you’ve created an API token, it then has to be provided once you run the app image.

  1. The app image file needs to updated to be executable. Open the terminal of your choice, and within the location of the file, run chmod +x Atmosphere_Project.AppImage to update the file to be executed as an application.
  2. From the terminal, run the application file as root.
    • Atmosphere applications install and run on the Raspberry Pi 4 as a system service. Because system services are run as the root user, the file will return an error if it’s not run as such.
  3. When the file attemptes to execute, you’ll be prompted to enter an API key. This is the API token you generated earlier. Enter the key and submit.

Once the API token is entered, the application executes and initiates communication with Atmosphere and the Raspberry Pi 4 registers itself as a device and is displayed in the platform’s Devices area. The application then installs itself as a system service on the Raspberry Pi. If the Raspberry Pi is powered off and on again, the application will run on boot with other system services; the above steps only need to be completed once in order to run the application and register the Raspberry Pi.

The complete registration process should resemble the following command line output:

pi@raspberrypi:~ $ chmod +x Atmosphere_Project.AppImage
pi@raspberrypi:~ $ sudo ./Atmosphere_Project.AppImage
== Atmosphere IoT Raspberry Pi Setup ==

Please enter your API Key:
1ab234c5-6d78-1234-abc1-d23456ef78a9
Registering Project Atmosphere Demo to https://platform.atmosphereiot.com...
Registration Successful...
Stopping Atmosphere System Service...
Installing Atmosphere_Project.bin to /usr/bin...
Installing Atmosphere System Service...
Created symlink /etc/systemd/system/multi-user.target.wants/atmosphere.service → /etc/systemd/system/atmosphere.service.

At this point, the application is running and the CPU temperature data is sent to Atmosphere through the Internet connection maintained on the Raspberry Pi.

Step 6 of 6: View CPU Temperature Data

Now that data is being sent to Atmosphere, let’s view it through one of the many dashboard widgets available. In this guide we’ll use a data graph widget to chart the temperature data. We’ll do this directly on the device’s console page, so click on the newly-added Raspberry Pi 4 to enter its console.

  1. To add a widget to the device’s dashboard, click the Configuration button on the right side of the screen. This displays the menu of available widgets. Select the Data Graph data graph widget to add a data graph to the dashboard.
  2. Once on the dashboard, click the widget’s Menu menu icon to display its menu, then click Settings.
  3. Give the data graph a name (such as “Raspberry Pi 4 CPU Temperature Data”), then in its Data Source field click Select and choose the following configuration options for the widget:
    • Cloud Storage: Select the cloud storage (TempStorage, or whatever you named your cloud storage) that is storing the temperature data.
    • X-axis Value: Select the timestamp to go along the graph’s x-axis.
    • Y-axis Value: Select the temperature’s dataset to go up the graph’s y-axis (Temperature, unless you provided a custom label for the cloud event data).
  4. When finished click Save. This populates the data graph plotting the CPU temperature value as time progresses. If you’d like to adjust the graph’s timeline, bounds, or colors, you can edit those properties from the data graph’s menu as well.

Raspberry Pi Guide Dashboard

Congratulations, you just finished a complete Raspberry Pi 4 project with Atmosphere!