If you’re going to transmit large amounts of data to the cloud, you can improve performance and response times by using your Raspberry Pi as an edge gateway. EdgeX Foundry is a platform that you can use to build custom Internet of Things (IoT) solutions, by consuming and processing data from the various smart devices and sensors on your home automation network.
In this article you’ll learn how to record your data more efficiently by transforming your Raspberry Pi 4 into a connection point between the cloud and any sensors, smart devices and controllers on your network.
Logging your data in the cloud can help you identify trends: for example, using your smart scale to record your daily weigh-ins or your smart exercise bike to record the number of miles you’ve cycled. When you’re transmitting large amounts of data to the cloud, you can often reduce response times and network transmission costs by pre-processing that data locally.
What you’ll need
To complete this tutorial, you’ll need:
- Raspberry Pi 4
- SD card
- Laptop or computer where you’ll download the Ubuntu system image
- Power cable that’s compatible with your Raspberry Pi
- Ethernet cable
- Micro HDMI cable
- External monitor
- External keyboard and a way to attach it to your Raspberry PI
- A mouse is optional or use the trackpad on your external keyboard
Flash Ubuntu to your Raspberry Pi
To transform your Raspberry Pi into an Edge Gateway, you’ll need Ubuntu 19.10. Later versions of Ubuntu will likely also support EdgeX Foundry, but the process of setting up your Raspberry Pi as an Edge Gateway may differ.
In this tutorial, we’ll flash the Ubuntu system image using the free balenaEtcher application.
- Head to the Ubuntu website and download the 64-bit version of Ubuntu 19.10 for Raspberry Pi 4.
- Insert the SD card into the laptop or computer.
- Launch the Etcher app.
- In Etcher, click “Select image,” and then choose the Ubuntu file that was just downloaded.
- Click “Select target,” and then choose the target boot medium, which in this instance is the SD card.
Etcher will now flash the system image to the SD card.
Boot your Raspberry Pi into Ubuntu
We’re now ready to boot the Raspberry Pi:
- Remove the SD card from the laptop or computer and insert it into the Raspberry Pi.
- Attach the monitor to the Raspberry Pi using the micro HDMI cable.
- Attach the keyboard to the Raspberry Pi device.
- Attach an ethernet cable to the Raspberry Pi.
- Plug the Raspberry Pi into a power source. The device should now boot automatically.
- When Ubuntu is launched for the first time, there will be a prompt to enter a username and password. The default username for Ubuntu 19.10 is “ubuntu,” and the password is also “ubuntu.”
- When prompted, create a new password.
There will now be access to a Terminal to enter all of the commands needed to provision the Raspberry Pi as an Edge Gateway.
Installing EdgeX Foundry
To install the EdgeX Foundry platform, run the following command in the Terminal:
Ubuntu will now download the EdgeX Foundry snap, which contains all the services required to run EdgeX, including EdgeX core, security and support reference services, plus Consul, Kong, MongoDB, and Vault.
All of the EdgeX work can be performed in a web user interface (UI). To download this UI, enter the following command in the Terminal:
Once the download has finished, launch the web browser and enter the following URL: http://((your-raspberry-pir-url):4000/
For example, my Raspberry Pi’s IP address is 192.168.1.45, so this gives me the following URL: http://192.168.1.45:4000/.
If the IP address of the Raspberry Pi is unknown, then retrieve it using the following Terminal command:
Once this URL has loaded, you’ll be taken to the EdgeX Foundry Console.
Add Raspberry Pi as an Edge Gateway
Log into the console using the default username and password, which are both “admin.”
To provision the Raspberry Pi as an Edge Gateway:
- In the Console’s menu on the left, select “Gateway.”
- Create a new gateway by clicking “Add.”
- Give your Gateway a name and a description.
- Enter the IP address of the Raspberry Pi device.
- Click “Submit”
The Raspberry Pi should now appear in the Console, ready to use.
In this article you learned how to setup a Raspberry Pi 4 as an Edge Gateway.
If you’ve followed along with this tutorial, then we’d love to hear how you’re using Raspberry Pi as a connection point between the cloud and your smart home network, so be sure to share your gateway projects in the comments below!
Our latest tutorials delivered straight to your inbox