Skip to content

Commit 05cef93

Browse files
swoboda1337claudebdraco
committed
[cc1101] Add packet mode documentation (#5776)
* [cc1101] Add packet mode documentation - Document new packet mode with FIFO buffering, sync word detection, and CRC - Add on_packet trigger and cc1101.send_packet action - Document missing config options: sync_mode, sync0, sync1, num_preamble, manchester - Document automatic pin mode switching in begin_tx/begin_rx - Add CRC troubleshooting section - Simplify single-pin wiring examples 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Clean * Clean * [cc1101] Add on_packet trigger section * Clean * Clean * Clean * Update content/components/cc1101.md Co-authored-by: J. Nick Koston <nick+github@koston.org> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: J. Nick Koston <nick+github@koston.org>
1 parent 8eba62a commit 05cef93

File tree

1 file changed

+101
-39
lines changed

1 file changed

+101
-39
lines changed

content/components/cc1101.md

Lines changed: 101 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ chip commonly used for wireless communication in the 300-928 MHz frequency bands
1212

1313
The **CC1101** supports multiple modulation schemes (ASK/OOK, 2-FSK, 4-FSK, GFSK, MSK), configurable data
1414
rates from 600 to 500,000 baud, and adjustable output power from -30 dBm to +11 dBm. It connects to
15-
ESPHome via the [SPI Bus](/components/spi) and integrates with the
16-
[Remote Transmitter](/components/remote_transmitter) and
17-
[Remote Receiver](/components/remote_receiver) components for encoding and decoding RF protocols.
15+
ESPHome via the [SPI Bus](/components/spi).
16+
17+
The component supports two operating modes:
18+
19+
- **Async Mode** (default): Integrates with the [Remote Transmitter](/components/remote_transmitter)
20+
and [Remote Receiver](/components/remote_receiver) components for encoding and decoding RF protocols.
21+
- **Packet Mode**: Built-in packet handling with sync word detection, CRC, and the `on_packet` trigger.
22+
Best for FSK/GFSK modulation when communicating with other packet-based radios.
1823

1924
{{< img src="cc1101-full.webp" alt="CC1101 Module" width="50.0%" class="align-center" >}}
2025

@@ -33,6 +38,8 @@ cc1101:
3338
3439
- **cs_pin** (**Required**, [Pin](/guides/configuration-types/#pin)):
3540
The SPI Chip Select (CSN) pin connected to the module.
41+
- **gdo0_pin** (*Optional*, [Pin](/guides/configuration-types/#pin)):
42+
The GDO0 pin. Required when `packet_mode` is enabled, also used for single pin mode switching.
3643

3744
### General Settings
3845

@@ -47,6 +54,7 @@ cc1101:
4754
- **rx_attenuation** (*Optional*, enum): Internal RX attenuation.
4855
Options: `0dB`, `6dB`, `12dB`, `18dB`. Defaults to `0dB`.
4956
- **dc_blocking_filter** (*Optional*, boolean): Enable the digital DC blocking filter. Defaults to `true`.
57+
- **manchester** (*Optional*, boolean): Enable Manchester encoding. Defaults to `false`.
5058

5159
### Tuner Settings
5260

@@ -60,8 +68,25 @@ cc1101:
6068
Range: `25kHz` to `405kHz`. Defaults to `200kHz`.
6169
- **if_frequency** (*Optional*, frequency): Intermediate Frequency.
6270
Range: `25kHz` to `788kHz`. Defaults to `153kHz`.
63-
- **pktlen** (*Optional*, int): Packet length configuration. Sets the expected packet size for
64-
fixed-length packet mode. Range: `1` to `255`. Not typically needed for OOK/ASK modulation.
71+
72+
### Packet Mode Settings
73+
74+
These settings enable the CC1101's built-in packet handling with FIFO buffering, sync word detection,
75+
and optional CRC checking.
76+
77+
- **packet_mode** (*Optional*, boolean): Enable FIFO packet mode. When enabled, `gdo0_pin` is
78+
required. Defaults to `false`.
79+
- **packet_length** (*Optional*, int): Packet length in bytes. Set to `0` for variable length packets
80+
(length byte prepended to data). Range: `0` to `64`. Defaults to `0`.
81+
- **crc_enable** (*Optional*, boolean): Enable CRC-16 calculation and checking. The CC1101 uses
82+
CRC-16-IBM (polynomial 0x8005). Defaults to `false`.
83+
- **whitening** (*Optional*, boolean): Enable data whitening to improve DC balance. Defaults to `false`.
84+
- **sync_mode** (*Optional*, enum): Sync word detection mode.
85+
Options: `None`, `15/16`, `16/16`, `30/32`. Defaults to `16/16`.
86+
- **sync0** (*Optional*, hex): Lower sync word byte. Defaults to `0x91`.
87+
- **sync1** (*Optional*, hex): Upper sync word byte. Defaults to `0xD3`.
88+
- **num_preamble** (*Optional*, int): Number of preamble bytes to transmit.
89+
Range: `0` to `7` (maps to 2, 3, 4, 6, 8, 12, 16, 24 bytes). Defaults to `2` (4 bytes).
6590

6691
### AGC (Automatic Gain Control) Settings
6792

@@ -79,8 +104,10 @@ See the [CC1101 Datasheet](https://www.ti.com/lit/ds/symlink/cc1101.pdf) for det
79104
Options: `Default`, `-1`, `-2`, `-3`. Defaults to `-3`.
80105
- **lna_priority** (*Optional*, boolean): If true, reduce LNA gain before DVGA gain when decreasing
81106
overall gain. Useful for optimizing noise figure. Defaults to `false`.
107+
- **carrier_sense_above_threshold** (*Optional*, boolean): Only accept packets when carrier sense
108+
indicates a signal is present. Defaults to `false`.
82109
- **carrier_sense_abs_thr** (*Optional*, int): Absolute RSSI threshold for carrier sense. The radio
83-
considers a carrier present when RSSI exceeds this level.
110+
considers a carrier present when RSSI exceeds this level. Range: `-8` to `7`.
84111
- **carrier_sense_rel_thr** (*Optional*, enum): Relative RSSI threshold for carrier sense, compared
85112
to the current noise floor. Options: `Default`, `+6dB`, `+10dB`, `+14dB`.
86113
- **filter_length_fsk_msk** (*Optional*, enum): Averaging length for AGC in FSK/MSK modes.
@@ -94,20 +121,67 @@ See the [CC1101 Datasheet](https://www.ti.com/lit/ds/symlink/cc1101.pdf) for det
94121
- **hyst_level** (*Optional*, enum): Hysteresis level to prevent gain oscillation on borderline signals.
95122
Options: `None`, `Low`, `Medium`, `High`.
96123

124+
## Triggers
125+
126+
### `on_packet` Trigger
127+
128+
In packet mode, this trigger fires when a packet has been received. A variable `x` of type
129+
`std::vector<uint8_t>` containing the packet data is passed to the automation. The variables
130+
`rssi` (signal strength in dBm) and `lqi` (link quality indicator, 0-127, lower is better)
131+
are also available.
132+
133+
```yaml
134+
cc1101:
135+
cs_pin: GPIOXX
136+
gdo0_pin: GPIOXX
137+
frequency: 433.92MHz
138+
modulation_type: GFSK
139+
symbol_rate: 4800
140+
packet_mode: true
141+
packet_length: 8
142+
on_packet:
143+
then:
144+
- lambda: |-
145+
ESP_LOGD("cc1101", "packet %s rssi %.1f dBm lqi %u", format_hex(x).c_str(), rssi, lqi);
146+
```
147+
97148
## Actions
98149

99-
This component provides actions to control the radio state, primarily used for coordinating transmission.
150+
### `cc1101.begin_tx` Action
151+
152+
This [action](/automations/actions#all-actions) puts the radio into TX mode and switches `gdo0_pin` to output mode.
153+
154+
### `cc1101.begin_rx` Action
100155

101-
- **cc1101.begin_tx**: Puts the radio into TX mode. Must be called before transmitting.
102-
- **cc1101.begin_rx**: Puts the radio into RX mode. Call after transmitting to resume receiving.
103-
- **cc1101.set_idle**: Puts the radio into an idle state. In single-pin configurations, this should be
104-
called before switching between TX and RX modes to ensure clean state transitions.
105-
- **cc1101.reset**: Resets the CC1101 chip and re-applies configuration.
156+
This [action](/automations/actions#all-actions) puts the radio into RX mode and switches `gdo0_pin` to input mode.
157+
158+
### `cc1101.set_idle` Action
159+
160+
This [action](/automations/actions#all-actions) puts the radio into an idle state.
161+
162+
### `cc1101.reset` Action
163+
164+
This [action](/automations/actions#all-actions) resets the CC1101 chip and re-applies configuration.
165+
166+
### `cc1101.send_packet` Action
167+
168+
This [action](/automations/actions#all-actions) transmits a packet. Only available when `packet_mode` is enabled.
169+
170+
#### Configuration variables
171+
172+
- **data** (**Required**, list): The packet to send, length should match the configured `packet_length`.
173+
174+
```yaml
175+
on_...:
176+
- cc1101.send_packet:
177+
data: [0x12, 0x34, 0x56, 0x78]
178+
```
106179

107180
## Integration with Remote Receiver/Transmitter
108181

109-
The component automatically configures the GDO pins to support both dual and single pin wiring schemes
110-
without any extra configuration.
182+
For ASK/OOK modulation, the CC1101 integrates with Remote Receiver/Transmitter for protocol encoding
183+
and decoding. The component automatically configures the GDO pins to support both dual and single pin
184+
wiring schemes.
111185

112186
### 1. Dual Pin Wiring (Recommended)
113187

@@ -121,7 +195,7 @@ cc1101:
121195
cs_pin: GPIOXX
122196
123197
remote_transmitter:
124-
pin: GPIOXX # Must match GDO0
198+
pin: GPIOXX # Must match GDO0
125199
carrier_duty_percent: 100%
126200
on_transmit:
127201
then:
@@ -131,15 +205,14 @@ remote_transmitter:
131205
- cc1101.begin_rx
132206
133207
remote_receiver:
134-
pin: GPIOXX # CC1101 GDO2
208+
pin: GPIOXX # Must match GDO2
135209
dump: all
136210
```
137211

138212
### 2. Single Pin Wiring
139213

140214
This wiring scheme uses a single MCU pin for both transmitting and receiving data, connected to GDO0.
141215
This requires careful configuration of the `remote_transmitter` and `remote_receiver` to avoid conflicts.
142-
Using an open-drain pin mode is recommended to simplify the setup.
143216

144217
- **GDO0 (Module Pin 3)**: Connect to a single MCU GPIO pin.
145218
- **GDO2 (Module Pin 8)**: Leave disconnected.
@@ -155,10 +228,11 @@ before `begin_rx`.
155228
```yaml
156229
cc1101:
157230
cs_pin: GPIOXX
231+
gdo0_pin: GPIOXX
158232
159233
remote_receiver:
160234
pin:
161-
number: GPIOXX # Must match GDO0
235+
number: GPIOXX # Must match GDO0
162236
mode:
163237
input: true
164238
output: true
@@ -169,7 +243,7 @@ remote_receiver:
169243
170244
remote_transmitter:
171245
pin:
172-
number: GPIOXX # Must match GDO0
246+
number: GPIOXX # Must match GDO0
173247
mode:
174248
input: true
175249
output: true
@@ -190,43 +264,32 @@ remote_transmitter:
190264
- cc1101.begin_rx
191265
```
192266

193-
#### Single Pin with Mode Switching
267+
#### Single Pin with Automatic Mode Switching
194268

195-
This method requires lambdas to manually switch the pin mode between input and output around transmissions.
196-
On boot, the pin must be set to input mode so the receiver can operate.
269+
When `gdo0_pin` is configured, `begin_tx` and `begin_rx` automatically switch the pin between output
270+
and input modes, simplifying the configuration.
197271

198272
```yaml
199-
esphome:
200-
on_boot:
201-
- priority: 0
202-
then:
203-
- lambda: id(rx_pin)->pin_mode(gpio::FLAG_INPUT);
204-
205273
cc1101:
206274
cs_pin: GPIOXX
275+
gdo0_pin: GPIOXX
207276
208277
remote_receiver:
209278
pin:
210-
id: rx_pin
211-
number: GPIOXX # Must match GDO0
279+
number: GPIOXX # Must match GDO0
212280
allow_other_uses: true
213281
dump: all
214282
215283
remote_transmitter:
216284
pin:
217-
id: tx_pin
218-
number: GPIOXX # Must match GDO0
285+
number: GPIOXX # Must match GDO0
219286
allow_other_uses: true
220287
carrier_duty_percent: 100%
221288
on_transmit:
222289
then:
223-
- cc1101.set_idle
224-
- lambda: id(tx_pin)->pin_mode(gpio::FLAG_OUTPUT);
225290
- cc1101.begin_tx
226291
on_complete:
227292
then:
228-
- cc1101.set_idle
229-
- lambda: id(rx_pin)->pin_mode(gpio::FLAG_INPUT);
230293
- cc1101.begin_rx
231294
```
232295

@@ -237,12 +300,11 @@ remote_transmitter:
237300
If you see a log entry stating `FF0F`, `0000`, or `FFFF` during setup, this indicates an SPI
238301
communication failure. Check your wiring (MISO/MOSI/CS).
239302

240-
### No Signal during Transmit
303+
### No Signal During Transmit
241304

242305
- **Check Pinout**: For all modes, the data line must be connected to GDO0 (Module Pin 3),
243306
as the CC1101 chip only supports transmission input via the GDO0 pin.
244-
- **Check Pin Mode**: If using the Single Pin with Mode Switching method,
245-
ensure your `on_transmit`/`on_complete` logic correctly flips the pin mode.
307+
- **Check Pin Mode**: Ensure `gdo0_pin` is configured for automatic pin mode switching.
246308

247309
## See Also
248310

0 commit comments

Comments
 (0)