Hi, I just started trying to send data through a CC1101 using this library here --> GitHub - simonmonk/CC1101_arduino: A clone of the ELECHOUSE_CC1101 http://www.elechouse.com library updated for Arduino 1.0 plus.
I want to transmit two 6 digit numbers at every loop, for example, "12.123456 12.6754322". But I am having issues understanding the data types that are required since the library's documentation is not extensive.
I modified the example code like this:
#include <ELECHOUSE_CC1101.h>
const int n = 61;
byte stringToByte(char * src){
return byte(atoi(src));
}
void setup() {
Serial.begin(9600);
ELECHOUSE_cc1101.Init(F_433); // set frequency - F_433, F_868, F_965 MHz
}
void loop() {
char Lat[]= "12.123456 12.6754322";
byte buffer = stringToByte(Lat);
int len = sizeof(buffer);
if (Serial.available()) {
ELECHOUSE_cc1101.SendData(buffer, len);
}
}
The code compiles, but my receiver does not appear to see anything. My intention was to take a char array and convert it into an array of bytes which seems to be the data format that is then transmitted. Am I missing something?
As recieve code, I am using:
#include <ELECHOUSE_CC1101.h>
const int n = 61;
void setup()
{
Serial.begin(9600);
Serial.println("Rx");
ELECHOUSE_cc1101.Init(F_433); // set frequency - F_433, F_868, F_965 MHz
ELECHOUSE_cc1101.SetReceive();
}
byte buffer[61] = {0};
void loop()
{
if (ELECHOUSE_cc1101.CheckReceiveFlag())
{
int len = ELECHOUSE_cc1101.ReceiveData(buffer);
buffer[len] = '\0';
Serial.println((char *) buffer);
ELECHOUSE_cc1101.SetReceive();
}
}
Thanks