Go Down

Topic: Serial.begin and current draw (Read 591 times) previous topic - next topic


Hi All,

I just wanted to check whether I should expect current draws of around 30mA whenever using Serial.begin(115200); I have a barebones arduino setup on a breadboard that I can sleep down to 0.7mA when using a very basic sleep sketch. As soon as I add in Serial.begin I am seeing this jump up to 30mA even when sleeping. Is this normal?

Nick Gammon

Can you post this sketch? Then we can try for ourselves.



Serial.begin() should activate the internal UART and do - among other stuff - the equivalent of
Code: [Select]
pinMode(1, OUTPUT);
digitalWrite(1, HIGH); // idle , 0 = start bit

What do you have connected there ?
How much current does this code alone invoke ?
Are you sure it sleeps, if something is connected to the Rx pin, sending data ?


Here is the sketch, please excuse the mess I am purely prototyping at the moment.

Some notes, I am using the breadboard setup that Nick has on his site: http://www.gammon.com.au/images/Arduino/Minimal_Arduino1.jpg with a 328P that has been re-flashed to run at 8mhz lillypad style.

The gps I am using is the adafruit ultimate gps breakout.

The code essentially runs the following:

Arduino starts up and attempts a GPS fix, which counts through to 2 minutes. If no GPS fix then the arduino sleeps into power down mode and the GPS is turned off via its enable pin. If a fix is found within the 2 minutes then the sleep is initiated earlier.

The code is:

I have highlighted in the code above where the command (line 74.. message length was too long for post so had to put this on pastebin) is called to start the serial (it has been uncommented along with all of the serial.print lines whilst I have been measuring current draw). With the code as above during sleep I can get 0.7mA as expected. However if I uncomment the serial.begin line and the corresponding serial.print lines later on it seems to run much higher as shown below.

The following consumption readings have been measured:
barebones as lilly running 8mhz:
arduino awake = 11.6mA
arduino sleep = 0.3mA
arduino + gps (aquiring fix) = 49 - 57mA Note: Seems quite high as GPS aquiring fix is only around 20-25mA from data sheet
arduino + gps + sleep = 37mA // figures incorrect serial.begin adds in another 20ma atleast?! GPS is definitely asleep as tested without GPS breakout on board
arduino + gps + sleep + gps disabled + no serial.begin = 0.7ma sleep and 20mA wake[/li][/list]

On the 3rd test case you can see I noted that it seems quite high consumption. I would have expected 30mA approx but something was pushing nearly another 30mA on top of this.
On the 4th test whilst everything was asleep I noticed a draw of still 37mA.. I even disconnected the GPS and still had over 30mA being pulled.
On the 5th test I commented out all of the serial.begin and print code and everything worked as I would have expted.

Conclusion was that the serial.begin was causing the issue?

Nick Gammon

You can attach files, you know. Not everyone wants to go to pastebin.

I'm not at my main PC right now but I think you can do a Serial.end to close the serial connection.



Attached for those who do not want to use pastebin..

Nick Gammon

Code: [Select]

  char c = GPS.read();

I wouldn't be doing serial reads inside an ISR.

Code: [Select]

// Interrupt is called once a millisecond, looks for any new GPS data, and stores it

Surely the GPS doesn't need to be queried every mS?

Code: [Select]


I haven't used the Narcoleptic library, however in my testing I found you should be able to get sleep current down to well under one milliamp.


For example, this temperature/humidity logger:


Despite the 8-digit LED display, the SD card, the sensors, etc. most of the time it uses about 7 µA when asleep.

My immediate suggestion is to make sure everything is turned off, including your use of the SoftwareSerial port. I don't know if Narcoleptic does that or not.


Thank you for the input Nick. I can get under 1mA when sleeping if I ditch the serial reads. It is only when using them that I get a spike, even when awake I see more current draw during serial reads than if I comment them out. I guess I will just use them for debug and then remove them anyway as they will not be needed in the final solution.


I see more current draw during serial reads than if I comment them out. I guess I will just use them for debug and then remove them anyway as they will not be needed in the final solution.

Why do you think you need to remove them? If the Arduino does not have the USB cable (supplying power) connected, then Serial.available() will never return a positive value, so you'll never call Serial.read().

If the USB cable is connected, I can't imagine why power consumption is an issue.


Because I will be running the project from batteries in the future..


Because I will be running the project from batteries in the future..

Very few batteries are able to send serial data. Serial.available() should be able to tell you that there is nothing to read. There will, therefore, be no need to call Serial.read().

Go Up

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.

shortcuts: alt+s submit/post or alt+p preview