Hello every one
I am working on 2esp8266 and a pair of HC12 ref module.
At this time i have one problem to make a virtual button on a HTTP request that
send a command to hc12 to send a code to HC12 receiver to activate a led.
the 2 esp and the pair of hc12 work well
SENDER
int buttonState = (incomingByte);
delay(100);
Serial.println("///////////////////////");
while (HC12.available()) { // If HC-12 has data
incomingByte = HC12.read(); // Store each incoming byte from HC-12
readBuffer += char(incomingByte); // Add each byte to ReadBuffer string variable
}
delay(100);
while (Serial.available()) {
HC12.write(Serial.read());
}
delay(5000);
if(buttonState == incomingByte)
HC12.write("1234");
else if(buttonState == incomingByte)
HC12.println("1235");
delay(5000);
Serial.println("Sending Signal...");
while (HC12.available()) {
Serial.write(HC12.read());
}
readBuffer = "";
RECEIVER
boolean ledState = digitalRead(bleuLed);//check if the LED is turned on or off. Returns 1 or 0
// if(mySerial.available() > 1){
// incomingByte = mySerial.read(); // Store each icoming byte from HC-12
// readBuffer += char(incomingByte); // Add each byte to ReadBuffer string variable
// String input = readBuffer;//read serial input and convert to integer (-32,768 to 32,767)
// if(millis() - last > 250){//if time now is 250 milliseconds greater than last time
// if(ledState == 1 && readBuffer == "1234"){//if LED is off and button code is ok
// delay(3000);
// Serial.println("DATA RECEIVED!!!");
// Serial.println("");
// digitalWrite(bleuLed, HIGH);
// delay(3000);
// }else if(ledState == 0 && readBuffer == "1235"){//if LED is on and button code is ok
// delay(3000);
// Serial.println("DATA RECEIVED!!!");
// Serial.println("");
// digitalWrite(bleuLed, LOW);
// }
that code working well of serial monitor
what i want to do is:
if (request.indexOf("/LED=ON") != -1 ) {
delay(3000);
Serial.write("1234");
Serial.println("Sending Signal...");
value = HIGH;
}
if (request.indexOf("/LED=OFF") != -1) {
delay(3000);
HC12.write("1235");
what i have noticed,
that hc12 communication seems to interfer with esp8266 wifi
Some help will be welcom