wladimir-computin / CC1101-ESP-Arduino

ESP8266 / ESP32 / Arduino driver lib for using the great TI C1101 transceiver
Other
76 stars 13 forks source link

CC1101-ESP-Arduino

ESP8266 / ESP32 / Arduino driver lib for using the great TI C1101 transceiver

About

The Texas Instruments CC1101 is a very versatile, high quality and cheap transceiver, supporting a wide range of frequencies and modulations. Ready-to-use CC1101 modules are as cheap as 5.00€ and at the same time significantly better than simple 433MHz receiver and transmitter modules.

The confusing part about these CC1101s is, they are actually kind of over powered, providing logic for sync word detection, CRC checks, packet formats and so on. However, it's still possible to use them as simple digital transceivers, giving them a minimum of configuration and letting the MCU (like our ESP8266/ESP32/Arduino) do all the work. Especially useful, if you want to transmit or decode non-standard packet formats. Like the vast majority of us, I suppose ;)

This library aims to help developers using the CC1101 module without having to read the whole 105 pages datasheet first.

Features

CC1101 technical info

RX/TX modes

Limitations

I develop this library in my free time. Some features are not done yet. For now only asynchronous serial mode is supported.

Progress

TODO

Examples

Look into /examples :)

Wiring

Connect SPI_SCK, SPI_MISO, SPI_MOSI to the corresponding SPI Pins on your board. SPI_CS can be any pin usable as INPUT and OUTPUT, but most boards have a default one.

The CC1101 has two multi-purpose pins, GDO0 and GDO2. (Actually three, but GDO1 is SPI_MISO, which is only usable if SPI_CS is HIGH.)

PIN FEATURES
GDO0 INPUT/OUTPUT
GDO1 OUTPUT (only usable if SPI_CS=HIGH)
GDO2 OUTPUT

API

Constructors:

CC1101(int gdo0);
CC1101(int gdo0, int gdo2);
CC1101(int sck, int miso, int mosi, int cs, int gdo0);
CC1101(int sck, int miso, int mosi, int cs, int gdo0, int gdo2);

High level methods:

void init();
void softReset();
void hardReset ();
void setIdle();
void setRx();
void setTx();
void setMHZ(double mhz);
void setChannel(uint8_t channel);
void setChannelSpacing(int spacing_hz);
void setTXPwr(TX_DBM value);
void setRxBW(RX_BW_KHZ RxBW);
void setDataRate(unsigned long baud);
void setModulation(MOD_FORMAT mod);
void setDeviationHZ(int deviation_hz); //1586hz - 380859hz
uint8_t getPartnum();
uint8_t getVersion();

Low level methods:

void spiStrobe(uint8_t strobe);
uint8_t spiReadReg(uint8_t addr);
uint8_t spiReadStatus(uint8_t addr);
void spiReadRegBurst(uint8_t addr, uint8_t* buffer, uint8_t buffer_len);
void spiWriteReg(uint8_t addr, uint8_t value);
void spiWriteRegBurst(uint8_t addr, const uint8_t* buffer, uint8_t buffer_len);

Definitions (see CC1101_ESP_Arduino.h for more)

enum TX_DBM {
    TX_DEFAULT_DBM = 0,
    TX_MINUS_30_DBM = 1,
    TX_MINUS_20_DBM = 2,
    TX_MINUS_15_DBM = 3,
    TX_MINUS_10_DBM = 4,
    TX_0_DBM = 5,
    TX_PLUS_5_DBM = 6,
    TX_PLUS_7_DBM = 7,
    TX_PLUS_10_DBM = 8
};

enum RX_BW_KHZ {
    RX_BW_812_KHZ = 0,
    RX_BW_650_KHZ = 1,
    RX_BW_541_KHZ = 2,
    RX_BW_464_KHZ = 3,
    RX_BW_406_KHZ = 4,
    RX_BW_325_KHZ = 5,
    RX_BW_270_KHZ = 6,
    RX_BW_232_KHZ = 7,
    RX_BW_203_KHZ = 8,
    RX_BW_162_KHZ = 9,
    RX_BW_135_KHZ = 10,
    RX_BW_116_KHZ = 11,
    RX_BW_102_KHZ = 12,
    RX_BW_81_KHZ = 13,
    RX_BW_68_KHZ = 14,
    RX_BW_58_KHZ = 15
};

enum MOD_FORMAT {
    FSK2 = 0,
    GFSK = 1,
    ASK_OOK = 3,
    FSK4 = 4,
    MSK = 7
};

Contribute

Help is always welcome :)