GSM PROGRAM COMPILE ERROR

Discussion in 'Embedded Systems and Microcontrollers' started by AJIN NADH, Mar 7, 2015.

  1. AJIN NADH

    Thread Starter Member

    Dec 18, 2014
    79
    4
    Dear Team,

    I TRY TO COMPILE THE FOLLOWING ARDUINO PROGRAM BUT ITS SHOWING ERROR( ATTACHED).

    Code (Text):
    1.  
    2. #include <EEPROM.h>// libraries
    3. #include <GSM.h>
    4. byte value;
    5. // initialize the library instance
    6. GSM gsmAccess; // include a 'true' parameter for debug enabled
    7. GSM_SMS sms;
    8. void setup()
    9. {
    10.  
    11.   Serial.begin(9600);
    12.   Serial.println("GSM initialized");
    13.   pinMode(4,OUTPUT);
    14. }
    15.  
    16. void loop()
    17. {
    18.   char k[20];
    19.   char txtMsg[200];
    20.   Serial.print("Enter a mobile number: ");
    21.   char remoteNumber[20];  // telephone number to send sms
    22.   for(int i=0;i<20;i++)
    23.   {
    24.   k[I]=readSerial(remoteNumber);
    25.   Serial.println(remoteNumber);
    26.   }
    27.   for(int i=0;i<200;i++)
    28.     {
    29.     txtMsg[I]=sms.read();
    30.     }
    31.     numberfunction(k[20],txtMsg);
    32.     sms.flush();
    33.     Serial.println("MESSAGE DELETED");
    34.   }
    35.  
    36.  
    37. /*
    38.   Read input serial
    39. */
    40. int readSerial(char result[])
    41. {
    42.   int i = 0;
    43.   while(1)
    44.   {
    45.     while (Serial.available() > 0)
    46.     {
    47.       char inChar = Serial.read();
    48.       for(int i=0;i<20;i++)
    49.       {
    50.         result[I] = inChar;
    51.         return(result[I]);
    52.       }
    53.     }
    54.   }
    55. }
    56.  
    57.  
    58.  
    59. void numberfunction(int Number ,char sms[200])
    60.   {
    61.     int address = 0;
    62.     if(sms=="REG")
    63.     {
    64.        for (int i = 0; i < 512; i++)
    65.     EEPROM.write(i, 0);
    66.     value = EEPROM.read(Number);
    67.     EEPROM.write(address,value);
    68.   Serial.print(address);
    69.   Serial.print("\t");
    70.   Serial.print(value, DEC);
    71.   Serial.println();
    72.   address = address + 1;
    73.   if (address == 512)
    74.   address = 0;
    75.   delay(500);
    76. }
    77. else if(sms!="REG")
    78. {
    79.   if(value==Number)
    80.   {
    81. relay(sms);
    82. } }
    83.   }
    84.   void relay(char sms[200])
    85. {
    86. if (sms=="ON")
    87. {
    88.   digitalWrite( 4, HIGH );
    89. }
    90. if(sms=="OFF")
    91.  
    92. {
    93.   digitalWrite( 4, HIGH );
    94. }
    95. }
    96.  
    I WAS TRYING TO READ THE SENDER MOBILE NUMBER AND THE SMS CONTENT,
    AND THESE VALUES ARE PASSED TO FUNCTION,PLS FIND THE ATTACHED ERROR


    PLS HELP ME ......................................:(:(:(:(


    Regards,
    Ajin Nadh

    Moderators note: Please use code tags for pieces of code
     
    Last edited by a moderator: Mar 9, 2015
  2. Motanache

    Member

    Mar 2, 2015
    70
    4
    Well, put bold the program line that gave error.

    The line 72 of file [......]verification.cpp
     
  3. Motanache

    Member

    Mar 2, 2015
    70
    4
    <<I WAS TRYING TO READ THE SENDER MOBILE NUMBER AND THE SMS CONTENT,>>

    That's not hard.

    Good to monitor a serial line from phone to microcontroller.

    In Hyperterminal you tried to practice AT commands?

    Decoding PDU will be more difficult, but there are online applications that make it.
     
  4. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,802
    832
    A few errors I found.

    • You define the function "readserial" as an int, but try to assign it to a char variable. It won't like that.
    • What does sms.read return? It appears to return an int and you try to assign it to a char array
    • You also are trying to assign a char to a char pointer (in the line "result = inChar;")
    Interestingly, I did not receive any errors specific to the GSM library. However, the ones I noted could confuse the libraries.

    Overall, you are confused with the various data types, and attempt to assign incompatible variables/functions.

    These are the errors I received when compiling your program:
    Code (Text):
    1. Arduino: 1.5.6-r2 (Windows 7), Board: "Arduino Uno"
    2.  
    3. sketch_mar07a.ino: In function 'void loop()':
    4. sketch_mar07a:24: error: incompatible types in assignment of 'int' to 'char [20]'
    5. sketch_mar07a:29: error: incompatible types in assignment of 'int' to 'char [200]'
    6. sketch_mar07a.ino: In function 'int readSerial(char*)':
    7. sketch_mar07a:50: error: invalid conversion from 'char' to 'char*'
    8. sketch_mar07a:51: error: invalid conversion from 'char*' to 'int'
    9.  
    10.   This report would have more information with
    11.   "Show verbose output during compilation"
    12.   enabled in File > Preferences.
    13.  
    By the way, your attachment was so small as to be nearly unreadable. Normally, we complain about attachments being too big, but we should be able to read what you post.
     
  5. AJIN NADH

    Thread Starter Member

    Dec 18, 2014
    79
    4
    Hi,

    I rewrite the program as like, Can anybody check that it will work properly,

    Code (Text):
    1.  
    2. #include <EEPROM.h>
    3.  
    4. #include <SoftwareSerial.h>
    5.  
    6. #include <OneWire.h>
    7.  
    8. #include <DallasTemperature.h>
    9.  
    10. #include <Wire.h>
    11.  
    12. const int exterior_light = 6;
    13.  
    14. int button = A0;
    15.  
    16. char inchar;
    17.  
    18. char message[160];
    19.  
    20. int val = 0;
    21.  
    22. int  param;
    23.  
    24. char *tel_nr = "\" +0123456789 \"";
    25.  
    26.  
    27. SoftwareSerial SIM900(2, 3);
    28.  
    29.  
    30. #define ONE_WIRE_BUS A2
    31.  
    32.  
    33. OneWire oneWire(ONE_WIRE_BUS);
    34.  
    35.  
    36. DallasTemperature sensors(&oneWire);
    37.  
    38.  
    39. void setup()
    40.  
    41. {
    42.  
    43. pinMode(exterior_light, OUTPUT);
    44.  
    45. digitalWrite(exterior_light,LOW);
    46.  
    47. SIM900.begin(19200);
    48.  
    49.  
    50. delay(3000);
    51.  
    52. SIM900.print("AT+CMGF=1\r");
    53.  
    54. delay(100);
    55.  
    56. SIM900.print("AT+CNMI=2,2,0,0,0\r");
    57.  
    58. delay(1000);
    59.  
    60. }
    61.  
    62.  
    63. void sendSMS(char *message, char *number)
    64.  
    65. {
    66.  
    67.  
    68. SIM900.print("AT+CMGF=1\r\n");
    69.  
    70. delay(100);
    71.  
    72. SIM900.print("AT + CMGS =");
    73.  
    74. SIM900.println(number);
    75.  
    76. delay(100);
    77.  
    78. SIM900.println(message);  // messageul care trebuie trimis, direct cu terminatorul dupa el
    79.  
    80. delay(100);
    81.  
    82. SIM900.println((char)0x1A);  // CTRL+Z
    83.  
    84. delay(100);
    85.  
    86. SIM900.println();
    87.  
    88. delay(5000);
    89.  
    90. if(message!="REG")
    91.  
    92. {
    93.  
    94. int addr = 0;
    95.  
    96. int value = EEPROM.read(addr);
    97.  
    98. if(value==*number)
    99.  
    100. {
    101.  
    102. if (message=="ON")
    103.  
    104. {
    105.  
    106. digitalWrite( 4, HIGH );
    107.  
    108. }
    109.  
    110. if(message=="OFF")
    111.  
    112.  
    113. {
    114.  
    115. digitalWrite( 4, LOW );
    116.  
    117.  
    118.  
    119. }
    120.  
    121. }}
    122.  
    123. else if(message=="REG")
    124.  
    125. {
    126.  
    127. for (int i = 0; i < 512; i++)
    128.  
    129. {
    130.  
    131. EEPROM.write(i, 0);
    132.  
    133. }
    134.  
    135. int addr = 0;
    136.  
    137. EEPROM.write(addr, int (number));
    138.  
    139. int value = EEPROM.read(addr);
    140.  
    141. addr = addr + 1;
    142.  
    143. if (addr == 512)
    144.  
    145. addr = 0;
    146.  
    147. delay(100);
    148.  
    149. }
    150.  
    151.  
    152.  
    153. }
    154.  
    155. void loop()
    156.  
    157. {
    158.  
    159. unsigned int wADC;
    160.  
    161. double t;
    162.  
    163.  
    164.  
    165. ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3));
    166.  
    167. ADCSRA |= _BV(ADEN);
    168.  
    169.  
    170. delay(50);
    171.  
    172.  
    173. ADCSRA |= _BV(ADSC);
    174.  
    175.  
    176. while (bit_is_set(ADCSRA,ADSC));
    177.  
    178.  
    179. wADC = ADCW;
    180.  
    181.  
    182.  
    183. t = (wADC - 324.31 ) / 1.22;
    184.  
    185. delay(500);
    186.  
    187. char command[255] = {0};
    188.  
    189. while (SIM900.available() > 0)
    190.  
    191. {
    192.  
    193. char ch = SIM900.read();
    194.  
    195. sprintf(command, "%s%c", command, ch);
    196.  
    197. sendSMS(message, tel_nr);
    198.  
    199. }
    200.  
    201. }
    202.  
    Regards,
    Ajin nadh

    Moderators note: Please use code tags for pieces of code
     
    Last edited by a moderator: Mar 9, 2015
  6. xainnasir

    New Member

    Nov 8, 2012
    26
    2
Loading...