Serial USB connection

Hello,
I have an Arduino Uno with SIM800c shield connected to the Uno.
I’m using a testing Send SMS code:

#include <SoftwareSerial.h>
SoftwareSerial GPRS(7, 8);
int PowerKey = 9;

void setup()
{
  PowerOnSIM();
  Serial.begin(19200);
  GPRS.begin(19200);
  SendSMS(true);
}

void loop()
{

}




//********** Power On the SIM 800c ***************
void PowerOnSIM(void)
{
  digitalWrite(PowerKey, HIGH);
  delay(1000);
  digitalWrite(PowerKey, LOW);
  delay(2000);

}
//**************** Send SMS Message ***************
void SendSMS(bool begin)
{
  GPRS.print("\r");
  delay(1000);                    
  GPRS.print("AT+CMGF=1\r"); 
  delay(1000);
  GPRS.print("AT+CMGS=\"+xxxxxxxxxx\"\r");    
  delay(1000);
  GPRS.print("Testing SMS\r");
  delay(1000);
  GPRS.write(0x1A); 
  Serial.println("Message Sent");
}

When I power the Uno with SIM800c shield using USB only everything works finem and I received the SMS.

Now i removed the USB cable and i power the system using Power adapter (7.5 Volt, 2 Ampere) only (without USB cable) i didn’t receive the SMS message unless i connect the USB cable when the power adapter is connected.

Does the Serial connection “USB to my PC” is required to be connected all the time?

zeroone:
Now i removed the USB cable and i power the system using Power adapter (7.5 Volt, 2 Ampere) only (without USB cable) i didn't receive the SMS message unless i connect the USB cable when the power adapter is connected

How do you know?

If you disconnect the USB cable the Arduino cannot send data to the Arduino Serial Monitor.

...R

I didn’t receive the sms at mobile.
The problem when it is powered from the adapter only and power off the adapter and reconnect again, i didn’t receive the sms at mobile, at that time i connect the usb to pc the message is sent to mobile.

That sounds like a power problem. I can't see anything in your program that would be affected by being connected to your PC, or not.

Do you have a USB-TTL cable so you can check the output from Rx on your Arduino when the regular USB cable is not connected to the PC?

I don't have a SIM module so I can't test your program.

...R

I have an HP USB to RS232 cable if it is can help me for troubleshooting?

as you see that my sending SMS is within the setup section, so when it is powered by the adapter it is not executed but once the USB cable is connected it is executed, so does the serial.begin (for PC USB) which is within the setup section is required to be connected in order to complete execution?
my second question if you please, when Uno is powered from the adapter and we connect the USB cable, do Uno shift power source from adapter to usb?

thanks in advance

zeroone:
I have an HP USB to RS232 cable if it is can help me for troubleshooting?

A USB - RS232 cable is NOT suitable. You need a USB - TTL cable. RS232 voltage levels can damage an Arduino.

...R

zeroone:
I have an HP USB to RS232 cable if it is can help me for troubleshooting?

my second question if you please, when Uno is powered from the adapter and we connect the USB cable, do Uno shift power source from adapter to usb?

thanks in advance

it dependes : if you have the official board or clone, if you power from connector or Vin.

note depending on board manufacturer connecting both external power and usb power may cause problem to Vin voltage regulator.

Do you have a DMM? if yes,

measure the voltage on 5V VCC pin (and GND) of uno a) with usb power only, b) with external adapter power only and c) (read note above) with both external and usb.

If reading on c is closer to a then power comes from usb ..etc

Q : with usb power only, how do you power sim800? Does it have a regulator on module?

You could make the LED on the Arduino blink a few times as confirmation that a certain part of the program has been executed, but it does sound like a power problem.

Deva_Rishi:
You could make the LED on the Arduino blink a few times as confirmation that a certain part of the program has been executed, but it does sound like a power problem.

I have added the Flash Leds code to the testing sketch, disconnect the USB cable and connect the power adapter alone and the Led is flashing.

#include <SoftwareSerial.h>
SoftwareSerial GPRS(7, 8);
int PowerKey = 9;
int LED10 = 10;
int LedState=LOW;
unsigned long previousMillisResponse = 0;
const long OneSecond = 1000;
int count;

void setup()
{
  PowerOnSIM();
  Serial.begin(19200);
  GPRS.begin(19200);
  SendSMS(true);
  pinMode(LED10, OUTPUT);
}

void loop()
{
  FlashLeds();
}

