I have SIM800l module connected to Arduino and I'm trying to initialize it in my setup function with this code:

#include <SoftwareSerial.h>

//SIM800 TX is connected to Arduino D8
#define SIM800_TX_PIN 6
//SIM800 RX is connected to Arduino D7
#define SIM800_RX_PIN 7
SoftwareSerial serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN);

void setup()
  Serial.println("wait for .... it");

  // comments added just for example, both commands return junk

  Serial.println("command sent");


But Serial.write returns junk.

When I use this code in loop:

  //Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor
  //Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800

and send AT+SAPBR=3,1,"Contype","GPRS" or just AT command with serial monitor, everything works fine.

Can someone help with this?

  • Can you place your schematic? Are you using the 4V regulation and transistor on RST pin? Maybe this library might help
    – brtiberio
    Jun 21, 2016 at 10:36
  • What sort of junk? Copy and paste please. Also writing the output from a read, without testing for available is likely to return "junk" or at least ÿ.
    – Nick Gammon
    Jun 22, 2016 at 3:55
  • You're reading only a byte like others have noted. Also, you seem to be sending 2 commands, one immediately after the other. This could result in gibberish. Though it would be nice to see exactly what your 'junk' results are. Jun 23, 2016 at 3:26
  • 1
    I'm a bit surprised you have put a bounty of +100 rep on this question, but are not answering queries like the comments above, that might help resolve it.
    – Nick Gammon
    Jun 23, 2016 at 21:33

7 Answers 7


You can try to use serialSIM800.println("AT") instead of write. Here some examples https://github.com/stanleyhuangyc/Freematics/issues/17


NeoSWSerial would be better for this. It can read and write at the same time, unlike SoftwareSerial, and it doesn't disable interrupts for the entire character receive time (~1ms!). AltSoftSerial would be even better, but you can only use it on pins 8 & 9 (on an UNO, different pins on other Arduinos).


Somewhere you said that ...but Serial.write return's junk.... Make sure that serial print is Both NL & CR


You are getting junk because of baud rate, set as 9600.

Serial.begin(9600); while(!Serial); serialSIM800.begin(9600); Serial.println("wait for .... it"); delay(10000);


IIRC, SIM800 modems are very 1990s, they default to 9600 baud. You will get garbage at 38400.

I successfully used a SIM800 at 9600.


My SIM808 returns a bit of junk right from the get-go, so that might be influencing things.

Also, it's conceivable you are retrieving a -1 from your initial serialSIM800.read() call - it's a nonblocking call and returns -1 when no data is available. That would almost definitely appear as junk.


Sim800 series free Atcommander software.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.