CC1101 Failure with esp32

I cannot get the Hello_World code from CC1101 to work (only changed cs to pin 5). I'm using the ELEGOO ESP32. For wiring I add some pictures. I keep getting:

15:24:39.447 -> Starting ...
15:24:40.411 -> Chip not found!



Thats the code:


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


using namespace CC1101;


Radio radio(/* cs pin */ 5);


void setup() {
  Serial.begin(115200);
  delay(3000);
  Serial.println(F("Starting ..."));
  delay(1000);


  if (radio.begin() == STATUS_CHIP_NOT_FOUND) {
    Serial.println(F("Chip not found!"));
    while (true) { delay(1000); }
  }


  radio.setModulation(MOD_ASK_OOK);
  radio.setFrequency(433.8);
  radio.setDataRate(10);
  radio.setOutputPower(10);


  radio.setPacketLengthMode(PKT_LEN_MODE_VARIABLE);
  radio.setAddressFilteringMode(ADDR_FILTER_MODE_NONE);
  radio.setPreambleLength(64);
  radio.setSyncWord(0x1234);
  radio.setSyncMode(SYNC_MODE_16_16);
  radio.setCrc(true);
  radio.setDataWhitening(true);
  radio.setManchester(false);
  radio.setFEC(false);
}


int counter = 0;


void loop() {
  String data = "Hello #" + String(counter++);


  Serial.print(F("Transmitting: "));
  Serial.print(data);
  Serial.print(F(" "));
  Status status = radio.transmit((uint8_t *)data.c_str(), data.length());


  if (status == STATUS_OK) {
    Serial.println(F("[OK]"));
  } else {
    Serial.print("[ERROR ");
    Serial.print(status);
    Serial.println("]");
  }


  delay(1000);
}#include <Arduino.h>
#include <cc1101.h>


using namespace CC1101;


Radio radio(/* cs pin */ 5);


void setup() {
  Serial.begin(115200);
  delay(3000);
  Serial.println(F("Starting ..."));
  delay(1000);


  if (radio.begin() == STATUS_CHIP_NOT_FOUND) {
    Serial.println(F("Chip not found!"));
    while (true) { delay(1000); }
  }


  radio.setModulation(MOD_ASK_OOK);
  radio.setFrequency(433.8);
  radio.setDataRate(10);
  radio.setOutputPower(10);


  radio.setPacketLengthMode(PKT_LEN_MODE_VARIABLE);
  radio.setAddressFilteringMode(ADDR_FILTER_MODE_NONE);
  radio.setPreambleLength(64);
  radio.setSyncWord(0x1234);
  radio.setSyncMode(SYNC_MODE_16_16);
  radio.setCrc(true);
  radio.setDataWhitening(true);
  radio.setManchester(false);
  radio.setFEC(false);
}


int counter = 0;


void loop() {
  String data = "Hello #" + String(counter++);


  Serial.print(F("Transmitting: "));
  Serial.print(data);
  Serial.print(F(" "));
  Status status = radio.transmit((uint8_t *)data.c_str(), data.length());


  if (status == STATUS_OK) {
    Serial.println(F("[OK]"));
  } else {
    Serial.print("[ERROR ");
    Serial.print(status);
    Serial.println("]");
  }


  delay(1000);
}

Please correct your post and add code tags around your code.

There is a small pencil image below your existing posts.

  • click on this pencil ➜ that will let you edit your post.
  • Select the part of the text that corresponds to the code
  • Click on the <code/> icon in the toolbar to indicate that it is code
  • click image Save Edit

(Also make sure to properly indent the code in the IDE before copying and pasting it here. This can be done by pressing ctrlT on a PC or cmdT on a Mac)

———
I moved your topic to an appropriate forum category as you are not using a Nano ESP32.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.

———

don't you need an antenna plugged there ?

Thanks! I'm just trying to set it up, for actually sending an antenna would be necessary.

Changed from what? Post your pin to pin description.

In the provided "Hello World" example pin 10 was used. I changed it to pin 5.

That's the wiring:
ESP 32 - ESP32
2: VCC|3.3 V|3V3|
1: GND|GND|GND|
5: SCK|GPIO18|D18|
6:MOSI (SI)|GPIO23|D23|
7: MISO (SO)|GPIO19|D19|
4: CSN (SS)|GPIO5|D5|
3: GDO0 |GPIO4|D4|
8: GDO2 |GPIO2|D2|

which library is that ?

try with VSPI

GPIO18 (SCK), GPIO23 (MOSI), GPIO19 (MISO) et GPIO5 (CS)

thats the library. I used the wiring you suggested...

I had missed post 5

in your library's code I see they deal with ESP32 in a specific manner

I think you should pass the pins in the constructor.

I changed it to this:


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

using namespace CC1101;

// ---- ESP32 VSPI pins ----
#define PIN_SCK   18
#define PIN_MISO  19
#define PIN_MOSI  23
#define PIN_CS    5

// Radio constructor ONLY takes CSN
Radio radio(PIN_CS);

void setup() {
  Serial.begin(115200);
  delay(2000);

  Serial.println("Starting...");

  SPI.begin(PIN_SCK, PIN_MISO, PIN_MOSI, PIN_CS);

  // Optional but recommended
  pinMode(PIN_CS, OUTPUT);
  digitalWrite(PIN_CS, HIGH);

  // ---- Initialize CC1101 ----
  if (radio.begin() == STATUS_CHIP_NOT_FOUND) {
    Serial.println("Chip not found!");
    while (true) {
      delay(1000);
    }
  }

  // ---- Radio configuration ----
  radio.setModulation(MOD_ASK_OOK);
  radio.setFrequency(433.8);
  radio.setDataRate(10);
  radio.setOutputPower(10);

  radio.setPacketLengthMode(PKT_LEN_MODE_VARIABLE);
  radio.setAddressFilteringMode(ADDR_FILTER_MODE_NONE);
  radio.setPreambleLength(64);
  radio.setSyncWord(0x1234);
  radio.setSyncMode(SYNC_MODE_16_16);
  radio.setCrc(true);
  radio.setDataWhitening(true);
  radio.setManchester(false);
  radio.setFEC(false);

  Serial.println("CC1101 initialized");
}

int counter = 0;

void loop() {
  String data = "Hello #" + String(counter++);

  Serial.print("Transmitting: ");
  Serial.print(data);
  Serial.print(" ");

  Status status = radio.transmit(
    (uint8_t*)data.c_str(),
    data.length()
  );

  if (status == STATUS_OK) {
    Serial.println("[OK]");
  } else {
    Serial.print("[ERROR ");
    Serial.print(status);
    Serial.println("]");
  }

  delay(1000);
}

and it works. Thank you :)

glad it helped :slight_smile: