Helium Raspberry Pi Guide


This guide covers getting up and running with the Helium Atom Prototyping Module and the Rasberri Pi platform. Specifically it will walk you through:

Required Hardware and Software

Before we get started, make sure to have all of the following:

Building your Helium Raspberry Pi Development Board

The first thing we need to do is contruct our complete development board. This will be the combination of the Helium Atom Prototyping Module, the Helium Rasberry Pi adapter, and the Raspberry Pi board you're using. To build this, drop the Helium Adapter onto the Raspberry Pi and then pin Helium Atom Prototyping Module onto the Rasberry Pi adapter. That's it. It should look like this when you're done:

Configuring your Raspberry Pi Development Environment

After building the board we'll need to set up your Raspberry Pi with an operating system. Step by step hardware instructions and software instructions are available to set up your Raspberry Pi.

In the following we're going to assume that this installation completed and you're logged in as user pi, and have an open terminal.

Installing the python-dev package

Install the python-dev package so that the native extensions that are part of the Helium Python client library can be built during installation:

sudo apt-get install python-dev

Installing the Helium Python Client Library

If your Helium Atom is connected through an adapter, you will need to disable the login shell on the serial port of the Raspberry Pi. Start by running this in your terminal:

sudo raspi-config

Then select Interface Options > Serial and disable the login shell over serial, while enabling access to the Serial ports. Save the configuration and reboot the Raspberry Pi.

You can then install the Helium Python Client library in one of two ways:

Method 1: From Source

On a command line, check out the helium-client-python repository:

git clone https://github.com/helium/helium-client-python

Install the package locally

cd helium-client-python
sudo pip install .

Method 2: From Pypi

On a command line, install the library using pip:

sudo pip install helium-client

Registering the Atom Prototyping Module in Helium Dashboard

Now it's time to register your device in the Helium Dashboard. Helium Dashboard is our hosted device management and visualization interface. This is where you'll configure and deploy all Atoms and Element Access Points that are part of your Helium Organization. You should have receieved an invite to Dashboard when you purchased your Helium hardware. If you still need an account, you can sign up here.

Before we start developing on the Rasberry Pi, it needs to be added to your Helium Dashboard organization and configured. To add it to your Helium Dashboard organization, log in to Dashboard, click + Add Atom, give it a name, the last four digits of the MAC Address, and the 4 digit HVV Identifier. Here's how simple this is:

Deploying the Helium Element

We then need to deploy your Helium Element Access Point and make sure it's connected to the network. The Element is what creates the local network coverage for your Helium Atom Prototyping Module. To deploy your Element, you will need to plug it into power (and Ethernet if applicable) and register the Element the Helium Dashboard.

Power up your Element

If you purchased your Helium Element as part of the Helium Starter Kit, it can use both Cellular and Ethernet for data backhaul. The easiest way to connect it is to plug it into power using the supplied power cable. If you wish for redundancy in the backhaul, you can also plug it into a live Ethernet port using the supplied cable. (Note that the Ethernet port must serve DCHP.)

For the Ethernet-only variant of the Element, connect the supplied Ethernet cable to the back of the Element and the other end into an internet-connected port that serves DHCP.

Your Element will be connected when the front-facing LED turns green (signalling Ethernet connectivity) or teal (for Cellular connectivity).

Note You can watch a short video about the Element and how to connect it here.

Activate the Element in Helium Dashboard

Once your Element is plugged into power and connected to either cellular or ethernet, it's time to register it in the Helium Dashboard. This process is similar to how you registered the Atom Prototyping Module. Log in to Helium Dashboard, select +Add Element, and enter the Element details.

Programming the Raspberry Pi

Now onto actually writing some code. The easiest way to get started is to look at the basic example included with the Helium Python library. (The example can be found in the GitHub repository.)

Here it is in its entirety:


    from helium_client import Helium

    helium = Helium("/dev/serial0")
    helium.connect()

    channel = helium.create_channel("Helium MQTT")
    channel.send("hello from Python")

Let’s walk through what this example does. The first thing you’ll see, below the import line, is:

helium = Helium("/dev/serial0")

This creates an instance of the Helium class, in this case called helium. The parameter is the serial port that is used to communicate with the Helium Atom.

Next we have this:

helium.connect()

This tells the Helium Atom to the network. You should see red and blue blinking lights on the Helium Atom as it tries to securely connect to the Helium Network.

Creating a Channel

This code then creates what's known as a channel. Channels are the optimized routing layers Helium has built to send your device data directly to the Cloud Service(s) and endpoints of your chosing. Channels are managed and deployed from the Helium Dashboard but your client code on the device also needs to know what Channels it's sending data to. This Python script will tell your device to start sending data to the Helium MQTT Channel. Every Dashboard account has this Channel created and enabled, so no additional setup is required to test the Helium MQTT Channel.

So, here's the part of the example that creates the MQTT channel and starts sending the string hello from Python to it:


    channel = helium.create_channel("Helium MQTT")
    channel.send("hello from Python")

That's all there is to it. The call either returns successfully or will raise an error if a failure occurs.

To verify data is flowing over the air to the Helium infrastrcuture, head to either the Atom or Channel section of Dashboard to see an Event Log of the last 100 messages sent by the Atom or to the Channel. From here, you can use an MQTT client such as Mosquitto to subscribe to the Helium MQTT server and see the messages as they flow in. The MQTT server settings can be found within the Helium MQTT Channel page within Dashboard.

Questions and Next Steps

Congratulations. You're now up and running with Helium and Rasberry Pi. Your future is undoubtedly brighter than when you started this guide. If you have any questions or comments on this tutorial, or want to get in touch with Helium or the community for whatever reason, here's are some options: