Dear All,
I would like to copy/clone a remote controller that operates in 868Mhz. As I didn't have a 868Mhz recever / transmitter module before I bought one mentioned on the subject of this topic.
I did this kind of project before but with 433Mhz remote controller and with 433Mhz recever / transmitter module bougth from aliexp... There is this library: rc-switch that can be used but in my case it didn't work, unknown protocol. Anyway a got a nice code from here somewhere which I could use: it told me how long(milisecunds) the data pin was HIGH and how long was LOW. From that I could generate a squre wave signal, save it, and feed the same signal back to a transmitter module. Worked like a charm.
Now that I received this nice LoRa device I would like to do the same but I am unsure which pin I can use for that porpuse if any (I looked into the pinouts and got confused), this module looks more complacated than what I used before? With the 433mhz module there was a clear data pin (+ VCC, GND and no more).
I know that my question is not clearly programming related but I think the final solution will be there. Here is a code I used with a 433mhz module attached to an arduino: (I got this code searching this forum)
//Define settings
const int INPUT_PIN = 2; //Input pin
const unsigned int MAX_SAMPLE = 256; //Maximum number of samples to record
const unsigned long MAX_TIME = 30000UL; //Maximum record time after start pulse (msec)
//Variables used in the ISR
volatile boolean running = false;
volatile unsigned long last = 0;
volatile unsigned int count = 0;
volatile unsigned long samples[MAX_SAMPLE];
void setup() {
pinMode(INPUT_PIN,INPUT);
Serial.begin(9600);
while (!Serial) {};
Serial.println("RecordPin sketch started");
}
void loop() {
unsigned long startTime;
int startState = 0;
while (Serial.read() != -1) {}; //Clear the serial input buffer
Serial.println("Send character to start");
while (Serial.read() == -1) {}; //Wait until we receive the first character
while (Serial.read() != -1) {}; //Clear the rest of the buffer
startState = digitalRead(INPUT_PIN); //Save the initial port state
attachInterrupt(0, receiver, CHANGE); //Interrupt 0 = Pin 2
count = 0;
last = micros();
running = true;
Serial.print("Running. Send a character to stop");
startTime = millis();
while (running && ((millis() - startTime) < MAX_TIME)) { //Run until the buffer is full, the time is up, or we receive a character
if (Serial.read()!= -1) { //Stop if we receive a character
running = false;
}
}
Serial.println("Stopped");
detachInterrupt(0);
Serial.print("I recorded ");
Serial.print(count);
Serial.println(" samples");
for (unsigned int x = 0; x < count; x++) {
Serial.print("");
if (startState == 0) {
Serial.print("0");
} else {
Serial.print("1");
}
startState = !startState;
Serial.print(";");
Serial.print(samples[x]);
Serial.println("");
}
Serial.println("");
}
//Pin change interrupt routine
//Called when the state of the input pin changes
void receiver()
{
if (running) { //If we are running
samples[count] = micros() - last; //Save the time from the last change to this one
last = micros(); //Reset the time of last change
count++; //Go to next buffer entry
if (count > MAX_SAMPLE) { //If we are past the last entry
running = false; // we stop
}
}
}
I am afraid that I can not do something simular with this LoRa module, but I still hope there is a way to do it.
Thanks in advance,
Robert