Author Topic: MoteinoMega with Davis ISS Weather Station  (Read 4605 times)

scott216

  • Newbie
  • *
  • Posts: 41
MoteinoMega with Davis ISS Weather Station
« on: January 19, 2015, 05:39:00 PM »
I've had a Moteino receiving wireless data from a Davis ISS weather station and it works reasonably well. You can see the project here: https://github.com/Scott216/Weather_Station_Data 

But there isn't much memory left, so I wanted to try a MoteinoMega, but I can't get it to work.  I created a stripped down version of my program, code is here:
https://gist.github.com/Scott216/3cd6cc56393bccdf2981

The program just gets the wireless Davis ISS data, decodes the packets and prints it to the serial port.  The program works fine when I upload to a Moteino, but I don't get any data printing to the serial port when I try the MoteinoMega.

To make sure the MoteinoMega wasn't defective I loaded an example Sender program on the Moteino and example Receiver program on the MoteinoMega and it worked fine.

I'm using Dekay's DavisRFM69.h library.  Could there be a default config setting I need for the MoteinoMega that's different then the Moteino?  I'd appreciate any suggestions for debugging this.

kobuki

  • Sr. Member
  • ****
  • Posts: 289
Re: MoteinoMega with Davis ISS Weather Station
« Reply #1 on: January 19, 2015, 06:42:25 PM »
You're probably missing the #defines present in newer versions of RFM69.h. DeKay's receiver code was written way before the MoteinoMega appeared. Most importantly, RF69_IRQ_NUM has changed from 0 to 2 for the bigger chip, but there might be some other small bits to support the 1284p.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
  • Country: us
    • LowPowerLab
Re: MoteinoMega with Davis ISS Weather Station
« Reply #2 on: January 19, 2015, 09:56:02 PM »
Right, you have to ensure you have installed the MEGA core and that you have the latest library. Dekay's version might be older like kobuki has mentioned.

scott216

  • Newbie
  • *
  • Posts: 41
Re: MoteinoMega with Davis ISS Weather Station
« Reply #3 on: January 20, 2015, 12:13:32 AM »
I do have the MEGA core installed.  I updated my copy of Dekay's RFM69 library.  I added the following to DavisRFM69.h set the right interrupt pin.

Code: [Select]
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
  #define RF69_IRQ_PIN          2
  #define RF69_IRQ_NUM          0
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
  #define RF69_IRQ_PIN          2
  #define RF69_IRQ_NUM          2
#endif

But this didn't solve the problem.  I'm not sure what else to do to bring make Dekay's library compatible with the MoteinoMega. 



Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
  • Country: us
    • LowPowerLab
Re: MoteinoMega with Davis ISS Weather Station
« Reply #4 on: January 20, 2015, 08:27:41 AM »
There isn't much difference other than the interrupt and pinout in the libraries, but there have been changes to the lib over the past weeks/months.
Any chance you could adapt the ISS changes into the original library?

scott216

  • Newbie
  • *
  • Posts: 41
Re: MoteinoMega with Davis ISS Weather Station
« Reply #5 on: January 20, 2015, 10:36:31 AM »
There isn't much difference other than the interrupt and pinout in the libraries, but there have been changes to the lib over the past weeks/months.
Any chance you could adapt the ISS changes into the original library?

I don't know.  DeKay could do it, I don't know if I've got the skills. Maybe.  Do you know about when Dekay forked from your library?

Were the recent library changes things that affected the MoteinoMega but not so much the Moteino?


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
  • Country: us
    • LowPowerLab
Re: MoteinoMega with Davis ISS Weather Station
« Reply #6 on: January 20, 2015, 10:55:30 AM »
Please see the github history for details on when things got changed etc.
All changes are universal, they will work on all Moteinos. Looks like the changes to allow MEGA to work were added some time after dekay's fork.

scott216

  • Newbie
  • *
  • Posts: 41
Re: MoteinoMega with Davis ISS Weather Station
« Reply #7 on: January 20, 2015, 11:04:34 AM »
Please see the github history for details on when things got changed etc.
All changes are universal, they will work on all Moteinos. Looks like the changes to allow MEGA to work were added some time after dekay's fork.

I was looking at the GitHub history last night.  I'll spend some more time looking it over and see if it's something I can tackle.

scott216

  • Newbie
  • *
  • Posts: 41
Re: MoteinoMega with Davis ISS Weather Station
« Reply #8 on: January 20, 2015, 07:34:23 PM »
I got my Davis ISS test program working on the MoteinoMega.  The problem was the interrupt was hard coded as zero:
So I changed the program work the same way your library does by passing the interrupt number based on the MCU type:

I also changed the SPI.setClockDivider to SPI_CLOCK_DIV4 based on your note that this works better with the mega1284

Also, Dekay has this SPI code in initialize() function
Code: [Select]
SPI.setDataMode(SPI_MODE0);
SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV4);
You moved it to select() function.  Would you recommend I make this same change and move it to select() function?

Do you think I should also use the code below to prevent mode switching in setFrequency() function?
Code: [Select]
  
