Skip to main content
9 votes
Accepted

How to pass 'Serial' as an input argument in Arduino function?

The Serial object is the end of a chain of classes, each with a different set of functionality. Print -> Stream -> HardwareSerial => [Serial] Since you are reading from it the best class to ...
Majenko's user avatar
  • 106k
9 votes
Accepted

Non-blocking SoftwareSerial.Write

In short, you don't. The SoftwareSerial implementation for AVR doesn't have an outbound buffer at all. It just turns the interrupts off during each character outbound and it sends them all immediately....
timemage's user avatar
  • 5,719
7 votes
Accepted

Create New Serial Class Inheriting from Stream

The Stream class has pure virtual methods which must be implemented in derived not abstract class. The pure virtual method from base class Print is: virtual size_t write(uint8_t) = 0; The pure ...
Juraj's user avatar
  • 18.3k
6 votes

How to write a library that support both HW and SW Serial communication and allow user to chose which one to use?

The trick here is to go "up a level". Both HardwareSerial and SoftwareSerial inherit from the Stream class. It is that class that provides the majority of the interface that you actually ...
Majenko's user avatar
  • 106k
6 votes

Printing the array using print and serial write function in Arduino Uno

Serial.write(some_byte) writes a byte on the serial output. The Arduino serial monitor tries to interpret the bytes it receives as text: 0x11 is a control character, displayed as “□” 0x22 is the ...
Edgar Bonet's user avatar
  • 45.2k
6 votes

reading device or board specific properties from the Arduino MKR WiFi 1010 device

