From 5fcf02af5a195a52e747c31ddf775030448132b9 Mon Sep 17 00:00:00 2001 From: Dattel Date: Tue, 10 Jan 2023 20:13:06 +0100 Subject: [PATCH] Small fix on BME280 Config & CC1101-TXPower Throttle (#1382) * https://github.com/1technophile/OpenMQTTGateway/issues/1380 CC1101 TXPower selection * Creates the possability the define SDA/SCL Pins correct through a compiler switch from the platformio.ini Sample: '-DBME280_PIN_SDA=0' '-DBME280_PIN_SCL=2' --- docs/use/rf.md | 20 ++++++++++++++------ main/ZgatewayRF.ino | 5 +++++ main/config_BME280.h | 8 ++++++-- main/config_RF.h | 6 ++++++ 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/docs/use/rf.md b/docs/use/rf.md index 047037c..0b924aa 100644 --- a/docs/use/rf.md +++ b/docs/use/rf.md @@ -74,16 +74,17 @@ Arduino IDE serial data received when receiving data by 433Mhz ### Send data by MQTT with advanced RF parameters -RF sending support three advanced parameters; bits length, RF protocol and RF pulselength -if you want to use a different RCswitch protocol put inside your payload the protocol number 2, "protocol":2. +RF sending support three advanced parameters: bits length, RF protocol and RF pulselength -if you want to use a pulselength 315 put inside your topic "delay":315 +-if you want to use a bits number different than 24 put inside your topic "length":24 for example -if you want to use a bits number different than 24 put inside your topic "length":24 for example +-if you want to use a different RCswitch protocol put inside your payload the protocol number 2, "protocol":2. + +-if you want to use a pulselength 315 put inside your topic "delay":315 Example: `mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTto433" -m '{"value":1315156,"protocol":2,"length":24,"delay":315}'` -will make RCSwitch use the protocol 2 with a pulselength of 315ms and a bits number of 24 +will make RCSwitch use the protocol 2 with a pulselength of 315ms and a bits number of 24 with a power of 5 ### Repeat the RF signal OpenMQTTGateway receive So as to repeat the RF signal received by the gateway once set the following parameter to true in config_RF.h @@ -96,7 +97,7 @@ You can add a "repeat" key/value to the MQTTto433 JSON message to override the d Example: `home/OpenMQTTGateway/commands/MQTTto433 {"value":1315156,"protocol":1,"length":24,"delay":317, "repeat":10}` -### Set Transmit and Receive Frequency of CC1101 Transceiver Module +### Set Transmit and Receive Frequency and Transmit Power of CC1101 Transceiver 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. @@ -110,6 +111,13 @@ Messages received will include the frequency, and when transmitting on a differe `{"value":4534142,"protocol":6,"length":26,"delay":356,"mhz":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. +If you want to send a transmission with a power of 5 db than use the message + +`{"value":1315156,"protocol":2,"length":24,"delay":315, "cc1101_pa":5}` + + ## Pilight gateway ### Receiving data from RF signal diff --git a/main/ZgatewayRF.ino b/main/ZgatewayRF.ino index 9541123..7a18e21 100644 --- a/main/ZgatewayRF.ino +++ b/main/ZgatewayRF.ino @@ -184,6 +184,7 @@ void MQTTtoRF(char* topicOri, char* datacallback) { # ifdef ZradioCC1101 // set Receive off and Transmitt on disableActiveReceiver(); ELECHOUSE_cc1101.SetTx(receiveMhz); + Log.notice(F("Transmit mhz: %F" CR), receiveMhz); # endif mySwitch.disableReceive(); mySwitch.enableTransmit(RF_EMITTER_GPIO); @@ -256,6 +257,10 @@ void MQTTtoRF(char* topicOri, JsonObject& RFdata) { // json object decoding Log.notice(F("RF Pulse Lgth: %d" CR), valuePLSL); Log.notice(F("Bits nb: %d" CR), valueBITS); # ifdef ZradioCC1101 // set Receive off and Transmitt on + int txPower = RFdata["txpower"] | RF_CC1101_TXPOWER; + ELECHOUSE_cc1101.setPA((int)txPower); + Log.notice(F("CC1101 TX Power: %d" CR), txPower); + float trMhz = RFdata["mhz"] | CC1101_FREQUENCY; if (validFrequency((int)trMhz)) { disableActiveReceiver(); diff --git a/main/config_BME280.h b/main/config_BME280.h index 24df8eb..5ddb723 100644 --- a/main/config_BME280.h +++ b/main/config_BME280.h @@ -58,8 +58,12 @@ unsigned long timebme280 = 0; int BME280_i2c_addr = 0x76; // Bosch BME280 I2C Address // Only supported for ESP -int BME280_PIN_SDA = SDA; // PIN SDA -int BME280_PIN_SCL = SCL; // PIN SCL +#ifndef BME280_PIN_SDA +# define BME280_PIN_SDA SDA +#endif +#ifndef BME280_PIN_SCL +# define BME280_PIN_SCL SCL +#endif // Oversampling for BME280/BMP280 devices diff --git a/main/config_RF.h b/main/config_RF.h index 34b0a80..f563fcf 100644 --- a/main/config_RF.h +++ b/main/config_RF.h @@ -175,6 +175,12 @@ const char parameters[39][3][16] = { #if defined(ZradioCC1101) || defined(ZradioSX127x) float receiveMhz = CC1101_FREQUENCY; #endif +/*-------------------CC1101 DefaultTXPower----------------------*/ +//Adjust the default TX-Power for sending radio if ZradioCC1101 is used. +//The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! +#ifndef RF_CC1101_TXPOWER +# define RF_CC1101_TXPOWER 12 +#endif /*-------------------PIN DEFINITIONS----------------------*/ #ifndef RF_RECEIVER_GPIO