Benutzer Diskussion:Bernhard p361
Hallo alle zusammen!!
Ich habe eine Frage zum Thema GSM-Shield. Ich habe mir vor kurzem das
GSM- Shield "GPRS Shield V1.4" bestellt, das problem ist nur dass das
nicht wirklich kompatible mit meinem Arduino Mega ist, und ich es nun
über Kabelbrücken anschließen muss, genauso verwende ich eine externe
Spannungsversorgung(d.h. nicht die vom Arduino Mega), doch sobald ich
jetzt die Jumper des Shield auf HWSerial stelle und ich die Pins 0 und 1
des Shields mit den Pins RX0 und TX0 des Arduinos verbinde, und jetzt
irgendeinen Sketch von Arduino für GSM auf meinen Arduino hochlade kommt
in meinem Seriellen Monitor immer nur die Meldung "SMS Messages
Sender"(komt auf den Sketch drauf an). Empfang hab ich einen guten und
einen Pin verwende ich auch nicht. Das shield besitzt einen SIM900. Ich
hoffe irgendjeman kann mir bei meinem Problem schnell weiterhelfen, da
ich nicht mehr weiß was ich ausprobieren sollte.
CODE:
1 | include <GSM.h>
|
2 | define PINNUMBER ""
|
3 | // initialize the library instance GSM gsmAccess; // include a 'true' parameter for debug enabled GSM_SMS sms;
|
4 |
|
5 | void setup() {
|
6 |
|
7 | // initialize serial communications
|
8 | Serial.begin(9600);
|
9 | Serial.println("SMS Messages Sender");
|
10 | // connection state
|
11 | boolean notConnected = true;
|
12 | // Start GSM shield
|
13 | // If your SIM has PIN, pass it as a parameter of begin() in quotes
|
14 | while(notConnected)
|
15 | {
|
16 | if(gsmAccess.begin(PINNUMBER)==GSM_READY)
|
17 | notConnected = false;
|
18 | else
|
19 | {
|
20 | Serial.println("Not connected");
|
21 | delay(1000);
|
22 | }
|
23 | }
|
24 | Serial.println("GSM initialized");
|
25 | }
|
26 |
|
27 | void loop() {
|
28 |
|
29 | Serial.print("Enter a mobile number: ");
|
30 | char remoteNumber[20]; // telephone number to send sms
|
31 | readSerial(remoteNumber);
|
32 | Serial.println(remoteNumber);
|
33 | // sms text
|
34 | Serial.print("Now, enter SMS content: ");
|
35 | char txtMsg[200];
|
36 | readSerial(txtMsg);
|
37 | Serial.println("SENDING");
|
38 | Serial.println();
|
39 | Serial.println("Message:");
|
40 | Serial.println(txtMsg);
|
41 | // send the message
|
42 | sms.beginSMS(remoteNumber);
|
43 | sms.print(txtMsg);
|
44 | sms.endSMS();
|
45 | Serial.println("\nCOMPLETE!\n");
|
46 | }
|
47 |
|
48 | /*
|
49 |
|
50 | Read input serial
|
51 | */
|
52 | int readSerial(char result[]) {
|
53 |
|
54 | int i = 0;
|
55 | while(1)
|
56 | {
|
57 | while (Serial.available() > 0)
|
58 | {
|
59 | char inChar = Serial.read();
|
60 | if (inChar == '\n')
|
61 | {
|
62 | result[i] = '\0';
|
63 | Serial.flush();
|
64 | return 0;
|
65 | }
|
66 | if(inChar!='\r')
|
67 | {
|
68 | result[i] = inChar;
|
69 | i++;
|
70 | }
|
71 | }
|
72 | }
|
73 | }
|
Euer Berni