I'm trying to send a stream of int values (0-4096) from one arduino to another using an RFM69HCW module.
Here's my main code:
#include <RFM69.h>
#include <SPI.h>
#define NETWORKID 0 // Must be the same for all nodes
#define MYNODEID 1 // My node ID
#define TONODEID 2 // Destination node ID
#define FREQUENCY RF69_915MHZ
#define ENCRYPT true // Set to "true" to use encryption
#define ENCRYPTKEY "TOPSECRETPASSWRD" // Use the same 16-byte key on all nodes
#define RFM69_CS 10
#define RFM69_IRQ 2
#define RFM69_IRQN 0 // Pin 2 is IRQ 0!
#define RFM69_RST 9
#define IS_RFM69HCW true
#define USEACK true // Request ACKs or not
#define LED 9 // LED positive pin
#define GND 8 // LED ground pin
#define PULSEPIN 0 // Heart Rate Monitor at pin A0
RFM69 radio = RFM69(RFM69_CS, RFM69_IRQ, IS_RFM69HCW, RFM69_IRQN);
String pulsearray;
bool recHR = true;
unsigned long oldtime = 0;
int interval = 5000;
static int readtime = 3000;
static int sampletime = 10; // 1000/this is the thing
static int txinterval = 1000; // delay between transmissions
void setup() {
initSerial();
initLed();
initRadio();
}
void loop() {
unsigned long newtime = millis();
if (!recHR && newtime - oldtime >= interval) {
recHR = true;
oldtime = newtime;
Serial.println("recording HR now");
}
while (recHR) {
unsigned long newtime = millis();
if (newtime - oldtime >= sampletime) {
readhr();
}
if (newtime - oldtime >= readtime) {
recHR = false;
oldtime = newtime;
Serial.println("stopped reading HR");
}
}
}
And the function I'm using:
void readhr() {
for (int i = 0; i < 20; i++) {
int pulse = analogRead(PULSEPIN);
pulsearray = pulsearray + pulse;
pulsearray = pulsearray + '\n';
Serial.println(pulse);
}
}
The library function sendWithRetry() requires the following arguments:
bool RFM69::sendWithRetry(uint8_t toAddress, const void* buffer, uint8_t bufferSize, uint8_t retries, uint8_t retryWaitTime)
I would like a way to set up a buffer which can be transmitted in multiple packets during the 5 second analogRead() downtime. Using a string as my buffer doesn't work when I try to transmit the first n (<60) characters in the String. I've also tried using a char[ ] as my buffer (a lot more troublesome when storing int values) but it still gives the same error:
exit status 1
no matching function for call to 'RFM69::sendWithRetry(int, String&, unsigned int)'