Author Topic: [Update] RFM69 Library for ESP8266 - Moteino Compatible!  (Read 50760 times)

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #45 on: May 14, 2016, 01:17:23 PM »
Quote
From a quick, very preliminary comparison of RSSI numbers, it appears to perform  significantly better (head and shoulders better) than any  monopole RFM69HW system that I've thus far tried. 

But now and confirming your results: using a lamda/2 dipole improved sensitivity by 16dBm.

I'm really glad you did an independent measurement. That's about what I'm seeing as well.  "Not too shabby," really understates it.  It was such a vast improvement that I had trouble believing it.

The attached photo shows a different, more compact monopole configuration.  I load the ESP8266 with software and do a simple standalone test before attaching the radio board, so in theory I don't need the FTDI header afterward (or I could just relocate it further underneath), which could make it even more compact.

« Last Edit: May 14, 2016, 01:27:05 PM by WhiteHare »

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #46 on: May 14, 2016, 01:39:07 PM »
Quote
It was such a vast improvement that I had trouble believing it.

AC powered Moteino vs espgw on dipole I measure a difference of 24dBm!!!

Of course at some point you realize that the moteino just has a very much preferred rx direction. When pointing the ftdi header into the direction of the sender the difference melts down to 3-4dBm. That's a difference of 19dBm for a 180 degrees turn on a plane that supposedly does not affect gain. Pretty stunning ...

Black magic as they say.

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #47 on: May 15, 2016, 07:55:28 AM »
Given these results: Has anybody tried pcb-etched dipoles yet? Any monopole with a ground plane worth its name will be huge. But I could imagine a 25mm * 180mm PCB containing esp12e, rfm69hw and the 866mhz dipole antenna being pretty useful and living room compatible.

Maybe it could directly plug into a AC outlet - though that's probably asking for EMI again. Or you connect a usb power supply and mount it on a wall.

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #48 on: May 15, 2016, 08:23:32 PM »
More good news:  apparently there's a theory which says that a 1/2 lambda dipole (with each leg being 1/4 lambda) is the most efficient:

So, if that bears out, it will be easier to manage, and perhaps we'll see even more improvement.
« Last Edit: May 15, 2016, 08:31:58 PM by WhiteHare »

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #49 on: May 16, 2016, 02:48:28 AM »
Mine is lambda/2. And yes, that's why I asked about your choice of 2 x 5/8 lambda. I haven't tried other lengths yet.

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #50 on: May 16, 2016, 03:17:23 AM »
Quote
It's probably the inadequate ground plane which causes these issues. In theory a monopole should perform even better since it doesn't radiate into the floor.

https://www.researchgate.net/profile/Hao_Ling/publication/4198932_Ground_plane_size_reduction_in_monopole_antennas_for_ground_wave_transmission/links/02e7e51f91fbf1fe93000000.pdf

Interesting paper on the impact of a reduced ground plane.

Quote
It is well known that most monopole antennas need a ground plane with a diameter on the order of λ/2 to perform well [2]. The transmission loss increases rapidly if the diameter of the ground plane is reduced to below λ/10.

There is a nice graph showing transmission loss vs ground plane size at the end. Based on this the 16dBm improvement I've seen from a dipole over a Moteino is entirely plausible.

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #51 on: May 16, 2016, 11:29:49 AM »
Quote
It's probably the inadequate ground plane which causes these issues. In theory a monopole should perform even better since it doesn't radiate into the floor.

https://www.researchgate.net/profile/Hao_Ling/publication/4198932_Ground_plane_size_reduction_in_monopole_antennas_for_ground_wave_transmission/links/02e7e51f91fbf1fe93000000.pdf

Interesting paper on the impact of a reduced ground plane.

Quote
It is well known that most monopole antennas need a ground plane with a diameter on the order of λ/2 to perform well [2]. The transmission loss increases rapidly if the diameter of the ground plane is reduced to below λ/10.

There is a nice graph showing transmission loss vs ground plane size at the end. Based on this the 16dBm improvement I've seen from a dipole over a Moteino is entirely plausible.

Yup.

Quote
It is well known that most monopole antennas need a ground plane with a
diameter on the order of λ/2 to perform well.

I have seen on some home automation forums where some people do use a monopole with a large ground plane, but they hang it upside down from their attic rafters in order to maximize the antenna gain into the house. 

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #52 on: May 16, 2016, 03:56:51 PM »
Quote
I have seen on some home automation forums where some people do use a monopole with a large ground plane, but they hang it upside down from their attic rafters in order to maximize the antenna gain into the house.

That sounds like a very sensible approach. Unfortunately also one you can't probably convince the general public to take. Although a wireless gw might help. The monopole has a null straight up - or down in this case. But reflections would likely fix that.

fgomes

  • Jr. Member
  • **
  • Posts: 65
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #53 on: May 31, 2016, 06:57:08 PM »
Hi joelucid, WhiteHare,

I'm trying to use NodeMCU with RFM69HW and even the initialization seems to fail, I've just introduced some debug after writing the RFM69 registers (RFM69::initialize) and I'm reading all zeros. I've started making only the changes you suggested, then added also this:

  pinMode(12, FUNCTION_2); //MISO
  pinMode(13, FUNCTION_2); //MOSI
  pinMode(14, FUNCTION_2); //SCLK

but still get the same results. Also tried with the SPI clock divider at SPI_CLOCK_DIV2 and SPI_CLOCK_DIV4, but had the same results,

