As a Python developer, you’re probably eager to control and monitor your Raspberry Pi GPIOs remotely. Well, you have landed in the right place. 

This article builds upon our previous introduction to “Visualize your Raspberry Pi data with Arduino Cloud | Part I.” Now, we’ll explore using Python to configure Raspberry Pi GPIOs, a fundamental step for many IoT projects that is usually considered as the “hello world” of IoT applications. Whether you’re controlling relays or monitoring digital inputs, managing GPIOs is crucial. 

But IoT applications need to be accessed remotely with a dashboard that allows you to visualize your device data both in real time and its historical evolution, as well as acting remotely over your device.

Well, let’s deep dive into how we can achieve all that!

Physical setup

In this blog post, we show a very simple but comprehensive example. We will see how to use an Arduino Cloud dashboard to act remotely over your Raspberry Pi digital GPIOs. In a nutshell, we will see how to:

First, let’s connect our Raspberry Pi to an LED and a push button as shown in the following diagram.

It’s a very simple setup. Now that we have everything ready, let’s get started!

Create the Device and Thing in Arduino Cloud

To send your Raspberry Pi data to the Arduino Cloud, you have to follow these simple steps:

1. Set up an Arduino Cloud account if you didn’t have one before.
2. Create your Device as a Manual device.

Note: Note down your Device ID and Secret, as we will need them later.

3. Create your Thing and add your variables.

In the example shown in this blog post, we use the following three variables:

4. Create an Arduino Cloud dashboard for data visualization:

With the dashboard, you will be able to:

Note: You can find more detailed info about the full process in our documentation guide.

Program your IoT device using Python

Now it’s time to develop your Python application.

Create a file called credentials.py with your Device ID and secret.

This code can be used across all the various Raspberry Pi flavors and it should work also in any Linux-based machine. Just beware that you need to use the right gpiochip and set the right GPIO lines in the following code section:

You can get more information about the project in Project Hub and all the code and more details in the GitHub repository. Additionally, you can find a full python guide in the following article

Tutorial: Connect your Raspberry Pi to Arduino Cloud

Start with Arduino Cloud for free

Connecting your Raspberry Pi to the Arduino Cloud couldn’t be easier. All you need to do is create your free account and you are ready to go. It’s ready to use and it is free. You can explore the premium features for enhanced functionality.

So, if you’re looking to streamline data visualization of your Raspberry Pi applications using Python, give the Arduino Cloud a try and leverage its full potential for your projects.

Stay tuned for Part III and IV of our Raspberry Pi GPIO basic control blog post series in the Arduino Cloud. 

The post Control your Raspberry Pi GPIOs with Arduino Cloud using Python | Part II appeared first on Arduino Blog.