LSatan / SmartRC-CC1101-Driver-Lib

This driver library can be used for many libraries that use a simple RF ASK module, with the advantages of the cc1101 module. It offers many direct setting options as in SmartRF Studio and calculates settings such as MHz directly.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Finally got it working - setting custom pins - NodeMCU ESP32

frspp opened this issue · comments

commented

I have NodeMCU ESP32. Using default pins introduced flash MD5 hash error so I chose custom pins. I recommend using GPIO pins 16-33 because pins 0-15 have some special functions and caused problems (see https://randomnerdtutorials.com/esp32-pinout-reference-gpios/ )

Provided examples were not working and documentation is not solid. Took long to find these needed modifications to make it work:

  • setSpiPin() before init()
  • setGDO() before init()
  • if-else getCC1101() AFTER the settings, not before like in example.

Working Arduino sketch: Set custom pins

/*
  Example for receiving
  
  https://github.com/sui77/rc-switch/
  https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
  If you want to visualize a telegram copy the raw data and 
  paste it into http://test.sui.li/oszi/
  ----------------------------------------------------------
  Mod by Little Satan. Have Fun!
  ----------------------------------------------------------
*/
#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <RCSwitch.h>

int pin; // Create variable for receive pin.

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);

  pin = 33; // GDO2 pin (33 for me)

  ELECHOUSE_cc1101.setSpiPin(18, 19, 23, 17); // Set custom pins: (SCK, MISO, MOSI, CSN). Must be BEFORE Init()!
  ELECHOUSE_cc1101.setGDO(32, 33); // Set custom GDO pins: (GDO0, GDO2). Gdo0 (tx) and Gdo2 (rx). Must be BEFORE Init();
  ELECHOUSE_cc1101.Init(); // initialize the cc1101
  //ELECHOUSE_cc1101.setRxBW(812.50);  // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.
  //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. Possible values: (-30, -20, -15, -10, -6, 0, 5, 7, 10, 11, 12). Default is max!
  ELECHOUSE_cc1101.setMHZ(433.92); // Set basic frequency. The lib calculates the frequency automatically (default: 433.92). CC1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
  
  mySwitch.enableReceive(pin);  // Receiver on interrupt 0

  ELECHOUSE_cc1101.SetRx();  // set Receive on

  // Check the CC1101 Spi connection.
  if (ELECHOUSE_cc1101.getCC1101()) { 
    Serial.println("CC1101: Connection OK.");
  }
  else {
    Serial.println("CC1101: Connection error.");
  }
}

void loop() {
  if (mySwitch.available()) {
    output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol());
    mySwitch.resetAvailable();
  }
}

it doenst work either !!!!

I dont receive any code either

Could you please explain how do i connect my cc1101 to my esp32? i mean like putting 1- gnd 2- 3.3v
thanks and sorry, im really new in this world