14 votes
Accepted

Why is Serial.Write that slower when writing x+1 characters than when it is writing x characters?

The Arduino core has a 64 byte transmission buffer. Characters are sent out of that buffer by the hardware. When you blast lots of characters out of serial the first 64 just get put into that buffer ...
Majenko's user avatar
  • 105k
10 votes

When Raspberry Pi is preferred over Arduino

The claim that the Pi is more "powerful" is a bit misleading. What does "powerful" really mean? And is it relevant to making a weather station? I made a temperature and humidity sensor as described ...
Nick Gammon's user avatar
  • 38.2k
10 votes
Accepted

Arduino Nano is performing really slowly, even though the calculations are simple and there are no delays

I put in some timing into your code. As a tip for you and others who may want to time code, here is a simple way of doing that ... Timer class Define a timer class as follows: class timer { ...
Nick Gammon's user avatar
  • 38.2k
6 votes

When Raspberry Pi is preferred over Arduino

As opposed to the Arduino boards, the Raspberry Pi is a single-board computer with a quad-core CPU, a GPU, on-board RAM, and many peripherals. The main difference between the Pi and the Arduino (or ...
altai's user avatar
  • 161
6 votes
Accepted

Does serial speed affect performance of other tasks?

It depends. Serial data is received into, or sent from, buffers (one for sending and one for receiving). If you have a processor with 1024 bytes of RAM or more, then the buffer size is 64 bytes, ...
Nick Gammon's user avatar
  • 38.2k
5 votes

Will unnecessary Serial.print() statements slow down my program?

No, there is no USART wasn't enabled so skip all prints. Everything must be done anyways (calls, conversions to strings, writes to UDR - USART Data Register). It is just not sent outside by USART and ...
KIIV's user avatar
  • 4,752
4 votes
Accepted

Why would anyone use Arduino in 2017?

This is the ATtiny. It costs < $1 and is completely capable of most tasks that a hobbyist requires of a chip. Truthfully, it’s more than capable of many tasks a pro requires as well. It’s perfect ...
RubberDuck's user avatar
4 votes

Why does Arduino IDE take so long to open?

The simple answer is "libraries". Every time you start the application, all files inside your library folder are parsed. And this is not done over your OS, but over the Java-Virtual Machine. So it ...
Adriano's user avatar
  • 336
4 votes

Extrapolate require MCU from Arduino MEGA2560 performance

There are three things that i can see that are holding your code back. AnalogRead in Arduino is very slow. The ADC in the chip is not the greatest but also the AnalogRead function will hold you ...
vini_i's user avatar
  • 141
3 votes

Why is Serial.Write that slower when writing x+1 characters than when it is writing x characters?

Your "long" delay is not too long at all. If you measure the throughput of the right part, you have about 30 characters sent in 2500 microseconds. This means the rate is roughly (30 * 8 * 1,000,000) /...
IMil's user avatar
  • 131
3 votes

Why is Serial.Write that slower when writing x+1 characters than when it is writing x characters?

Majenko already gave the right answer: as soon as the buffer is full, everything falls apart (for a time sensitive application). It is possible to enlarge the serial buffer for your project. However, ...
Jot's user avatar
  • 3,246
3 votes
Accepted

for loop reads pots, passes value to PWM pins, can this be in the same for loop?

Having both the analogRead() and analogWrite() in the same loop is perfectly fine. That would be be my preferred choice if only for one reason: less RAM consumption. If you split them in two loops, ...
Edgar Bonet's user avatar
  • 43.1k
3 votes

Why would anyone use Arduino in 2017?

An arduino board is really a breakout for a micro processor. Microprocessors you can get separately. A rPi is really a full system without that modularity. There are also other size factors for that ...
ratchet freak's user avatar
2 votes

When Raspberry Pi is preferred over Arduino

In "pure hardware" based systems, real time systems, you can always prefer Arduino over Pi with OS. Power consumption, price are other plus points for UNO. Pi is always the better one in complex ...
Mitu Raj's user avatar
  • 424
2 votes
Accepted

Performance tuning PORTB manipulation - mask

4 cycles: IN Rd,PORTB CBR Rd,7 ORI Rd,x OUT PORTB,Rd Translation into proper GCC inline assembly syntax is left as an exercise for the reader.
Ignacio Vazquez-Abrams's user avatar
2 votes
Accepted

Use of "static" with "RTClib"

You wrote: DateTime now = rtc.now(); Thus, with every iteration of loop() "now" gets defined anew (on the heap?!), right? No. Local variables like this are usually allocated on the stack, ...
Edgar Bonet's user avatar
  • 43.1k
2 votes
Accepted

Slow refresh rate on I2C OLED screen

Solved by updating the Adafruit sdd1306 library and the Adafruit GFX library EDIT: Why am I being downvoted?
none none's user avatar
  • 233
2 votes

UDP Packet Loss

UDP does not guarantee delivery. https://en.wikipedia.org/wiki/User_Datagram_Protocol It has no handshaking dialogues, and thus exposes the user's program to any unreliability of the underlying ...
Nick Gammon's user avatar
  • 38.2k
2 votes

Hardware implementation of trigonometric functions?

I do not know the answer to your main question, but I will try to answer the underlying question: I want to know if it is feasible to implement more efficient trigonometric functions for specific use ...
Edgar Bonet's user avatar
  • 43.1k
1 vote
Accepted

What is the overhead of a saturated serial connection at 256k baud?

So I decided a little empirical testing was in order. This is using a nano (328P) Using a simple for loop in loop() (calculating the squares of 0 to 255) over 10 seconds with and without there being ...
Simm's user avatar
  • 51
1 vote

Asymmetric encryption on a Teensy?

Teensy4.1 has 55 digital IO (serial) pins at up to 200MHz. The USB port supports 480mbps, and ethernet is 10/100mbps. You're limited to 32 DMA channels, though (complicated but these are used to ...
CSoft's user avatar
  • 23
1 vote

Use of "static" with "RTClib"

You don't need to use the static keyword. The cleanest solution is to define DateTime outside of the loop function: DateTime now; This will allocate the memory, and call the constructor of the ...
Michel Keijzers's user avatar
1 vote
Accepted

Difference in increment & decrement loop execution speed

Comment out these 2 lines Serial.print("the value is="); Serial.print("\t"); And report back on the speed difference. Why not add a reading of micros() before and after each loop and see how much ...
CrossRoads's user avatar
  • 2,415
1 vote

real-time reading of a quadrature encoder at full resolution with only one interrupt on ATmega328

This is just a partial, rushed answer. You should be able to get a significant speed-up if you define your own ISR for handling the interrupt, as in: ISR(INT1_vect) { ... } The Arduino way of using ...
Edgar Bonet's user avatar
  • 43.1k
1 vote

Does serial speed affect performance of other tasks?

No, it affects code performance always. For how much is dependent on used data types, baudrate, tx buffer size. Data types: AVR doesn't have hardware floating point operation support. Software ...
KIIV's user avatar
  • 4,752
1 vote

Will unnecessary Serial.print() statements slow down my program?

A quick test shows that not doing a Serial.begin makes things run 10 times as fast. For example: void setup () { Serial.begin (115200); pinMode (13, OUTPUT); } // end of setup void loop () ...
Nick Gammon's user avatar
  • 38.2k
1 vote

Will unnecessary Serial.print() statements slow down my program?

The compiler cannot know what the situation with the device is at runtime. The function itself must determine that, so the call will take place, with arguments and everything. A well-written function ...
John Burger's user avatar
  • 1,875
1 vote

for loop reads pots, passes value to PWM pins, can this be in the same for loop?

Obviously you can. Except that in most cases your loop execution is much faster than your own period so that you end up changing the duty cycles multiple times in one period. Not an advisable ...
dannyf's user avatar
  • 2,770

Only top scored, non community-wiki answers of a minimum length are eligible