ENG-CANSAT-RFM69HCW-TEST

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche

Forewords

It is now time to establish a communication between:

  • a Data Emitter made with a Feather M0 Express + RFM69HCW-433MHz.
  • a Data Receiver made with the second RFM69HCW that should be linked to a second micro controller.

As the kit contains only one micro controller (the Feather M0 Express), we will use the very common Arduino UNO (not included) as micro controller for the Data Receiver.

In this simple exemple:

  1. The Data Emitter will send a message and wait 500ms for a response.
  2. The Data Receiver will receive the message.
  3. The Data Receiver will send a reply.

ENG-CANSAT-RFM69HCW-TEST-00.jpg

As we will see, there are 2 key items will be highlighted:

  1. The frequency must be identical in the emitter and receiver (eg: 433.0 MHz in this example).
  2. The encryption key must be identical on the both side.

Installing the RadioHead library

If not done yet, we will have to install the RadioHead library in Arduino IDE.

That library support lot of RFM modules including our RFM69HCW.

Adafruit did fork the RadioHead library and add some useful sample, so we will install the small|Adafruit's RadioHead forked library.

Download-icon.pngDownload RadioHead forked library

For easy install, you can run Arduino IDE and open the menu "Sketch -> Add a .ZIP library..."

ENG-CANSAT-RFM69HCW-TEST-20.jpg

Then pick-up the downloaded RadioHead ZIP file.

ENG-CANSAT-RFM69HCW-TEST-21.png

Once installed the RFM69 examples are available from the menu "File -> Examples".

ENG-CANSAT-RFM69HCW-TEST-22.png

We will focus our interest in the following examples:

  • File -> Examples -> RadioHead -> Feather -> RadioHead69_RawDemo_RX
  • File -> Examples -> RadioHead -> Feather -> RadioHead69_RawDemo_TX

About Antennas

The antenna design is a key feature to ensure a reliable communication over a long distance.

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 µFl connector (also named uFl) is locking to this:

ENG-CANSAT-RFM69HCW-TEST-uFL-connector.jpg

A PCB SMA Connector is locking to this:

ENG-CANSAT-RFM69HCW-TEST-SMA-connector.jpg

The Emitter

We will prepare our message emitter, typically stored inside the CanSat can.

This will involve:

  • The Feather M0 Express plateform
  • One of the RFM69HCW 433 Mhz module
  • An wire antenna

To ease the learning, we will also connect the Feather to the computer to spy the emitted messages (which implies additional code to activate the serial port.

Wiring

ENG-CANSAT-RFM69HCW-Wiring-Feather.jpg

Feather M0 Express RFM69
3V VIN
GND GND
MO MOSI
MI MISO
SCK SCK
6 CS
9 G0
10 RST

The code

Now we will load the emitter example code from the RadioHead Library.

Load the sketch file -> Examples -> RadioHead (or RadioHead-master) -> feather -> RadioHead69_RawDemo_TX

ENG-CANSAT-RFM69HCW-TEST-22.png

Indeed, the example code is provided for the Feather M0 and not the Feather M0 Express so we will have to adapt the used pinout because pins 3,4 and 8 are not available on the Feather M0 Express.

Update for Interface:

Locate the following lines in the code:

#if defined(ARDUINO_SAMD_FEATHER_M0) // Feather M0 w/Radio
  #define RFM69_CS      8
  #define RFM69_INT     3
  #define RFM69_RST     4
  #define LED           13
#endif

and change it as follow ("Feather M0 Express" it is still the a "Feather M0" plateform):

#if defined(ARDUINO_SAMD_FEATHER_M0) 
  // UPDATE for Feather M0 EXPRESS with RFM69HCW radio module
  // G0 is the Radio Module interrupt pin
  #define RFM69_CS      6
  #define RFM69_INT     9 
  #define RFM69_RST     10
  #define LED           13
#endif

Update for frequency plan:

The RFM69HCW exists in 2 flavor:

  • 900 MHz for United State usage (with a green dot)
  • 433 Mhz for "Europe" license-free ISM usage (with a red dot ).

The code is the same for the both flavor, you must indicates the right frequency according to the module you have. Trying to generate 900Mhz signal on a 433Mhz would result in "nothing generated"!

The RFM69HCW 433Mhz can generate signal from 424 Mhz to 510 Mhz (see datasheet). You have to select the Frequency accordingly to the authorised Frequency Plan and Radio License. The 433 Mhz is free for use, please select your own frequency in that range.

Locate the following lignes:

// Change to 434.0 or other frequency, must match RX's freq!
#define RF69_FREQ 915.0

And update it to:

// Change to 434.0 or other frequency, must match RX's freq!
#define RF69_FREQ 433.0

Activate the Serial Line:

The begin of the setup() function does contains the following lines.

void setup() 
{
  Serial.begin(115200);
  //while (!Serial) { delay(1); } // wait until serial console is open, remove if not tethered to computer

Update it and remove the comment mark in the front of the while loop like showed here under.

void setup() 
{
  Serial.begin(115200);
  while (!Serial) { delay(1); } // wait until serial console is open, remove if not tethered to computer

This way, the Feather will wait for the "serial monitor" to be open before starting the sketch.

This while loop is important otherwise, none of the serial.print() would be visible in the serial monitor.

Voilà, We are ready to compile and upload.

Compile and upload

Select the proper board in the menu Tools -> Type of board : Adafruit Feather M0 Express

Select the proper port in the menu Tools -> Port

Then press the "compile" button.

Running the sketch

Now open the Serial Monitor and set the baud rate to 115200 baud.

As there is no board listening and answering, you should see the following result on the screen.

ENG-CANSAT-RFM69HCW-TEST-25.png

Later, when the the receiver would be ready, the message will turn to:

ENG-CANSAT-RFM69HCW-TEST-25.png



Written by Meurisse D. from MC Hobby - License: CC-SA-BY.