SX127* LoRa and PJON “libraries” for PICAXE M2s & X2S

J G

Active member
We recently needed a remote monitor to see how the battery in a solar powered electric fence installation was behaving. As a radio link, we bought a couple of Ra-01 LoRa modules, based around an SX1278 chip, due to their relatively low cost, very good claimed range, performance and already having an Arduino library that makes using them with Arduinos quite easy once level shifting is taken care of.

At one point after discovering an unmodified Arduino Uno on its own draws more current than the fence itself, I thought it would be nice to implement the remote unit using a PICAXE microcontroller. The HABAXE2 balloon tracker also used SX1278 based radio modules, however its code was implemented using the hardware SPI capability of the X2 parts and the largest PICAXE chip I have lying around is the 18m2. As I didn’t know too much about the low level operation of the radio modules and had already dealt with the Arduino library, I have attempted to port the code from it to PICAXE basic, using similar subroutines and structure. The SPI bus is bit banged and while only having a clock speed of around 1.5kHz, is adequate for a radio that isn’t optimised for speed anyway.

Once I had LoRa modules successfully sending packets, I needed a method for addressing for if when I add other monitoring boxes for things like the pressure pump running time. I have played with the PJON protocol over RS485 busses before and there is a strategy for using this with LoRa on Arduinos, so I thought I would implement a limited version of that for PICAXE microcontrollers. This handles addressing, as well as handles the calculation and verification of checksums and can successfully communicate with the Arduino PJON library in local mode (no bus ids).

Both of these “libraries” are contained in a couple of files that can be included in projects as required. The LoRa code can be used with or without the PJON protocol as required.

The LoRa and PJON PICAXE code and more information on using it can be found here and the code for the battery monitor can be found here.

I know there is also an SX126* series of chip as discussed in this thread that has a lower receiving mode current and UART interface, however we already had SX1278 based modules, so found a way to use them.

Here is a small photo of the battery monitoring unit before it had a few additions including a mosfet to remotely control the fence and an external antenna to improve range (even if the coax cable is the wrong impedance , it still is a lot better than the small included antenna stuck inside a tin shed :) ).

24448

Hope this is interesting and possibly useful.
 

J G

Active member
Tidy layout (at least, pre-modification).
Thanks. I read an article online about using KiCad to plan out veroboard layouts, so thought I would give it a go. I have used PEBBLE in the past for the same job, but am liking the ability to draw the schematic at the same time with a PCB layout tool. The main rules I set myself when routing was that everything should be on a 0.1" grid, the bottom layer tracks must be horisontal only and the top layer representing jumper wires, preferably vertical.
 
Top