// Test for GEVINO opto npn v1.2 / v1.3 / v1.4 // 04/11/2021 Giorgio Evangelista #include "gevino_opto_npn_io.h" void WaitForOk(String cWait); #define SIM808 Serial String risposta; int TestResult; void setup() { SerialUSB.begin(115200); gevino_io_setup(); // Change baud at SIM808 SerialUSB.println("Ricezione SMS"); SIM808.begin(9600); SIM808.println("AT"); WaitForOk("OK"); SIM808.println("AT"); WaitForOk("\nOK\n"); delay(500); SIM808.println("ATE1"); // echo on WaitForOk("OK"); SIM808.println("AT+CSCS=\"GSM\""); // Caracter Set WaitForOk("OK"); SIM808.println("AT+CMGF=1"); // Setta GSM in Text Mode WaitForOk("OK"); SIM808.println("AT+GMR"); // Chiede versione firmware modem WaitForOk("OK"); SIM808.println("AT+CMGDA=\"DEL ALL\""); // Cancella tutti gli SMS WaitForOk("OK"); } void loop() { WaitForOk("OK"); } //------------------------------------------------------------------------------------- void WaitForOk(String cWait) // Attende un OK o altro messaggio contenuto in cWait dal modem { delay(500); risposta = SIM808.readString(); SerialUSB.println(risposta); risposta.trim(); if ( risposta == "+CMTI: \"SM\",1" ) // Se ha ricevuto un SMS { SerialUSB.println("Ricevuto SMS"); SIM808.println("AT+CMGL=\"ALL\""); // Chiedo di leggere il SMS } }