Moteino/RFM69 as a Serial Transfer device

Started by doppler, March 17, 2018, 07:25:58 PM

doppler

Hi all, my first post here....., I am in the process of upgrading a Picaxe-based weather station and wanted a more robust RF solution than I had been using, and I stumbled across "Moteino".  I had already acquired some RFM69HCW modules (and had some Arduino's), but it is a nightmare to code the needed SPI stuff for a Picaxe.  I was able to fairly easily hack the Moteino "node" and "gateway" code such that I could serial-send data bytes (temp, humidity, wind speed and dir, rainfall) from the Picaxe to an Arduino/RFM69HCW node, and from the receiving Arduino/RFM69HCW gateway back to a Picaxe.  I hope to be able to learn Arduino well enough to put together a total Moteino based weather station, but regardless, I will be ordering a 3.3v Moteino for my outdoor station to minimize the footprint.

Anyway, that said, here are my simple hacks in case another "noob" like me wants to take advantage of the excellent Moteino RF solution for transferring serial data.  My outdoor station is 100+ meters from the house, with a large metal barn in the path, and two house walls in between, and I am getting an RSSI around -80 with no lost packets.  Below are only the additions/mods to the original code, tagged with a "ZZ" comment.  I'd love to hear any suggestions regarding appropriate/efficient coding.   

Thank you for this excellent information resource!  Greg
---------------------------------------------------------------
Moteino "node" serial data transfer code mods:
#include <SoftwareSerial.h>     //ZZ
byte payload[16];                     //ZZ  16 8-bit bytes of data from the Picaxe
SoftwareSerial SoftSerial(5, 6);  //ZZ
SoftSerial.begin(38400);           //ZZ  Did not work at bauds slower than this, have not tried faster

//######################## SoftSerial In and Data Out Below ZZ #############

    while (SoftSerial.available() < 16) {}
       for(int i=0; i<16; i++)
      payload[i] = {SoftSerial.read()};

    for(byte i=0; i<16; i++) // sendSize; i++)
    Serial.print((byte)payload[i]);
    
      if (radio.sendWithRetry(GATEWAYID, payload, 16))
       Serial.print(" ok!");
      else Serial.print(" nothing...");
    }

// End "node" mods ZZ

---------------------------------------------------------------
Moteino "gateway" serial data transfer code mods:
#include <SoftwareSerial.h>         //ZZ
SoftwareSerial SoftSerial(5, 6);     //ZZ
SoftSerial.begin(38400);               //ZZ

//######################## Data Receive and SoftSerial Out Below ##############

    for (byte i = 0; i < radio.DATALEN; i++)
      Serial.print((int)radio.DATA[i]);
      Serial.print("   [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");

        for (int k = 0 ; k< radio.DATALEN ;k++)
        {
          SoftSerial.write(radio.DATA[k]);
        }

// End "gateway" mods ZZ

Felix

Thanks for sharing your experience and code ! :)