Get Arduino Serial data from RF remote with RF receiver having TX












0















I have this 433 Mhz remote with 12 key using PT2264 and having universal receiver module to decode signal from this remote. Receiver module output in TX pin with 9600 baud rate.
It send data after receiving from remote as REMOTE_ID:KEY_NUMBER.
for example after pressing key 1 from remote I get #AAAA:01 this as data.



Problem is that it does not send any data if pressed once. Instead we have to keep remote key pressed to transmit key code. This creates a burst of continuous data for that key in format #AAAA:01.



Now my problem is I want to interface this remote to ESP8266 and toggle a http resource. I understand this very typical setup, but i need it this way. My problem is how to detect multiple same key as one event on serial so that if it happens again I can achieve the toggle action.



So in short i want to toggle a resource upon pressing switch on remote.



Hardware setup is simple:
Ive attached 433Mhx receiver modules TX pin to ESP8266's D13 and using SoftwareSerial to read data.
Currently I get :



#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01


I want it only to detect as one #AAAA:01
but if pressed again after few seconds its second #AAAA:01 with which we can toggle some variable.



code is simple.



#include <SoftwareSerial.h>
SoftwareSerial mySerial(12, 14, false, 256);//RX, TX
String readString; //main captured String

int buttonState = LOW; //this variable tracks the state of the button, low if not pressed, high if pressed
int ledState = 0; //this variable tracks the state of the LED, negative if off, positive if on

long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 10; // the debounce time; increase if the output flickers
const byte interruptPin = 13;
void setup() {
pinMode(interruptPin, INPUT_PULLUP);
Serial.begin(9600);
mySerial.begin(9600);

}

void loop() {
if (mySerial.available()) {
char c = mySerial.read(); //gets one byte from serial buffer
if (c == '#') {
//do stuff

int ind1 = readString.indexOf(':');
String id = readString.substring(0, ind1);
String key = readString.substring(ind1 + 1);


Serial.println(id);

if (id == "AAAA") {
Serial.println(millis());
if ((millis() - lastDebounceTime) > 50 ) {
//lastDebounceTime = millis();
Serial.println("key Pressed: ");
Serial.println(key);
}
}
readString = ""; //clears variable for new input
id = "";
key = "";

}
else {
readString += c; //makes the string readString
}
}
}


I tried debauching like code with millis() but it did not work.










share|improve this question























  • When you receive a string, store it in a buffer. Every 1sec (or how much you like) read the buffer for the values and clear it. This way you can have a method which checks values every 1sec and toggle some variable.

    – svtag
    Nov 22 '18 at 10:49











  • Hi @svtag, when i press button from remote it sends burst of same key values on serial. I just want this to be detect as one key event instead of many. So if i press the same key again after say interval keyPressedDelay then its detected as another key press event.

    – Rajendra
    Nov 24 '18 at 11:36
















0















I have this 433 Mhz remote with 12 key using PT2264 and having universal receiver module to decode signal from this remote. Receiver module output in TX pin with 9600 baud rate.
It send data after receiving from remote as REMOTE_ID:KEY_NUMBER.
for example after pressing key 1 from remote I get #AAAA:01 this as data.



Problem is that it does not send any data if pressed once. Instead we have to keep remote key pressed to transmit key code. This creates a burst of continuous data for that key in format #AAAA:01.



Now my problem is I want to interface this remote to ESP8266 and toggle a http resource. I understand this very typical setup, but i need it this way. My problem is how to detect multiple same key as one event on serial so that if it happens again I can achieve the toggle action.



So in short i want to toggle a resource upon pressing switch on remote.



Hardware setup is simple:
Ive attached 433Mhx receiver modules TX pin to ESP8266's D13 and using SoftwareSerial to read data.
Currently I get :



#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01


I want it only to detect as one #AAAA:01
but if pressed again after few seconds its second #AAAA:01 with which we can toggle some variable.



code is simple.



#include <SoftwareSerial.h>
SoftwareSerial mySerial(12, 14, false, 256);//RX, TX
String readString; //main captured String

int buttonState = LOW; //this variable tracks the state of the button, low if not pressed, high if pressed
int ledState = 0; //this variable tracks the state of the LED, negative if off, positive if on

