Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RTL_433][BREAKING] Beta support for FSK modulation, webUI frequency and active receiver change #1812

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ jobs:
- "esp32dev-rtl_433"
- "esp32doitv1-aithinker-r01-sx1278"
- "heltec-rtl_433"
- "heltec-rtl_433-fsk"
- "heltec-ble"
- "lilygo-rtl_433"
- "lilygo-rtl_433-fsk"
- "lilygo-ble"
- "esp32dev-multi_receiver"
- "esp32dev-multi_receiver-pilight"
Expand Down
85 changes: 37 additions & 48 deletions docs/use/rf.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,34 @@ OpenMQTTGateway leverages several libraries for RF communication:
RTL_433 library can only receive data, RCSwitch, PiLight, RF2 can receive and transmit.
:::

## Common parameters accross modules

### Change default frequency (SX127X and CC1101)

The frequency can be can changed by sending an MQTT message or through the WebUI. Parameter is `frequency` and valid values are 300-348 Mhz, 387-464Mhz and 779-928Mhz. Actual frequency support will depend on your board

`home/OpenMQTTGateway/commands/MQTTtoRF/config {"frequency":315.026}`

Note that with CC1101 this frequency will be used as the default sending frequency.

### Changing Active Receiver Modules

Switching of the active transceiver (RTL_433 receiver only) module is available between the RF, RF2, and (RTL_433 or Pilight) gateway modules, allowing for changing of signal decoders without redeploying the OpenMQTTGateway package. Sending a JSON message to the command topic will change the active transceiver module.

To enable the RF gateway module send a json message to the RF gateway module command subject with the key being 'active', and any value. The value at this time is ignored.

1 - PiLight
2 - RF
3 - RTL_433
4 - RF2

Example to receive from the RF gateway:
`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoRF/config" -m '{"active":2}'`

The active receiver can also be changed with the WebUI.

The OpenMQTTGateway RFtoMQTT status message contains a key `active` which is the current active receiver module.

## RTL_433 device decoders

This feature is only available on a ESP32 based device with a supported transceiver connected due to the resource requirements of the rtl_433 device decoders. At the present time only Pulse Position Modulation (OOK_PPM), Pulse Width Modulation (OOK_PWM) and Pulse Manchester Zero Bit (OOK_PULSE_MANCHESTER_ZEROBIT) based decoders are available.
Expand Down Expand Up @@ -122,21 +150,15 @@ Registering protocol [101] "X10 RF"
Registering protocol [102] "X10 Security"
```

### Change receive frequency

Default receive frequency of the module is 433.92 Mhz, and this can be can changed by sending a message with the frequency. Parameter is `mhz` and valid values are 300-348 Mhz, 387-464Mhz and 779-928Mhz. Actual frequency support will depend on your board

`home/OpenMQTTGateway/commands/MQTTtoRTL_433 {"mhz":315.026}`

### Change Signal RSSI Threshold Delta

Delta applied to RSSI floor noise level to determine start and end of signal, defaults to 9db.

`home/OpenMQTTGateway/commands/MQTTtoRTL_433 {"rssi": 9}`
`home/OpenMQTTGateway/commands/MQTTtoRF/config {"rssiThreshold": 9}`

### Retrieve current status of receiver

`home/OpenMQTTGateway/commands/MQTTtoRTL_433 {"status":1}`
`home/OpenMQTTGateway/commands/MQTTtoRF/config {"status":1}`

```
{"model":"status",
Expand All @@ -159,42 +181,6 @@ Delta applied to RSSI floor noise level to determine start and end of signal, de
"freeMem":112880} - ESP32 memory available
```


## Changing Active Receiver Modules

### Switching Active Receiver Module

Switching of the active transceiver (RTL_433 receiver only) module is available between the RF, RF2, RTL_433 and Pilight gateway modules, allowing for changing of signal decoders without redeploying the openMQTTGateway package. Sending a JSON message to the command topic of the desired receiver will change the active transceiver module.

To enable the RF gateway module send a json message to the RF gateway module command subject with the key being 'active', and any value. The value at this time is ignored.

Example:
`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTto433" -m '{"active":true}'`

To enable the PiLight gateway module send a json message to the PiLight gateway module command subject with the key being 'active', and any value. The value at this time is ignored.

