Arduino code doesn't work without connection to laptop

So i have a arduino uno, and i tried to connect it to a gsm module, and turn an led on/off using sms sent from my phone. I connected the tx and rx pin of module to digital pin 9 and 10 of arduino, and then created a SoftwareSerial object and passed 9, 10 to it's constructor so i could send and receive data using gsm.read() and gsm.println() (gsm being the object of SoftwareSerial)

I wrote all the code and it worked fine when i powered the arduino using my laptop's usb, and the led turned on and off when i sent messages.

However when i disconnected the usb and connected an external power supply to the arduino, it stopped working. The lights on the arduino also lit, but the led no longer changed state. I powered it using a 9 volt wall adapter and plugged it into the cylindrical power socket on the uno

Is your code still waiting for the PC connection to be made?

1 Like

Umm i assume you mean Serial connection? In that case i have not used the Serial object

The you have included NO way to debug your code.

I don't get what you mean, the code works fine with the laptop, i use no communication with the laptop, i only communicate with the gsm module, so it should work, i mean there should be no difference, right?

I mean you have included no way to show yourself how far the code gets before the problem occurs.

1 Like

Ahh yes i guess i should do that, will try that tomorrow since it's past midnight for me here. Will update after testing. Anyways, thanks for the help :slight_smile:

Let's see a schematic. I'm going to guess it's a ground thing.

The Arduino code may try to initialize the module when it is not ready, you can solve it by give some delay at the beginning of setup() function. See more detailed here Arduino code does not work when switching from USB to power supply

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.