long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 10; // the debounce time; increase if the output flickers
const byte interruptPin = 13;
void setup() {
pinMode(interruptPin, INPUT_PULLUP);
Serial.begin(9600);
mySerial.begin(9600);

}

void loop() {
if (mySerial.available()) {
char c = mySerial.read(); //gets one byte from serial buffer
if (c == '#') {
//do stuff

int ind1 = readString.indexOf(':');
String id = readString.substring(0, ind1);
String key = readString.substring(ind1 + 1);


Serial.println(id);

if (id == "AAAA") {
Serial.println(millis());
if ((millis() - lastDebounceTime) > 50 ) {
//lastDebounceTime = millis();
Serial.println("key Pressed: ");
Serial.println(key);
}
}
readString = ""; //clears variable for new input
id = "";
key = "";

}
else {
readString += c; //makes the string readString
}
}
}


I tried debauching like code with millis() but it did not work.










share|improve this question























  • When you receive a string, store it in a buffer. Every 1sec (or how much you like) read the buffer for the values and clear it. This way you can have a method which checks values every 1sec and toggle some variable.

    – svtag
    Nov 22 '18 at 10:49











  • Hi @svtag, when i press button from remote it sends burst of same key values on serial. I just want this to be detect as one key event instead of many. So if i press the same key again after say interval keyPressedDelay then its detected as another key press event.

    – Rajendra
    Nov 24 '18 at 11:36














0












0








0








I have this 433 Mhz remote with 12 key using PT2264 and having universal receiver module to decode signal from this remote. Receiver module output in TX pin with 9600 baud rate.
It send data after receiving from remote as REMOTE_ID:KEY_NUMBER.
for example after pressing key 1 from remote I get #AAAA:01 this as data.



Problem is that it does not send any data if pressed once. Instead we have to keep remote key pressed to transmit key code. This creates a burst of continuous data for that key in format #AAAA:01.



Now my problem is I want to interface this remote to ESP8266 and toggle a http resource. I understand this very typical setup, but i need it this way. My problem is how to detect multiple same key as one event on serial so that if it happens again I can achieve the toggle action.



So in short i want to toggle a resource upon pressing switch on remote.



Hardware setup is simple:
Ive attached 433Mhx receiver modules TX pin to ESP8266's D13 and using SoftwareSerial to read data.
Currently I get :



#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01


I want it only to detect as one #AAAA:01
but if pressed again after few seconds its second #AAAA:01 with which we can toggle some variable.



code is simple.



#include <SoftwareSerial.h>
SoftwareSerial mySerial(12, 14, false, 256);//RX, TX
String readString; //main captured String

int buttonState = LOW; //this variable tracks the state of the button, low if not pressed, high if pressed
int ledState = 0; //this variable tracks the state of the LED, negative if off, positive if on

long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 10; // the debounce time; increase if the output flickers
const byte interruptPin = 13;
void setup() {
pinMode(interruptPin, INPUT_PULLUP);
Serial.begin(9600);
mySerial.begin(9600);

}

void loop() {
if (mySerial.available()) {
char c = mySerial.read(); //gets one byte from serial buffer
if (c == '#') {
//do stuff

int ind1 = readString.indexOf(':');
String id = readString.substring(0, ind1);
String key = readString.substring(ind1 + 1);


Serial.println(id);

if (id == "AAAA") {
Serial.println(millis());
if ((millis() - lastDebounceTime) > 50 ) {
//lastDebounceTime = millis();
Serial.println("key Pressed: ");
Serial.println(key);
}
}
readString = ""; //clears variable for new input
id = "";
key = "";

}
else {
readString += c; //makes the string readString
}
}
}


I tried debauching like code with millis() but it did not work.










share|improve this question














I have this 433 Mhz remote with 12 key using PT2264 and having universal receiver module to decode signal from this remote. Receiver module output in TX pin with 9600 baud rate.
It send data after receiving from remote as REMOTE_ID:KEY_NUMBER.
for example after pressing key 1 from remote I get #AAAA:01 this as data.



Problem is that it does not send any data if pressed once. Instead we have to keep remote key pressed to transmit key code. This creates a burst of continuous data for that key in format #AAAA:01.