Example:
`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoPilight" -m '{"active":true}'`

To enable the RF2 gateway module send a json message to the RF2 gateway module command subject with the key being 'active', and any value. The value at this time is ignored.

Example:
`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoRF2" -m '{"active":true}'`

To enable the RTL_433 gateway module send a json message to the RTL_433 gateway module command subject with the key being 'active', and any value. The value at this time is ignored.

Example:
`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoRTL_433" -m '{"active":true}'`

### Status Messages

The openMQTTGateway status message contains a key `actRec` which is the current active receiver module.

1 - PiLight
2 - RF
3 - RTL_433
4 - RF2

## RCSwitch based gateway

### Receiving data from RF signal
Expand Down Expand Up @@ -258,15 +244,15 @@ Example:

Default transmit frequency of the CC1101 module is 433.92 Mhz, and this can be can changed by including the frequency in the transmit message. Parameter is `mhz` and valid values are 300-348 Mhz, 387-464Mhz and 779-928Mhz. Actual frequency support will depend on your CC1101 board.

`home/OpenMQTTGateway/commands/MQTTto433 {"value":1150,"protocol":6,"length":12,"delay":450,"repeat":8,"mhz":303.732}`
`home/OpenMQTTGateway/commands/MQTTto433 {"value":1150,"protocol":6,"length":12,"delay":450,"repeat":8,"frequency":303.732}`

Default receive frequency of the CC1101 module is 433.92 Mhz, and this can be can changed by sending a message with the frequency. Parameter is `mhz` and valid values are 300-348 Mhz, 387-464Mhz and 779-928Mhz. Actual frequency support will depend on your CC1101 board
Default receive frequency of the CC1101 module is 433.92 Mhz, and this can be can changed by sending a message with the frequency. Parameter is `frequency` and valid values are 300-348 Mhz, 387-464Mhz and 779-928Mhz. Actual frequency support will depend on your CC1101 board

`home/OpenMQTTGateway/commands/MQTTto433 {"mhz":315.026}`
`home/OpenMQTTGateway/commands/MQTTtoRF/config {"frequency":433.92}`

Messages received will include the frequency, and when transmitting on a different frequency the module return to the receive frequency afterwards. ie transmit messages on 303.732 Mhz then receive messages on 433.92 Mhz

`{"value":4534142,"protocol":6,"length":26,"delay":356,"mhz":315.026}`
`{"value":4534142,"protocol":6,"length":26,"delay":356,"frequency":315.026}`

You can adjust the tx-power in db for a transmission. Parameter is `cc1101_pa` and valid values in decibel are (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!
That can be done to reduce range and therefore disturbances with other nearby devices.
Expand Down Expand Up @@ -339,6 +325,9 @@ To list the enabled protocols on the Serial -

These commands will transmit by RF the signals to actuate an elro_400 switch.

With a different frequency (CC1101 only):
`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoPilight" -m '{"message":"{\"systemcode\":12,\"unitcode\":22,\"off\":1}","protocol":"elro_400_switch","frequency":315.026}'`

#### Using a raw signal
You can transmit raw signal data by using the "raw" protocol. This uses the Pilight pulse train string format. One such example string, representing a transmission for Nexus protocol weather stations, looks like this: `c:03020202010102020102010101010101010202020201020102020202020101010201010202;p:500,1000,2000,4000;r:12@`. This string represents pulses and gaps directly.

Expand Down
76 changes: 70 additions & 6 deletions environments.ini
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ custom_description = RF gateway using ESPilight library
[env:esp32dev-pilight-cc1101]
platform = ${com.esp32_platform}
board = esp32dev
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
${libraries.esppilight}
Expand Down Expand Up @@ -653,7 +654,6 @@ build_flags =
; *** OpenMQTTGateway Config ***
;'-UZmqttDiscovery' ; disables MQTT Discovery
'-DvalueAsATopic=true' ; MQTT topic includes model and device
'-DLOG_LEVEL=LOG_LEVEL_TRACE'
'-DGateway_Name="OMG_rtl_433_ESP"'
; *** OpenMQTTGateway Modules ***
'-DZgatewayRTL_433="rtl_433"'
Expand Down Expand Up @@ -728,6 +728,7 @@ board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
${libraries.rtl_433_ESP}
${libraries.smartrc-cc1101-driver-lib}
build_flags =
${com-esp32.build_flags}
; *** OpenMQTTGateway Config ***
Expand Down Expand Up @@ -787,6 +788,40 @@ build_flags =
; '-DDISPLAY_BRIGHTNESS=80'
; '-DDISPLAY_METRIC=false'
custom_description = Gateway using RTL_433_ESP and RadioLib
custom_hardware = ESP32 HELTEC LORA32 V2

[env:heltec-rtl_433-fsk]
platform = ${com.esp32_platform}
board = heltec_wifi_lora_32_V2
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
${libraries.ssd1306}
${libraries.rtl_433_ESP}
build_flags =
${com-esp32.build_flags}
; *** OpenMQTTGateway Config ***
;'-UZmqttDiscovery' ; disables MQTT Discovery
'-DvalueAsATopic=true' ; MQTT topic includes model and device
'-DGateway_Name="OMG_heltec_rtl_433_ESP"'
'-DOOK_MODULATION=false' ; FSK modulation activated
'-DRF_FREQUENCY=915'
;-DRF_FREQUENCY=868.300'
;-DRF_FREQUENCY=433.9'
; *** OpenMQTTGateway Modules ***
'-DZgatewayRTL_433="rtl_433"'
'-DZradioSX127x="SX127x"'
; *** ssd1306 Display Options ***
'-DZdisplaySSD1306="HELTEC_SSD1306"'
; '-DLOG_TO_OLED=false' ; Enable log to OLED
; '-DJSON_TO_OLED=true'
; '-DLOG_LEVEL_OLED=LOG_LEVEL_NOTICE'
; '-DDISPLAY_IDLE_LOGO=false'
; '-DDISPLAY_BRIGHTNESS=80'
; '-DDISPLAY_METRIC=false'
custom_description = Gateway using RTL_433_ESP and RadioLib with FSK modulation (beta)
custom_hardware = ESP32 HELTEC LORA32 V2

[env:heltec-ble]
platform = ${com.esp32_platform}
Expand All @@ -810,6 +845,7 @@ build_flags =
; '-DDISPLAY_BRIGHTNESS=80'
; '-DDISPLAY_METRIC=false'
custom_description = Heltec BLE gateway with adaptive scanning activated, automatically adapts the scan parameters depending on your devices
custom_hardware = ESP32 HELTEC LORA32 V2

[env:lilygo-rtl_433]
platform = ${com.esp32_platform}
Expand Down Expand Up @@ -840,6 +876,39 @@ build_flags =
custom_description = For ESP32, Gateway using RTL_433_ESP and RadioLib
custom_hardware = ESP32 LILYGO LoRa32 V2.1

[env:lilygo-rtl_433-fsk]
platform = ${com.esp32_platform}
board = ttgo-lora32-v21
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
${libraries.ssd1306}
${libraries.rtl_433_ESP}
build_flags =
${com-esp32.build_flags}
; *** OpenMQTTGateway Config ***
;'-UZmqttDiscovery' ; disables MQTT Discovery
'-DvalueAsATopic=true' ; MQTT topic includes model and device
'-DGateway_Name="OMG_lilygo_rtl_433_ESP"'
'-DOOK_MODULATION=false' ; FSK modulation activated
'-DRF_FREQUENCY=915'
;-DRF_FREQUENCY=868.300'
;-DRF_FREQUENCY=433.9'
; *** OpenMQTTGateway Modules ***
'-DZgatewayRTL_433="rtl_433"'
'-DZradioSX127x="SX127x"'
; *** ssd1306 Display Options ***
'-DZdisplaySSD1306="LilyGo_SSD1306"'
; '-DLOG_TO_OLED=true' ; Enable log to OLED
; '-DJSON_TO_OLED=true'
; '-DLOG_LEVEL_OLED=LOG_LEVEL_NOTICE'
; '-DDISPLAY_IDLE_LOGO=false'
; '-DDISPLAY_BRIGHTNESS=80'
; '-DDISPLAY_METRIC=false'
custom_description = For ESP32, Gateway using RTL_433_ESP and RadioLib with FSK modulation (beta)
custom_hardware = ESP32 LILYGO LoRa32 V2.1

[env:lilygo-ble]
platform = ${com.esp32_platform}
board = ttgo-lora32-v21
Expand Down Expand Up @@ -873,7 +942,6 @@ lib_deps =
${libraries.rc-switch}
${libraries.smartrc-cc1101-driver-lib}
${libraries.rtl_433_ESP}
${libraries.esppilight}
${libraries.newremoteswitch}
build_flags =
${com-esp32.build_flags}
Expand All @@ -883,7 +951,6 @@ build_flags =
'-DZradioCC1101="CC1101"'
'-DGateway_Name="OMG_multi_receiver"'
'-DvalueAsATopic=true' ; MQTT topic includes model and device (rtl_433) or protocol and id (RF and PiLight)
; '-DDEFAULT_RECEIVER=1' ; Default receiver to enable on startup
; *** RF Module Options ***
'-DRF_CC1101="CC1101"' ; CC1101 Transceiver Module
'-DRF_MODULE_CS=5' ; pin to be used as chip select
Expand All @@ -900,7 +967,6 @@ lib_deps =
${com-esp32.lib_deps}
${libraries.rc-switch}
${libraries.smartrc-cc1101-driver-lib}
${libraries.rtl_433_ESP}
${libraries.esppilight}
${libraries.newremoteswitch}
build_flags =
Expand All @@ -911,7 +977,6 @@ build_flags =
'-DZradioCC1101="CC1101"'
'-DGateway_Name="OMG_multi_receiver"'
'-DvalueAsATopic=true' ; MQTT topic includes model and device (rtl_433) or protocol and id (RF and PiLight)
; '-DDEFAULT_RECEIVER=1' ; Default receiver to enable on startup
; *** RF Module Options ***
'-DRF_CC1101="CC1101"' ; CC1101 Transceiver Module
'-DRF_MODULE_CS=5' ; pin to be used as chip select
Expand All @@ -920,7 +985,6 @@ build_flags =
; '-DRF_MODULE_INIT_STATUS=true' ; Display transceiver config during startup
custom_description = Multi RF library with the possibility to switch between ESPilight, NewRemoteSwitch and RCSwitch, need CC1101


[env:tinypico-ble]
platform = ${com.esp32_platform}
board = tinypico
Expand Down
17 changes: 8 additions & 9 deletions main/ZactuatorSomfy.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
# endif

void setupSomfy() {
# ifdef ZradioCC1101 //using with CC1101
ELECHOUSE_cc1101.Init();
# endif
pinMode(RF_EMITTER_GPIO, OUTPUT);
digitalWrite(RF_EMITTER_GPIO, LOW);

Expand All @@ -54,10 +51,13 @@ void setupSomfy() {
# if jsonReceiving
void MQTTtoSomfy(char* topicOri, JsonObject& jsonData) {
if (cmpToMainTopic(topicOri, subjectMQTTtoSomfy)) {
# ifdef ZradioCC1101
ELECHOUSE_cc1101.SetTx(CC1101_FREQUENCY_SOMFY);
# endif
Log.trace(F("MQTTtoSomfy json data analysis" CR));
float txFrequency = jsonData["frequency"] | RFConfig.frequency;
# ifdef ZradioCC1101 // set Receive off and Transmitt on
disableCurrentReceiver();
ELECHOUSE_cc1101.SetTx(txFrequency);
Log.notice(F("Transmit frequency: %F" CR), txFrequency);
# endif

const int remoteIndex = jsonData["remote"];
if (remoteIndex >= SOMFY_REMOTE_NUM) {
Expand All @@ -72,9 +72,8 @@ void MQTTtoSomfy(char* topicOri, JsonObject& jsonData) {
EEPROMRollingCodeStorage rollingCodeStorage(EEPROM_ADDRESS_START + remoteIndex * 2);
SomfyRemote somfyRemote(RF_EMITTER_GPIO, somfyRemotes[remoteIndex], &rollingCodeStorage);
somfyRemote.sendCommand(command, repeat);
# ifdef ZradioCC1101
ELECHOUSE_cc1101.SetRx(receiveMhz); // set Receive on
# endif
initCC1101();
enableActiveReceiver();
}
}
# endif
Expand Down
Loading