This guide covers getting up and running with the Helium Atom Prototyping Module and the Rasberri Pi platform. Specifically it will walk you through:
Before we get started, make sure to have all of the following:
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:
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.
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
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:
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 PyPi
On a command line, install the library using
sudo pip install helium-client
Method 2: From Source
On a command line, check out the
git clone --recursive https://github.com/helium/helium-client-python
Install the package locally
cd helium-client-python sudo pip install .
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:
Before going any further, we need to power up and connect the Helium Element. 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.
To turn on the Helium Element with Ethernet connectivity, connect the supplied Ethernet cable to the back of the unit and into an internet-connected port that serves DCHP. The Element supports power over ethernet or you can connect the supplied power cable into an outlet. The Ethernet-only Element is in a white and purple case.
The orange LED light reports internet connectivity. When the LED is solid orange, you've got internet connection.
|Blue LED blinks once per second||Normal operation, the Element is transmitting data to Atoms in range|
|Red LED blinks||Normal operation. The Element is receiving data from Atoms in range|
|Red LED blinks rapidly for 10s to 1 min||The Element is receiving a firmware update. Afterwards, the Element will reboot. No action is required on your part.|
|All 3 LEDs blink simultaneously once per second||Fault code. The Element will reset on its own. No action is required on your part.|
To turn on the Helium Element with Cellular and Ethernet connectivity, connected the supplied power cable into an outlet. 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).
Your Element will be connected when the front-facing LED turns green (signaling Ethernet connectivity) or teal (for Cellular connectivity).
Note You can watch a short video about the Element and how to connect it here.
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.
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:
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.
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.
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: