first commit

This commit is contained in:
Jérôme Delacotte
2025-03-06 11:15:32 +01:00
commit 7b30d6e298
5276 changed files with 2108927 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
/*
Basic ESPiLight receive raw (pulse train) signal example
https://github.com/puuu/espilight
*/
#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <ESPiLight.h>
int RECEIVER_PIN; // any intterupt able pin
int TRANSMITTER_PIN;
ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter
// callback function. It is called on successfully received and parsed rc signal
void rfRawCallback(const uint16_t* codes, size_t length) {
// print pulse lengths
Serial.print("RAW signal: ");
for (unsigned int i = 0; i < length; i++) {
Serial.print(codes[i]);
Serial.print(' ');
}
Serial.println();
// format of pilight USB Nano
String data = rf.pulseTrainToString(codes, length);
Serial.print("string format: ");
Serial.print(data);
Serial.println();
}
void setup() {
Serial.begin(115200);
#ifdef ESP32
RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.
#elif ESP8266
RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.
#else
RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
#endif
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}
//CC1101 Settings: (Settings with "//" are optional!)
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.
//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!
ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
ELECHOUSE_cc1101.SetRx(); // set Receive on
// set callback funktion for raw messages
rf.setPulseTrainCallBack(rfRawCallback);
// inittilize receiver
rf.initReceiver(RECEIVER_PIN);
}
void loop() {
// process input queue and may fire calllback
rf.loop();
delay(10);
}

View File

@@ -0,0 +1,81 @@
/*
Basic ESPilight receive example
https://github.com/puuu/espilight
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
----------------------------------------------------------
Mod by Little Satan. Have Fun!
----------------------------------------------------------
*/
#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <ESPiLight.h>
int RECEIVER_PIN; // any intterupt able pin
int TRANSMITTER_PIN;
ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter
// callback function. It is called on successfully received and parsed rc signal
void rfCallback(const String &protocol, const String &message, int status,
size_t repeats, const String &deviceID) {
Serial.print("RF signal arrived [");
Serial.print(protocol); // protocoll used to parse
Serial.print("][");
Serial.print(deviceID); // value of id key in json message
Serial.print("] (");
Serial.print(status); // status of message, depending on repeat, either:
// FIRST - first message of this protocoll within the
// last 0.5 s
// INVALID - message repeat is not equal to the
// previous message
// VALID - message is equal to the previous message
// KNOWN - repeat of a already valid message
Serial.print(") ");
Serial.print(message); // message in json format
Serial.println();
// check if message is valid and process it
if (status == VALID) {
Serial.print("Valid message: [");
Serial.print(protocol);
Serial.print("] ");
Serial.print(message);
Serial.println();
}
}
void setup() {
Serial.begin(115200);
#ifdef ESP32
RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.
#elif ESP8266
RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.
#else
RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
#endif
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}
//CC1101 Settings: (Settings with "//" are optional!)
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.
//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!
ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
ELECHOUSE_cc1101.SetRx(); // set Receive on
// set callback funktion
rf.setCallback(rfCallback);
// inittilize receiver
rf.initReceiver(RECEIVER_PIN);
}
void loop() {
// process input queue and may fire calllback
rf.loop();
delay(10);
}

View File

@@ -0,0 +1,58 @@
/*
Basic ESPiLight transmit RAW signal example
https://github.com/puuu/espilight
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
----------------------------------------------------------
Mod by Little Satan. Have Fun!
----------------------------------------------------------
*/
#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <ESPiLight.h>
int TRANSMITTER_PIN;
void setup() {
Serial.begin(115200);
#ifdef ESP32
TRANSMITTER_PIN = 2; // for esp32! Transmit on GPIO pin 2.
#elif ESP8266
TRANSMITTER_PIN = 5; // for esp8266! Transmit on pin 5 = D1.
#else
TRANSMITTER_PIN = 6; // for Arduino! Transmit on pin 6.
#endif
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}
//CC1101 Settings: (Settings with "//" are optional!)
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.
//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!
ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
ELECHOUSE_cc1101.SetTx(); // cc1101 set Transmit on
ESPiLight rf(TRANSMITTER_PIN);
int length = 0;
uint16_t codes[MAXPULSESTREAMLENGTH];
// get pulse train from string (format see: pilight USB Nano)
length = rf.stringToPulseTrain(
"c:102020202020202020220202020020202200202200202020202020220020202203;p:"
"279,2511,1395,9486@",
codes, MAXPULSESTREAMLENGTH);
// transmit the pulse train
rf.sendPulseTrain(codes, length);
}
// Toggle state of elro 800 switch evrey 2 s
void loop() {
// stop
}

View File

@@ -0,0 +1,47 @@
/*
Basic ESPiLight transmit example
https://github.com/puuu/espilight
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
----------------------------------------------------------
Mod by Little Satan. Have Fun!
----------------------------------------------------------
*/
#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <ESPiLight.h>
int TRANSMITTER_PIN;
void setup() {
Serial.begin(115200);
#ifdef ESP32
TRANSMITTER_PIN = 2; // for esp32! Transmit on GPIO pin 2.
#elif ESP8266
TRANSMITTER_PIN = 5; // for esp8266! Transmit on pin 5 = D1.
#else
TRANSMITTER_PIN = 6; // for Arduino! Transmit on pin 6.
#endif
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}
//CC1101 Settings: (Settings with "//" are optional!)
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.
//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!
ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
ELECHOUSE_cc1101.SetTx(); // cc1101 set Transmit on
}
// Toggle state of elro 800 switch evrey 2 s
void loop() {
ESPiLight rf(TRANSMITTER_PIN);
rf.send("elro_800_switch", "{\"systemcode\":17,\"unitcode\":1,\"on\":1}");
delay(2000);
rf.send("elro_800_switch", "{\"systemcode\":17,\"unitcode\":1,\"off\":1}");
delay(2000);
}

View File

@@ -0,0 +1,107 @@
/*
Basic ESPiLight pilight_debug example
This example mimic the output of the piligh_debug tool.
https://github.com/puuu/espilight
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
----------------------------------------------------------
Mod by Little Satan. Have Fun!
----------------------------------------------------------
*/
#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <ESPiLight.h>
#define PULSE_DIV 34
int RECEIVER_PIN; // any intterupt able pin
int TRANSMITTER_PIN;
ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter
unsigned int normalize(unsigned int i, unsigned int pulselen) {
double x;
x = (double)i / pulselen;
return (unsigned int)(round(x));
}
// callback function. It is called on successfully received and parsed rc signal
void rfRawCallback(const uint16_t* pulses, size_t length) {
uint16_t pulse;
uint16_t pulselen = pulses[length - 1] / PULSE_DIV;
if (pulselen > 25) {
for (unsigned int i = 3; i < length; i++) {
if ((pulses[i] / pulselen) >= 2) {
pulse = pulses[i];
break;
}
}
if (normalize(pulse, pulselen) > 0 && length > 25) {
/* Print everything */
Serial.println("--[RESULTS]--");
Serial.println();
Serial.print("time:\t\t");
Serial.print(millis());
Serial.println(" ms");
Serial.println("hardware:\tESPiLight");
Serial.print("pulse:\t\t");
Serial.println(normalize(pulse, pulselen));
Serial.print("rawlen:\t\t");
Serial.println(length);
Serial.printf("pulselen:\t");
Serial.println(pulselen);
Serial.println();
Serial.println("Raw code:");
for (unsigned int i = 0; i < length; i++) {
Serial.print(pulses[i]);
Serial.print(" ");
}
Serial.println();
}
}
}
void setup() {
Serial.begin(115200);
#ifdef ESP32
RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.
#elif ESP8266
RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.
#else
RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
#endif
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}
//CC1101 Settings: (Settings with "//" are optional!)
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.
//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!
ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
ELECHOUSE_cc1101.SetRx(); // set Receive on
// set callback funktion for raw messages
rf.setPulseTrainCallBack(rfRawCallback);
// inittilize receiver
rf.initReceiver(RECEIVER_PIN);
Serial.println(
"Press and hold one of the buttons on your remote or wait until");
Serial.println("another device such as a weather station has sent new codes");
Serial.println(
"The debugger will automatically reset itself after one second of");
Serial.println(
"failed leads. It will keep running until you explicitly stop it.");
}
void loop() {
// process input queue and may fire calllback
rf.loop();
delay(10);
}

View File

@@ -0,0 +1,67 @@
/*
Basic ESPiLight pilight_raw example
This example mimic the output of the piligh_raw tool.
https://github.com/puuu/espilight
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
----------------------------------------------------------
Mod by Little Satan. Have Fun!
----------------------------------------------------------
*/
#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <ESPiLight.h>
int RECEIVER_PIN; // any intterupt able pin
int TRANSMITTER_PIN;
ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter
// callback function. It is called on successfully received and parsed rc signal
void rfRawCallback(const uint16_t* pulses, size_t length) {
Serial.print("ESPiLight:");
for (unsigned int i = 0; i < length; i++) {
Serial.print(" ");
Serial.print(pulses[i]);
if (pulses[i] > 5100) {
Serial.printf(" -# ");
Serial.println(i);
}
}
}
void setup() {
Serial.begin(115200);
#ifdef ESP32
RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.
#elif ESP8266
RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.
#else
RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
#endif
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
}else{
Serial.println("Connection Error");
}
//CC1101 Settings: (Settings with "//" are optional!)
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.
//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!
ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
ELECHOUSE_cc1101.SetRx(); // set Receive on
// set callback funktion for raw messages
rf.setPulseTrainCallBack(rfRawCallback);
// inittilize receiver
rf.initReceiver(RECEIVER_PIN);
}
void loop() {
// process input queue and may fire calllback
rf.loop();
delay(10);
}