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

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #30 on: April 07, 2016, 11:40:27 AM »
For those who aren't yet aware of it, you can update your ESP8266 "arduino" sketches OTA directly from the Arduino IDE.  Instead of specifying a serial link in the port selector, I simply pick which ESP8266 I want to upload to and then specify "Upload using: OTA" in the sketch Tools menu.  Pretty cool.    Once set, I don't even need to think about it anymore, and it just happens automatically thereafter on each compile+upload iteration.  :)

[Edit:  Note that to make this work, you need to include some boilerplate code in your sketches.  If you're running the current IDE, you already have an OTA sketch as one of the built-in examples.  Here's a link that explains how to get started with it:  http://esp8266.github.io/Arduino/versions/2.0.0/doc/ota_updates/ota_updates.html]
« Last Edit: April 07, 2016, 02:00:00 PM by WhiteHare »

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #31 on: April 09, 2016, 09:24:46 AM »

I wired a rfm69hw to the esp HSPI port and DIO0 to D2.

By that, do you mean the following?
pin  function
== ======
12. SPI_MISO
13. SPI_MOSI
14. SPI_CLK
15. SPI_SS

However, did you have to do something to activate the SPI functionality of the HSPI pins?  Are you doing
pinMode(12, SPECIAL);
pinMode(13, SPECIAL);
pinMode(14, SPECIAL);
pinMode(15, SPECIAL);
or something else?

It looks as though someburner connected DIO0 to GPIO5.  I think I may try doing the same, with the hope of leaving GPIO2 as a secondary serial Tx in case it's beneficial to have for debugging.

Someburner's approach was quite sophisticated (amazing work!), and one of the benefits of that was the OTA updating.  However, I'm hoping the OTA that one can get for little effort within the Arduino framework (see post immediately above) will do the job, especially since it's already so well integrated with the Arduino IDE.  So, at the moment I'm trying to mash the ESP8266 Arduino OTA with the Arduino LPL  RFM69 library, with the hope that the two will dance together without stepping on each other's toes.
« Last Edit: April 09, 2016, 11:01:17 AM by WhiteHare »

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #32 on: April 09, 2016, 12:36:10 PM »
I wired it up with the above using the RFM69 example node code, but although the ArduinoOTA part appears as though it may be working, it's getting stuck in the RFM69 part.  After a while, the WDT times out, causing a reboot loop:

Code: [Select]
Ready
IP address: 192.168.3.244

Transmitting at 915 Mhz...

Sending[1]: 1
Soft WDT reset

ctx: cont
sp: 3ffeff50 end: 3fff0210 offset: 01b0

>>>stack>>>
3fff0100:  00000001 3ffef038 3ffeeebc 00000001 
3fff0110:  00000027 3ffef038 3ffeeebc 402052cd 
3fff0120:  00000000 3ffeeebc 00000001 402054af 
3fff0130:  3ffe8370 00000001 3ffeeebc 402058f0 
3fff0140:  0000003d 00000001 3ffeeebc 000003e7 
3fff0150:  3ffe8370 00000001 3ffeeebc 40205b85 
3fff0160:  00000546 00000001 00000001 402076b0 
3fff0170:  00000009 40105c5f 3ffef1f0 00000001 
3fff0180:  00000001 3ffeeebc 00000000 4020521f 
3fff0190:  3ffe8370 00000001 00000002 00000028 
3fff01a0:  3ffeeed4 3ffeeebc 3ffef120 00000001 
3fff01b0:  3ffeeec8 3ffeeebc 3ffef120 40202984 
3fff01c0:  3ffe8370 7a684d20 002e2e2e feefeffe 
3fff01d0:  feefeffe feefeffe feefeffe 3ffef1dc 
3fff01e0:  3fffdad0 00000000 3ffef1d5 402029d7 
3fff01f0:  3fffdad0 00000000 3ffef1d5 40206cb4 
3fff0200:  feefeffe feefeffe 3ffef1f0 40100958 
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld
Booting
Ready
IP address: 192.168.3.244

Transmitting at 915 Mhz...

Sending[1]: 1
Soft WDT reset

Maybe I'm missing a pull-up or a pull-down resistor somewhere...?

« Last Edit: April 13, 2016, 11:45:34 AM by WhiteHare »

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #33 on: April 09, 2016, 01:16:06 PM »
Quote
12. SPI_MISO
13. SPI_MOSI
14. SPI_CLK
15. SPI_SS

You've got to use the HSPI port. It's D5-D8 on NodeMCU 1.0.

Other than that I'm not doing anything special. I initialize the SPI bus with

Code: [Select]
  SPI.begin();
  SPI.setDataMode( SPI_MODE0);
  SPI.setBitOrder( MSBFIRST );
  SPI.setClockDivider( SPI_CLOCK_DIV2 );

But that's it. Works amazingly well.



WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #34 on: April 25, 2016, 03:39:58 AM »

I wired a rfm69hw to the esp HSPI port and DIO0 to D2. Then in RFM69.cpp:

Code: [Select]
#define RF69_IRQ_PIN          D2
#define RF69_IRQ_NUM          D2


I tried  connecting an RFM69 to an esp8266 nodemcu version 1, and although I can talk over the SPI just fine with the RFM69, DIO0 doesn't seem to be triggering any interrupts, despite the above settings using #define.  The D2 silkscreened onto the nodemcu corresponds to the GPIO4 pin on the esp8266.

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #35 on: April 25, 2016, 05:02:41 AM »
Quote
I tried  connecting an RFM69 to an esp8266 nodemcu version 1, and although I can talk over the SPI just fine with the RFM69, DIO0 doesn't seem to be triggering any interrupts, despite the above settings using #define.  The D2 silkscreened onto the nodemcu corresponds to the GPIO4 pin on the esp8266.

Can you try just reading dio0 with a digitalRead() to see if the mapping works? This works fine for me so I guess it's probably the wrong pin? Maybe wrong variant?

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #36 on: April 25, 2016, 03:23:51 PM »
Fixed it.  It turned out to be a configuration error on my part.

I have it working on three different platforms: an  ESP13, a WeMos, and now a NodeMCU v1.0.

I like a lot of things about the WeMos. However, even without an RFM69HW, I had doubts as to whether its tiny voltage regulator was truly adequate for supplying the currents needed by the ESP8266, and adding the RFM69HW seemed to push it over the edge to failure.  So I replaced its voltage regulator with an LD1117-3.3 that I had laying around, and now it seems solid.

[Edit: "Witty Cloud," which is yet another platform, comes with a much beefier voltage regulator than the WeMos, and so it may be worth considering as well.   ]

« Last Edit: April 25, 2016, 05:03:59 PM by WhiteHare »

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #37 on: April 26, 2016, 08:34:30 PM »
I hooked up an RFM69HW to an ESP8266 "witty cloud" today.  Now that I've got four different platforms working, I can see a definite pattern to most of them: they receive great, but they transmit horribly.  Most of the Tx power just doesn't seem to get converted to RF.  It's the classic case of "If I touch the antenna, then the Rx transmission improves tremendously."  I know that because I can see it on an RTL-SDR running C#.  I'm guessing it's the near lack of ground plane that's to blame, so I'm going to add that and see if it fixes it.  Still, even though these are just some lash-ups, I didn't have this problem when I  similarly lashed-up RFM69HW's with Pro Mini's during prior experimentation, so I'm puzzled as to why now if not before.   :o
« Last Edit: April 27, 2016, 12:10:26 AM by WhiteHare »

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #38 on: April 27, 2016, 07:17:26 AM »
Finally, success with this issue.  Just now I wired up an Adafruit ESP8266 Huzzah to an RFM69HW, but this time I also attached a small ground plane--not much bigger than the RFM69HW itself--to the RFM69HW.  Bingo.  Now the Huzzah-RFM69HW both Rx's and Tx's beautifully.

If time allows I'll make and test a dipole antenna on the RFM69HW  and see how that compares.  Assuming I've read John K2ox's postings correctly, it should perform even better.

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #39 on: May 12, 2016, 12:24:29 AM »
Attached is a photo of a dipole version of an esp8266-RFM69HW gateway that I threw together today.  Center frequency ist 915Mhz.  I made both the antenna (white) and the ground wire (black) of the dipole be 5/8 wavelength long.  This was my first attempt at a dipole.  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. 


joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #40 on: May 12, 2016, 08:25:21 AM »
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. 

Cool! A word of caution though: I've done a lot of testing using RSSI measurements (both signal and noise floor). Today I ran a battery of tests measuring actual rx success rates. Let's just say one isn't a good substitute for the other:

For example I measured a noise floor a bit higher with my gw on an iPhone power supply than with batteries. Turns out rx success rates are about identical, but with the iPhone power supply I measure a higher RSSI of packets sent with the same TX power. So the gw on a iPhone power supply will generally just measure higher RSSI.

Overall I'm pretty happy though: The espgw running from iPhone supply does not affect rx success. With a stock moteino you need to increase TX power by >10dBm to get the same success rate as with batteries when running from iPhone supply.

 

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #41 on: May 12, 2016, 08:29:00 AM »
Quote
I made both the antenna (white) and the ground wire (black) of the dipole be 5/8 wavelength long.

Why?

WhiteHare

  • Hero Member
  • *****
  • Posts: 1300
  • Country: us
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #42 on: May 12, 2016, 11:04:06 AM »
Quote
I made both the antenna (white) and the ground wire (black) of the dipole be 5/8 wavelength long.

Why?
Uh, because any longer and it would wobble too much and maybe fall over under its own weight?   ;)   

