Adding the RFM69 module Apr 2016

The last step to create a wireless node is to hook up the RFM radio. Here is what we’re after:

There are 4 signals and 2 power pins to connect (more can be added later, for pin interrupts):

SSEL (NSS) PA4 +3.3V

And here is the other side, all hooked up with thin “Kynar” wirewrap wire in this case:

It doesn’t matter which of the two ground pins on the RFM69CW you connect, either one is fine. Also, don’t forget to attach an antenna wire of about 82 mm to the ANT pin (for 868 MHz).

So much for the hardware. If you have no other RFM69 nodes already in operation, you’ll need to build a pair of these to try out actual wireless communication, of course.

To get all the software needed for the RFM69CW into the µC, and assuming you’re starting from scratch, the easiest will be to install a single “combined” image, containing Mecrisp Forth for the STM32F103 plus a slew of Forth definitions from the embello/explore/1608-forth/flib/ area, in particular the RF69 driver (which in turn depends on SPI words, etc):

Now launch Folie as follows: folie -p <comport> -u mf224-ztw.hex

If all went well, the output will be similar to this (add the -v flag to see more):

$ folie -p /dev/cu.usbserial-A8009L2N -u mf224-ztw.hex
Connected to: /dev/cu.usbserial-A8009L2N
        File: mf224-ztw.hex
       Count: 32768 bytes (converted from Intel HEX)
    Checksum: c0574666 hex
 Synchronise: .+ OK
 Boot loader: 22 hex
   Chip type: 0410 hex - STM32F1, performance, medium-density
   Unprotect: OK
      Resume: .+ OK
  Mass erase: OK
   Uploading: ++++++++++++++++++++++<etc>++++++++++++++++++++++ OK

Good, almost there! Just restore the BOOT0 jumper to “0” and press reset. If you now connect again with Folie in normal mode, and type “reset”, this is what should appear:

$ folie -p /dev/cu.usbserial-A8009L2N
Connected to: /dev/cu.usbserial-A8009L2N
reset ?Mecrisp-Stellaris 2.2.4 for STM32F103 by Matthias Koch
64 KB <ztw> 32a92103 

Those last two lines are the key: Mecrisp reports its version, platform, and creator on one line, and then the auto-launched init word prints a second line with some more titbits:

If you type “list”, you will see a dump of all the words currently defined on your board.

At this point, the board is working, Mecrisp is working, and there’s a bunch of Forth code in flash, ready to serve you. The next step is to find out whether the RFM69 radio is also working.

Type “rf-init” to initialise SPI and the radio (using net group 42 @ 868.6 MHz defaults):

rf-init  ok.

Now type “rf.” (with the period at the end) to get a listing of the radio’s internal registers:

     0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F 
00: -- 04 00 02 8A 02 E1 D9 26 40 41 60 02 92 F5 20
10: 24 9F 09 1A 40 B0 7B 9B 08 4A 42 40 80 06 1C 00
20: 00 00 00 02 FF 00 07 80 00 A0 00 00 00 05 88 2D
30: 2A 00 00 00 00 00 00 D0 42 00 00 00 8F 12 00 00
40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00
50: 00 01 88 08 00 00 01 00 1B 09 55 80 70 33 CA 08 ok.

Excellent - we’re seeing all sorts of settings. You could look them up in the HopeRF RFM69 datasheet, if you’re so inclined…

Now the tricky bit: as we all know, wireless needs (at least) two to tango!

If all goes well, the first node should now report a new incoming packet:

RF69 21EE2A7C040022801805 3132333435
         ^^            ^^ ^^^^^^^^^^
          |            |  |
      group      5 bytes  payload

Bingo! Lift-off! Wireless! Communication! Magic! Drumroll!

To select a different net group or frequency, you can adjust these variables:

123 !  ok.
8683 rf.freq !  ok.

Well, that’s the ideal case anyway. If for any reason this is not immediately working for you as expected, please consider registering and posting on the JeeLabs Forum or submitting an issue on GitHub. This code is still very young - getting it working under all circumstances (especially from Windows), is bound to take some more effort and detective work.

Still… it’s worth pointing out that we only needed two files to get a complete RF69 development environment going: the Folie serial utility, and the latest firmware hex dump. Once that works, everything else can be done in Forth, including reloading updated versions of the code in flash.

Weblog © Jean-Claude Wippler. Generated by Hugo.