Liczba postów: 654
Liczba wątków: 3
Dołączył: Apr 2017
Reputacja:
51
Pokaż kod.
Pokaż schemat/zdjęcie układu.
Jeśli masz problem z kodem lub sprzętem, zadaj pytanie na forum. Nie odpowiadam na PW, jeśli nie dotyczą one spraw forum lub innych tematów prywatnych.
Liczba postów: 4
Liczba wątków: 1
Dołączył: Jan 2019
Reputacja:
0
31-01-2019, 14:50
(Ten post był ostatnio modyfikowany: 31-01-2019, 14:53 przez kami.)
#include <GSM.h>
#include <AltSoftSerial.h>
#define PINNUMBER ""
AltSoftSerial a6thinker(8, 9);
GSM_SMS sms;
GSM gsmAccess;
char remoteNumber[20];
void setup()
{
Serial.begin(38400);
a6thinker.begin(38400);
delay(20000);
Serial.print("a6thinker gotowy ...");
//a6thinker.print("AT+CMGF=1\r");
//delay(100);
//a6thinker.print("AT+CPMS=\"SM\"\r");
//delay(100);
//a6thinker.print("AT+CMGR=1\r");
//delay(100);
//a6thinker.print("ATE1\r");
//delay(100);
//a6thinker.print("AT+CMGR=1,0\r");
//delay(500);
//Serial.println();
//gsm.print("AT+CNMI=2,1,0,0,0\r");
//delay(100);
Serial.println("SMS Messages Receiver");
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}
void loop()
{
char c;
// If there are any SMSs available()
if (sms.available())
{
Serial.println("Message received from:");
// Get remote number
sms.remoteNumber(remoteNumber, 20);
Serial.println(remoteNumber);
// This is just an example of message disposal
// Messages starting with # should be discarded
if(sms.peek()=='#')
{
Serial.println("Discarded SMS");
sms.flush();
}
// Read message bytes and print them
while(c=sms.read())
Serial.print©;
Serial.println("\nEND OF MESSAGE");
// delete message from modem memory
sms.flush();
Serial.println("MESSAGE DELETED");
}
delay(1000);
}
witam, kaczkat w tej bibliotece nie ma chyba mozliwosci odczytania numeru chyba, ze sie myle i czegos niedopatrzylem
tak jak pisalem wiadomosc sms na karcie sie znajduje ze statusem "read" ale funkcja sms.available jej nie widzi probowalem juz roznych ustawien bez skutku moze ktos na cos wpadnie, a moze to wina modemu ? program zatrzymuje sie na bloku Serial.print("SMS mesages receiver");
monitor portu juz nie wyswietla kolejnych blokow serial.print()
Liczba postów: 4
Liczba wątków: 1
Dołączył: Jan 2019
Reputacja:
0
dzieki za pomoc, teraz na pewno przetestuje