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
...
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 ...
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 ...
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. ...
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....
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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) {...
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
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 (...
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 ...
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 ...
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 ...
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 ...
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 ...
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" ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
softwareserial × 461serial × 199
arduino-uno × 191
esp8266 × 75
bluetooth × 39
arduino-mega × 36
gsm × 34
communication × 32
uart × 30
arduino-nano × 28
hc-05 × 21
gps × 20
serial-data × 17
nodemcu × 16
attiny × 16
c++ × 15
arduino-ide × 12
sensors × 11
wifi × 10
arduino-pro-mini × 10
xbee × 10
rs232 × 10
esp32 × 9
atmega328 × 9
interrupt × 8