Hello,
currently im wokring on a project where i want to have a sort of an rc rover, which is controlled by a radio, and sends back some data like temperature etc.
Now im just trying to send something from groundstation to the rover and the rover as an answer send a message back. But i can send a message from groundstation, even recieve an ACK from the rover, but nothing is sent back from the rover. I even tried to switch which hardware is doing what and the result is identical.
Heres the code for ground station:
#include <RFM69.h>
/*
#include <Wire.h>
#include <SPI.h>
*/
char payload[50];
RFM69 radio;
bool promiscuousMode = false; //set to 'true' to sniff all packets on the same network
//Radio Parameters
#define NODEID 1 //unique for each node on same network
#define NETWORKID 100 //the same on all nodes that talk to each other
#define GATEWAYID 2 //Receiving node
#define ENCRYPTKEY "1234567887654321" //exactly the same 16 characters/bytes on all nodes!
void setup() {
//Serial.begin(9600);
delay(1000);
radio.initialize(FREQUENCY,NODEID,NETWORKID);
radio.setHighPower(); //To use the high power capabilities of the RFM69HW
//radio.encrypt(ENCRYPTKEY);
//radio.setFrequency(433900000);
}
unsigned int packetCount = 0;
char testMsg[50] = "data";
unsigned long curT = millis();
unsigned long prevT = 0;
char inMsg[65];
void loop()
{
curT = millis();
if(curT - prevT > 2000)
{
prevT = curT;
radio.sendWithRetry(GATEWAYID, testMsg, 50, 2, 200);
/*Serial.println(radio.sendWithRetry(GATEWAYID, testMsg, 50, 2, 200) ? "true" : "false");
Serial.print("[");
Serial.print(curT);
Serial.print("]sending: ");
Serial.println(testMsg);*/
}
if (radio.receiveDone())
{
//Serial.print("response recieved: ");
if (radio.ACKRequested())
{
radio.sendACK();
//Serial.print(" - ACK sent.");
}
//Serial.println((char*)radio.DATA);
//Serial.println();
}
delay(500);
}
and here is the rover
#include <RFM69.h>
/*
#include <Wire.h>
#include <SPI.h>
*/
char payload[50];
RFM69 radio;
bool promiscuousMode = false; //set to 'true' to sniff all packets on the same network
//Radio Parameters
#define NODEID 2 //unique for each node on same network
#define NETWORKID 100 //the same on all nodes that talk to each other
#define GATEWAYID 1 //Receiving node
#define ENCRYPTKEY "1234567887654321" //exactly the same 16 characters/bytes on all nodes!
void setup()
{
//Serial.begin(9600);
delay(1000);
radio.initialize(FREQUENCY,NODEID,NETWORKID);
radio.setHighPower(); //To use the high power capabilities of the RFM69HW
//radio.encrypt(ENCRYPTKEY);
//radio.setFrequency(433900000);
}
unsigned int packetCount = 0;
char inMsg[50];
char msg[65] = "response";
void loop()
{
if (radio.receiveDone())
{
//Serial.print("recieved...\t");
if (radio.ACKRequested())
{
radio.sendACK();
//Serial.print(" - ACK sent.");
}
//Serial.println((char*)radio.DATA);
/* for (byte i = 0; i < radio.DATALEN; i++)
inMsg[i] = (char)radio.DATA[i];
sprintf(msg,"RES[%d]: %s", packetCount++, inMsg);*/
//Serial.println(radio.canSend() ? "true" : "false");
//Serial.println(" sending...\t");
//Serial.println(radio.sendWithRetry(GATEWAYID, msg, 65, 2, 200) ? "true" : "false");
radio.sendWithRetry(GATEWAYID, msg, 65, 2, 200);
//Serial.println(msg);
}
delay(50);
}
when i tried writing out the radio.canSend(), it always said false, so i tried to look for examples from the library, and for me it looks theres no mistake. From the canSend() being false i tried to look if i had to change state to sending, but it is an internal function of the library, so im lost.
Also, this is my copletely first project on radio and im a highschool student, so i can be missing some basic stuff. Please, i would appreciate any help.
Thanks!