# Using the RockBLOCK Iridium Modem

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/089/586/medium800thumb/sensors_Iridium_Coverage_Animation.jpg?1584638220)

Who's got the best coverage map? Anyone using the [Iridium satellite constellation](https://en.wikipedia.org/wiki/Iridium_satellite_constellation), that's who. How does **whole Earth** coverage sound? Summit of K2 to summit of Everest? Check. South pole to North pole? Super check. In the animated image above, red is good. Check that coverage at the poles!

So how do you use the Iridium satellites? Similar to cellphones, you need to purchase both hardware and service, and there are various options out there. In this guide we will show you how to setup and use the [Ground Control](http://www.groundcontrol.com/) [RockBLOCK 9603](https://www.groundcontrol.com/product/rockblock-9603-compact-plug-and-play-satellite-transmitter/) Iridium Satellite Modem. This hardware is tied to service that is also provided by [Ground Control](http://www.groundcontrol.com/).

We also have a [CircuitPython](https://circuitpython.org/) library that provides an easy way to transmit messages from any [CircuitPython board](https://circuitpython.org/downloads) with an available UART.

## Parts
# Using the RockBLOCK Iridium Modem

## System Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/089/503/medium800/sensors_rockblock_system.png?1584461559)

The Rock Seven RockBLOCK 9603 works with the [Iridium Satellite System](https://en.wikipedia.org/wiki/Iridium_satellite_constellation) and the [Rock Seven](http://www.rock7.com/) Servers to connect you between two points on Earth **via space**. That's right. That little square thing is talking to outer space!

The graphic above provides a general overview of the whole system. In the middle is the [RockBLOCK 9603 modem](https://www.adafruit.com/product/4521) itself. Data can flow in either direction.

1. The RockBLOCK 9603 communicates with the Iridium satellites to send/receive data.
2. The Iridium satellites communicate with ground based stations to send/receive data between space and Earth.
3. Data is sent between the Iridium ground stations and the Rock Seven Servers. You can access this server via a web interface.
4. Your specific application talks to the Rock Seven servers.

# Using the RockBLOCK Iridium Modem

## Hardware

![](https://cdn-learn.adafruit.com/assets/assets/000/089/585/medium800/sensors_modem_banner.jpg?1584637924)

There's not much to the little RockBLOCK 9603 itself. There's only one connector for both power and data. There are a couple of status LEDs. Besides some mounting holes, that's pretty much it. A nice tidy little package.

## Pinout
![](https://cdn-learn.adafruit.com/assets/assets/000/089/401/medium800/sensors_rockblock_9603_pins.jpg?1584400509)

1. **RXD** Serial output from RockBLOCK, **so it's really TX**
2. **CTS** Clear to Send (output from RockBLOCK)
3. **RTS** Ready To Send (input to RockBLOCK)
4. **NET** Network Available
5. **RI** Ring Indicator (active low)
6. **TXD** Serial input to RockBLOCK, **so it's really RX**
7. **SLP** Sleep control (pull to ground to switch off)
8. **5V** 5V in power supply (450mA limit)
9. **BAT** 3.7V power supply (450mA limit)
10. **GND** Ground

Info: 

Info: 

## Connector

The connector on the RockBLOCK modem is a [Molex PicoBlade](https://www.molex.com/molex/products/family/picoblade). The mating connector housing is Molex part number **51021-1000**. Bare connectors are available in Molex product series **50079** or **50058** , but need a special (very expensive) crimping tool. There are also pre-crimped cables available in Molex product series **79758**.

You can get these on DigiKey:

- [Connector housing](https://www.digikey.com/short/z8d9hv)
- Pre-crimped cables
  - [6 inch](https://www.digikey.com/short/z8d9ff)
  - [12 inch](https://www.digikey.com/short/z8d9rd)

With these parts you can make custom cable assemblies.

![](https://cdn-learn.adafruit.com/assets/assets/000/089/402/medium800/sensors_wires.jpg?1584401834)

Info: 

## LED Indicators

There are two small LED indicators on the side with the big capacitors.

![](https://cdn-learn.adafruit.com/assets/assets/000/089/505/medium800/sensors_status_leds.jpg?1584463351)

- **Red** = DC power present.
- **Green** = Capacitors are charged. This is needed for satellite communication.

## Antenna

This is the antenna which talks to the satellites. Make sure it has a good clear view of the sky. Butter side up!

![](https://cdn-learn.adafruit.com/assets/assets/000/089/509/medium800/sensors_antenna.jpg?1584464408)

An external antenna can be attached via the coaxial connector on the side. But in this guide we show basic usage with the built in antenna.

## Mixed Power/Logic Warning on SLP Pin

Due to a design change in the on/off control circuit, there is a potential issue when interfacing with 3.3V logic level devices. **Starting with the v3.F version of the hardware, the SLP pin requires special attention.** More info here:

[RockBLOCK Sleep Pin On/Off Control](https://docs.rockblock.rock7.com/docs/power-supply#onoff-control)
&gt; If the RB was supplied by 5V, the connecting device should also be 5V tolerant. If not, it is recommended to use an interfacing circuit, eg MOSFET, transistor, relay, etc. to connect to a microcontroller.

The hardware version number is printed on the antenna side of the RockBLOCK modem.

![sensors_rb.png](https://cdn-learn.adafruit.com/assets/assets/000/130/291/medium640/sensors_rb.png?1717167832)

# Using the RockBLOCK Iridium Modem

## Service Setup

![](https://cdn-learn.adafruit.com/assets/assets/000/130/739/medium800/sensors_ground_control_login.png?1718718426)

Ground Control provides a web based interface for managing your account which you can access at the [RockBLOCK Admin](https://rockblock.rock7.com/Operations) page. Once you've created an account and logged in, you can register your specific Rock BLOCK 9603 modem and enable (purchase) service.

## Enabling Service

In addition to the modem hardrware, you will also need to purchase line rental AND credits to use the service.

- **Line Rental** - Purchased in one month increments, currently £12.00 per month. Needed to communicate with the Iridium satellites. Expires after the purchased time has elapsed. This is a fixed base cost.
- **Credits** - Needed to send/receive data through the Iridium satellites. These get consumed at a rate of about 1 credit / 50 bytes sent/received. They never expire. Cost varies depending on how many you buy at once, from £0.13 to £0.045 per credit. This is a variable cost.

You can purchase the above through the web based management system once logged in to your account.

Pricing information can be found on the product page (see the AIRTIME tab):

[RockBLOCK 9603 Product Page](https://www.groundcontrol.com/product/rockblock-9603-compact-plug-and-play-satellite-transmitter/)
# Using the RockBLOCK Iridium Modem

## Basic Comms Check

The RockBLOCK modem is controlled via text messages sent over a serial connection. The easiest way to get started with the RockBLOCK modem is to use the included USB serial cable and attach it to a host PC's USB port. It's a good idea to test things this way initially to make sure the basic setup is working. Later, we'll show examples with the RockBLOCK model connected to a microcontroller.

![](https://cdn-learn.adafruit.com/assets/assets/000/089/511/medium800/sensors_usb_setup.jpg?1584466508)

This cable contains an [FTDI FT232R](https://www.ftdichip.com/Products/ICs/FT232R.htm) chip. You may need to install drivers, which are available here:

[FTDI Virtual COM Port Drivers](https://www.ftdichip.com/Drivers/VCP.htm)
The RockBLOCK 9603 can not communicate with the Iridium satellites indoors. So to actually try a satellite data transfer, you'll need to somehow have the antenna obtain a view of the sky. We just placed it on an open window sill and it worked OK. If you have a laptop, that could make things easier.

Once you have the COM port showing up on your PC, use a terminal program to connect. The serial parameters are:

- **Baud Rate** = 19200
- **Data Bits** = 8
- **Parity** = N
- **Stop Bits** = 1

The examples here show using `screen` on a linux machine.

## AT Commands

The RockBLOCK 9603 uses an AT command set that is documented here:

[AT Command Reference](https://cdn-shop.adafruit.com/product-files/4521/4521-AT%20command.pdf)
All commands start with **AT** followed by the specific command and end with a carriage return ( **\r** ). There are a lot commands, but only a few really matter. Here's a short list of the important ones:

- **+SBDIX** - Initiate an Short Burst Data session, i.e. talk to the satellites. Make sure you have loaded message data first.
- **+SBDWT** - Write text message into outbound buffer
- **+SBDWB** - Write binary data into outbound buffer
- **+SBDRT** - Read text message from inbound buffer
- **+SBDRB** - Read binary data in from inbound buffer
- **+SBDSX** - Status

For example, to get status, you would send:

```none
AT+SBDSX\r
```

If you are using a terminal program, the **\r** is typically sent when you press the Enter key. So you don't actually type it. But when you are writing custom software to talk directly over serial, then you'll need to remember to add a **\r** to your data string.

## Basic Info

Before we try a satellite data transfer, let's make sure the basics work. We'll use the commands **+CGMI** and **+CGMM** to obtain model information. This information comes directly from the RockBLOCK 9603 modem and does not require any satellite access.

Launch `screen` or whatever terminal program you are using.

Set baud rate to 19200. For `screen`, that's a command line parameter.

![sensors_basic_test1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/404/medium640/sensors_basic_test1.jpg?1584404754)

Then type **AT** and press Enter. You don't need to actually enter the \r.

If you get the **OK** response, you're talking. Then try **AT+CGMI** and **AT+CGMM** and you should get something like the info shown.

![sensors_basic_test2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/405/medium640/sensors_basic_test2.jpg?1584404780)

## Hello World

OK, fun part time. Let's try and send a message. If you aren't already connected to the RockBLOCK, see the previous section. You also need to have your service enabled by purchasing line rental and credits.

For this initial test we'll use text. Later we'll use binary data, which is generally the way all the communication should be done. Text is just a convenience feature.

Once you are connected, type **AT+SBDWT=Hello World** and then press Enter.

You should receive the response **OK**.

![sensors_hello_world1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/407/medium640/sensors_hello_world1.jpg?1584405515)

To send the message, type **AT+SBDIX** and press Enter.

It will attempt to talk to the satellites and after a period of time return a status as **+SBDIX: 32, 8, 2, 0, 0, 0**.

If the first number is not 0, then the message did **NOT** transmit and you'll need to try again.

![sensors_hello_world2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/408/medium640/sensors_hello_world2.jpg?1584405587)

Keep entering the **AT+SBDIX** command until the first number in the status return is 0.

You may have to try this several times depending on how good your view of the sky is, where the satellites are, etc. Wait 10s of seconds between each try. Don't spam the sats, yo.

![sensors_hello_world3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/409/medium640/sensors_hello_world3.jpg?1584406021)

If you now log into your account and got to Messages, you should see the arrived message with "Hello World" in the payload.

![sensors_hello_world4.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/410/medium640/sensors_hello_world4.jpg?1584406372)

Info: 

Danger: Each successful SBDIX transfer consumes 1 credit, even if the message buffers are empty.

## What Are Those Status Numbers?

The status values, the six numbers, returned from a call to **AT+SBDIX** are:

**MO status, MOMSN, MT status, MTMSN, MT length, MT**  
**queued**

where:

- **MO status** = status of outgoing transmission
- **MOMSN** = outbound sequence number
- **MT status** = status of inbound transmission
- **MTMSN** = inbound sequence number
- **MT length** = bytes received
- **MT queued** = messages waiting to be delivered

The first one, **MO status** , is the most important for determining transmission success. There is a full list of possible values and their meaning in the [AT Command Reference](https://cdn-shop.adafruit.com/product-files/4521/4521-AT%20command.pdf). Briefly:

- **0 - 4** = Transmit successful
- **32** = No network service

And for completeness:

- **MO** = **M** obile **O** riginated, i.e. **from the RockBLOCK**
- **MT** = **M** obile **T** erminated, i.e. **to the RockBLOCK**

# Using the RockBLOCK Iridium Modem

## Sending and Receiving Messages

![](https://cdn-learn.adafruit.com/assets/assets/000/130/727/medium800/sensors_Message_Flow.png?1718390837)

All traffic will end up going through [Ground Control](https://www.groundcontrol.com)'s servers. Messages that are sent **from** the modem are called **Mobile Originated (MO)**. Messages that are sent **to** the modem are called **Mobile Terminated (MT)**.

- **Mobile Originated (MO)** - messages from modem
- **Mobile Terminated (MT)** - messages to modem

Options for sending/receiving messages to/from the RockBLOCK modem from the outside world are covered in the RockBLOCK Web Services User Guide:

[RockBLOCK Web Services User Guide](https://www.groundcontrol.com/en/wp-content/uploads/2022/02/RockBLOCK-Web-Services-User-Guide.pdf)
However, there are very limited options.

- For Receiving **MO** Messages from the RockBLOCK, options are:
  - HTTP POST to your application
  - Email delivery

- For Sending **MT** Messages to the RockBLOCK modem, options are:
  - HTTP POST to RockBLOCK API
  - Rock 7 CORE web interface

This guide provides examples for using the HTTP POST methods for both MO and MT message.

# Using the RockBLOCK Iridium Modem

## CircuitPython Example

![](https://cdn-learn.adafruit.com/assets/assets/000/089/552/medium800/sensors_blinka_space.jpg?1584550650)

Actual applications will most likely end up using some form of microcontroller to control the RockBLOCK. We've written a [CircuitPython library](https://github.com/adafruit/Adafruit_CircuitPython_RockBlock) to allow you to do this using an available [CircuitPython board](https://circuitpython.org/downloads).

In this example, we'll use a [Feather nRF52840 Sense](https://www.adafruit.com/product/4516) to send data from the onboard sensors. You'll also need the [accessory cable](https://www.adafruit.com/product/4529) to attach the RockBLOCK to the Feather.

Info: This is an example of sending a Mobile Originated (MO) message from the modem.

### Adafruit Feather nRF52840 Sense

[Adafruit Feather nRF52840 Sense](https://www.adafruit.com/product/4516)
The **Adafruit Feather Bluefruit Sense** takes our popular [Feather nRF52840 Express](https://www.adafruit.com/product/4062) and adds a smorgasbord of sensors to make a great wireless sensor platform. This Feather microcontroller comes with Bluetooth® Low Energy and...

In Stock
[Buy Now](https://www.adafruit.com/product/4516)
[Related Guides to the Product](https://learn.adafruit.com/products/4516/guides)
![Angled shot of blue, rectangular, microcontroller.](https://cdn-shop.adafruit.com/640x480/4516-06.jpg)

## Wiring

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**

![sensors_feather_wiring.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/520/medium640/sensors_feather_wiring.jpg?1584999175)

 **\*** 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](https://circuitpython.org/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

![](https://cdn-learn.adafruit.com/assets/assets/000/089/529/medium800/sensors_req_libraries.jpg?1584474238)

## Code

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

https://github.com/adafruit/Adafruit_CircuitPython_RockBlock/blob/main/examples/rockblock_feather_sense_sensors.py

Save that code as **code.py** 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:

![](https://cdn-learn.adafruit.com/assets/assets/000/089/530/medium800/sensors_feather_test1.jpg?1584475338)

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:

![](https://cdn-learn.adafruit.com/assets/assets/000/089/531/medium800/sensors_feather_test2.jpg?1584475446)

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:

![](https://cdn-learn.adafruit.com/assets/assets/000/089/532/medium800/sensors_feather_test3.jpg?1584475922)

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](https://docs.python.org/3/library/struct.html) module, the example data can be decoded with:

```python
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:

```python
>>> 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!

# Using the RockBLOCK Iridium Modem

## Raspberry Pi Example

A Raspberry Pi or similar Single Board Computer (SBC) can also be used, as long it has a serial port for talking to the RockBLOCK. If you want to use the CircuitPython library, you'll also want to use a SBC that has [Blinka](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/overview) support.

You can use any Raspberry Pi. However, since the remote location will likely not have WiFi and power will probably be a premium, the Pi Zero is a good option.

### Raspberry Pi Zero - Version 1.3

[Raspberry Pi Zero - Version 1.3](https://www.adafruit.com/product/2885)
At first glance, the Pi Zero isn't much. &nbsp;It just looks like a slimmed down version of the Raspberry Pi we know and love. &nbsp;But when we started to think of the possibilities - [and what a well-chosen set of accessories could add](https://www.adafruit.com/product/2816) -...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2885)
[Related Guides to the Product](https://learn.adafruit.com/products/2885/guides)
![Angled shot of Raspberry Pi Zero computer](https://cdn-shop.adafruit.com/640x480/2885-06.jpg)

## Wiring

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.

- **5V** to **VIN**
- **GND** to **GND**
- **TX** to **TXD\***
- **RX** to **RXD\***

![sensors_rpi_wiring.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/142/medium640/sensors_rpi_wiring.jpg?1617144969)

 **\*** Yep, TX to TX and RX to RX. The RockBLOCK uses backwards nomenclature for its TX/RX pins.

## Enable Serial

Follow these steps to enable serial on the Pi's GPIO header. The general process is to enable the serial hardware AND remove the default login shell that would otherwise use it.

You can do all this via raspi-config.

```none
sudo raspi-config
```

- Select **5 Interfacing Options**

![sensors_rpi_serial1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/713/medium640/sensors_rpi_serial1.jpg?1585000465)

- Select **P6 Serial**

![sensors_rpi_serial2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/714/medium640/sensors_rpi_serial2.jpg?1585000526)

- Answer **NO** to "Would you like a login shell to be accessible over serial?"

![sensors_rpi_serial3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/715/medium640/sensors_rpi_serial3.jpg?1585000564)

- Answer **YES** to "Would you like the serial port hardware to be enabled?"

![sensors_rpi_serial4.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/716/medium640/sensors_rpi_serial4.jpg?1585000693)

- Select **OK**
- Exit and reboot

![sensors_rpi_serial5.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/717/medium640/sensors_rpi_serial5.jpg?1585000785)

## Install CircuitPython Library

See here for information on how to install Blinka to allow using CircuitPython libraries with Python on the Raspberry Pi:

[Installing CircuitPython Libraries on Raspberry Pi](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi)
and make sure you have passed the [Blinka Test](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi#blinka-test-3-15).

Then, install the RockBLOCK library with:

```none
pip3 install adafruit-circuitpython-rockblock
```

## Run Simpletest Check

As a quick test to make sure you are connected and talking to the RockBLOCK, use the simpletest example from the library. Here's the code.

https://github.com/adafruit/Adafruit_CircuitPython_RockBlock/blob/main/examples/rockblock_simpletest.py

We need to make some changes first.

Comment out these lines:

```python
uart = board.UART()
uart.baudrate = 19200
```

so they look like this:

```python
# uart = board.UART()
# uart.baudrate = 19200
```

and add these new lines:

```python
import serial
uart = serial.Serial("/dev/serial0", 19200)
```

and now your UART is talking on the Pi's GPIO header.

Try running the example:

![](https://cdn-learn.adafruit.com/assets/assets/000/089/720/medium800/sensors_rpi_serial6.jpg?1585002705)

and you should see the model information text printed out as shown above.

## Additional Examples

The only change that should be needed for running other examples is to make the changes for configuring the UART. Once you've done that and passed that UART to the CircuitPython RockBLOCK library, the rest should just work.

Check out the other examples in the library repo.

[RockBLOCK Examples](https://github.com/adafruit/Adafruit_CircuitPython_RockBlock/tree/master/examples)
# Using the RockBLOCK Iridium Modem

## Forwarding Messages

OK, we've covered how to use the RockBLOCK to send messages from **anywhere on Earth**. But how do you get those messages to your final destination? That is, how do you forward them from the Rock Sever server to your specific end application, like so:

![](https://cdn-learn.adafruit.com/assets/assets/000/089/513/medium800/sensors_rockblock_system2.jpg?1584467185)

Rock Seven only provides a very basic functionality here. Once a message is received on their server, it can be forwarded to a location you specify. There are only two options:

- **Email** - You'll receive an email at the supplied address(es).
- **HTTP** - An HTTP POST request will be made to the supplied URL(s)

Rock Seven has documentation on this here:

[Integration with your application](https://docs.rockblock.rock7.com/docs/integration-with-application)
The HTTP API is documented here:

[Receiving Messages via HTTP](https://docs.rockblock.rock7.com/reference#receiving-mo-messages-via-http-webhook)
## Delivery Groups

You configure message forwarding using the web based Management System. Once logged in, click Delivery Groups in the left hand navigation.

It's a fairly simple idea. Each **Delivery Group** is associated with one or more RockBLOCK devices. Then, for each group, you can specify one or more delivery destinations in the **Delivery Addresses**. It's a simple forwarding scheme. Any messages received from the RockBLOCK devices in the **Delivery Group** will be forwarded to the destinations in the **Delivery Addresses**.

Info: The following is an HTTP POST example for forwarding Mobile Originated messages.

## Adafruit IO

There is a way to get your RockBLOCK message to Adafruit IO, however it has some limitations. Rock Seven doesn't allow for any special formatting of the out going HTTP POST message. So we can't interface it directly with the AIO API. However, we can use the webhook feature of AIO to provide an endpoint destination for the HTTP POST data.

Start by following this guide for how to create a webhook for your AIO feed:

[Webhooks with Adafruit IO](https://learn.adafruit.com/all-the-internet-of-things-episode-four-adafruit-io/webhooks)
When creating the webhook URL on Adafruit IO, **enable the feature to send the whole contents of the webhook event**. This can be done by clicking the option in the webhook creation dialog:

![](https://cdn-learn.adafruit.com/assets/assets/000/121/303/medium800/sensors_wh.png?1685467555)

You will end up with a URL for the feed's webhook.

Danger: 

Now log in to your Rock Seven account and go to Delivery Groups. Add a new Delivery Address for your RockBLOCK.

1. Add the URL for the AIO feed's webhook into the **Address** field.
2. Select **HTTP\_JSON** from the Format drop down.

![](https://cdn-learn.adafruit.com/assets/assets/000/089/546/medium800/sensors_rb_webhook.jpg?1584547713)

Now when you transmit a message from your RockBLOCK it will be forwarded as JSON data to your feed. It will show up as something like this:

![](https://cdn-learn.adafruit.com/assets/assets/000/089/545/medium800/sensors_aio_webhook_example.png?1584547276)

It's not super useful. All you get is a raw blob of JSON text. You will have to do further processing. But that actual data is there in the aptly named **data** field.

Here's an example of how you could grab that JSON data, process it to get actual values in CPython (desktop, Raspberry Pi, etc), and then send those values back to the AIO feeds of interest. The data used is based on the CircuitPython example from this guide.

```python
import struct
from Adafruit_IO import Client
from secrets import secrets

aio = Client(secrets['aio_username'], secrets['aio_key'])

# get the raw data
raw_feed = aio.feeds('test-feed')
raw_data = aio.receive(raw_feed.key).value

# the JSON blob is truncated, so just parse manually
print("Getting raw data...")
data = bytes.fromhex(raw_data.split(',')[2].split(':')[1].strip('"'))
values = struct.unpack("<6fB5f", data)
print(values)

# send parsed data back to specific feeds
print("Sending to AIO...")
aio.append(aio.feeds('rock-block.rb-humidity').key, values[7])
aio.append(aio.feeds('rock-block.rb-temperature1').key, values[8])
aio.append(aio.feeds('rock-block.rb-pressure').key, values[9])
aio.append(aio.feeds('rock-block.rb-temperature2').key, values[11])
print("DONE.")
```

# Using the RockBLOCK Iridium Modem

## Send Message to Modem

The following example shows how to use the HTTP POST option for sending a Mobile Terminated (MT) message to the RockBLOCK modem. See the [RockBLOCK Web Services User Guide](https://www.groundcontrol.com/en/wp-content/uploads/2022/02/RockBLOCK-Web-Services-User-Guide.pdf) for more information. It also shows how to use the CircuitPython library to receive that message at the modem.

Info: This is an example of sending a Mobile Terminated (MT) message to the modem.

Generating a HTTP POST can be done in numerous ways:

- use curl from the command line
- use the requests module in Python
- similar options in Ruby, PHP, JavaScript, etc.
- enter URL in a web browser

The basic HTTP POST URL is:

```terminal
https://rockblock.rock7.com/rockblock/MT?imei=IMEI&username=USERNAME&password=PASSWORD&data=DATA
```

where the **four required parameters** are:

- **IMEI** = The unique IMEI of your RockBLOCK modem
- **USERNAME** = Your Rock 7 Core username
- **PASSWORD** = Your Rock 7 Core password
- **DATA** = The message (hex encoded)

Warning: Account user name and password information must be included in the URL. Be careful not to expose these.

## Finding the IMEI Number

To find the IMEI number for your RockBLOCK modem, first log in to your account. Once logged in, select the My RockBLOCKs tab in the left hand menu. The IMEI number will be shown for each RockBLOCK in the list.

![](https://cdn-learn.adafruit.com/assets/assets/000/130/728/medium800/sensors_imei.png?1718394115)

## Hex Encoded Data

The data being sent to the modem must be in the form of raw bytes, with each byte represented by its hex value. For example, if you want to send "hello world", it **won't work** to have:

```terminal
data="hello world"
```

Instead, the text must be converted. In Python, the [hexlify()](https://docs.python.org/3/library/binascii.html#binascii.hexlify) command in the [binascii](https://docs.python.org/3/library/binascii.html) module can be used. The text string must also be converted to bytes before sending to hexlify(). This can be done using encode() or via the b prefix to indicate raw bytes.&nbsp;

```python
>>> import binascii
>>> DATA = binascii.hexlify(b'hello world')
>>> type(DATA)
<class 'bytes'>
>>> DATA
b'68656c6c6f20776f726c64'
>>>
```

So the resulting data parameter in the URL would look like:

```terminal
data=68656c6c6f20776f726c64
```

## Final URL Example

There's no way to show a complete URL example without revealing secrets. But a representative URL to send "hello world" to a RockBLOCK modem would look something like:

```terminal
https://rockblock.rock7.com/rockblock/MT?imei=123456789&username=foo&password=bar&data=68656c6c6f20776f726c64
```

The RockBLOCK online API reference includes a page that helps with generating the URL. It also provides code snippets for various programming languages:

[URL builder](https://docs.rockblock.rock7.com/reference/testinput)
## Checking Messages

Once the HTTP POST has been successfully made, the message has been sent. It can be viewed in the Messages tab of the RockBLOCK admin page:

![](https://cdn-learn.adafruit.com/assets/assets/000/130/729/medium800/sensors_msg.png?1718396666)

Sending this message consumed 1 credit.

Danger: Sending messages to the RockBLOCK modem with HTTP POST consumes credits!

## Receiving Message with Modem

Once the message has been sent, it can be received via the RockBLOCK modem. The receive text example from the CircuitPython library can be used:

https://github.com/adafruit/Adafruit_CircuitPython_RockBlock/blob/main/examples/rockblock_recv_text.py

Here is the example output running the above example on a PC with the RockBLOCK modem attached via the USB-to-serial cable:

```terminal
$python3 rockblock_recv_text.py 
Talking to satellite...
0 (32, 14, 2, 0, 0, 0)
1 (32, 14, 2, 0, 0, 0)
2 (32, 14, 2, 0, 0, 0)
... deleted output ...
80 (32, 14, 2, 0, 0, 0)
81 (32, 14, 2, 0, 0, 0)
82 (0, 14, 1, 2, 11, 0)

DONE.
hello world
```

The number of tries it takes to finally make satellite contact will depend on location and available sky view area. For the above test, the modem was placed in a window which also had several trees outside. The view of the sky was not great, but it still eventually was able to make contact - after 82 tries.&nbsp;

# Using the RockBLOCK Iridium Modem

## More Info on Data Transmission

## TLDR

The RockBLOCK sends and receives raw data bytes. It's up to your applications, both on the send and receive end, to encode and decode those as you see fit.

Info: 

## Text vs. Binary

The RockBLOCK essentially just sends and receives 1s and 0s. It really does not care what those are or what they mean. It sends these in groups of 8, which is what a byte is. You can send up to **340 bytes** in one satellite transmission.

When we ran the Hello World example, we were able to use a simple text style entry:

```none
AT+SBDWT=Hello World
```

This is generally fine since there is a known single byte representation for each character. But what if you wanted to send a value? Like the temperature from a sensor which is reading 23.6245198. Should you do something like this?

```
AT+SBDWT=Temperatureis23.6245198
```
You could, and it would work, but there are a couple of issues with this.

For one, sending the text "Temperature is" is unnecessary. You will most likely know the format of whatever data you are dealing with. So then this?

```none
AT+SBDWT=23.6245198
```

That would also work, but sending the value as text is costly in terms of the number of bytes used in the transmission. Each character will consume a byte, so **10 bytes** total. It's much better to send the value as an actual byte representation. There are different size bytes representations that can be used for values, but for example, a typical floating point value can be stored in **4 bytes** (for single precision). **So you could send that same temperature value for less than half the number of bytes it would take to send it as text.**

Great, but how do you actually do this? It will depend on what programming language you are using. We'll discuss this a little further using Python.

Info: 

## Packing Data in Python

The process of turning values into raw data bytes is generally referred to as **packing**. The reverse process, turning the raw data bytes back into values, is referred to as **unpacking**. The Python module [struct](https://docs.python.org/3/library/struct.html) provides what is needed.

Let's look at a simple example. Our goal is to send the value of 23.6245198 with the RockBLOCK modem, through the Iridium satellites, to some other place on Earth. We want to do this as efficiently as possible since we burn credits on a per byte basis.

First, let's create our `value`:

```python
$ python3
Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> value = 23.6245198
```

If we wanted to send that as `text`, we would do something like:

```python
>>> text = "{}".format(value).encode()
>>> text
b'23.6245198'
>>> len(text)
10
```

Note that the text is generally readable. Also note that is takes **10 bytes**.

OK, now let's use `struct` to create a raw byte `data` representation:

```python
>>> import struct
>>> data = struct.pack("f", value)
>>> data
b'\x04\xff\xbcA'
>>> len(data)
4
```

[See here for meaning of the "f" formatting character.](https://docs.python.org/3/library/struct.html#format-characters)

The contents are no longer human readable. But it only requires **4 bytes**.

To prove that the value is still there, we can `unpack` it:

```python
>>> struct.unpack("f", data)
(23.62451934814453,)
```

That's what someone would do on the receiving end, after the 4 bytes went through the satellite system.

The key thing to note here is that it would take 10 bytes to send the text representation of the value vs. 4 bytes for the raw byte representation.

## Integer vs Float

Note how in the previous example when we unpacked the value we got extra digits and it wasn't exactly the same value we started with. This is due to the general issue of floating point precision. There's no 100% cure for this. About the only thing that can be done is to throw more bytes at the issue. For example, using double precision, which takes 8 bytes, we get better results:

```python
>>> value = 23.6245198
>>> data = struct.pack("d", value)
>>> len(data)
8
>>> struct.unpack("d", data)
(23.6245198,)
```

Great, but we just doubled the amount of bytes that needs to be sent.

The better solution to this problem is to use integers for everything. But how do you turn floating point numbers into integers without losing data? You generally can't. But that's not necessary.

These values will most likely have started out as integers to begin with. They originated from registers on the sensors where they were stored as a series of 1s and 0s. The datasheet would have all the information about the layout which could then be used to compute the actual values of interest. Doing this work for you is one of the main features of using a sensor library. But, for the sake of efficient satellite data transfer, instead of reading the register, computing the value of the physical property of interest, and then trying to transmit that value - **just send the raw register values as integers**.

The integer value can store all the 1s and 0s of the registers as they actually are. It is efficient and no information is lost. And turning those values into the engineering units of interest on the receiving end is a trivial task.


## Featured Products

### RockBLOCK 9603 with USB Cable - Iridium Satellite Modem Bundle

[RockBLOCK 9603 with USB Cable - Iridium Satellite Modem Bundle](https://www.adafruit.com/product/4521)
The **RockBLOCK 9603** allows you to send and receive short messages from anywhere on Earth with a clear view of the sky. And when we say anywhere we mean **anywhere**. It works far beyond the reach of WiFi and GSM networks. Maybe you want to transmit weather...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/4521)
[Related Guides to the Product](https://learn.adafruit.com/products/4521/guides)
### RockBLOCK 9603 Accessory Cable

[RockBLOCK 9603 Accessory Cable](https://www.adafruit.com/product/4529)
The **RockBLOCK 9603 Accessory Cable** is terminated with a simple 10-pin Molex-style connector at one end and male jumper wires at the other.

This accessory cable will help speed up your development time, meaning you no longer need to terminate and crimp your own connector...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/4529)
[Related Guides to the Product](https://learn.adafruit.com/products/4529/guides)

## Related Guides

- [Cartoon Network MakeCode: Garnet's Gauntlets from Steven Universe](https://learn.adafruit.com/cartoon-network-makecode-garnets-gauntlets-from-steven-universe.md)
- [Bluefruit Ouija Board](https://learn.adafruit.com/bluefruit-ouija-board.md)
- [FunHouse Mail Slot Detector](https://learn.adafruit.com/funhouse-mail-slot-detector.md)
- [Adafruit AS5600 Magnetic Angle Sensor](https://learn.adafruit.com/adafruit-as5600-magnetic-angle-sensor.md)
- [Portable PyPortal](https://learn.adafruit.com/portable-pyportal.md)
- [Adafruit 1.14" 240x135 Color Newxie TFT Display](https://learn.adafruit.com/adafruit-1-14-240x135-color-newxie-tft-display.md)
- [Hexpad](https://learn.adafruit.com/hexpad.md)
- [Adafruit MMA8451 Accelerometer Breakout](https://learn.adafruit.com/adafruit-mma8451-accelerometer-breakout.md)
- [Neopixel Crystal Chandelier with CircuitPython Animations and Speed Control](https://learn.adafruit.com/neopixel-crystal-chandelier-with-circuitpython-animations-and-speed-control.md)
- [Adafruit HX711 24-bit ADC](https://learn.adafruit.com/adafruit-hx711-24-bit-adc.md)
- [HalloWing Jump Scare Trap](https://learn.adafruit.com/hallowing-jump-scare-trap.md)
- [Yoga Pose Chime](https://learn.adafruit.com/yoga-pose-chime.md)
- [NeoPixel Badge Lanyard with Bluetooth LE](https://learn.adafruit.com/bluetooth-neopixel-badge-lanyard.md)
- [Adafruit TSSP77038 38KHz Infrared IR Demodulator Breakout](https://learn.adafruit.com/adafruit-tssp77038-38khz-infrared-ir-demodulator-breakout.md)
- [No-Code IoT Soil Sensor](https://learn.adafruit.com/soil-node.md)