uint8_t oldMode = _mode;
if (oldMode == RF69_MODE_TX) {
    setMode(RF69_MODE_RX);
}
I don't know if that's a problem with Dekay's library.  The Moteino is only receiving data from the Davis ISS, it's not transmitting anything (that I know of) - I don't know if that matters for this mode switching problem.

I see that the RSSI is done a little bit differently in the two libraries.  Dekay reads it at the start of InterruptHandler(), you've got it at the end.  Should I move it to the end?

Here's a link to Diff Checker where you can see the changes I've made so far:
https://www.diffchecker.com/7oyor10h


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
  • Country: us
    • LowPowerLab
Re: MoteinoMega with Davis ISS Weather Station
« Reply #9 on: January 20, 2015, 11:20:53 PM »
I moved the SPI init stuff in select() because I need to make sure that is set to what RFM69 expects on every transaction. I would recommend moving it in select().
Everything else can stay the same.

scott216

  • Newbie
  • *
  • Posts: 41
Re: MoteinoMega with Davis ISS Weather Station
« Reply #10 on: January 21, 2015, 05:49:02 AM »
I moved the SPI init stuff in select() because I need to make sure that is set to what RFM69 expects on every transaction. I would recommend moving it in select().
Everything else can stay the same.
I'll make that one change, thanks!

DeKay

  • Newbie
  • *
  • Posts: 10
    • Mad Scientist Labs
Re: MoteinoMega with Davis ISS Weather Station
« Reply #11 on: March 22, 2015, 04:56:32 PM »
I don't know.  DeKay could do it, I don't know if I've got the skills. Maybe.  Do you know about when Dekay forked from your library?

Were the recent library changes things that affected the MoteinoMega but not so much the Moteino?

I updated my library today if you'd like to give it a shot.  It includes
- Felix's RFMregiseters.h
- the SPI changes
- the MEGA fixes
- formatting cleanups
- more DEFINEs and less magic numbers, some "borrowed" from kobuki's code
- other goodness

Seems to be working well with my 328P based Moteino.  I have XP in a Linux VM running Cumulus right now picking up stuff from the outdoor Integrated Sensor Suite.


scott216

  • Newbie
  • *
  • Posts: 41
Re: MoteinoMega with Davis ISS Weather Station
« Reply #12 on: March 22, 2015, 10:45:09 PM »
I updated my library today if you'd like to give it a shot.  It includes
- Felix's RFMregiseters.h
- the SPI changes
- the MEGA fixes
- formatting cleanups
- more DEFINEs and less magic numbers, some "borrowed" from kobuki's code
- other goodness

Seems to be working well with my 328P based Moteino.  I have XP in a Linux VM running Cumulus right now picking up stuff from the outdoor Integrated Sensor Suite.

 That's awesome.  I can't wait to try your updated version. 

scott216

  • Newbie
  • *
  • Posts: 41
Re: MoteinoMega with Davis ISS Weather Station
« Reply #13 on: March 24, 2015, 08:27:48 AM »
I updated my library today if you'd like to give it a shot.  It includes
- Felix's RFMregiseters.h
- the SPI changes
- the MEGA fixes
- formatting cleanups
- more DEFINEs and less magic numbers, some "borrowed" from kobuki's code
- other goodness

Seems to be working well with my 328P based Moteino.  I have XP in a Linux VM running Cumulus right now picking up stuff from the outdoor Integrated Sensor Suite.

Hi DeKay,
I think the latest SPI changes by Paul Stoffregen which are in the new Arduino IDE are supposed to help prevent conflicts between multiple SPI devices (I don't really understand the intricacies of it).  Do the SPI changes you mention take advantage of this?
My project with the Moteino sending Davis ISS data to Weather Underground using a Ethernet module became a lot more reliable when I added a watchdog timer (WDT).  I only enable the WDT for the Ethernet upload code because the frequency hopping stuff can often take over 8 seconds and would trigger the WDT all the time.  I hope to try your new library this week.

DeKay

  • Newbie
  • *
  • Posts: 10
    • Mad Scientist Labs
Re: MoteinoMega with Davis ISS Weather Station
« Reply #14 on: March 24, 2015, 08:12:16 PM »
Hi DeKay,
I think the latest SPI changes by Paul Stoffregen which are in the new Arduino IDE are supposed to help prevent conflicts between multiple SPI devices (I don't really understand the intricacies of it).  Do the SPI changes you mention take advantage of this?
My project with the Moteino sending Davis ISS data to Weather Underground using a Ethernet module became a lot more reliable when I added a watchdog timer (WDT).  I only enable the WDT for the Ethernet upload code because the frequency hopping stuff can often take over 8 seconds and would trigger the WDT all the time.  I hope to try your new library this week.

Nope.  The SPI changes refer to updating my stuff to how Felix has reworked his in the RFM69 library.  I wasn't aware of the SPI problem Paul talks about and it wouldn't affect my setup here because I only have one device on my SPI bus.  Interesting stuff Paul has done here though.

You comment about the hopping stuff taking over eight seconds doesn't sound right at all.  I remember a comment you made about this at one point, but I thought the blame was placed on the Ethernet upload instead.