Emonhub with Jeelink in Ubuntu: can't decode byte

I think the archive might be able to help.

Go to the home page https://openenergymonitor.org click on search and ‘jeelink’. There are quite a few results.

I also wonder if @pb66 might be able to help.

It depends on what JeeLink wants. It should be spelled out in the documentation - if there is any. All I can find that’s accessible is The JeeLabs Shop - JeeLink (v3c). The link at the bottom “The documentation and full design details are freely available.” is dead.

I don’t have one, I’ve never used one, so that’s the best I can do.

Another Edit:
This has a suggestion for the JeeLink: SOLVED Problem with new Jeelink not receiving data from emonTX v3.4 | Archived Forum
Note the quite important line:
The Jeelink came pre-installed with RF12demo.13 on group 212 and nodeID 1, so I changed the group to 210 ...
If yours is working on Group 212, that will explain a lot.

If you search here for “JeeLink”, there are many archived mentions:

path21

Hello
Thanks for the links. I am afraid that I need to load a new firmware into my Jeelink.
Upon opening a terminal I get the string [pcaSerial.10.1]…
This firmware does not even allow me to select a “group”… that is not good
I think I have this firmware: pcaSerial
and I need to change it to some “RFM12” like this: RFM12.
Now I need to figure out if that is possible and how to do that.

Can you confirm exactly what you have and from where you purchased it please.

I have been assuming you have one of these from digitalsmarties

Which, assuming the listing is still correct) states it still uses the RF12demo sketch which is what the RFM2Pi and then the emonPi FW’s were derived from.

The only mention of a “jeelink” with “PCA301” I found was this on Amazon

https://www.amazon.co.uk/JeeLink-PCA301-868MHz-FTDI-Stick-Antenna-Adapter/dp/B07V4N98F3

which clearly states it is a JeeLink clone and comes pre-installed with “serial_v10.1” FW. That word “clone” does a lot of heavy lifting here as this device looks nothing like a JeeLink. A JeeLink is a USB stick with a full size USB plug that can plug straight into a USB port on your PC, it is not a RFM board strapped to an Arduino Nano.

So although I do not know what device you physically have, I do suspect you probably do need to install another firmware (although I do not know that for sure). That will be HW dependent so we do need to know what you have there.

Somewhere on the archived forum there is/was a compiled rfm2pi FW for a genuine JeeLink, which is much like the RFM2Pi FW we run here except the clock is 16MHz not 8MHz. If we can’t find the compiled hex, it will just mean recompiling the RFM2Pi FW for the correct board, ie correct clock speed, voltage and upload baud etc.

This is the OEM FW you need to install should you wish to.

Line 31 must be set to 0 (not 1) if you have a rfm12b device

There maybe other changes too, but IIRC it should just compile ok, it’s just getting the board detials right to upload correctly.

1 Like

Hello
I got it. I need to update the firmware of the JeeLink.
I got it on ebay Here
Title mentioned RFM12b but the detail indicated “PcaSerial” version…
Anyway now I try to update the device.
Arduino compiler complaints that Jeelib.h is missing. Do you have it? (and other dependencies, I ask you because Jeelabs.org seems to have some problem).
Thanks in advance for your support!

JeeLib is here

There is info on installing libs here

https://learn.openenergymonitor.org/electricity-monitoring/arduino-ide/windows10lib

Mac & Linux instructions are also available.

1 Like

Hello
I managed to flash the Jeelink with the sketch you sent me (used Arduino 1.8.13
Tools\Board=Adruino Nano
Tools\Processo=AtMega328P (old bootloader))
The miniterm now shows “[RF12demo.14]” but no help menu is displayed.
“v” and other command produce no output… I am not sure that firmware is running correctly.
I am afraid that some HW depending settings need to be define… And here i am lost

Emoncms now detects the board and there are no more warnings , but signals are still not detected.
I will keep trying

