17 votes
Accepted

How does serial communications work on the Arduino?

Asynchronous serial (usually referred to as serial) communications is used to send bytes from one device to another. A device could be one or more of the following: Arduino PC GPS RFID card reader ...
Nick Gammon's user avatar
  • 37.9k
9 votes
Accepted

Send AT commands to ESP8266 from Arduino Uno via a SoftwareSerial port

Does anyone know if what I am trying to do is possible? Absolutely possible :) And if it is, what am I doing wrong? SoftwareSerial isn't capable of 115200 baud rate (despite "allowing" this as a ...
Grant's user avatar
  • 385
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
  • 105k
8 votes

Send AT commands to ESP8266 from Arduino Uno via a SoftwareSerial port

Well you may try this: Start by uploading blink sketch to your Arduino then connect it to your ESP8266 like this: TX-TX and RX-RX. Now open Serial Monitor and send AT command and see if it responds. ...
Ikbel's user avatar
  • 640
8 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,018
7 votes
Accepted

WiFiEsp not working on Software Serial, working fine on Hardware Serial

If you're going to talk to your ESP at 9600 baud - and that's about the upper limit for SoftwareSerial - you need to first change the ESP board's baud rate to 9600 baud. It is probably at 115200 right ...
JRobert's user avatar
  • 15.1k
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
  • 17.8k
6 votes
Accepted

HardwareSerial - check for overflow

A look at HardwareSerial_private.h shows incoming bytes are always read (interrupt-based), regardless of what your code is doing. So we can't set up a hardware interrupt to notify us when the chip's ...
SoreDakeNoKoto's user avatar
6 votes

How to define a SoftwareSerial object inside a class?

Personally I wouldn't go down this route. Instead I would pass a Stream object (as a pointer or a reference) to the constructor and use that. Then it is up to your sketch to define what that Stream ...
Majenko's user avatar
  • 105k
6 votes
Accepted

Is the a low memory alternative to SoftwareSerial?

Simplest thing would probably be to edit your copy of SoftwareSerial.h and replace #define _SS_MAX_RX_BUFF 64 on line 42 by something smaller. If your loop() runs fast enough (no delays, no blocking ...
Edgar Bonet's user avatar
  • 42.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
  • 105k
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
  • 42.3k
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
  • 17.8k
5 votes

SIM808 module GSM working fine, GPS not working (No GPS ready message on power on)

You have a version2 module. Use AT+CGNSxxx instead of AT+CGPSxxx
user24177's user avatar
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
  • 105k
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.1k
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,270
4 votes

Trying to pass a char to software serial with a button press

As pointed out by Edgar you should debounce the button. Perhaps increasing the delay() should do the trick. Try with 100-200 milliseconds. With this edit you can delete Once unless you are planning ...
Facorazza's user avatar
  • 431
4 votes
Accepted

How can I reduce the redundancy of this code, so one function can perform the task of printing on Serial and Softserial?

Just send your data to a tee: this is a type of pipe fitting where you push the data through one end and it goes out through the other two ends. As it happens, both Serial and Softserial (and almost ...
Edgar Bonet's user avatar
  • 42.3k
4 votes
Accepted

Arduino char showing as 2 characters

do { r = XBee.read(); Serial.print(r); } while (r != -1); Think about it. Since you tested for XBee.available() you will have at least one iteration of this loop. And then you ...
Nick Gammon's user avatar
  • 37.9k
4 votes
Accepted

Strange binary number representation

print never prints leading zeroes (how many should it print anyway?). print doesn't start a new line - you need println for that So you get your 4 in binary printed twice followed by something else (...
Majenko's user avatar
  • 105k
4 votes

Make Sure \n is the last character in serial string

Since you are using all 8 bits of the serial data for your data there is nothing "in band" that you can use for a delimiter. Instead you will have to think outside the box somewhat and create some ...
Majenko's user avatar
  • 105k
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.1k
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
  • 105k
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
  • 15.8k
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
  • 15.8k
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
  • 105k
3 votes

SoftwareSerial with ESP8266

I have been playing with an ESP8266 over the last couple of days with similar results. My conclusion was that it is very timing dependent. If you build in (fairly large) delays into your code then ...
Nick Gammon's user avatar
  • 37.9k
3 votes

Is SoftwareSerial left out for the ATTiny85/84?

Below you can find the code for a minimal bit-bang send serial implementation ideally suited for debugging. Code size is about 60 bytes. It gives 38400 baud for 1 MHz or 230400 baud on 8 MHz Attiny ...
Armin J.'s user avatar
  • 141

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