Author Topic: Serial.println()  (Read 2489 times)

0 Members and 1 Guest are viewing this topic.

Offline thelearnerTopic starter

  • Contributor
  • Posts: 21
  • Country: in
Serial.println()
« on: August 19, 2021, 04:59:16 am »
Hello,
I have a standalone device with ATtiny85 MCU running Arduino firmware. In the firmware there are serial.println() functions that write its status to the serial port. Since it is a standalone device serial port is not connected to a system or to any other device.
Will this affect the device in any way in the long run?

TIA

Regards,
thelearner
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3171
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Serial.println()
« Reply #1 on: August 19, 2021, 05:41:12 am »
No, as long as nothing is connected to the serial pins, no problem.
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 
The following users thanked this post: thelearner

Offline Rick Law

  • Super Contributor
  • ***
  • Posts: 3538
  • Country: us
Re: Serial.println()
« Reply #2 on: August 21, 2021, 05:00:01 am »
One thing to consider...  Why would you want to bring in the serial library (which is not small) and add complication.

I would think, eliminating those serial related codes with #define then #if to block them out would be a far superior way to handle them rather than leaving the serial.whatever() in place relying (hoping) it would do no harm.
 
The following users thanked this post: Ian.M

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Serial.println()
« Reply #3 on: August 21, 2021, 07:33:30 am »
One thing to consider...  Why would you want to bring in the serial library (which is not small) and add complication.

Not all that much, even for an ATTiny85. I don't have the ATTiny package installed on this machine, but it won't be much different to the 328.

Adding Serial.begin(9600) to a sketch adds 994 bytes of code.
Serial.println() of an int adds 98 bytes more.
Serial.println() of a string instead adds 36 bytes.
Printing both an int and a string adds 104 bytes [1] over just Serial.Begin() or 1098 bytes over the sketch with no use of Serial at all.

Those numbers include the call to the library as well as the library code.


[1] that's so little more than just printing an int that I expect it's not actually adding any more library code,  and the 6 bytes difference is simply the call to the string print function.

ATTiny85 has 8K of program space, so using 1K for Serial is probably usually not a big deal. You probably want to have the ability to add debug printing if necessary, so leaving that flash space empty in production deployments doesn't actually save anything.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->