ENG-CANSAT-PICO-RFM69HCW-TEST
Forewords
It is now time to establish a communication between:
- a Data Emitter (CanSat) made with a raspberry-Pico + RFM69HCW-433MHz.
- a Data Receiver (Base Station) made with the second RFM69HCW coupled to another Pico microcontroler.
As the kit contains contains two Pico microcontroller we will be able to create the "Data Emitter" on the CanSat as well as the Data Receiver at the ground station.
In this simple example:
- The Data Emitter will send a message and wait 500ms for a response (ACK).
- The Data Receiver will receive the message.
- The Data Receiver will send a ACK reply.
As we will see, there are 2 key items to be highlighted:
- The frequency must be identical in the emitter and the receiver (eg: 433.1 MHz in this example).
- The encryption key must be identical on the both side.
Installing the RFM69 library
The Adafruit's FRM69HCW are provided with a MicroPython library available on GitHub.
You can download and copy the library manually to your board from the Repository.
First, open the repository, then navigate to the file lib/rfm69.py .
Follow the steps describes in the "BMP280 library installation" to copy the RFM69 library to your micropython board.
Once copied, you can also check the proper installation by typing from rfm69 import * .
The RFM69 library repository contains many examples of usage. Do not hesitate to check them! |
About Antennas
The RFM69HCW will not work without antenna, even at 1m distance of each other. |
For this example, a simple wire twisted in the antenna hole will do a great job for testing.
Please wait before soldering the wire inside the antenna hole!. The antenna hole can be populated with:
- a simple wire
- a µFl SMT antenna connector where you could plug various kind of antenna.
- a PCB SMA Connector where you could plus various kind of antenna.
A µFl connector (also named uFl) is looking to this:
A PCB SMA Connector is looking to this:
Frequency, Encryption & Power
To make the module communicating together:
- The module must be identical. You cannot mix them.
- The tuned frequency must be identical.
- The encryption key must be identical.
Tuned frequency
The tuned frequency is declared with a line like this:
#define RF69_FREQ 433.0
...
if (!rf69.setFrequency(RF69_FREQ)) {
Serial.println("setFrequency failed");
}
where the tuned frequency is declared with the constant RF69_FREQ.
Use the frequency assigned to your team by the instructor. |
In packet radio, several teams can share the same frequency if they use distinct encryption key.
Like TCP (from TCP/IP network), the packet radio is able to detect packet colission try to recover from it.
However, more teams share the same frequency, more collision we have.
Encyption Key
The module encrypts the data with AES-128.
The encryption key is defined into the following lines.
// The encryption key has to be the same as the one in the server
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
rf69.setEncryptionKey(key);
It is highly recommended for each team to define its own encryption key. |
When all the teams do use the same frequency and the same key then they will all receives the messages from the other teams sending messages. Your messages will also been received by all the other teams.
Transmission Power
The transmission power is set with the function call.
The range of power is 14 to 20 (in dBi). Lowest values requires less power. Means higher battery life but also smaller transmission distance.
rf69.setTxPower(20, true);
Notice: the second parameter concerns the HCW radio modules and indicates that extra amplifier is present.
Written by Meurisse D. for MCHobby