Do you have any tip? Or can you share the code you are using in order to verify my hardware setup? The RFM69HW module works when connected to an ATMEGA328 MCU. It is currently being powered by the 3.3V output on the NodeMCU.

The connections used are the following (no other connections are made to any of the modules except the USB able to the NodeMCU):

Node ESP            RFM69HW
D2     GPIO04     DIO0 (interrupt)
D5     GPIO14     SCK (spi clock)
D6     GPIO12     MISO (spi miso)
D7     GPIO13     MOSI (spi mosi)
D8     GPIO15     NSS (spi ss)
+3V                    3.3V
G                        GND

Thanks in advance

Fernando

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #54 on: June 01, 2016, 03:00:52 AM »
Fernando,

it looks to me like you've done everything correctly. RFM69::initialize waits for the radio to become available by writing some registers and checking if it sticks. If initialize returns RFM69 was successful to write these registers. You'd want to have any code that checks for the same thing after the code that waits for the radio to become available.

If write/read never works it could be that you're not using the correct slave select pin in RFM69::select. If you are I'd probably just try to scope out the MISO/MOSI/SCLK/SS pins to see if everything is connected correctly electrically.

Joe

fgomes

  • Jr. Member
  • **
  • Posts: 65
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #55 on: June 01, 2016, 06:03:59 AM »
HI Joe, thanks for your feedback. The example doesn't test the return code from the  initialize function, it returns always false. I'll test it later with an oscilloscope,  to check MOSI. MISO, CLK and SS, and will post here my feedback.

Best regards

Fernando
« Last Edit: June 01, 2016, 11:03:10 AM by fgomes »

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #56 on: June 01, 2016, 12:41:32 PM »
Not sure if it applies to your situation, but I've found that very often mysterious failures disappear if you use an alternate 3.3v power source that you can be certain is capable of delivering ample current on demand, and then run wire from that directly to the points of large current consumption (of which the RFM69HW would certainly be one) rather than rely on just traces.  I'd start with that, at least until after you get it working. 

[Edit: Having said that, though, I don't believe I needed to do so on an "official" NodeMCU, which comes with an AMS1117-3.3V converter.  If you're driving that from a good enough 5v USB source (say, a 500ma capable one, which is fairly typical), that should be sufficient, and IIRC it worked OK for me without needing an auxillary power source.  I tried a number of the different off-the-shelf ESP8266 platforms, and I do recollect that not all of them came equipped with enough power to handle the current requirements of both the ESP8266 and the RFM69HW.  For instance, at least in my case, the WeMo D1 Mini couldn't supply enough juice on its own.]
« Last Edit: June 01, 2016, 05:34:14 PM by WhiteHare »

fgomes

  • Jr. Member
  • **
  • Posts: 65
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #57 on: June 01, 2016, 08:14:11 PM »
Hi, thanks for your replies! I was checking with an oscilloscope but didn't find many differences from the library running on an ATMEGA328. What I found is that MISO has no activity on the ESP8266, so it seems that the RFM69 never noticed it was addressed, and never reply, but the other signals seems similar to the ATMEGA (in the SDS00001 image the yellow line is the MOSI for the ESP8266, in the SDS00011 is for the ATMEGA). The main difference is that with the ESP8266 there is an extra lag between the SS fall and the clock start (about 1,5us) , with the ATMEGA it is almost immediate (not mensurable in the same scale) - in SDS00007 image the yellow line is the SS of the ESP8266, in the SDS00009 the yellow line is the SS from the ATMEGA.
The NodeMCU I'm using uses also an AMS1117, I'll try it tomorow powered by a lab power supply to see if makes some difference. Do you have any other suggestion? Can you share the exact RFM69.cpp/RFM69.h that you are using with the ESP8266 in order to be sure I'm not missing anything else?

Best regards

Fernando

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #58 on: June 02, 2016, 04:55:20 PM »
I made this as a handy tool for both powering and communicating at 3.3v.  The CP2102 can level shift the logic signals just fine but otherwise lacks enough oomph to power both an esp8266 and an RFM69HW together just by itself.  It's nothing grand, but this simple tool fixes that.  Also, I find the CP2102 easily supports 921600 baud communications.

I also use it on Moteino's which have had their voltage regulator removed, because it can handle any load I'm likely to encounter.  Again, convenience.  To enable that, when I remove the moteino's voltage regulator I do a solder bridge across where the voltage regulator used to be so that the header pins can still power the Moteino.   

« Last Edit: June 02, 2016, 05:47:44 PM by WhiteHare »

fgomes

  • Jr. Member
  • **
  • Posts: 65
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #59 on: June 02, 2016, 07:20:00 PM »
Hi WhiteHare,

Thanks for the tip,it is convenient, really!

In the meantime I tested with a lab power supply (30W) and the results are the same. I said before that the MISO didn't change, but I have now placed a pull-up resistor and now it moves almost together with the SS signal, as can bee seen in the attached picture. So now MISO goes low and stays low while the SS is low, but during that period it doesn't move, so it is replying with all zeros to the master. With the ATMEGA I don't have any pull-up and the MISO signal works, is the pull-up necessary with the ESP8266? What SPI frequency are you using, are you using the SPI clock divider as SPI_CLOCK_DIV2, SPI_CLOCK_DIV4,...? I've tested with different clock dividers but the result were similar. I'm getting out of ideas...

Best regards

Fernando