Skip to content

Commit ab519c1

Browse files
authored
Update README.md
1 parent 72b8496 commit ab519c1

File tree

1 file changed

+84
-50
lines changed

1 file changed

+84
-50
lines changed

README.md

+84-50
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# SmartCC1101
2-
This driver library offers a simple access to data transfer using the cc1101 module. It gives access to many configuration options without need to use RFStudio.
2+
This driver library offers a simple access to data transfer using the **CC1101** module. It gives access to many configuration options without need to use RFStudio.
33
## Basic Function
44
This library was mainly implemented to efficiently send data from decentral battery powered sensors to a central hub. Howwever it may as well be used for bi-directional communication between several nodes.
5-
The maximum amount of data which can be be sent in a single transfer is limited to the size of the internal buffer of the CC1101, leading to a possible payload of 61 bytes.
5+
The maximum amount of data which can be be sent in a single transfer is limited to the size of the internal buffer of the **CC1101**, leading to a possible payload of 61 bytes.
66
The code was designed to have a small memory footprint and runs fine on an Arduino Pro Mini (ATMega328p). However, for a single caclulation, floating point math is needed, excluding platforms like ATTiny. In a future version, I might re-implement the offending algortihm to integer math tpo remove the restriction. Besides that, no specific platform-dependant code is used and the library should behave well everywhere else (although it is only explicitely testetd on Arduino Pro Mini and ESP8266).
77
## Wiring
88
I promise I will add some drawings later on, but for now, I'll stick with the pin numbers - which are standard pins for SPI connections on the boards mentioneed.
99

10-
### CC1101
10+
### **CC1101**
1111
If the module lays with the antenna connectors to the top, on the lower connection pins are from left to right:
1212
+ VCC
1313
+ GND
@@ -18,7 +18,7 @@ If the module lays with the antenna connectors to the top, on the lower connecti
1818
+ GDO0 (unused)
1919
+ CS (or CSN)
2020

21-
The modules usually support voltages from 1.8V to 3.6V, so please use a level converter when connecting to a 5V CPU board. Also, be careful when soldering the connections, I have grilled several CC1101 modules...
21+
The modules usually support voltages from 1.8V to 3.6V, so please use a level converter when connecting to a 5V CPU board. Also, be careful when soldering the connections, I have grilled several **CC1101** modules...
2222

