Hi all,
I'm very new to Moteino and fairly new to arduino so bear with me, but I just can't seem to work out how to send a piece of unique data with my pair of Moteino LoRa modules.
I've got both modules powered up and programmed using the example programs, and they are happily sending "hello world!" and "And hello back to you" to each other and I can see this on the serial monitor.
My problem is I can't seem to work out how to swap the 'dumb' text for data that I can use in a program. My ultimate goal is to send gps coordinates, but for the moment I'm just trying to create a variable called 'data_to_send', and then send that variable across the link. But everything I try just give compile errors.
This is the code on the module with the gps:
// rf95_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing client
// with the RH_RF95 class. RH_RF95 class does not provide for addressing or
// reliability, so you should only use RH_RF95 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example rf95_server
// Tested with Anarduino MiniWirelessLoRa
#include <SPI.h>
#include <RH_RF95.h>
#ifdef __AVR_ATmega1284P__
#define LED 15 // Moteino MEGAs have LEDs on D15
#define FLASH_SS 23 // and FLASH SS on D23
#else
#define LED 9 // Moteinos have LEDs on D9
#define FLASH_SS 8 // and FLASH SS on D8
#endif
// Singleton instance of the radio driver
RH_RF95 rf95;
void setup()
{
Serial.begin(115200);
if (!rf95.init())
Serial.println("init failed");
else Serial.println("init OK - 915mhz");
// Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
rf95.setFrequency(915);
}
void loop()
{
Serial.println("Sending to rf95_server");
// Send a message to rf95_server
uint8_t data[] = "Hello World!";
rf95.send(data, sizeof(data));
rf95.waitPacketSent();
// Now wait for a reply
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (rf95.waitAvailableTimeout(3000))
{
// Should be a reply message for us now
if (rf95.recv(buf, &len))
{
Serial.print("got reply: ");
Serial.println((char*)buf);
Serial.print("RSSI: ");
Serial.println(rf95.lastRssi(), DEC);
}
else
{
Serial.println("recv failed");
}
}
else
{
Serial.println("No reply, is rf95_server running?");
}
Blink(LED,3);
delay(200);
}
void Blink(byte PIN, int DELAY_MS)
{
pinMode(PIN, OUTPUT);
digitalWrite(PIN,HIGH);
delay(DELAY_MS);
digitalWrite(PIN,LOW);
}
I've searched for hours and can't find anything that relates to my LoRa modules. I'm sure it's a simple fix, and if someone can reply with a well annotated reply, I'll be able to continue my learning how to code.
And I would give some examples of what I've tried, but as everything has failed, I doubt it will help haha.
Thanks
Dave