2020-08-14 06:12:47,053 INFO     MainThread Opening hub...
2020-08-14 06:12:47,053 INFO     MainThread Logging level set to DEBUG
2020-08-14 06:12:47,053 INFO     MainThread Creating EmonHubJeeInterfacer 'RFM2Pi'
2020-08-14 06:12:47,194 DEBUG    MainThread Opening serial port: /dev/ttyUSB0 @ 57600 bits/s
2020-08-14 06:12:49,196 INFO     MainThread RFM2Pi device firmware version: [RF12demo.1
2020-08-14 06:12:49,196 INFO     MainThread RFM2Pi device current settings:
2020-08-14 06:12:49,196 INFO     MainThread Setting RFM2Pi baseid: 15 (15i)
2020-08-14 06:12:50,198 INFO     MainThread Setting RFM2Pi frequency: 868 (8b)
2020-08-14 06:12:51,199 INFO     MainThread Setting RFM2Pi group: 210 (210g)
2020-08-14 06:12:52,200 INFO     MainThread Setting RFM2Pi quiet: 0 (0q)
2020-08-14 06:12:53,202 INFO     MainThread Setting RFM2Pi calibration: 230V (1p)
2020-08-14 06:12:54,205 DEBUG    MainThread Setting RFM2Pi pubchannels: ['ToEmonCMS']
2020-08-14 06:12:54,205 DEBUG    MainThread Setting RFM2Pi subchannels: ['ToRFM12']
2020-08-14 06:12:54,205 INFO     MainThread Creating EmonHubMqttInterfacer 'MQTT'
2020-08-14 06:12:54,206 DEBUG    MainThread Setting MQTT pubchannels: ['ToRFM12']
2020-08-14 06:12:54,206 DEBUG    MainThread Setting MQTT subchannels: ['ToEmonCMS']
2020-08-14 06:12:54,206 INFO     MainThread Setting MQTT node_format_enable: 1
2020-08-14 06:12:54,206 INFO     MainThread Setting MQTT nodevar_format_enable: 0
2020-08-14 06:12:54,206 INFO     MainThread Setting MQTT nodevar_format_basetopic: emon/

I adapted the sketch for baud rate: config.nodeId = 0x8F; //Hope “8F” means 868Mhz, id=15
and had to move #include <RF69_compat.h> on top to allow compilation.

Here is the code:

#include <RF69_compat.h>
#include <JeeLib.h>

#include <Ports.h>
#include <PortsBMP085.h>
#include <PortsLCD.h>
#include <PortsSHT11.h>

#include <RF12.h>
#include <RF12sio.h>
#include <RF69.h>
#include <RF69_avr.h>

//RFM12Pi V2 with RFM69CW Firmware
//Based on JCW RF12 Demo: https://github.com/jcw/jeelib/tree/master/examples/RF12/RF12demo
//Edited for RFM12Pi and emonPi operation June 2014 by Glyn Hudson and Trystan Lea
//http://OpenEnergyMonitor.org
//https://github.com/openenergymonitor/RFM2Pi

// V1.4 Jan 17
// Compile with platformIO and relase with GH releases using TravisCI

// V1.3 July 15 - add RF trace mode debug and fix node ID isse, merge pb66 pull requests
 // https://github.com/openenergymonitor/RFM2Pi/pull/2
 // https://github.com/openenergymonitor/RFM2Pi/pull/4

// Version V1.0 - Nov 2014
// * 433Mhz default frequency, 15 default node ID

// V0.9 June 2014
// * 210 default network group
// * activity LED to light on startup and each time packet is received

//--------------------------------------------------------------------------------------------------------------------------------------------

/// @dir RF12demo
/// Configure some values in EEPROM for easy config of the RF12 later on.
// 2009-05-06 <[email protected]> http://opensource.org/licenses/mit-license.php

// this version adds flash memory support, 2009-11-19
// Adding frequency features, author JohnO, 2013-09-05
// Major EEPROM format change, refactoring, and cleanup for v12, 2014-02-13

#define RF69_COMPAT 0 // define this to use the RF69 driver i.s.o. RF12

#include <JeeLib.h>
#include <util/crc16.h>
#include <avr/eeprom.h>
#include <avr/pgmspace.h>
#include <util/parity.h>

#define MAJOR_VERSION RF12_EEPROM_VERSION // bump when EEPROM layout changes
#define MINOR_VERSION 2                   // bump on other non-trivial changes
#define VERSION "[RF12demo.14]"           // keep in sync with the above

//#define SERIAL_BAUD 38400   // max baud for 8Mhz RFM12Pi http://openenergymonitor.org/emon/node/6244/
#define SERIAL_BAUD 57600   // max baud for 8Mhz RFM12Pi http://openenergymonitor.org/emon/node/6244/
#define DATAFLASH   0       // set to 0 for non-JeeLinks, else 4/8/16 (Mbit)
#define LED_PIN     9       // activity LED, comment out to disable


/// Save a few bytes of flash by declaring const if used more than once.
const char INVALID1[] PROGMEM = "\rInvalid\n";
const char INITFAIL[] PROGMEM = "config save failed\n";

#if RF69_COMPAT
 byte trace_mode = 0;
#endif

#define _receivePin 8
static int _bitDelay;
static char _receive_buffer;
static byte _receive_buffer_index;

// TODO: replace with code from the std avr libc library:
//  http://www.nongnu.org/avr-libc/user-manual/group__util__delay__basic.html
void whackDelay (word delay) {
 byte tmp=0;

 asm volatile("sbiw      %0, 0x01 \n\t"
 "ldi %1, 0xFF \n\t"
 "cpi %A0, 0xFF \n\t"
 "cpc %B0, %1 \n\t"
 "brne .-10 \n\t"
 :
 "+r" (delay), "+a" (tmp)
 :
 "0" (delay)
);
}

ISR (PCINT0_vect) {
 char i, d = 0;
 if (digitalRead(_receivePin))       // PA2 = Jeenode DIO2
   return;             // not ready!
 whackDelay(_bitDelay - 8);
 for (i=0; i<8; i++) {
   whackDelay(_bitDelay*2 - 6);    // digitalread takes some time
   if (digitalRead(_receivePin)) // PA2 = Jeenode DIO2
     d |= (1 << i);
 }
 whackDelay(_bitDelay*2);
 if (_receive_buffer_index)
   return;
 _receive_buffer = d;                // save data
 _receive_buffer_index = 1;  // got a byte
}


static byte inChar () {
 byte d;
 if (! _receive_buffer_index)
   return -1;
 d = _receive_buffer; // grab first and only byte
 _receive_buffer_index = 0;
 return d;
}


static unsigned long now () {
 // FIXME 49-day overflow
 return millis() / 1000;
}

static void activityLed (byte on) {
#ifdef LED_PIN
 pinMode(LED_PIN, OUTPUT);
 digitalWrite(LED_PIN, on);
#endif
}

static void printOneChar (char c) {
 Serial.print(c);
}

/// @details
/// For the EEPROM layout, see http://jeelabs.net/projects/jeelib/wiki/RF12demo
/// Useful url: http://blog.strobotics.com.au/2009/07/27/rfm12-tutorial-part-3a/

// RF12 configuration area
typedef struct {
 byte nodeId;            // used by rf12_config, offset 0
 byte group;             // used by rf12_config, offset 1
 byte format;            // used by rf12_config, offset 2
byte hex_output   :
 2;   // 0 = dec, 1 = hex, 2 = hex+ascii
byte collect_mode :
 1;   // 0 = ack, 1 = don't send acks
byte quiet_mode   :
 1;   // 0 = show all, 1 = show only valid packets
byte spare_flags  :
 4;
 word frequency_offset;  // used by rf12_config, offset 4
 byte pad[RF12_EEPROM_SIZE-8];
 word crc;
}
RF12Config;

static RF12Config config;
static char cmd;
static word value;
static byte stack[RF12_MAXDATA+4], top, sendLen, dest;
static byte testCounter;

static void showNibble (byte nibble) {
 char c = '0' + (nibble & 0x0F);
 if (c > '9')
   c += 7;
 Serial.print(c);
}

static void showByte (byte value) {
 if (config.hex_output) {
   showNibble(value >> 4);
   showNibble(value);
 }
 else
   Serial.print((word) value);
}

static void showString (PGM_P s) {
 for (;;) {
   char c = pgm_read_byte(s++);
   if (c == 0)
     break;
   if (c == '\n')
     printOneChar('\r');
   printOneChar(c);
 }
}

static word calcCrc (const void* ptr, byte len) {
 word crc = ~0;
 for (byte i = 0; i < len; ++i)
   crc = _crc16_update(crc, ((const byte*) ptr)[i]);
 return crc;
}

static void loadConfig () {
 // eeprom_read_block(&config, RF12_EEPROM_ADDR, sizeof config);
 // this uses 166 bytes less flash than eeprom_read_block(), no idea why
 for (byte i = 0; i < sizeof config; ++ i)
   ((byte*) &config)[i] = eeprom_read_byte(RF12_EEPROM_ADDR + i);
}

static void saveConfig () {
 config.format = MAJOR_VERSION;
 config.crc = calcCrc(&config, sizeof config - 2);
 // eeprom_write_block(&config, RF12_EEPROM_ADDR, sizeof config);
 // this uses 170 bytes less flash than eeprom_write_block(), no idea why
 eeprom_write_byte(RF12_EEPROM_ADDR, ((byte*) &config)[0]);
 for (byte i = 0; i < sizeof config; ++ i)
   eeprom_write_byte(RF12_EEPROM_ADDR + i, ((byte*) &config)[i]);

 if (rf12_configSilent())
   rf12_configDump();
 else
   showString(INITFAIL);
}

static byte bandToFreq (byte band) {
 return band == 4 ? RF12_433MHZ : band == 8 ? RF12_868MHZ : band == 9 ? RF12_915MHZ : 0;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// OOK transmit code

#if RF69_COMPAT // not implemented in RF69 compatibility mode
static void fs20cmd(word house, byte addr, byte cmd) {
}
static void kakuSend(char addr, byte device, byte on) {
}
#else

// Turn transmitter on or off, but also apply asymmetric correction and account
// for 25 us SPI overhead to end up with the proper on-the-air pulse widths.
// With thanks to JGJ Veken for his help in getting these values right.
static void ookPulse(int on, int off) {
 rf12_onOff(1);
 delayMicroseconds(on + 150);
 rf12_onOff(0);
 delayMicroseconds(off - 200);
}


static void fs20sendBits(word data, byte bits) {
 if (bits == 8) {
   ++bits;
   data = (data << 1) | parity_even_bit(data);
 }
 for (word mask = bit(bits-1); mask != 0; mask >>= 1) {
   int width = data & mask ? 600 : 400;
   ookPulse(width, width);
 }
}

static void fs20cmd(word house, byte addr, byte cmd) {
 byte sum = 6 + (house >> 8) + house + addr + cmd;
 for (byte i = 0; i < 3; ++i) {
   fs20sendBits(1, 13);
   fs20sendBits(house >> 8, 8);
   fs20sendBits(house, 8);
   fs20sendBits(addr, 8);
   fs20sendBits(cmd, 8);
   fs20sendBits(sum, 8);
   fs20sendBits(0, 1);
   delay(10);
 }
}

static void kakuSend(char addr, byte device, byte on) {
 int cmd = 0x600 | ((device - 1) << 4) | ((addr - 1) & 0xF);
 if (on)
   cmd |= 0x800;
 for (byte i = 0; i < 4; ++i) {
   for (byte bit = 0; bit < 12; ++bit) {
     ookPulse(375, 1125);
     int on = bitRead(cmd, bit) ? 1125 : 375;
     ookPulse(on, 1500 - on);
   }
   ookPulse(375, 375);
   delay(11); // approximate
 }
}

#endif

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// DataFlash code

#if DATAFLASH
#include "dataflash.h"
#else // DATAFLASH

#define df_present() 0
#define df_initialize()
#define df_dump()
#define df_replay(x,y)
#define df_erase(x)
#define df_wipe()
#define df_append(x,y)

#endif

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

const char helpText1[] PROGMEM =
"\n"
"Available commands:\n"
"  <nn> i     - set node ID (standard node ids are 1..30)\n"
"  <n> b      - set MHz band (4 = 433, 8 = 868, 9 = 915)\n"
"  <nnnn> o   - change frequency offset within the band (default 1600)\n"
"               96..3903 is the range supported by the RFM12B\n"
"  <nnn> g    - set network group (RFM12 only allows 212, 0 = any)\n"
"  <n> c      - set collect mode (advanced, normally 0)\n"
"  t          - broadcast max-size test packet, request ack\n"
"  ...,<nn> a - send data packet to node <nn>, request ack\n"
"  ...,<nn> s - send data packet to node <nn>, no ack\n"
"  <n> q      - set quiet mode (1 = don't report bad packets)\n"
"  <n> x      - set reporting format (0: decimal, 1: hex, 2: hex+ascii)\n"
#if RF69_COMPAT
"  <nnn> y    - enable signal strength trace mode, default:0 (disabled)\n"
"               sample interval <nnn> secs/100 (0.01s-2.5s) eg 10y=0.1s\n"
#endif
"  123 z      - total power down, needs a reset to start up again\n"
"Remote control commands:\n"
"  <hchi>,<hclo>,<addr>,<cmd> f     - FS20 command (868 MHz)\n"
"  <addr>,<dev>,<on> k              - KAKU command (433 MHz)\n"
;

const char helpText2[] PROGMEM =
"Flash storage (JeeLink only):\n"
"    d                                  - dump all log markers\n"
"    <sh>,<sl>,<t3>,<t2>,<t1>,<t0> r    - replay from specified marker\n"
"    123,<bhi>,<blo> e                  - erase 4K block\n"
"    12,34 w                            - wipe entire flash memory\n"
;



static void showHelp () {
 showString(helpText1);
 if (df_present())
   showString(helpText2);
 showString(PSTR("Current configuration:\n"));
 rf12_configDump();
}

static void handleInput (char c) {
 if ('0' <= c && c <= '9') {
   value = 10 * value + c - '0';
   return;
 }

 if (c == ',') {
   if (top < sizeof stack)
     stack[top++] = value; // truncated to 8 bits
   value = 0;
   return;
 }

 if ('a' <= c && c <= 'z') {
   showString(PSTR("> "));
   for (byte i = 0; i < top; ++i) {
     Serial.print((word) stack[i]);
     printOneChar(',');
   }
   Serial.print(value);
   Serial.println(c);
 }

 // keeping this out of the switch reduces code size (smaller branch table)
 if (c == '>') {
   // special case, send to specific band and group, and don't echo cmd
   // input: band,group,node,header,data...
   stack[top++] = value;
   // TODO: frequency offset is taken from global config, is that ok?
   rf12_initialize(stack[2], bandToFreq(stack[0]), stack[1],
   config.frequency_offset);
   rf12_sendNow(stack[3], stack + 4, top - 4);
   rf12_sendWait(2);
   rf12_configSilent();
 }
 else if (c > ' ') {
   switch (c) {

   case 'i': // set node id
     if ((value > 0) && (value < 31)) {
       config.nodeId = (config.nodeId & 0xE0) + (value & 0x1F);
       saveConfig();
       }
     break;

   case 'b': // set band: 4 = 433, 8 = 868, 9 = 915
     value = bandToFreq(value);
     if (value) {
       config.nodeId = (value << 6) + (config.nodeId & 0x3F);
       config.frequency_offset = 1600;
       saveConfig();
     }
     break;

   case 'o':
     { // Increment frequency within band
       // Stay within your country's ISM spectrum management guidelines, i.e.
       // allowable frequencies and their use when selecting operating frequencies.
       if ((value > 95) && (value < 3904)) { // supported by RFM12B
         config.frequency_offset = value;
         saveConfig();
       }
       break;
     }

   case 'g': // set network group
     config.group = value;
     saveConfig();
     break;

   case 'c': // set collect mode (off = 0, on = 1)
     config.collect_mode = value;
     saveConfig();
     break;

   case 't': // broadcast a maximum size test packet, request an ack
     cmd = 'a';
     sendLen = RF12_MAXDATA;
     dest = 0;
     for (byte i = 0; i < RF12_MAXDATA; ++i)
       stack[i] = i + testCounter;
     showString(PSTR("test "));
     showByte(testCounter); // first byte in test buffer
     ++testCounter;
     break;

   case 'a': // send packet to node ID N, request an ack
   case 's': // send packet to node ID N, no ack
     cmd = c;
     sendLen = top;
     dest = value;
     break;

   case 'f': // send FS20 command: <hchi>,<hclo>,<addr>,<cmd>f
     rf12_initialize(0, RF12_868MHZ, 0);
     activityLed(1);
     fs20cmd(256 * stack[0] + stack[1], stack[2], value);
     activityLed(0);
     rf12_configSilent();
     break;

   case 'k': // send KAKU command: <addr>,<dev>,<on>k
     rf12_initialize(0, RF12_433MHZ, 0);
     activityLed(1);
     kakuSend(stack[0], stack[1], value);
     activityLed(0);
     rf12_configSilent();
     break;

   case 'z': // put the ATmega in ultra-low power mode (reset needed)
     if (value == 123) {
       showString(PSTR(" Zzz...\n"));
       Serial.flush();
       rf12_sleep(RF12_SLEEP);
       cli();
       Sleepy::powerDown();
     }
     break;

   case 'q': // turn quiet mode on or off (don't report bad packets)
     config.quiet_mode = value;
     saveConfig();
     break;

   case 'x': // set reporting mode to decimal (0), hex (1), hex+ascii (2)
     config.hex_output = value;
     saveConfig();
     break;

   case 'v': //display the interpreter version and configuration
     displayVersion();
     rf12_configDump();
     break;

   case 'l': // turn activity LED on or off
     activityLed(value);
     break;

   case 'd': // dump all log markers
     if (df_present())
       df_dump();
     break;

   case 'r': // replay from specified seqnum/time marker
     if (df_present()) {
       word seqnum = (stack[0] << 8) | stack[1];
       long asof = (stack[2] << 8) | stack[3];
       asof = (asof << 16) | ((stack[4] << 8) | value);
       df_replay(seqnum, asof);
     }
     break;

   case 'e': // erase specified 4Kb block
     if (df_present() && stack[0] == 123) {
       word block = (stack[1] << 8) | value;
       df_erase(block);
     }
     break;

   case 'w': // wipe entire flash memory
     if (df_present() && stack[0] == 12 && value == 34) {
       df_wipe();
       showString(PSTR("erased\n"));
     }
     break;
#if RF69_COMPAT
   case 'y': // turn signal strength trace mode on or off (rfm69 only)
     trace_mode = value;
     break;
#endif

   default:
     showHelp();
   }
 }

 value = top = 0;
}

static void displayASCII (const byte* data, byte count) {
 for (byte i = 0; i < count; ++i) {
   printOneChar(' ');
   char c = (char) data[i];
   printOneChar(c < ' ' || c > '~' ? '.' : c);
 }
 Serial.println();
}

static void displayVersion () {
 showString(PSTR(VERSION));
}

void setup () {
 activityLed(1);
 delay(100); // shortened for now. Handy with JeeNode Micro V1 where ISP
 // interaction can be upset by RF12B startup process.

 Serial.begin(SERIAL_BAUD);
 Serial.println();
 displayVersion();

 if (rf12_configSilent()) {
   loadConfig();
 }
 else {
   memset(&config, 0, sizeof config);
  // config.nodeId = 0x4F;                           // RFM12Pi - 433 MHz, node 15 //original
   config.nodeId = 0x8F;                           // RFM12Pi - 868 MHz, node 15
   config.group = 0xD2;                           // RFM12Pi - default group 210
   config.frequency_offset = 1600;
   config.quiet_mode = true;   // Default flags, quiet on
   saveConfig();
   rf12_configSilent();
 }

 rf12_configDump();
 df_initialize();

 delay(1000);        //rfm12pi keep LED for for 1s to show it's working at startup
 activityLed(0);
}

void loop () {
 if (Serial.available())
   handleInput(Serial.read());

#if RF69_COMPAT
 if (trace_mode == 0) {
#endif
 if (rf12_recvDone()) {
   byte n = rf12_len;
   if (rf12_crc == 0)
   {
     activityLed(1);
     showString(PSTR("OK"));
   }
   else {
     if (config.quiet_mode)
       return;
     showString(PSTR(" ?"));
     if (n > 20) // print at most 20 bytes if crc is wrong
       n = 20;
   }
   if (config.hex_output)
     printOneChar('X');
   if (config.group == 0) {
     showString(PSTR(" G"));
     showByte(rf12_grp);
   }
   printOneChar(' ');
   showByte(rf12_hdr & 0x1F);
   for (byte i = 0; i < n; ++i) {
     if (!config.hex_output)
       printOneChar(' ');
     showByte(rf12_data[i]);
   }
#if RF69_COMPAT
   // display RSSI value after packet data
   showString(PSTR(" ("));
   if (config.hex_output)
     showByte(RF69::rssi);
   else
     Serial.print(-(RF69::rssi>>1));
   showString(PSTR(") "));
#endif
   Serial.println();

   if (config.hex_output > 1) { // also print a line as ascii
     showString(PSTR("ASC "));
     if (config.group == 0) {
       showString(PSTR(" II "));
     }
     printOneChar(rf12_hdr & RF12_HDR_DST ? '>' : '<');
     printOneChar('@' + (rf12_hdr & RF12_HDR_MASK));
     displayASCII((const byte*) rf12_data, n);
   }

   if (rf12_crc == 0) {
     activityLed(1);

     if (df_present())
       df_append((const char*) rf12_data - 2, rf12_len + 2);

     if (RF12_WANTS_ACK && (config.collect_mode) == 0) {
       showString(PSTR(" -> ack\n"));
       rf12_sendStart(RF12_ACK_REPLY, 0, 0);
     }
     activityLed(0);
   }
 }

 if (cmd && rf12_canSend()) {
   activityLed(1);

   showString(PSTR(" -> "));
   Serial.print((word) sendLen);
   showString(PSTR(" b\n"));
   byte header = cmd == 'a' ? RF12_HDR_ACK : 0;
   if (dest)
     header |= RF12_HDR_DST | dest;
   rf12_sendStart(header, stack, sendLen);
   cmd = 0;

   activityLed(0);
 }
 activityLed(0);
#if RF69_COMPAT
 } else {
     rf12_recvDone();
     byte y = (RF69::rssi>>1);
     for (byte i = 0; i < (100-y); ++i) {
         printOneChar('-');
     }
     Serial.print("*");
     for (byte i = 0; i < (y); ++i) {
         printOneChar(' ');
     }
     Serial.print(-y);
     Serial.println("dB");

     delay(trace_mode*10);

 }
#endif
}

What radio module do you have on your JeeLink?
Pictures:
https://learn.openenergymonitor.org/electricity-monitoring/networking/which-radio-module

If it is a RFM12B, which I think you ordered, you should NOT have
#include <RF69_compat.h>
That is for the RFM69CW module ONLY.

1 Like

WOW! It worked! Thanks a lot for your support and your patience!
Now I get data from a EmonGLCD (very near). A EmonTX placed in another room gets “unreliable content”, but if I get close to the EmonTX the data is fine.

For some reason now emoncms says “connection refused” when emoncms send data…

2020-08-14 17:52:34,175 WARNING  emoncmsorg emoncmsorg couldn't send to server: HTTPSConnectionPool(host='127.0.0.1', port=443): Max
 retries exceeded with url: /input/bulk.json?apikey=<my rw api key> (Caused by NewConnectionError('<urllib3.connect
ion.VerifiedHTTPSConnection object at 0x7f2bc0284630>: Failed to establish a new connection: [Errno 111] Connection refused',))

emonhub is running on same host as emoncms…

Can you post your emonhub.conf

However, the usual way to send data locally is via MQTT (Paul would say always use HTTP) so unless you changed the host to be your local IP it will fail.

Here is my config file.
password and user in clear… this is just a test virtual machine.

#######################################################################
#######################      emonhub.conf     #########################
#######################################################################

## **LEGACY CONFIG: For use with 17thJune2015 emonPi/emonBase image and older **
## (check image version by looking for file in /boot)
## Uses old CSV MQTT topic structure compatible with Emoncms Nodes
## Does not use MQTT server authentication

### emonHub configuration file, for info see documentation:
### https://github.com/openenergymonitor/emonhub/blob/emon-pi/configuration.md
#######################################################################
#######################    emonHub  settings    #######################
#######################################################################

[hub]
### loglevel must be one of DEBUG, INFO, WARNING, ERROR, and CRITICAL
loglevel = DEBUG #(default:WARNING)
### Uncomment this to also send to syslog
# use_syslog = yes

#######################################################################
#######################       Interfacers       #######################
#######################################################################

[interfacers]
### This interfacer manages the RFM12Pi/RFM69Pi/emonPi module
[[RFM2Pi]]
    Type = EmonHubJeeInterfacer
    [[[init_settings]]]
        com_port = /dev/ttyUSB0
        com_baud = 38400                      # 9600 for old RFM12Pi modules
    [[[runtimesettings]]]
        pubchannels = ToEmonCMS,
        subchannels = ToRFM12,

        group = 210
        frequency = 868
        baseid = 1                              # emonPi / emonBase nodeID
        quiet = false                            # Report incomplete RF packets (no implemented on emonPi)
        #calibration = 230V                      # (UK/EU: 230V, US: 110V)
        #interval =  10                         # Interval to transmit time to emonGLCD (seconds)

[[MQTT]]

    Type = EmonHubMqttInterfacer
    [[[init_settings]]]
        mqtt_host = 127.0.0.1
        mqtt_port = 1883
        mqtt_user = 'franz'
        mqtt_passwd = 'franz'

    [[[runtimesettings]]]
        pubchannels = ToRFM12,
        subchannels = ToEmonCMS,

        # emonhub/rx/10/values format
        # Use with emoncms Nodes module
        node_format_enable = 1
        node_format_basetopic = emonhub/
	
        # emon/emontx/power1 format - use with Emoncms MQTT input
        # http://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/MQTT.md
	# era a 1 qui sotto
        nodevar_format_enable = 1 
        nodevar_format_basetopic = emon/

[[emoncmsorg]]
    Type = EmonHubEmoncmsHTTPInterfacer
    [[[init_settings]]]
    [[[runtimesettings]]]
        pubchannels = ToRFM12,
        subchannels = ToEmonCMS,
        url = https://127.0.0.1
        apikey = a32fc3a89b98133e8035a82e43b2753e
        senddata = 1                    # Enable sending data to Emoncms.org
        sendstatus = 1                  # Enable sending WAN IP to Emoncms.org MyIP > https://emoncms.org/myip/list
        interval = 30                   # Bulk send interval to Emoncms.org in seconds

#######################################################################
#######################          Nodes          #######################
#######################################################################

[nodes]

## See config user guide: https://github.com/openenergymonitor/emonhub/blob/emon-pi/configuration.md

[[10]]
    nodename = emonpi
    [[[rx]]]
        names =power1,power2,power3,vrms,T1,T2,T3,T4,T5,AI5,AI5raw,RoofTempX10,SelfUsedPower,PowerSold,PowerBought
        datacodes = h, h, h, h, h, h, h, h, h, h, h, h, h, h, h
        scales = 1,1,1,1.1,10,10,10,10,1,1.0,1
        units = W,W,W,V,C,C,C,C,C,C,p

[[6]]
    nodename = emontxshield
    [[[rx]]]
       names = power1, power2, power3, power4, vrms
       datacode = h
       scales = 1,1,1,1,0.01
       units =W,W,W,W,V

[[7]]
   nodename = emontx4
   [[[rx]]]
      names = power1, power2, power3, power4, vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
      datacodes = h,h,h,h,h,h,h,h,h,h,h,L
      scales = 1,1,1,1,0.01,0.1,0.1, 0.1,0.1,0.1,0.1,1
      units =W,W,W,W,V,C,C,C,C,C,C,p

[[8]]
    nodename = emontx3
    [[[rx]]]
       names = power1, power2, power3, power4, vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
       datacodes = h,h,h,h,h,h,h,h,h,h,h,L
       scales = 1,1,1,1,0.01,0.1,0.1, 0.1,0.1,0.1,0.1,1
       units =W,W,W,W,V,C,C,C,C,C,C,p

[[9]]
   nodename = emontx2
   [[[rx]]]
      names = power1, power2, power3, power4, vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
      datacode = h
      scales = 1,1,1,1,0.01,0.1,0.1, 0.1,0.1,0.1,0.1,1
      units =W,W,W,W,V,C,C,C,C,C,C,p


[[11]]
    nodename = 3phase
    [[[rx]]]
       names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
       datacodes = h,h,h,h,h,h,h,h,h,h,h,L
       scales = 1,1,1,1,0.01,0.01,0.01,0.01,0.01,0.01,0.01,1
       units =W,W,W,W,V,C,C,C,C,C,C,p
       
 [[12]]
    nodename = 3phase2
    [[[rx]]]
       names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
       datacodes = h,h,h,h,h,h,h,h,h,h,h,L
       scales = 1,1,1,1,0.01,0.01,0.01,0.01,0.01,0.01,0.01,1
       units =W,W,W,W,V,C,C,C,C,C,C,p

[[13]]
    nodename = 3phase3
    [[[rx]]]
       names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
       datacodes = h,h,h,h,h,h,h,h,h,h,h,L
       scales = 1,1,1,1,0.01,0.01,0.01,0.01,0.01,0.01,0.01,1
       units =W,W,W,W,V,C,C,C,C,C,C,p

[[14]]
    nodename = 3phase4
    [[[rx]]]
       names = powerL1, powerL2, powerL3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse
       datacodes = h,h,h,h,h,h,h,h,h,h,h,L
       scales = 1,1,1,1,0.01,0.01,0.01,0.01,0.01,0.01,0.01,1
       units =W,W,W,W,V,C,C,C,C,C,C,p

[[19]]
   nodename = emonth1
   [[[rx]]]
      names = temperature, external temperature, humidity, battery
      datacode = h
      scales = 0.1,0.1,0.1,0.1
      units = C,C,%,V

[[20]]
   nodename = emonGLCD
   [[[rx]]]
      names = temperature, another
      datacode = h
      scales = 0.01,1
      units = C

[[21]]
   nodename = emonth3
   [[[rx]]]
      names = temperature, external temperature, humidity, battery
      datacode = h
      scales = 0.1,0.1,0.1,0.1
      units = C,C,%,V

[[22]]
   nodename = emonth4
   [[[rx]]]
      names = temperature, external temperature, humidity, battery
      datacode = h
      scales = 0.1,0.1,0.1,0.1
      units = C,C,%,V

[[23]]
    nodename = emonth5
    [[[rx]]]
       names = temperature, external temperature, humidity, battery, pulsecount
       datacodes = h,h,h,h,L
       scales = 0.1,0.1,0.1,0.1,1
       units = C,C,%,V,p

[[24]]
    nodename = emonth6
    [[[rx]]]
       names = temperature, external temperature, humidity, battery, pulsecount
       datacodes = h,h,h,h,L
       scales = 0.1,0.1,0.1,0.1,1
       units = C,C,%,V,p

[[25]]
    nodename = emonth7
    [[[rx]]]
       names = temperature, external temperature, humidity, battery, pulsecount
       datacodes = h,h,h,h,L
       scales = 0.1,0.1,0.1,0.1,1
       units = C,C,%,V,p

[[26]]
    nodename = emonth8
    [[[rx]]]
       names = temperature, external temperature, humidity, battery, pulsecount
       datacodes = h,h,h,h,L
       scales = 0.1,0.1,0.1,0.1,1
       units = C,C,%,V,p

There are not the right credentials for the Broker on an emonPi unless you have changed them.

Is this the write Key?

Arghh… too many virtual machines.
SOLVED NOW!

I had the default user/password as per install scripts (I used your “EmonScripts”, very useful!)
Now emoncms gets data from my from my EmonGLCD. Data sent using MQTT is OK.
Data sent using JSON failed because I wrote “https” instead of “http” in the URL variable.

Now I also get data from my EmonTX… but only if I am very close to it (less that 1 meter).
When I used the raspberry with my old EmonRX (dated 2011) the data was received even if far away in other rooms.

Sounds like the operating frequencies of the two are different.
e.g. one of them is using 433 MHz and the other 868 MHz.

Another possibility is an antenna issue. (no antenna, or cut to the wrong length)

How old is your emonTx, and how old is the sketch that’s in it?

The reason for asking is it has been about 5 years since 868 MHz has been available as an option from our shop. If it is older than that, you can have a 868 MHz module, but if you have a newer sketch and have not changed the frequency, it will be working at 434 MHz.

You don’t need to play with that at all. The node id is 15 by default and once you can take to it over serial you can set the frequency by writing a 8b and group with 210g. The nodeid can be set with 15i, all these settings are held in eeprom and not lost during a reset or power cycle.

This is actually all managed by emonhub so no matter what you write in code or set via serial will be overridden by emonhub when it connects. For example your emonhub.conf shows the base id as 1 so the nodeid of the device will be 1 not 15 once emonhub initializes the jeeinterfacer.

So I would undo that change just to be safe as in short, I don’t know for sure off hand what the exact ramifications are regards the “other 3 bits” as the node id is only the least significant 5 bits.

My emontx uses 868Mhz and was bought in december 2013… (see below)
The sketches inside EmonGLCD and EmonTX are also from 2013.
Transmit power of EmonTX,EmonGLCD is ok… I believe they are running at 868Mhz

The problem is the Jeelink (or its antenna). The antenna is connected using a screw and I believe that something is wrong with that.
I think I will buy a new JeeLink. Any suggestion?

My devices from the shop:

RFM12Pi Raspberry Pi Expansion board kit (868 Mhz - Europe Only) RFM12Pi868

Solar PV Monitor Kit Bundle 868Mhz (Europe only) Euro plug
(emonTx 868Mhz: emonTx 868Mhz kit , CT 1: 100A max clip-on current sensor CT, CT 2: 100A max clip-on current sensor CT, AC-AC Europe: AC-AC Adapter - AC voltage sensor (Euro plug), emonGLCD 868Mhz: emonGLCD 868Mhz kit)

OK, so it’s been working OK for 7 years, so most likely it is not a wrong frequency.

Do you mean the SMA connector?

How long is the antenna overall? If it’s about 110 mm from the bend, it is correct. If it is about 190 mm, it is a 433 MHz one.

I know nothing about JeeLinks, so I can’t comment.

However, if you have a soldering iron and as a temporary test, you could unscrew the antenna and connect a length of wire 82 mm long to the antenna pin of the RFM12B (see the pictures again - it’s the top left corner in each picture). If it comes good - you are right, it was the antenna.

It could be as he is replacing an RFM card on a Pi with the Jeelink on a VM AIUI.