More seriously, though, when it comes to whip antennas, I do get the impression that theory quickly takes a back seat to simply trying all the possibilities.    It's easy enough to simply measure, then reduce the antenna length with a snip and measure again.  Repeat until done.  In fact, I was reading some Nordic Semiconductor material regarding trace antenna design that more or less prescribed exactly that as its official way to "tune" an antenna.  It even suggested starting 30% longer than you might think you'll need and then iteratively cutting back from there.



« Last Edit: May 13, 2016, 09:14:48 PM by WhiteHare »

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #43 on: May 14, 2016, 12:40:07 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. 

I tested an espgw against a moteino today (300kbit, measurement is TX dBm required for lossless transmission). With the typical attached monopole they performed identically when the Moteino was on battery. Moteino on iPhone power supply caused a degradation again which wasn't seen with the espgw.

But now and confirming your results: using a lamda/2 dipole improved sensitivity by 16dBm. Not too shabby. I doubt it's the dipole vs monopole. 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.
« Last Edit: May 14, 2016, 12:44:44 PM by joelucid »

joelucid

  • Hero Member
  • *****
  • Posts: 868
Re: [Update] RFM69 Library for ESP8266 - Moteino Compatible!
« Reply #44 on: May 14, 2016, 01:04:51 PM »
Quote
It even suggested starting 30% longer than you might think you'll need and then iteratively cutting back from there.

I've definitely found longer antennas necessary in particular for my smaller motes. I'm using about 22cm for Tino and TH motes.