CC1101 433.92MHz support for pilight, rf and rf2 (#585)
* adds CC1101 (433mhz) support esp32 and esp8266
This commit is contained in:
1 parent
1385ddfa8d
commit
ac743ed350
7 files changed
+137
-3
No files matched your search
+11
-1
@@ -6,6 +6,7 @@
|
||||
|STX882 (recommended)|433Mhz Transmitter|[compatible parts list](https://docs.google.com/spreadsheets/d/1_5fQjAixzRtepkykmL-3uN3G5bLfQ0zMajM9OBZ1bx0/edit#gid=1323184277)|
|
||||
|XD RF 5V|433Mhz Receiver|[compatible parts list](https://docs.google.com/spreadsheets/d/1_5fQjAixzRtepkykmL-3uN3G5bLfQ0zMajM9OBZ1bx0/edit#gid=1323184277)|
|
||||
|FS1000A|433Mhz Transmitter|[compatible parts list](https://docs.google.com/spreadsheets/d/1_5fQjAixzRtepkykmL-3uN3G5bLfQ0zMajM9OBZ1bx0/edit#gid=1323184277)|
|
||||
|CC1101|433Mhz Transceiver|[compatible parts list](https://docs.google.com/spreadsheets/d/1_5fQjAixzRtepkykmL-3uN3G5bLfQ0zMajM9OBZ1bx0/edit#gid=1323184277)|
|
||||
|
||||
## Pinout
|
||||
|Board| Receiver Pin| Emitter Pin|
|
||||
@@ -18,7 +19,16 @@
|
||||
|SONOFF RFR3|4|-|
|
||||
|RF WIFI GATEWAY|5|-|
|
||||
|
||||
Connect the Emitter and Receiver to a 5V supply source, and the ground of your supply source to the ground of your board.
|
||||
Connect the Emitter and Receiver to a 5V (**3.3V** for CC1101) supply source, and the ground of your supply source to the ground of your board.
|
||||
|
||||
### CC1101 Pinout
|
||||
|Board|Receiver Pin(GDO2)|Emitter Pin(GDO0)|SCK|VCC|MOSI|MISO|CSN|GND
|
||||
|-|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|
||||
|ESP8266|D2/**D3**/D1/D8|**RX**/D2|D5|**3V3**|D7|D6|D8|GND
|
||||
|ESP32|**27**/26|12|D18|**3V3**|D23|D19|D5|GND
|
||||
|
||||
More information about the [CC1101 wiring](https://github.com/LSatan/SmartRC-CC1101-Driver-Lib#wiring).
|
||||
|
||||
|
||||
## Arduino Hardware setup
|
||||

|
||||
|
||||
@@ -153,6 +153,7 @@ char gateway_name[parameters_size * 2] = Gateway_Name;
|
||||
//#define ZsensorGPIOInput "GPIOInput" //ESP8266, Arduino, ESP32
|
||||
//#define ZmqttDiscovery "HADiscovery"//ESP8266, Arduino, ESP32, Sonoff RF Bridge
|
||||
//#define ZactuatorFASTLED "FASTLED" //ESP8266, Arduino, ESP32, Sonoff RF Bridge
|
||||
//#define ZradioCC1101 "CC1101" //ESP8266, ESP32
|
||||
|
||||
/*-------------DEFINE YOUR MQTT ADVANCED PARAMETERS BELOW----------------*/
|
||||
#define version_Topic "/version"
|
||||
|
||||
@@ -28,6 +28,11 @@
|
||||
#include "User_config.h"
|
||||
|
||||
#ifdef ZgatewayPilight
|
||||
|
||||
#ifdef ZradioCC1101
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#endif
|
||||
|
||||
#include <ESPiLight.h>
|
||||
ESPiLight rf(RF_EMITTER_PIN); // use -1 to disable transmitter
|
||||
|
||||
@@ -58,6 +63,12 @@ void pilightCallback(const String &protocol, const String &message, int status,
|
||||
void setupPilight()
|
||||
{
|
||||
#ifndef ZgatewayRF &&ZgatewayRF2 //receiving with Pilight is not compatible with ZgatewayRF or RF2 or RF315 as far as I can tell
|
||||
#ifdef ZradioCC1101 //receiving with CC1101
|
||||
ELECHOUSE_cc1101.Init();
|
||||
ELECHOUSE_cc1101.setMHZ(CC1101_FREQUENCY);
|
||||
ELECHOUSE_cc1101.SetRx(CC1101_FREQUENCY);
|
||||
rf.enableReceiver();
|
||||
#endif
|
||||
rf.setCallback(pilightCallback);
|
||||
rf.initReceiver(RF_RECEIVER_PIN);
|
||||
pinMode(RF_EMITTER_PIN, OUTPUT); // Set this here, because if this is the RX pin it was reset to INPUT by Serial.end();
|
||||
@@ -76,7 +87,10 @@ void PilighttoMQTT()
|
||||
|
||||
void MQTTtoPilight(char *topicOri, JsonObject &Pilightdata)
|
||||
{
|
||||
|
||||
#ifdef ZradioCC1101
|
||||
ELECHOUSE_cc1101.SetTx(CC1101_FREQUENCY); // set Transmit on
|
||||
rf.disableReceiver();
|
||||
#endif
|
||||
int result = 0;
|
||||
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoPilight))
|
||||
@@ -155,5 +169,9 @@ void MQTTtoPilight(char *topicOri, JsonObject &Pilightdata)
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef ZradioCC1101
|
||||
ELECHOUSE_cc1101.SetRx(CC1101_FREQUENCY); // set Receive on
|
||||
rf.enableReceiver();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -29,6 +29,10 @@
|
||||
|
||||
#ifdef ZgatewayRF
|
||||
|
||||
#ifdef ZradioCC1101
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#endif
|
||||
|
||||
#include <RCSwitch.h> // library for controling Radio frequency switch
|
||||
|
||||
RCSwitch mySwitch = RCSwitch();
|
||||
@@ -57,6 +61,11 @@ void setupRF()
|
||||
//RF init parameters
|
||||
Log.notice(F("RF_EMITTER_PIN: %d " CR), RF_EMITTER_PIN);
|
||||
Log.notice(F("RF_RECEIVER_PIN: %d " CR), RF_RECEIVER_PIN);
|
||||
#ifdef ZradioCC1101 //receiving with CC1101
|
||||
ELECHOUSE_cc1101.Init();
|
||||
ELECHOUSE_cc1101.setMHZ(CC1101_FREQUENCY);
|
||||
ELECHOUSE_cc1101.SetRx(CC1101_FREQUENCY);
|
||||
#endif
|
||||
mySwitch.enableTransmit(RF_EMITTER_PIN);
|
||||
mySwitch.setRepeatTransmit(RF_EMITTER_REPEAT);
|
||||
mySwitch.enableReceive(RF_RECEIVER_PIN);
|
||||
@@ -103,6 +112,11 @@ void RFtoMQTT()
|
||||
void MQTTtoRF(char *topicOri, char *datacallback)
|
||||
{
|
||||
|
||||
#ifdef ZradioCC1101 // set Receive off and Transmitt on
|
||||
ELECHOUSE_cc1101.SetTx(CC1101_FREQUENCY);
|
||||
mySwitch.disableReceive();
|
||||
mySwitch.enableTransmit(RF_EMITTER_PIN);
|
||||
#endif
|
||||
unsigned long data = strtoul(datacallback, NULL, 10); // we will not be able to pass values > 4294967295
|
||||
|
||||
// RF DATA ANALYSIS
|
||||
@@ -156,12 +170,22 @@ void MQTTtoRF(char *topicOri, char *datacallback)
|
||||
// Acknowledgement to the GTWRF topic
|
||||
pub(subjectGTWRFtoMQTT, datacallback); // we acknowledge the sending by publishing the value to an acknowledgement topic, for the moment even if it is a signal repetition we acknowledge also
|
||||
}
|
||||
#ifdef ZradioCC1101 // set Receive on and Transmitt off
|
||||
ELECHOUSE_cc1101.SetRx(CC1101_FREQUENCY);
|
||||
mySwitch.disableTransmit();
|
||||
mySwitch.enableReceive(RF_RECEIVER_PIN);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef jsonReceiving
|
||||
void MQTTtoRF(char *topicOri, JsonObject &RFdata)
|
||||
{ // json object decoding
|
||||
#ifdef ZradioCC1101 // set Receive off and Transmitt on
|
||||
ELECHOUSE_cc1101.SetTx(CC1101_FREQUENCY);
|
||||
mySwitch.disableReceive();
|
||||
mySwitch.enableTransmit(RF_EMITTER_PIN);
|
||||
#endif
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoRF))
|
||||
{
|
||||
Log.trace(F("MQTTtoRF json" CR));
|
||||
@@ -187,6 +211,11 @@ void MQTTtoRF(char *topicOri, JsonObject &RFdata)
|
||||
Log.error(F("MQTTtoRF Fail json" CR));
|
||||
}
|
||||
}
|
||||
#ifdef ZradioCC1101 // set Receive on and Transmitt off
|
||||
ELECHOUSE_cc1101.SetRx(CC1101_FREQUENCY);
|
||||
mySwitch.disableTransmit();
|
||||
mySwitch.enableReceive(RF_RECEIVER_PIN);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -37,6 +37,10 @@ sudo mosquitto_pub -t home/commands/MQTTtoRF2/CODE_8233372/UNIT_0/PERIOD_272 -m/
|
||||
|
||||
#ifdef ZgatewayRF2
|
||||
|
||||
#ifdef ZradioCC1101
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#endif
|
||||
|
||||
#include <NewRemoteTransmitter.h>
|
||||
#include <NewRemoteReceiver.h>
|
||||
|
||||
@@ -55,6 +59,11 @@ RF2rxd rf2rd;
|
||||
void setupRF2()
|
||||
{
|
||||
#ifndef ZgatewayRF //receiving with RF2 is not compatible with ZgatewayRF
|
||||
#ifdef ZradioCC1101 //receiving with CC1101
|
||||
ELECHOUSE_cc1101.Init();
|
||||
ELECHOUSE_cc1101.setMHZ(CC1101_FREQUENCY);
|
||||
ELECHOUSE_cc1101.SetRx(CC1101_FREQUENCY);
|
||||
#endif
|
||||
NewRemoteReceiver::init(RF_RECEIVER_PIN, 2, rf2Callback);
|
||||
Log.notice(F("RF_EMITTER_PIN: %d " CR), RF_EMITTER_PIN);
|
||||
Log.notice(F("RF_RECEIVER_PIN: %d " CR), RF_RECEIVER_PIN);
|
||||
@@ -101,6 +110,10 @@ void rf2Callback(unsigned int period, unsigned long address, unsigned long group
|
||||
#ifdef simpleReceiving
|
||||
void MQTTtoRF2(char *topicOri, char *datacallback)
|
||||
{
|
||||
#ifdef ZradioCC1101
|
||||
NewRemoteReceiver::disable();
|
||||
ELECHOUSE_cc1101.SetTx(CC1101_FREQUENCY); // set Transmit on
|
||||
#endif
|
||||
|
||||
// RF DATA ANALYSIS
|
||||
//We look into the subject to see if a special RF protocol is defined
|
||||
@@ -216,12 +229,20 @@ void MQTTtoRF2(char *topicOri, char *datacallback)
|
||||
pub((char *)MQTTRF2string.c_str(), (char *)MQTTswitchType.c_str());
|
||||
}
|
||||
}
|
||||
#ifdef ZradioCC1101
|
||||
ELECHOUSE_cc1101.SetRx(CC1101_FREQUENCY); // set Receive on
|
||||
NewRemoteReceiver::enable();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef jsonReceiving
|
||||
void MQTTtoRF2(char *topicOri, JsonObject &RF2data)
|
||||
{ // json object decoding
|
||||
#ifdef ZradioCC1101
|
||||
NewRemoteReceiver::disable();
|
||||
ELECHOUSE_cc1101.SetTx(CC1101_FREQUENCY); // set Transmit on
|
||||
#endif
|
||||
|
||||
if (cmpToMainTopic(topicOri, subjectMQTTtoRF2))
|
||||
{
|
||||
@@ -282,6 +303,10 @@ void MQTTtoRF2(char *topicOri, JsonObject &RF2data)
|
||||
Log.error(F("MQTTtoRF2 failed json read" CR));
|
||||
}
|
||||
}
|
||||
#ifdef ZradioCC1101
|
||||
ELECHOUSE_cc1101.SetRx(CC1101_FREQUENCY); // set Receive on
|
||||
NewRemoteReceiver::enable();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -90,6 +90,10 @@ RF supported protocols
|
||||
#define PilightRAW "RAW"
|
||||
#define repeatPilightwMQTT false // do we repeat a received signal by using mqtt with Pilight gateway
|
||||
|
||||
/*-------------------CC1101 frequency----------------------*/
|
||||
//Match frequency to the hardware version of the radio if ZradioCC1101 is used.
|
||||
#define CC1101_FREQUENCY 433.92
|
||||
|
||||
/*-------------------PIN DEFINITIONS----------------------*/
|
||||
#ifndef RF_RECEIVER_PIN
|
||||
#ifdef ESP8266
|
||||
|
||||
+48
-1
@@ -33,6 +33,7 @@ extra_configs =
|
||||
;default_envs = esp32dev-all
|
||||
;default_envs = esp32dev-rf
|
||||
;default_envs = esp32dev-pilight
|
||||
;default_envs = esp32dev-pilight-cc1101
|
||||
;default_envs = esp32dev-weatherstation
|
||||
;default_envs = esp32dev-ir
|
||||
;default_envs = esp32dev-ble
|
||||
@@ -41,8 +42,10 @@ extra_configs =
|
||||
;default_envs = esp32-m5stick-c-ble
|
||||
;default_envs = ttgo-lora32-v1
|
||||
;default_envs = nodemcuv2-rf
|
||||
;default_envs = nodemcuv2-rf-cc1101
|
||||
;default_envs = rf-wifi-gateway
|
||||
;default_envs = nodemcuv2-rf2
|
||||
;default_envs = nodemcuv2-rf2-cc1101
|
||||
;default_envs = nodemcuv2-pilight
|
||||
;default_envs = nodemcuv2-weatherstation
|
||||
;default_envs = nodemcuv2-ir
|
||||
@@ -86,6 +89,7 @@ wire = Wire
|
||||
fastled = FastLED@3.3.2
|
||||
onewire = OneWire
|
||||
dallastemperature = DallasTemperature
|
||||
smartrc-cc1101-driver-lib = SmartRC-CC1101-Driver-Lib@2.3.5
|
||||
|
||||
[env]
|
||||
framework = arduino
|
||||
@@ -217,7 +221,20 @@ lib_deps =
|
||||
build_flags =
|
||||
${com-esp.build_flags}
|
||||
'-DZgatewayPilight="Pilight"'
|
||||
'-DGateway_Name="OpenMQTTGateway_ESP32_RF"'
|
||||
'-DGateway_Name="OpenMQTTGateway_ESP32_Pilight"'
|
||||
|
||||
[env:esp32dev-pilight-cc1101]
|
||||
platform = ${com.esp32_platform}
|
||||
board = esp32dev
|
||||
lib_deps =
|
||||
${com-esp.lib_deps}
|
||||
${libraries.esppilight}
|
||||
${libraries.smartrc-cc1101-driver-lib}
|
||||
build_flags =
|
||||
${com-esp.build_flags}
|
||||
'-DZgatewayPilight="Pilight"'
|
||||
'-DZradioCC1101="CC1101"'
|
||||
'-DGateway_Name="OpenMQTTGateway_ESP32_Pilight-CC1101"'
|
||||
|
||||
[env:esp32dev-weatherstation]
|
||||
platform = ${com.esp32_platform}
|
||||
@@ -403,6 +420,21 @@ build_flags =
|
||||
'-DGateway_Name="OpenMQTTGateway_ESP8266_RF"'
|
||||
board_build.flash_mode = dout
|
||||
|
||||
[env:nodemcuv2-rf-cc1101]
|
||||
platform = ${com.esp8266_platform}
|
||||
board = nodemcuv2
|
||||
lib_deps =
|
||||
${com-esp.lib_deps}
|
||||
${libraries.rc-switch}
|
||||
${libraries.smartrc-cc1101-driver-lib}
|
||||
${libraries.esp8266_mdns}
|
||||
build_flags =
|
||||
${com-esp.build_flags}
|
||||
'-DZgatewayRF="RF"'
|
||||
'-DZradioCC1101="CC1101"'
|
||||
'-DGateway_Name="OpenMQTTGateway_ESP8266_RF-CC1101"'
|
||||
board_build.flash_mode = dout
|
||||
|
||||
[env:test-manual-wifi]
|
||||
platform = ${com.esp8266_platform}
|
||||
board = nodemcuv2
|
||||
@@ -444,6 +476,21 @@ build_flags =
|
||||
'-DGateway_Name="OpenMQTTGateway_ESP8266_RF2"'
|
||||
board_build.flash_mode = dout
|
||||
|
||||
[env:nodemcuv2-rf2-cc1101]
|
||||
platform = ${com.esp8266_platform}
|
||||
board = nodemcuv2
|
||||
lib_deps =
|
||||
${com-esp.lib_deps}
|
||||
${libraries.newremoteswitch}
|
||||
${libraries.smartrc-cc1101-driver-lib}
|
||||
${libraries.esp8266_mdns}
|
||||
build_flags =
|
||||
${com-esp.build_flags}
|
||||
'-DZgatewayRF2="RF2"'
|
||||
'-DZradioCC1101="CC1101"'
|
||||
'-DGateway_Name="OpenMQTTGateway_ESP8266_RF2-CC1101"'
|
||||
board_build.flash_mode = dout
|
||||
|
||||
[env:nodemcuv2-pilight]
|
||||
platform = ${com.esp8266_platform}
|
||||
board = nodemcuv2
|
||||
|
||||
Reference in new issue
Block a user