I’ve been setting up a monitoring system in a building where the standard 433MHz radio range is not quite enough. A long time ago now I used a USB powered EmonTH as a repeater to get around this issue and thought I would take the same approach again here but get this working with the LowPowerLabs library. It’s also possible to use a JeeLink (right) to do the same. Thought I would share this in case it’s useful for others.
The EmonTx4 in this case first transmits on group 200 , this message is received by the repeater and forwarded on on group 210, which is then received by the base station.
Here’s the code to make this work:
#include <RFM69.h>
RFM69 radio;
byte nativeMsg[66];
#define MAXMSG 66
char outmsg[MAXMSG];
byte outmsgLength;
struct {
byte srcNode = 0;
byte msgLength = 0;
signed char rssi = -127;
bool crc = false;
} rfInfo;
void setup()
{
Serial.begin(38400);
//Serial.println("Repeater");
radio.initialize(RF69_433MHZ,5,200);
radio.encrypt("89txbe4p8aik5kt3");
radio.setPowerLevel(31);
}
void loop()
{
if (radio.receiveDone())
{
rfInfo.srcNode = radio.SENDERID;
rfInfo.msgLength = radio.DATALEN;
for (byte i = 0; i < radio.DATALEN; i++) {
nativeMsg[i] = radio.DATA[i];
}
rfInfo.rssi = radio.readRSSI();
if (radio.ACKRequested()) {
radio.sendACK();
}
Serial.print(F("OK"));
Serial.print(F(" "));
Serial.print(rfInfo.srcNode, DEC);
Serial.print(F(" "));
for (byte i = 0; i < rfInfo.msgLength; i++) {
Serial.print((word)nativeMsg[i]);
Serial.print(F(" "));
}
Serial.print(F("("));
Serial.print(rfInfo.rssi);
Serial.print(F(")"));
Serial.println();
// Repeat
radio.setAddress(rfInfo.srcNode);
radio.setNetwork(210);
radio.sendWithRetry(5, nativeMsg, rfInfo.msgLength);
radio.setAddress(5);
radio.setNetwork(200);
}
}
and platformio.ini for those who prefer using platformio to compile:
[platformio]
default_envs = default
src_dir = .
[env:default]
platform = atmelavr
framework = arduino
board = uno
monitor_speed = 38400
lib_deps =
https://github.com/LowPowerLab/RFM69
The above code also repeats at the higher power level (level 31 or 13dBm).