user45129: I am making an Arduino program with SIM800L module and would like to check credit status of the SIM card.
When I manually enter the command: AT+CUSD=1,"*123#" into Serial Monitor, it works fine.
But in the Arduino (1.8.7) I am receiving an error 
      stray  "#" in program
when compiling this line of sketch:
      SIM800.print("AT+CUSD=1,"*123#"\r");
I am not experienced enough to fix this problem.
Could somebody help me, please?
Thank you.
Marko

user30198: Use the escape backslash to get a double quote in a text. See: https://en.cppreference.com/w/cpp/language/escape
Is the *123$ between double quotes?
Serial.println("Hello");
Serial.println("I said: Hello to you");
Serial.println("I said: \"Hello\" to you");
Serial.println("AT+CUSD=1,\"*123#\"\r");
Serial.println("AT+CUSD=1,\"*123#\"");

I think the carriage return \r at the end is not needed when the println is used. The println adds a linefeed \n by the way.

45129: <p>I am making an Arduino program with SIM800L module and would like to check credit status of the SIM card.
When I manually enter the command: AT+CUSD=1,"*123#" into Serial Monitor, it works fine.</p>

<p>But in the Arduino (1.8.7) I am receiving an error 
      <code>stray  "#" in program</code></p>

<p>when compiling this line of sketch:
      <code>SIM800.print("AT+CUSD=1,"*123#"\r");</code></p>

<p>I am not experienced enough to fix this problem.
Could somebody help me, please?</p>

<p>Thank you.
Marko</p>
 30198: <p>Use the escape backslash to get a double quote in a text. See: <a href="https://en.cppreference.com/w/cpp/language/escape" rel="nofollow noreferrer">https://en.cppreference.com/w/cpp/language/escape</a></p>

<p>Is the <code>*123$</code> between double quotes?</p>

<pre><code>Serial.println("Hello");
Serial.println("I said: Hello to you");
Serial.println("I said: \"Hello\" to you");
Serial.println("AT+CUSD=1,\"*123#\"\r");
Serial.println("AT+CUSD=1,\"*123#\"");
</code></pre>

<p>I think the carriage return <code>\r</code> at the end is not needed when the <code>println</code> is used. The <code>println</code> adds a linefeed <code>\n</code> by the way.</p>