2323
### Processor boards
2424
**Arduino Pro Mini (ATMega328p)**
@@ -59,26 +59,26 @@ The settings are not limited to the `setup()` and may be changed anytime in the
5959
void setup() {
6060
Serial.begin(115200);
6161

62-
Smartcc1101.init(); // must be called first to initialize the CC1101
62+
SmartCC1101.init(); // must be called first to initialize the **CC1101**
6363

64-
if (Smartcc1101.getCC1101()) { // Check the CC1101 SPI connection.
65-
Serial.println(F("[I] CC1101 connected."));
64+
if (SmartCC1101.get**CC1101**()) { // Check the **CC1101** SPI connection.
65+
Serial.println(F("[I] **CC1101** connected."));
6666
} else {
67-
Serial.println(F("[E] *** CC1101 connection Error ***"));
67+
Serial.println(F("[E] *** **CC1101** connection Error ***"));
6868
delay(20000);
6969
}
7070

71-
Smartcc1101.setSymbolRate(100000); // Set the Data Rate in Baud. Value from 20 to 1621830 Default is 115051 Baud
72-
Smartcc1101.setManchester(true); // Enables Manchester encoding/decoding. false = Disable (default), true = Enable.
73-
Smartcc1101.setWhiteData(true); // Turn data whitening on / off. false = Whitening off (default). true = Whitening on.
74-
Smartcc1101.setCRCCheck(true); // true = CRC calculation in TX and CRC check in RX enabled. false = CRC disabled for TX and RX (default).
71+
SmartCC1101.setSymbolRate(100000); // Set the Data Rate in Baud. Value from 20 to 1621830 Default is 115051 Baud
72+
SmartCC1101.setManchester(true); // Enables Manchester encoding/decoding. false = Disable (default), true = Enable.
73+
SmartCC1101.setWhiteData(true); // Turn data whitening on / off. false = Whitening off (default). true = Whitening on.
74+
SmartCC1101.setCRCCheck(true); // true = CRC calculation in TX and CRC check in RX enabled. false = CRC disabled for TX and RX (default).
7575
}
7676

7777
void loop() {
7878

7979
const char messageText[] = "Hello world!";
8080
// Send data. Returns when data is actually sent.
81-
Smartcc1101.sendData(messageText);
81+
SmartCC1101.sendData(messageText);
8282

8383
// Wait a moment untill next data sent.
8484
delay(1000);
@@ -95,36 +95,36 @@ The Corresponding receiver is also available:
9595
void setup() {
9696
Serial.begin(115200);
9797

98-
Smartcc1101.init(); // must be called first to initialize the CC1101
98+
SmartCC1101.init(); // must be called first to initialize the **CC1101**
9999

100-
if (Smartcc1101.getCC1101()) { // Check the CC1101 SPI connection.
101-
Serial.println(F("[I] CC1101 connected."));
100+
if (SmartCC1101.get**CC1101**()) { // Check the **CC1101** SPI connection.
101+
Serial.println(F("[I] **CC1101** connected."));
102102
} else {
103-
Serial.println(F("[E] *** CC1101 connection Error ***"));
103+
Serial.println(F("[E] *** **CC1101** connection Error ***"));
104104
delay(20000);
105105
}
106106

107-
Smartcc1101.setRXBandWitdth(SmartCC1101::bw_812kHz); // Set the Receive Bandwidth in kHz. Possible values: bw_58kHz = 58kHz, bw_68kHz, bw_81kHz, bw_102kHz,bw_116kHz, bw_135kHz, bw_162kHz, bw_203kHz (default), bw_232kHz, bw_270kHz, bw_325kHz, bw_406kHz, bw_464kHz, bw_541kHz, bw_650kHz, bw_812kHz = 812kHz
108-
Smartcc1101.setSymbolRate(100000); // Set the Data Rate in Baud. Value from 20 to 1621830 Default is 115051 Baud
109-
Smartcc1101.setManchester(true); // Enables Manchester encoding/decoding. false = Disable (default), true = Enable.
110-
Smartcc1101.setWhiteData(true); // Turn data whitening on / off. false = Whitening off (default). true = Whitening on.
111-
Smartcc1101.setCRCCheck(true); // true = CRC calculation in TX and CRC check in RX enabled. false = CRC disabled for TX and RX (default).
107+
SmartCC1101.setRXBandWitdth(SmartCC1101::bw_812kHz); // Set the Receive Bandwidth in kHz. Possible values: bw_58kHz = 58kHz, bw_68kHz, bw_81kHz, bw_102kHz,bw_116kHz, bw_135kHz, bw_162kHz, bw_203kHz (default), bw_232kHz, bw_270kHz, bw_325kHz, bw_406kHz, bw_464kHz, bw_541kHz, bw_650kHz, bw_812kHz = 812kHz
108+
SmartCC1101.setSymbolRate(100000); // Set the Data Rate in Baud. Value from 20 to 1621830 Default is 115051 Baud
109+
SmartCC1101.setManchester(true); // Enables Manchester encoding/decoding. false = Disable (default), true = Enable.
110+
SmartCC1101.setWhiteData(true); // Turn data whitening on / off. false = Whitening off (default). true = Whitening on.
111+
SmartCC1101.setCRCCheck(true); // true = CRC calculation in TX and CRC check in RX enabled. false = CRC disabled for TX and RX (default).
112112
}
113113

114114

115115
void loop() {
116-
uint8_t buffer[61]{ 0 }; // buffer for the data received by CC1101
116+
uint8_t buffer[61]{ 0 }; // buffer for the data received by **CC1101**
117117

118-
int len = Smartcc1101.receiveData(buffer);
118+
int len = SmartCC1101.receiveData(buffer);
119119
// len will be 0 if nothing is yet received.
120120
if (len > 0) {
121121
Serial.print(len);
122122
Serial.println(" bytes received.");
123123

124124
// check transfer quality parameters
125-
int8_t RSSI = Smartcc1101.getRSSI();
126-
bool CRC = Smartcc1101.checkCRC();
127-
uint8_t LQI = Smartcc1101.getLQI();
125+
int8_t RSSI = SmartCC1101.getRSSI();
126+
bool CRC = SmartCC1101.checkCRC();
127+
uint8_t LQI = SmartCC1101.getLQI();
128128

129129
// will try to interpret the buffer received as character array, just make sure it's zero-terminated.
130130
// if it was actually sent from a character array, this is not necessary
@@ -151,11 +151,11 @@ void loop() {
151151

152152
## Funtion reference
153153

154-
`void init(void)` must be called prior to using any other funtion. Will establish the necessary setup of the CC1101 chip. Only exception: `gtCC1101()`.
154+
`void init(void)` must be called prior to using any other funtion. Will establish the necessary setup of the **CC1101** chip. Only exception: `getCC1101()`.
155155

156156
`bool checkCRC(void)` Check if CRC is correct. Only meaningful after data is received via `receiveData()`.
157157

158-
`bool getCC1101(void)` checks for the presence of a CC1101 module on the SPI bus.
158+
`bool getCC1101(void)` checks for the presence of a **CC1101** module on the SPI bus.
159159

160160
`uint8_t getLQI(void)` Link Quality Indicator. The Link Quality Indicator is a metric of the current quality of the received signal (smaller is better). When called after data is received via `receiveData()`. LQI corresponds to the data received. If called intermittently, returns the current link quality.
161161

@@ -177,23 +177,39 @@ void loop() {
177177
| adc_YES0BC | Address check and 0 (0x00) broadcast |
178178
| adc_YES0FFBC | Address check and 0 (0x00) and 255 (0xFF) broadcast |
179179

180-
`void setCarrierFrequency(uint32_t freq)` Set tranmsision frequency in Hz. Default = 868.35 MHz). The cc1101 can use 300-348 MHZ, 387-464MHZ and 779-928MHZ. More info in the datasheet. Must match sender and receiver.
180+
`void setCarrierFrequency(uint32_t freq)` Set tranmsision frequency in Hz. Default = 868.35 MHz). The **CC1101** can use the frequenciy ranges 300-348 MHZ, 387-464MHZ and 779-928MHZ.
181+
> [!WARNING]
182+
> Please respect local regulations.
183+
184+
> [!IMPORTANT]
185+
> Must match sender and receiver.
186+
187+
> [!NOTE]
188+
> The effective carrier frequencies are quantized, the function will set it to the next possible lower value.
181189
182190
`void setCRCCheck(bool crcc)` On TX, enables CRC to be added to the payload. On RX, will calculate the CRC of received data and compare with CRC transmitted. Defaults to `false`.
183191

184-
`void setCRC_AF(bool af)` Autoflushes RX buffer if CRC check fails (if `setCRCCheck(true)`). No effect if `setCRCCheck(false)`.
185-
192+
`void setCRC_AF(bool af)` Autoflushes RX buffer if CRC check fails (if `setCRCCheck(true)`). Has no effect if `setCRCCheck(false)`.
193+
186194
`void setDCFilterOff(bool dcf)` Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud. The recommended IF frequency changes when the DC blocking is disabled. true = Disable (current optimized), false = Enable (better sensitivity).
187195

188196
`void setDelayFunction(void delayFunc(uint8_t))` The function supplied will be called repeatedly while waiting from the transmission to finish in `sendData()`. It must support a single parameter of type `uint8_t`, which is the delay in ms. If not set, `delay()` will be called. Should be needed only in very special caeses.
189197

190-
`void setDeviation(uint32_t deviation)` Set the frequency deviation in Hz. Possible values from 1586 to 380850. Default is 47607 Hz. Note: the algorithm rounds down. Using the exact interval limits, the next lower value might be taken (e.g. for 47607, you must actually specify 4760**8**.
198+
`void setDeviation(uint32_t deviation)` Set the frequency deviation in Hz. Possible values from 1586 to 380850. Default is 47607 Hz.
199+
> [!NOTE]
200+
> the effective deviation values are quantized and algorithm rounds down. Using the exact interval limits, the next lower value might be taken (e.g. for 47607, you must actually specify 4760**8**.
201+
202+
`void setFEC(bool fec)` Enable forward error correction. Only supported in fixed packet length mode (`PacketLengthConfig(pktl_FIXED)`) and `setCRCCheck(true)`.
203+
204+
`void setManchester(bool menc)` Enable Manchester encoding. Defaults to `false`.
205+
> [!IMPORTANT]
206+
> Must match sender and receiver.
191207
192-
`void setFEC(bool fec)` Enable forward error correction. Only supported in fixed packet length mode (`PacketLengthConfig(pktl_FIXED)`) and `setCRCCheck(true)`.
193208

194-
`void setManchester(bool menc)` Enable Manchester encoding. Defaults to `false`. Must match on sender and receiver.
209+
`void setModulation(Modulation m)` Set modulation mode. I nearly exclusively use 2FSK modulation.
210+
> [!IMPORTANT]
211+
> Must match sender and receiver.
195212
196-
`void setModulation(Modulation m)` Set modulation mode. Should match sender and receiver. I nearly exclusively use 2FSK modulation.
197213
| Value | Modulation |
198214
|------------|-------|
199215
|mod_2FSK| 2FSK modulation (default)|
@@ -202,37 +218,47 @@ void loop() {
202218
|mod_4FSK| 4FSK modulation|
203219
|mod_MSK| MFSK modulation|
204220

205-
`void setLengthConfig(PacketLengthConfig pktl)`From the different options the CC11101 supports in hardware, only the following two options are imlemented in this driver:
221+
222+
`void setLengthConfig(PacketLengthConfig pktl)` From the different options the CC11101 supports in hardware, only the following two options are imlemented in this driver:
206223
| Value | Packet length configuration |
207224
|------------|-------|
208225
| pktl_FIXED | fixed packet length as configured by `setLengthConfig()` |
209226
| pktl_VARIABLE | Variable packet length |
210227

211-
`void setPA(int8_t pa)` Set TXPower in dB. The following settings are possible depending on the frequency band: -30, -20, -15, -10, -6, 0, 5, 7, 10, 11, 12. Default is max.
228+
`void setPA(int8_t pa)` Set TXPower in dB. The following settings are possible depending on the frequency band: -30, -20, -15, -10, -6, 0, 5, 7, 10, 11, 12. Default is max.
229+
> [!WARNING]
230+
> Please respect local regulations.
231+
232+
> [!NOTE]
233+
> The effective PA values are quantized, the function will set it to the next possible lower value.
212234
213235
`void setPacketLength(uint8_t len)` Packet lentgh when `setLengthConfig(pktl_FIXED)`. On variable packet length, configures maximum packet length (optional). Defaults to 0.
214236

215-
`void setPktFormat(PacketFormat pktf)` Although the CC1101 supports different packet formats, only "normal" and RANDOM_TX are supported.
237+
`void setPktFormat(PacketFormat pktf)` Although the **CC1101** supports different packet formats, only "normal" and RANDOM_TX are supported.
216238
| Value | Packet format |
217239
|------------|-------|
218240
| pktf_NORMAL | Normal mode, use FIFOs for RX and TX (default)|
219241
| pktf_RANDOMTX | sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00) in RX |
220242

221243
`void setPRE(preamble_Bytes pre)` When enabling TX, the modulator will start transmitting the preamble. When the programmed number of preamble bytes has been transmitted, the modulator will send the sync word and then data from the TX FIFO.
244+
> [!IMPORTANT]
245+
> Must match sender and receiver.
246+
222247
| Value | Preamble Bytes |
223248
|------------|-------|
224249
| pre_2 |2 preamble bytes |
225250
| pre_3 | 3 preamble bytes |
226-
| pre_4 | 4 preamble bytes |
251+
| pre_4 | 4 preamble bytes (default) |
227252
| pre_6 | 6 preamble bytes |
228253
| pre_8 | 8 preamble bytes |
229254
| pre_12 | 12 preamble bytes |
230255
| pre_16 | 16 preamble bytes |
231256
| pre_24 = |/ 24 preamble bytes |
232257

258+
233259
`void setPQT(uint8_t pqt)` The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by eight each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. By setting the value to zero, the preamble quality qualifier of the sync word is disabled. Defaults to 0.
234260

235-
`void setRX(void)` Set the CC1101 to RX mode. Repeated calls do not have any effect, unless data was received in the meantime. If the internal buffer is not read via `receiveData()`, the data is lost.
261+
`void setRX(void)` Set the **CC1101** to RX mode. Repeated calls do not have any effect, unless data was received in the meantime. If the internal buffer is not read via `receiveData()`, the data is lost.
236262

237263
`void setRXBandWitdth(rx_BandWidth bw)` Set the Receive Bandwidth. Value can be cosen from predefined list of values:
238264
| Bandwidth | Value |
@@ -253,24 +279,32 @@ void loop() {
253279
| 650kHz | bw_650kHz |
254280
| 812kHz | bw_812kHz |
255281

256-
`void setSymbolRate(double symbolRate)` Data transmission rate in baud. Value from 20 to 1621830 Default is 115051 Baud. Must match on sender and receiver.
282+
`void setSymbolRate(double symbolRate)` Data transmission rate in baud. Value from 20 to 1621830 Default is 115051 Baud.
283+
> [!IMPORTANT]
284+
> Must match on sender and receiver.
285+
286+
> [!NOTE]
287+
> The effective symbol rates are quantized, the function will set it to the next possible lower value.
257288
258-
`void setSyncMode(sync_Mode syncm)` Combined sync-word qualifier mode.
289+
`void setSyncMode(sync_Mode syncm)` Combined sync-word qualifier mode. The hardware supports carrier sense with abolute and relative thresholds as well, but this is not implemented.
290+
>[!IMPORTANT]
291+
> `sync_3032` enables duplicate transmission of the sync word in TX. This must match the setting in RX, so chose `sync_3032` here as well.
292+
259293
| Value | Sync-Mode |
260294
|------------|-------|
261295
| sync_NONE | No preamble/sync |
262296
| sync_1516 | 15/16 sync word bits detected |
263297
| sync_1616 | 16/16 sync word bits detected (default)|
264298
| sync_3032 | 30/32 sync word bits detected |
265-
| sync_NONECS | No preamble/sync, carrier-sense above threshold |
266-
| sync_1516CS | 15/16 + carrier-sense above threshold |
267-
| sync_1616CS | 16/16 + carrier-sense above threshold |
268-
| sync_3032CS | 30/32 + carrier-sense above threshold |
269299

270-
`void setSyncWord(uint8_t sh, uint8_t sl)` If sync-word detection is enabled via setSyncMode,the CC1101 will not start filling the RX FIFO unless a valid sync word is detected.
300+
`void setSyncWord(uint8_t sh, uint8_t sl)` If sync-word detection is enabled via setSyncMode,the **CC1101** will not start filling the RX FIFO unless a valid sync word is detected.
301+
> [!IMPORTANT]
302+
> Must match on sender and receiver.
271303
272-
`void setWhiteData(bool white)` Enable data whitening. Defaults to `false`. Must match on sender and receiver.
304+
`void setWhiteData(bool white)` Enable data whitening. Defaults to `false`.
305+
> [!IMPORTANT]
306+
> Must match on sender and receiver.
273307
274-
`void sleep(void)` Sets the CC1101 to sleep mode, reducing power consumption. The next access will wake the chip up again, no special procedure is needed.
308+
`void sleep(void)` Sets the **CC1101** to sleep mode, reducing power consumption. The next access will wake the chip up again, no special procedure is needed.
275309

276310

0 commit comments

Comments
 (0)