//********** Power On the SIM 800c ***************
void PowerOnSIM(void)
{
  digitalWrite(PowerKey, HIGH);
  delay(1000);
  digitalWrite(PowerKey, LOW);
  delay(2000);

}
//**************** Send SMS Message ***************
void SendSMS(bool begin)
{
  GPRS.print("\r");
  delay(1000);                    
  GPRS.print("AT+CMGF=1\r"); 
  delay(1000);
  GPRS.print("AT+CMGS=\"+xxxxxxxx\"\r");    
  delay(1000);
  GPRS.print("Testing SMS\r");
  delay(1000);
  GPRS.write(0x1A); 
  Serial.println("Message Sent");
}

  //************ flash LEDs*************************
void FlashLeds(void)
{
unsigned long currentMillisResponse = millis();
      if (currentMillisResponse - previousMillisResponse >= OneSecond)
    {
      previousMillisResponse = currentMillisResponse;
      if (LedState == LOW)
      {
        LedState=HIGH;
      }
      else
      {
        LedState=LOW;
      }
      digitalWrite(LED10,LedState);
    }
}

so the code gets executed, can you post the schematic of how you wired up the SIM800C

Deva_Rishi:
so the code gets executed, can you post the schematic of how you wired up the SIM800C

The SIM800c is Shield which connect to the UNO directly - I have attached photos for that


I didn't want to download the picture.
Maybe it's something with the swSerial Library you are using ?
It doesn't make sense.. have you tried neosoftwareserial ?
or try commenting out all reference to hwSerial.
The power should not be an issue, where does the shield draw from ? the 5v pin ? or the 3.3v pin.

Deva_Rishi:


I didn't want to download the picture.
Maybe it's something with the swSerial Library you are using ?
It doesn't make sense.. have you tried neosoftwareserial ?
or try commenting out all reference to hwSerial.
The power should not be an issue, where does the shield draw from ? the 5v pin ? or the 3.3v pin.

hi again,
i don't thing it is a power problem since even if i power the system with the PC USB i didn't get the SMS unless i open the IDE and also open the serial monitor from IDE (Tools --> Serial Monitor), it is a strange behavior.

as i said before, i suspect the softwareserial library is somehow hooked in with the hwSerial, it is waiting for a hwSerial connection before continuing the softwareSerial transmission

Deva_Rishi:
as i said before, i suspect the softwareserial library is somehow hooked in with the hwSerial, it is waiting for a hwSerial connection before continuing the softwareSerial transmission

Yes I'm fully agree with you, so I have to replace it with another library but as you mentioned before "neosoftwareserial " as I read the SoftwareSerial is the replacement for neosoftwareserial? or I can use it?

I think i read somewhere that the current softwareSerial is in fact what used to be called neoSoftwareSerial, but have you tried commenting out all of the HardwareSerial statements ?

Hi and thank you, yes I have removed all the serial statements and failed, anyway I will repeat this test.
In addition, no other way or work around to use the UNO serial port "hardware" for communicating to the SIM800 shield but i think i will lose the connection between UNO and the PC.

option3: is there any added value to remove the pins 0,1 from the sim800c shield so UNO will not has any pin connection from pins 0,1 to the 800c shield?

option4: Do i need to replace the UNO with mega or any other boards that have more than one hardware serial ports?

If you are going to modify the pins on the shield, you could try altSoftSerial first it uses pin 8 & 9 always i think, but apparently it is good library. I have used it successfully.

if you connect the hwSerial to the chip you can not use it at the same time on the USB port this is true.

I doubt that pins 0 & 1 on the shield are actually connected to anything on the chip, removing the from the shield would pointless.

Hey do you have any of those arduino connecting cables female -> male ? then you could do some of the rewiring to different pins without doing any soldering.

Regarding altSoftSerial yes it uses 8,9 pins and the 800c is uses 7,8 and 9 for power control so altSoftSerial is not suitable for this sim I think.

I have repeated removing any serial command from the sketch and the test failed.
As I told you before, the sim800c uses 7,8 pins so I can't change them.

by the way, moving to hardware serial solve my issue by getting a mega or any Arduino boards with two hardware serial at least?

Deva_Rishi thank you for your help, It is really appreciated, the problem is solved by the help from some guy, he asked me to put a delay after poweron function the gsm and before the serial and gsm begin, I tried first with 10 seconds and then tried with 5 seconds and works fine.

again thank you and to any one who tried to help me!