The IDE shows the serial number so I looked into the SAMD core and found the function which reads the serial number from registers. It is in the CDC.cpp file uint8_t Serial_::getShortName(char* name) {...
Juraj's user avatar
  • 18.3k
5 votes

getting error 'Serial' was not declared in this scope

I learned that I needed to include Arduino.h header file apart from that I learned .ino files and .cpp files is that the .ino files transparently include particle.h for you. The other difference is ...
Ciasto piekarz's user avatar
5 votes

How to chose softserial library use on Arduino project?

I think your problem is that you need 4 serial ports. With software serial that's just not going to happen: SoftwareSerial can only receive on one serial port at any given time. AltSoftSerial is ...
Majenko's user avatar
  • 106k
5 votes
Accepted

What is the best delay to use between characters sent to the serial port

SoftwareSerial has a considerable overhead. It can often send at 115200 successfully but 9600 is about its limit for receiving, and you're trying both send and receive. In addition, for each character ...
JRobert's user avatar
  • 15.4k
5 votes

What is the best delay to use between characters sent to the serial port

Simply put, a serial port implemented in software requires the program to sample the input pin fast enough to detect every transition. To satisfy the Nyquist frequency rate we need the program to ...
st2000's user avatar
  • 7,513
4 votes

Can increasing the size of the software RX buffer cause problem in Arduino Uno

The buffer is in the UNO's limited (2K) RAM; you'd be using 1/4 of it for the input buffer. If your app is small enough and simple enough (limited call depth, specifcally), there may still be enough ...
JRobert's user avatar
  • 15.4k
4 votes

Why does SoftwareSerial::read() return int?

The documentation on Arduino's website shows SoftwareSerial::read() as returning a char. No it doesn't. There is nothing in the documentation that tells you the return type. There is only an example ...
Majenko's user avatar
  • 106k
4 votes
Accepted

Serial.availableForWrite versus Serial.flush

The line while (Serial.availableForWrite() <= 0) {} waits until the serial output buffer is not full. Whereas Serial.flush(); waits until the serial output buffer is empty.
Edgar Bonet's user avatar
  • 45.2k
4 votes
Accepted

Converting each digit in an integer to its respective ASCII characters

To convert a whole number to a char array in one go use the itoa function. That sounds like what you actually need. To convert one digit from decimal to ascii just add '0', the ascii value for a 0....
Delta_G's user avatar
  • 3,391
4 votes
Accepted

SoftwareSerial read until available is empty only works with delay

Serial does not transmit data as one bunch, but byte by byte. There can easily be some little delays introduced, especially, when transmitted via a packaged protocol like bluetooth, long enough, for ...
chrisl's user avatar
  • 16.6k
4 votes
Accepted

How to read from and write to rs232 device from/to Arduino

You didn't show how you connected the MAX3232, so I cannot say anything about that. But I can write something about your code and how the data gets received on the PC. On the PC: Here it is important ...
chrisl's user avatar
  • 16.6k
4 votes
Accepted

which is the best way to declare Serial while creating Arduino library?

As regards the use of Stream: I usually use Stream instead of HardwareSerial because: It allows the use of other serial devices, like SoftwareSerial or USBSerial that aren't "Hardware" ...
Majenko's user avatar
  • 106k
3 votes

SIM800L not registering to network

I am 90% sure it's a power issue. Not sure on what board/module you're using but the SIM800L/SIM900 needs a burst of current of 2 A during 577 µS (See the manual). Try using 4700 µF ...
Jorge Gonçalves's user avatar
3 votes

Arduino Pro Mini Serial Monitor garbage

I had the same issue. The problem was solved in an other forum: https://forum.arduino.cc/index.php?topic=434623.0 I copy the solution here: It appears that in fact your board is not running at 8MHz, ...
pvoj's user avatar
  • 193
3 votes
Accepted

SoftwareSerial runs out of "text" space on ATtiny

Your sketch doesn't fit into program memory of the ATtiny. If you comment out the println of the array, the compiler evaluates that the array is not used and doesn't attach it to the program. Then the ...
Juraj's user avatar
  • 18.3k
3 votes

SoftwareSerial runs out of "text" space on ATtiny

There is not enough room in program memory for 140KB. ATiny only has 8KB for the whole program. So there is no way to fix this with your current hardware. Options- add a storage device (SD card, ...
Chad G's user avatar
  • 630
3 votes

Receive data from Arduino board to Android application

I don't think your code is correct: void loop () { if (blueTooth.available()) Serial.write(blueTooth.read()); if (blueTooth.available()) <---- blueTooth.write(Serial.read()); } ...
Code Gorilla's user avatar
  • 5,652
3 votes

Sending PUBX commands to GPS Board (Ublox NEO-6M) through SoftwareSerial

I've tried your code sending those PUBX commands to a ublox module and they work successfully for me. There are a lot of fakes about on the internet using AT6558 chips repackaged as ublox. Check the ...
torntrousers's user avatar
3 votes
Accepted

Entire arrays are not read by Processing sent by Arduino unless cord is unplugged and plugged back in?

I would suggest that you are seeing reset-stutter from the serial. Basically the sketch is running and filling the serial buffer with data. Then you connect and the board resets, but some data is ...
Majenko's user avatar
  • 106k
3 votes
Accepted

Passing HardwareSerial and SoftwareSerial as a Class Property

A base type for Arduino hardware serial classes, SoftwareSerial and other software serial classes and some other Arduino classes is Stream (reference). Stream.h on GitHub class CustomSerial { private:...
Juraj's user avatar
  • 18.3k
3 votes

ESP8266 ASCII to HEX convertion and checking

A little explanation about HEX and ASCII: About HEX Raw computer data consists of zeros and ones. For humans it is difficult to read a (long) row of zeros and ones. You can represent such a row (of a ...
PimV's user avatar
  • 443
3 votes

Software serial conflict with WiFi on ESP8266

As noted, there are conflicts between Wifi and SoftwareSerial. The attempt in the question to disconnect WiFi is a step in the right direction, but not enough. You have to actually turn off the WiFi. ...
Llaves's user avatar
  • 261
3 votes
Accepted

Why does SoftwareSerial::read() return int?

You'll see in the code just above your third link that the function can return a value of -1 if there is no data present. Thus a 16-bit value is used to cover the range of 8-bit uint8_ts, plus one ...
user85471's user avatar
  • 836
3 votes

Getting issues while using SoftwareSerial

SoftwareSerial only works on a few select GPIO pins on the Mega. Specifically those pins that have PCINT on them. But that is irrelevant. There is no reason to use SoftwareSerial on a Mega except in ...
Majenko's user avatar
  • 106k
3 votes
Accepted

Reading from EEPROM and combining

You cannot use the + operator for that. However, since EEPROM.read only returns one byte and not a string, you can do a much easier implementation: void loop() { char result[] = "1:2:3"; for ...
Michel Keijzers's user avatar

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