Quantcast
Channel: Articles on JeeLabs
Viewing all articles
Browse latest Browse all 296

Hooking up an RFM69 radio

$
0
0

It’s time to step things up a bit. Let’s create a wireless node, with an RFM69 attached to an F103 µC, and then see if we can make it sing…

We’re going to need two nodes, if we want to actually test packet transmission and reception. Here is one node, hacked together with a Blue Pill and some fancy soldering:

The connections to the radio module are as follows, apart from +3.3V and GND:

  • PA4 = SSEL
  • PA5 = SCLK
  • PA6 = MISO
  • PA7 = MOSI

The setup shown above has more pins connected, but these are just “for future use”.

It’s not quite good enough though, we also need the serial port - so let’s also hot-glue a little JeeLabs Proto Board underneath, and hook up a 6-pin male header as FTDI connector:

The pinouts for the FTDI connector are:

  • DTR = optional, connected to “R” (RESET) on the Blue Pill
  • RX = tied to µC’s TX, i.e. PA9
  • TX = tied to µC’s RX, i.e. PA10
  • +5V = power, 5V in
  • RTS = optional, connected to the BOOT0 jumper, middle pin
  • GND = power, ground

Now we can plug this whole thingamajig into a USB-serial adapter. It’s very convenient.

To try this out, we’ll need the radio/ directory from GitHub - it contains the following files:

  • Makefile - the make settings for this example
  • main.cpp - this is identical to the one used in the previous echo example
  • radio.cpp - the actual application code, with setup() and loop()
  • rf69.h - the RF69 driver (same as used in several older projects)
  • spi.h - a header which interfaces to the polled SPI implementation in libopencm3

Builds and downloads can be done in the same way as before for the blink and echo examples. Here is a transcript of the entire process, using Folie for uploads:

$ make
  CXX     main.cpp
  CXX     radio.cpp
  LD      radio.elf
  OBJCOPY radio.bin
   text	   data	    bss	    dec	    hex	filename
  29960	   2220	    204	  32384	   7e80	radio.elf
$ folie -r
Select the serial port:
  1: /dev/cu.Bluetooth-Incoming-Port
  2: /dev/cu.usbmodem3430DC31
? 2
Enter '!help' for additional help, or ctrl-d to quit.
[connected to /dev/cu.usbmodem3430DC31]
!u radio.bin
  32180b .+V22 #0410 R .W .E writing: 126/126 done.

[radio]
  Enter 't' to broadcast a test packet as node 61.
  Listening for packets on 868.6 MHz, group 6 ...

rf69 21ee068803006ec0010a 8102c54bab019c179a80  (68+110:3)
rf69 21ee0687030070c00107 8102c44bac8080  (67.5+112:3)
rf69 21ee068a03007ec0010a 8102bd4bad019d179b80  (69+126:3)

In this case, the code was modified to listen to group 6, where existing wireless sensor nodes are already active here at JeeLabs. And as you can see, this example is picking up a number of packets and reporting them, nicely formatted.

If you don’t have compatible nodes running, you’ll need to create a second board with RFM69 attached, and upload the same code there as well. Then, by entering “t”, you can cause it to send out a test packet, which the other node should be picking up and reporting – if all is well.

That’s it - the start of a Wireless Sensor Network, built with low-cost “Blue Pill” boards based on the powerful ARM STM32F103 µC, and running code compiled with GCC and linked to the libopencm3 library for easy access to the chip’s GPIO, serial port, and built-in SPI hardware.

All this has taken us just five articles, to address and overcome all the hurdles involved when starting on ARM from scratch.

Coming up: a much simpler way to upload and talk to the Blue Pill and other ARM boards…


Viewing all articles
Browse latest Browse all 296

Trending Articles