TI CC1101 RF Library

Hi Jake,

Look at the error-explanation by the compiler.

pkt.data is an array of unsigned bytes (uint8_t), so if (pkt.data[0] == (“98”)) will not work.

uint8_t data[CC1101_DATA_LEN]

Try if (pkt.data[0] == 98) or if (pkt.data[0] == ‘b’)

The first position in pkt.data (pkt.data[0]) identifies the address of the radio, who send the message.

  if (pkt.data[0] == 98) {
      pinMode(7,OUTPUT);
      digitalWrite(7,HIGH);
  }

Should check if the message came from the radio with address 98.

Br Michael

1 Like

@Spangaard Thanks for the problem solved. The maximum number of cc1101 can communicate with one another.

Check the datasheet.

You can have 127 uniq radio addresses, and each radio can broadcast/transmit to all radio’s listening or one specific radio’s address.

But at any given time, only one radio can transmit on the same channel. Otherwise massages will collide in air :wink:

You can build very robust solutions if you implement message acknowledgment, auto-retransmit, ques, timing etc. But your code gets very complicated very easily.

Br Michael

@Spangaard How can I change the library according to the processor named Atmega128.

Hi Jake,

I don’t use Atmega 128 processors, so can’t help you there.

But I am sure you can find help in the Arduino communities - the library are very straight forward expect for the SPI part.

Good luck

Michael

@Spangaard I just need to change the pin numbers. But I did not find this part in the code.

If you are using hardware SPI you don’t need to change anything in code as the pins are “hard wired” to the respective SPI object - only the SS pin is selectably (by design).
Just look up the hardware specs of your controller and wire the board up accordingly.

If you want to run software SPI, on the other hand, you’d need to extend the library for that as it’s not meant to support software SPI.

Hi Jake,

I can’t help you with the Atmega128 processor. It is not a Particle related issue and you either don’t do the research or don’t have the needed skills - so changing the pins will likely just be the first issue you run into.

My advise would be to stick to the Particle/Photon until you are comfortable in C++ programming.

in the header file, 4 different mcu’s/processors are defined - including the Uno and the Mega Arduino boards. So changing the pins and clock divider are easy,

#if defined(__AVR_ATmega2560__) /* Arduino Mega */

#define board "Mega"
#define _SPI_SS_ 53
#define _GDO0pin_ 2
#define spiDivide SPI_CLOCK_DIV8
#define _default_deviceAddress 20
#define _default_remoteDeviceAddress 30

#elif defined(_VARIANT_ARDUINO_DUE_X_) /* ARDUINO DUE BOARD */

#define board "DUE"
#define _SPI_SS_ 52
#define _GDO0pin_ 2
#define spiDivide SPI_CLOCK_DIV16
#define _default_deviceAddress 30
#define _default_remoteDeviceAddress 40

#else // we use Arduino UNO GPIO

#define board "UNO"
#define _SPI_SS_ 10
#define _GDO0pin_ 2
#define spiDivide SPI_CLOCK_DIV4
#define _default_deviceAddress 40
#define _default_remoteDeviceAddress 30

#endif // board selection

But you need to understand how the compiler interprets the #define statements and make sure the right board is selected.

I have used the CC1101 radio on a number of different processors (a long time ago), and problems are often related to level shifting, interrupts and timing issues in the library and general application logic. Not the SPI interface.

If you need more help, you could look at the panStamp library and community.

Br Michael