Serial (UART) communication

Hello,

I’ve hooked up a sim800 gsm modem on an UNO (pin 0, 1). I wrote a simple sketch which sends 2 modem commands over the serial connection. First setup a call, delay 5 seconds and then disconnect the call. When I upload the sketch from the arduino ide everything works fine (tx is lid, modem receives commands and initiates/ends the call).

When I power cycle the arduino and modem the sketch is started again (blink check ok) but the serial transmission is not initiated. No AT commands send (tx not lid). Also tried with external power, same result no serial transmission. What could be the cause of this problem.

What happens if you just reset the Uno, with the reset button, without cycling the power? Can you, please, post your code? Please read the "how to use the forum-please read" stickies to see how to format and post code.

I suspect you have to wait a while after powering up the GSM modem before it can connect. It
has to negotiate with the network.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.... :slight_smile:

Here is the code, it works fine after an upload from the Arduino IDE. But with both powercycle and reset debug flash works but no tx led flashes. (also tried external power 9v 1A no tx either)

void setup() {
  pinMode(LED_BUILTIN, OUTPUT); //set debug blink
  digitalWrite(LED_BUILTIN, HIGH); //debug blink on

  Serial.begin(9600);
  while(!Serial);
  Serial.flush();

  delay(30000);   

  digitalWrite(LED_BUILTIN, LOW); //debug blink off
  
  Serial.print("ATD06********;\r");
  delay(5000);   
  Serial.print("ATH\r");
  delay(300);

}

void loop() {
 
}

What happens if you remove:

while(!Serial);
Serial.flush();

You say this is an Uno, though - so neither of those should be having any effect.

Here is the code, it works fine

No what you posted does not work at all. You need to post ALL your code.

See why here :- http://snippets-r-us.com/

A reminder is here:- https://www.youtube.com/watch?v=tdQL_7osGzc

Right, nice vid. Indeed I forgot to copy the empty loop.

Do you have any clue why the serial transmission of AT commands is successful only after a sketch upload?

Indeed I forgot to copy the empty loop.

And the variable declarations. And any libraries you may or not have included.

Reply #5? Did you try that?

Is your modem being power cycled?

I stripped my original sketch to eliminate other interference. There is no need for libs or vars in this simple example.

I tried #5, same effect; immediately after sketch upload it is working fine. But when power cycle, reset or external power is used the AT commands are not send. Only when the sketch is uploaded again it works. Could it be something which configured/set on the serial port by the uploading sequence?

You do not need to upload code again. We here this from beginners many times and they are always mistaken.

There is no need for libs or vars in this simple example.

Yes their is as your code as posted will not compile, so how can we try it?
As you choose not to cooperate with simple requests I guess you are in your own.