Im trying to control the outputs on a MKR GSM 1400 by sending a sms with a specific word.
But my problem is that when the text is printed out in the serial monitor there are several reversed question marks that comes directly after.
hope someone can see whats wrong and thanks in advance
// include the GSM library
#include <MKRGSM.h>
#include "arduino_secrets.h"
// Please enter your sensitive data in the Secret tab or arduino_secrets.h
// PIN Number
const char PINNUMBER[] = "xxxx";
// initialize the library instances
GSM gsmAccess;
GSM_SMS sms;
// Array to hold the number a SMS is retreived from
char senderNumber[20];
int pinArray[] = {0, 1, 2, 3};
int count = 0;
int timer = 1000;
void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("SMS Messages Receiver");
// connection state
bool connected = false;
// Start GSM connection
while (!connected) {
if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
connected = true;
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}
void loop()
{
char c;
char smsData[80];
byte smsIndex = 0;
if (sms.available()> 0){
Serial.println("Message received from:");
// Get remote number
sms.remoteNumber(senderNumber, 20);
Serial.println(senderNumber);
while(c=sms.read()){
Serial.print(c);
smsData[smsIndex++] = c;
smsData[smsIndex] = '\0'; // Keep string NULL terminated
}
if (strcmp(smsData, "on") == 0){
digitalWrite(A1, HIGH);
Serial.println("\non");
smsIndex = 0;
}
else if (strcmp(smsData, "stop") == 0){
digitalWrite(A1, LOW);
Serial.println("\noff");
smsIndex = 0;
sms.flush();
}
Serial.println("\nEND OF MESSAGE");
// Delete message from modem memory
sms.flush();
Serial.println("MESSAGE DELETED");
delay(1000);
}
}