Hi all,
I am trying to receive/send temperature sensor data (TFA 30.3144.IT, 868 Mhz, FSK) with a CC1101 module and RadioLib library. I am using an Arduino Nano clone.
Receiving data did not really work (no meaningful data received) and therefore I am trying to transmit with the CC1101 and check the data sent by SDR and Universal Radio Hacker.
I am expecting to receive the preamble (4 bytes) + sync (2 bytes) + 4 * (1111 1111 0000 0000)
but I am receiving the following:
10101010101010101010101010101010 (preamble) + 0010110111010100 (sync) +
00000000111000011110001010011010000100101000010111001100001001000
Any ideas why I am not receiving the correct payload?
#include <RadioLib.h>
// CC1101 has the following connections:
// CS pin: 10
// GDO0 pin: 2
// RST pin: unused
// GDO2 pin: 3
CC1101 cc = new Module(10, 2, NC, 3);
void setup() {
Serial.begin(9600);
// initialize CC1101
Serial.print(F("[CC1101] Initializing ... "));
int state = cc.begin(868.325, 17.240, 48.0, 325.0, 0 , 4);
if (state == ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true);
}
// 2 bytes can be set as sync word
//byte syncword[2] = {0xd4,0x2d};
if (cc.setSyncWord(0x2d,0xd4) == ERR_INVALID_SYNC_WORD) {
Serial.println(F("[CC1101] Selected sync word is invalid for this module!"));
while (true);
}
int crc_state = cc.setCrcFiltering(false);
if (crc_state == 0) {
Serial.println(F("CRC off "));
}
else {
Serial.print(F("failed, code "));
Serial.println(crc_state);
while (true);
}
// address filtering can also be disabled
// NOTE: Calling this method will also erase previously
// set node address
Serial.print(F("[CC1101] Disabling address filtering ... "));
state == cc.disableAddressFiltering();
if(state == ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while(true);
}
// enable fixed packet length mode
Serial.print(F("[CC1101] Start fixed packet length mode ... "));
state == cc.fixedPacketLengthMode();
if(state == ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while(true);
}
// Disable broadcast address
Serial.print(F("[CC1101] Disable broadcast address ... "));
state == cc.setNodeAddress(0,0);
if(state == ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while(true);
}
}
void loop() {
Serial.print(F("[CC1101] Transmitting packet ... "));
byte byteArr[] = {0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00};
int state = cc.transmit(byteArr, 8);
if (state == ERR_NONE) {
// the packet was successfully transmitted
Serial.println();
for (int i = 0; i < 9; i++) {
printBits(byteArr[i]);
Serial.print(" ");
}
Serial.println();
Serial.println(F("success!"));
} else if (state == ERR_PACKET_TOO_LONG) {
// the supplied packet was longer than 64 bytes
Serial.println(F("too long!"));
} else {
// some other error occurred
Serial.print(F("failed, code "));
Serial.println(state);
}
// wait for a second before transmitting again
delay(4000);
}
void printBits(byte n) {
byte numBits = 8; // 2^numBits must be big enough to include the number n
char b;
char c = ' '; // delimiter character
for (byte i = 0; i < numBits; i++) {
// shift 1 and mask to identify each bit value
b = (n & (1 << (numBits - 1 - i))) > 0 ? '1' : '0'; // slightly faster to print chars than ints (saves conversion)
Serial.print(b);
if (i < (numBits - 1) && ((numBits-i - 1) % 4 == 0 )) Serial.print(c); // print a separator at every 4 bits
}
}