Now my problem is I want to interface this remote to ESP8266 and toggle a http resource. I understand this very typical setup, but i need it this way. My problem is how to detect multiple same key as one event on serial so that if it happens again I can achieve the toggle action.



So in short i want to toggle a resource upon pressing switch on remote.



Hardware setup is simple:
Ive attached 433Mhx receiver modules TX pin to ESP8266's D13 and using SoftwareSerial to read data.
Currently I get :



#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01#AAAA:01


I want it only to detect as one #AAAA:01
but if pressed again after few seconds its second #AAAA:01 with which we can toggle some variable.



code is simple.



#include <SoftwareSerial.h>
SoftwareSerial mySerial(12, 14, false, 256);//RX, TX
String readString; //main captured String

int buttonState = LOW; //this variable tracks the state of the button, low if not pressed, high if pressed
int ledState = 0; //this variable tracks the state of the LED, negative if off, positive if on

long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 10; // the debounce time; increase if the output flickers
const byte interruptPin = 13;
void setup() {
pinMode(interruptPin, INPUT_PULLUP);
Serial.begin(9600);
mySerial.begin(9600);

}

void loop() {
if (mySerial.available()) {
char c = mySerial.read(); //gets one byte from serial buffer
if (c == '#') {
//do stuff

int ind1 = readString.indexOf(':');
String id = readString.substring(0, ind1);
String key = readString.substring(ind1 + 1);


Serial.println(id);

if (id == "AAAA") {
Serial.println(millis());
if ((millis() - lastDebounceTime) > 50 ) {
//lastDebounceTime = millis();
Serial.println("key Pressed: ");
Serial.println(key);
}
}
readString = ""; //clears variable for new input
id = "";
key = "";

}
else {
readString += c; //makes the string readString
}
}
}


I tried debauching like code with millis() but it did not work.







arduino






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 9:40









RajendraRajendra

15914




15914













  • When you receive a string, store it in a buffer. Every 1sec (or how much you like) read the buffer for the values and clear it. This way you can have a method which checks values every 1sec and toggle some variable.

    – svtag
    Nov 22 '18 at 10:49











  • Hi @svtag, when i press button from remote it sends burst of same key values on serial. I just want this to be detect as one key event instead of many. So if i press the same key again after say interval keyPressedDelay then its detected as another key press event.

    – Rajendra
    Nov 24 '18 at 11:36



















  • When you receive a string, store it in a buffer. Every 1sec (or how much you like) read the buffer for the values and clear it. This way you can have a method which checks values every 1sec and toggle some variable.

    – svtag
    Nov 22 '18 at 10:49











  • Hi @svtag, when i press button from remote it sends burst of same key values on serial. I just want this to be detect as one key event instead of many. So if i press the same key again after say interval keyPressedDelay then its detected as another key press event.

    – Rajendra
    Nov 24 '18 at 11:36

















When you receive a string, store it in a buffer. Every 1sec (or how much you like) read the buffer for the values and clear it. This way you can have a method which checks values every 1sec and toggle some variable.

– svtag
Nov 22 '18 at 10:49





When you receive a string, store it in a buffer. Every 1sec (or how much you like) read the buffer for the values and clear it. This way you can have a method which checks values every 1sec and toggle some variable.

– svtag
Nov 22 '18 at 10:49













Hi @svtag, when i press button from remote it sends burst of same key values on serial. I just want this to be detect as one key event instead of many. So if i press the same key again after say interval keyPressedDelay then its detected as another key press event.

– Rajendra
Nov 24 '18 at 11:36





Hi @svtag, when i press button from remote it sends burst of same key values on serial. I just want this to be detect as one key event instead of many. So if i press the same key again after say interval keyPressedDelay then its detected as another key press event.

– Rajendra
Nov 24 '18 at 11:36












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427902%2fget-arduino-serial-data-from-rf-remote-with-rf-receiver-having-tx%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427902%2fget-arduino-serial-data-from-rf-remote-with-rf-receiver-having-tx%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

'app-layout' is not a known element: how to share Component with different Modules

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

WPF add header to Image with URL pettitions [duplicate]