Actual applications will most likely end up using some form of microcontroller to control the RockBLOCK. We've written a CircuitPython library to allow you to do this using an available CircuitPython board.

In this example, we'll use a Feather nRF52840 Sense to send data from the onboard sensors. You'll also need the accessory cable to attach the RockBLOCK to the Feather.

Angled shot of blue, rectangular, microcontroller.
The Adafruit Feather Bluefruit Sense takes our popular Feather nRF52840 Express and adds a smorgasbord of sensors...
Out of Stock


Here's the wiring diagram. If you use the accessory cable, you should be able to match the colors. But it's also best to verify actual pin location on the RockBLOCK.

  • GND to GND
  • USB to 5V*
  • RX to RXD
  • TX to TXD

* in this example we will power everything via the Feather's micro USB connector (no battery).

CircuitPython Libraries

You'll need the following CircuitPython libraries installed. Make sure all of these are in your CIRCUITPY/lib folder.

  • adafruit_apds9960
  • adafruit_bus_device
  • adafruit_register
  • adafruit_bmp280
  • adafruit_lis3mdl
  • adafruit_lsm6ds
  • adafruit_rockblock
  • adafruit_sht31d


The code used is included as an example in the library. Here it is:

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
import struct
import board
import adafruit_lsm6ds
import adafruit_lis3mdl
import adafruit_apds9960.apds9960
import adafruit_sht31d
import adafruit_bmp280
import adafruit_rockblock

# RockBlock setup
uart = board.UART()
uart.baudrate = 19200
rb = adafruit_rockblock.RockBlock(uart)

i2c = board.I2C()  # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller

# all the sensors
accelo = adafruit_lsm6ds.LSM6DS33(i2c)
magno = adafruit_lis3mdl.LIS3MDL(i2c)
prox = adafruit_apds9960.apds9960.APDS9960(i2c)
sht = adafruit_sht31d.SHT31D(i2c)
bmp = adafruit_bmp280.Adafruit_BMP280_I2C(i2c)

# build data
# can decode on other end with struct.unpack("<6fB5f", data)
data = struct.pack("3f", *accelo.acceleration)
data += struct.pack("3f", *magno.magnetic)
data += struct.pack("B", prox.proximity())
data += struct.pack("2f", sht.relative_humidity, sht.temperature)
data += struct.pack("3f", bmp.pressure, bmp.altitude, bmp.temperature)

# send data
rb.data_out = data
print("Talking to satellite...")
retry = 0
status = rb.satellite_transfer()
while status[0] > 8:
    status = rb.satellite_transfer()
    print(retry, status)
    retry += 1

Save that code as to your CIRCUITPY folder. If you need to do a soft-reboot, you can with <CTRL>-<D> in the REPL. It will run and display the status of the attempts to send the message:

The output will show the number of attempts and the status (the numbers in parans). Just as in the simple test done before, the first number needs to be 0 for success. So it will keep trying until that happens:

Once it is successful, it will exit and is done.

If you then go to your account on the Rock Seven server and look in your Messages, you should see something like:

So what are all those numbers and letters? The next section is a brief run down. We'll go into more detail later.

Unpacking Data

For those familiar with Python's struct module, the example data can be decoded with:

struct.unpack("<6fB5f", data)

where data is a bytes or bytearray of the raw data in the message. An easy way to create that is to use bytes.fromhex() and give it the hex text (copy pasta it) from the message.

Using the above message as an example:

>>> import struct
>>> data = bytes.fromhex("88984cbe90267bbe50b21d41f43754c2081dac3fb40c82c2009cd2bf4110aed74188277a44b4a2d342cc86d741")
>>> struct.unpack("<6fB5f", data)
(-0.19980061054229736, -0.24526429176330566, 9.856033325195312, -53.05464172363281, 1.3446359634399414, -65.02481079101562, 0, 23.97783660888672, 26.959991455078125, 1000.61767578125, 105.81777954101562, 26.940818786621094)

And there's the data. First 3 are x/y/z acceleration from the LSM6DS33, next 3 are x/y/z magnetic from the LIS3MDL, next one is proximity from the APDS9960, then humidity and temperature from the SHT31D, and finally pressure, altitude, and temperature from the BMP280.

Much sensors. So data. Wow!

This guide was first published on Apr 08, 2020. It was last updated on Feb 29, 2024.

This page (CircuitPython Example) was last updated on Feb 27, 2024.

Text editor powered by tinymce.