1

I am using this libary from github:https://github.com/veonik/arduino-cc1101

With this example code. I will try to read the data which is send from a 868Mhz thermostat. I am using a arduino Mega and wired it like in the following picture.

enter image description here

First I get this error:

enter image description here

When i upload the code. I get this Serial Output. But no packages send and no packacges recived. Can somebody help me?

   CC1101_PARTNUM 0
CC1101_VERSION 20
CC1101_MARCSTATE 9
CC1101 radio initialized.

example code:

 #include <Arduino.h>
    #include <cc1101.h>
    #include <ccpacket.h>

    // Attach CC1101 pins to their corresponding SPI pins
    // Uno pins:
    // CSN (SS) => 10
    // MOSI => 11
    // MISO => 12
    // SCK => 13
    // GD0 => A valid interrupt pin for your platform (defined below this)

    #if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
    #define CC1101Interrupt 4 // Pin 19
    #define CC1101_GDO0 19
    #elif defined(__MK64FX512__)
    // Teensy 3.5
    #define CC1101Interrupt 9 // Pin 9
    #define CC1101_GDO0 9
    #else
    #define CC1101Interrupt 0 // Pin 2
    #define CC1101_GDO0 2
    #endif

    CC1101 radio;

    byte syncWord[2] = {199, 10};
    bool packetWaiting;

    unsigned long lastSend = 0;
    unsigned int sendDelay = 5000;

    void messageReceived() {
        packetWaiting = true;
    }

    void setup() {
        radio.init();
        radio.setSyncWord(syncWord);
        radio.setCarrierFreq(CFREQ_868);
        radio.disableAddressCheck();
        radio.setTxPowerAmp(PA_LongDistance);

        Serial.begin(9600);
        Serial.print(F("CC1101_PARTNUM "));
        Serial.println(radio.readReg(CC1101_PARTNUM, CC1101_STATUS_REGISTER));
        Serial.print(F("CC1101_VERSION "));
        Serial.println(radio.readReg(CC1101_VERSION, CC1101_STATUS_REGISTER));
        Serial.print(F("CC1101_MARCSTATE "));
        Serial.println(radio.readReg(CC1101_MARCSTATE, CC1101_STATUS_REGISTER) & 0x1f);

        Serial.println(F("CC1101 radio initialized."));
        attachInterrupt(CC1101Interrupt, messageReceived, FALLING);
    }

    // Get signal strength indicator in dBm.
    // See: http://www.ti.com/lit/an/swra114d/swra114d.pdf
    int rssi(char raw) {
        uint8_t rssi_dec;
        // TODO: This rssi_offset is dependent on baud and MHz; this is for 38.4kbps and 433 MHz.
        uint8_t rssi_offset = 74;
        rssi_dec = (uint8_t) raw;
        if (rssi_dec >= 128)
            return ((int)( rssi_dec - 256) / 2) - rssi_offset;
        else
            return (rssi_dec / 2) - rssi_offset;
    }

    // Get link quality indicator.
    int lqi(char raw) {
        return 0x3F - raw;
    }

    void loop() {
        if (packetWaiting) {
            detachInterrupt(CC1101Interrupt);
            packetWaiting = false;
            CCPACKET packet;
            if (radio.receiveData(&packet) > 0) {
                Serial.println(F("Received packet..."));
                if (!packet.crc_ok) {
                    Serial.println(F("crc not ok"));
                }
                Serial.print(F("lqi: "));
                Serial.println(lqi(packet.lqi));
                Serial.print(F("rssi: "));
                Serial.print(rssi(packet.rssi));
                Serial.println(F("dBm"));

                if (packet.crc_ok && packet.length > 0) {
                    Serial.print(F("packet: len "));
                    Serial.println(packet.length);
                    Serial.println(F("data: "));
                    Serial.println((const char *) packet.data);
                }
            }

            attachInterrupt(CC1101Interrupt, messageReceived, FALLING);
        }
        unsigned long now = millis();
        if (now > lastSend + sendDelay) {
            detachInterrupt(CC1101Interrupt);

            lastSend = now;
            const char *message = "hello world";
            CCPACKET packet;
            // We also need to include the 0 byte at the end of the string
            packet.length = strlen(message)  + 1;
            strncpy((char *) packet.data, message, packet.length);

            radio.sendData(packet);
            Serial.println(F("Sent packet..."));

            attachInterrupt(CC1101Interrupt, messageReceived, FALLING);
        }
    }
11
  • That is not serial output. That is compiler output. To see serial output open the serial monitor. – Majenko Mar 17 '19 at 18:21
  • Also note that 868MHz is not the frequency. It is the band. That band is typically subdivided into a number of channels with a specific bandwidth (no standard, but implementation specific). The actual frequency could be anywhere between 865MHz and 870MHz. You should use an SDR dongle (I use RTL2832U) to both locate and capture the data. Also note that there are multiple different modulation techniques that you will need to account for. – Majenko Mar 17 '19 at 18:25
  • 3
    Possible duplicate of CC1101 sniffing 868Mhz Protocol from thermostat – Duncan C Mar 17 '19 at 20:05
  • 1
    This was another problem I already solved... – otto Mar 17 '19 at 20:14
  • 1
    because it is another problem. I can delete this topic and change the question from yesterday. If you want it. – otto Mar 17 '19 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.