Skip to main content
4 votes
Accepted

Arduino IDE equivalent to DataView?

There is no use for a DataView in the Arduino environment. In the JavaScript language, a string and an array of bytes are two very different things. That's why you need something like this str2DV() ...
Edgar Bonet's user avatar
  • 45.2k
4 votes
Accepted

What is the minimal possible latency between arduino and PC

There is more to low-latency communication than just squirting data as fast as you can (though that is an important part of it). One thing people often forget is that the Arduino can only (easily) do ...
Majenko's user avatar
  • 106k
2 votes

What causes Serial.available() to become false after Serial.read() gets data?

It is an internal buffer and only the pointer gets increased. It it visible in the source code off the project, located on github: // Read data from buffer int SoftwareSerial::read() { if (!...
Stefan M's user avatar
  • 141
2 votes
Accepted

Buffer reverse to string

You can do it with snprintf_P: char mac[18]; snprintf_P(mac, 18, (PGM_P)F("%02X-%02X-%02X-%02X-%02X-%02X"), report->peer_addr.addr[5], report->peer_addr.addr[4], report->...
Majenko's user avatar
  • 106k
2 votes

Is Arduino Mega useing one buffer or multiple buffers?

Actually there are 2 buffers per Serial hardware interface: The hardware buffer, that is 1 byte (per direction of data transfer). The Serial library then transfers this byte in an extra buffer (64 ...
chrisl's user avatar
  • 16.6k
2 votes

What is the maximum size of Static Json Document in Arduino JSON?

The Arduino Mega has 8 KB of RAM, all of which you could use in a StaticJsonDocument. The ESP8266 has 80 KB of RAM, but the core limits the stack to 4 KB. If you need something bigger, switch to a ...
Benoit Blanchon's user avatar
2 votes
Accepted

Unexpected character added to char buffer array in serial monitor only when SD card initialized

const int BUF_DIM = 3; char inputString[BUF_DIM]; ... inputString[0] = 'a'; inputString[1] = 'b'; inputString[2] = 'c'; ... Serial.println(inputString); You have allowed three characters ...
Nick Gammon's user avatar
  • 38.9k
2 votes

Arduino interrupt for serial data on digital pin, that is too large for the serial buffer

GPS is a really slow communication, it communicates in 9600bps and data only available once in every second. Any MCU running at much slower than an Arduino Uno running at 16MHz should be able to ...
hcheung's user avatar
  • 1,988
1 vote
Accepted

How to faithfully collect geophone data by modbus RTU?

With the help of Github copilot and a bit of editting this code does the job. First the signal is averaged over 1000 readings. Then the absolute value is reported above an average of the baseline. ...
user36093's user avatar
  • 111
1 vote

Serial Buffer stays empty as soon as it becomes empty once

I second Nick Gammon in recommending a time-based condition, rather than counting the loop iterations. You can do it in a non-blocking fashion though: keep track of when was the last time you ...
Edgar Bonet's user avatar
  • 45.2k
1 vote
Accepted

How to optimize checking for specific string in a UART stream

Here is an idea that may work: instead of buffering the input stream and comparing the buffer with the search string, you could do the comparison on the fly, as you receive the characters. Then you ...
Edgar Bonet's user avatar
  • 45.2k
1 vote
Accepted

Problem cleaning string read from serial buffer

When sending text commands to an Arduino, it is common to define a “line-oriented protocol”: each command is transmitted as a single line, with the line ending signifying the end of the command. ...
Edgar Bonet's user avatar
  • 45.2k
1 vote
Accepted

Elements excluded from buffer array output after given structure (ESP8266 WifiSniffer) (snifferPacket)

What do each of the 12 elements represent? Things in the header. That is off-topic for here. Why is there a difference in the output between the output of the raw buffer and snifferPacket? ...
Majenko's user avatar
  • 106k
1 vote

Clearing string buffer with memset after a serial read

Thanks for the pointer - that did the trick. Applying it to my original code, if I update the few lines around handle call from Python to the following, it works as intended. ////////////////////...
David W's user avatar
  • 39
1 vote

Is Arduino Mega useing one buffer or multiple buffers?

Every instance of class HardwareSerial has own buffers. Here you can see it in source code. The instances are declared/definded at the end of the HardwareSerial.h/.cpp.
Juraj's user avatar
  • 18.3k
1 vote
Accepted

writting to buffer from serial input

A byte can only contain values from 0 to 255 (including). So my guess it works for values until 255. You should use a different type, e.g. unsigned int or unsigned short. for (unsigned short i = ...
Michel Keijzers's user avatar
1 vote

Error handling strings and chars

toCharArray is alias for getBytes. getBytes is documented as "Copies the String’s characters to the supplied buffer." You did not allocate the memory for the copied characters. the right use of '...
Juraj's user avatar
  • 18.3k
1 vote
Accepted

How to transmit string data using the rc-switch library?

The communication protocol used by this library is unreliable. Thus, each code word is sent multiple times, 10 times by default. One solution around this problem is to send a “byte number” along with ...
Edgar Bonet's user avatar
  • 45.2k
1 vote
Accepted

Communication with socketserver fails after specific number of packets

I found my stupid mistake: By using try without catching specific exceptions (I know one shouln't do that) in my Laptop-Server script I didn't recognize that I was trying to send unencoded strings. So,...
Sim Son's user avatar
  • 1,878
1 vote

Communication with socketserver fails after specific number of packets

close the disconnected socket before reconnecting if (!client.connected()) { client.stop(); client=TCPserver.available(); }
Juraj's user avatar
  • 18.3k

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