I have a problem receiving data from the transmitter. Packets are sent and the receiver registers them. But the data is empty.
The transmitter and receiver are connected to ESP8266 + NodeMCU V3. Two separate devices
The transmitter is the simplest sensor FS1000A.
TX technical data:
- Supply voltage: 3.5V - 12V
- Transmission speed: up to 9.6 Kb
- Operating frequency: 433 MHz
- Modulation: AM ASK/OOK
- Power: 10mW
TX code (FS1000A)
#include <Wire.h>
#define SENSOR_PIN 16
const int TX_NUMBER = 11887717;
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
pinMode(SENSOR_PIN, INPUT);
mySwitch.enableTransmit(TX_PIN);
mySwitch.setPulseLength(320);
}
void loop() {
sendAlert();
delay(250);
}
void sendAlert() {
Serial.println("SEND!!");
mySwitch.send(TX_NUMBER, 24);
}
The receiver is CC1101:
RX code (CC1101)
#include <ELECHOUSE_CC1101_SRC_DRV.h>
void setup() {
Serial.begin(9600);
int gdo0 = 5; // for ESP8266! GDO0 on pin 5 = D1.
if (ELECHOUSE_cc1101.getCC1101()) {
Serial.println("Connection OK");
} else {
Serial.println("Connection Error");
}
ELECHOUSE_cc1101.Init();
ELECHOUSE_cc1101.setGDO0(gdo0);
ELECHOUSE_cc1101.setMHZ(433.92);
ELECHOUSE_cc1101.SpiWriteReg(CC1101_MDMCFG2, 0x30);
ELECHOUSE_cc1101.SpiWriteReg(CC1101_MDMCFG4, 0xC8);
ELECHOUSE_cc1101.SpiWriteReg(CC1101_MDMCFG3, 0x83);
ELECHOUSE_cc1101.SpiWriteReg(CC1101_PKTCTRL0, 0x32);
delay(1000);
Serial.println("Rx Mode");
}
void loop() {
if (ELECHOUSE_cc1101.CheckReceiveFlag()) {
byte buffer[64];
byte length = ELECHOUSE_cc1101.ReceiveData(buffer);
Serial.print("Length: ");
Serial.println(length);
Serial.print("Received: ");
if (length > 0) {
for (byte i = 0; i < length; i++) {
Serial.print(buffer[i], HEX);
Serial.print(" ");
}
Serial.println();
} else {
Serial.println("No data");
}
int rssi = ELECHOUSE_cc1101.getRssi();
Serial.print("RSSI: ");
Serial.println(rssi);
// Debugging received data
if (length > 0) {
for (byte i = 0; i < length; i++) {
Serial.print("Byte ");
Serial.print(i);
Serial.print(": ");
Serial.println(buffer[i], BIN); // Display as binary
}
}
byte pktstatus = ELECHOUSE_cc1101.SpiReadStatus(CC1101_PKTSTATUS);
Serial.print("PKTSTATUS: ");
Serial.println(pktstatus, BIN);
Serial.print("CRC_OK: ");
Serial.println((pktstatus & 0x80) != 0);
Serial.print("CS: ");
Serial.println((pktstatus & 0x40) != 0);
Serial.print("CRL: ");
Serial.println((pktstatus & 0x20) != 0);
Serial.print("RX_BYTE_OK: ");
Serial.println((pktstatus & 0x10) != 0);
Serial.print("RX_BYTE: ");
Serial.println((pktstatus & 0x08) != 0);
Serial.print("PKT_L: ");
Serial.println((pktstatus & 0x04) != 0);
delay(250);
}
delay(100);
}
The receiver registers packets but they are empty. And I would like to read the data in this form "11887717". I've tried various configurations but nothing helped. I am a beginner Arduino programmer. Please give me some tips or correct configuration for the receiver.
This is a preview of the serial port and what the receiver returns:
Connection OK
Rx Mode
Length: 0
Received: No data
RSSI: -25
PKTSTATUS: 11100000
CRC_OK: 1
CS: 1
CRL: 1
RX_BYTE_OK: 0
RX_BYTE: 0
PKT_L: 0