Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to turn on relay by SIM7600E 4G module voice call in ESPHome
#11
i think you want use binary sensor to trigger other device. But you can receive serial port RING trigger AUTOMATION directly.
Reply
#12
interval:
- interval: 200ms # Shorten the interval to reduce blocking time
then:
- lambda: |-
static std:Confusedtring uart_buffer;
uint8_t c;
int count = 0;
const int max_reads = 10; // Limit the number of bytes read per interval

while (id(uart_2).available() && count < max_reads) {
if (id(uart_2).read_byte(&c)) {
uart_buffer += (char)c;
count++;

// Log each received character (optional for debugging)
ESP_LOGD("UART", "Received: %c", (char)c);

// Check if we have received the "RING" signal
if (uart_buffer.find("RING") != std:Confusedtring::npos) {
ESP_LOGI("SIM7600", "Incoming call detected, turning on relay 1.");
id(relay_1).turn_on(); // Turn on relay 1

HERE I TURN THE RELAY OFF AFTER 1s BUT IT WILL TURN BACK ON AFTER ANOTHER RING

uart_buffer.clear(); // Clear the buffer after processing
delay(1000);
id(relay_1).turn_off(); // Turn off relay 1

}

// Clear the buffer if it gets too large
if (uart_buffer.length() > 100) {
uart_buffer.clear();
}
}
}

So the ideal would be turn on the relay after the missed call.
also how do I hang up the call?

thanks
Reply
#13
To identify an incoming call number on the SIM7600 module, you can enable the Caller Line Identification (CLI) feature using the following AT commands:

AT+CLIP=1

Then when RING will show the phone number, such as:
RING

+CLIP: "15381188302",128,"",0,,0
   
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)