4

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 where the returned value is assigned to a char variable. That doesn't mean that it returns a char - it just means that whatever data type it does return can be ...


3

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 (int item = 0; item < 3; item++) { result[item * 2] = EEPROM.read(1 + item); } } This first create a string "1:2:3", where the digits are ...


3

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 exceptional circumstances. You have four hardware UARTs on the Mega, so there is no call to use SoftwareSerial. Use the real UART pins and objects: Serial -&...


3

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 extra value to show 'no valid data available'. For simplicity, I guess. Yes. This is what it's designed for. In short, for all intents and purposes, only an 8-bit ...


2

Arduino UNO is using pin 0 and pin 1 to have serial with USB serial Communication. You can not use them to softserial. Change softserial to other pins. /Mikael


2

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. If you just want to try to understand what's going on, it's something like this. char result[4] = {0}; int num = 345; int digit = num % 10; // get the 5 ...


2

The sketch in the question is not for NodeMCU. It is for Arduino with esp8266 wired on pins 9 and 10. But the error in title is a current error for esp8266 Arduino boards package 2.6.0. The EspSoftwareSerial bundled with the esp8266 Arduino boards package version 2.6.0 has a compatibility breaking change. The problem was immediately reported and the ...


2

I like the readBytes or readBytesUntil function. It doesn't end on a small gap between received bytes and fills the buffer. This functions are blocking with timeout, but if read some other device the input is usually fast and terminated reliably. example for readBytesUntil: if (Serial.available()) { char buff[32]; int l = Serial.readBytesUntil('\n', ...


2

First of all I swaped UART0 to GPIO15 (TX) and GPIO13 (RX), (Luckily the Tx of HLW8032 is connected to GPIO13 in my hardware design and This is the UART0 RX pin after swap). Then I analyzed the data coming and the results were the same as of that SoftwareSerial i.e the registers overflows. Then I used an HLW8032 Library (Which I've forked and will make ...


2

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.


2

https://www.arduino.cc/reference/en/language/functions/communication/serial/availableforwrite/ availableForWrite Get the number of bytes (characters) available for writing in the serial buffer without blocking the write operation Write operations on Arduino streams wait if they can't write the data to output. You can use the count returned by ...


2

First off, some comments about your code: Never use String unless it is absolutely unavoidable Unless you have a free() to balance your malloc() you will run out of memory almost immediately There is never any need to concatenate strings to send through serial like that. Instead of what you are currently doing, just scrap the String usage and your buf ...


1

SoftwareSerial can only listen to one port at a time. You cannot listen to both, no way. To really listen to both, you need an Arduino with more hardware Serial ports, where most of the protocol is done in hardware, thus can receive without CPU intervention. The Arduino Mega has 4 hardware Serial ports. Or you could impose a protocol on the Serial stream to ...


1

I cannot really narrow down the source of your observed problems, since the problem descriptions are not clear enough. But there are some obvious problems/potential for making it better in your code. In the Uno Code: It is totally unnecessary to use a timer interrupt for reading the SoftwareSerial interface. Instead you should write your loop() function ...


1

For what it's worth, I manage to make them working again by playing a bit with the settings of both modules. Using a simple test sketch I issued some AT commands to both modules; I had already tried setting them to the DEFAULT setup with AT+DEFAULT, but that was fruitless. I decided to left the mode as is (FU3), same for the serial rate (B9600), but I tried ...


1

As Juraj stated in the comments, you have 2 instances of SoftwareSerial, but only one of them can listen to it's receive pin at the same time (this is because they rely on the same interrupts to sample the pin). When you call gps.listen(), you set the gps interface to listen on it's receive pin. Serial1 (the second SoftwareSerial instance) will then no ...


1

Ok i found the issue and the solution. For some reason it seems that while the MCU is running Setup(); hardware or software serial don't work properly. In my case i have code that set the SIM module to SMS mode and to send those messages to the serial port. For some reason it doesn't send them (or probably the module is not ready to accept them). ...


1

The module may very well be dead now, due to giving it 5V. But depending on which board the module is mounted on, there might be a voltage regulator that expects 5V. Check the specifications for the board you bought. A window means that at least 50% of the sky is blocked by the building. The module might not be able to get a signal from enough satellites ...


1

:'( it's a bitter sweet solution. After @majenko's last comment: Ah. So is there something you have to do in that IDE to say "Include the files in lib in the compilation`? I remembered that this issue has bitten me before. Specifically, the issue of including subfolders into a sketch. Normally in programming languages (at least all of the ones I work ...


1

There's some heavy String usage in that library, would not recommend it for anything you want to be stable, especially with an Uno. The library seems to create a connection by first clearing the SoftwareSerial buffer and then issuing the right AT command. It waits for 500ms for a response before giving up. I suspect the wait interval is sometimes not long ...


1

Using a hardware interface takes a lot of load from the CPU. Let's take an asynchronous serial interface for example. With the UART built-in hardware you'll get parallel-serial conversion and back done in hardware. The CPU "just" needs to store the data to be sent in a register. The receiving part is handled completely by the hardware and the CPU "just" ...


1

In your question you ask about all communication interfaces in general, so the answer will be as general as your question. Hardware interfaces should always be preferred to software interfaces, though there are situations, where it is a better or needed to use a software interface due to limited resources. Because anyways the protocol is handled by the ...


1

Software Serial is a pretty crummy library. It disables interrupts while receiving for long periods of time. That causes any other library that uses interrupts to have issues with timing. There are a plethora of other soft serial libraries out there. Try one of those instead. AltSoftSerial comes to mind.


1

There is already an answer and comment about possible hardware / flow control issues, so this answer is only dealing with your Arduino sketch. Iv’e added a couple of print statements and the FreeMemory library to test your sketch. #include <MemoryFree.h> String data = ""; void setup() { Serial.begin(9600); while (!Serial); delay(1000); Serial....


1

Last test showed it mangles data only when using println() and doesn't depend on the char type. Then I remembered something about CRLF in the Sigfox datasheet: Is recommended to use full duplex UART. In case of using half duplex, AT commands has to be ended only with one of ‘\r’ or ‘\n’ not both. Because if you send “AT\r\n” the Sigfox devkit starts ...


1

The member initialization is intended for objects construction. For ints you can do an assignment in the constructors body TranscieverHandler(int txPinIn, int rxPinIn, int setPinIn, int baudRateIn) : hc12(txPin, rxPin) { txPin = txPinIn; rxPin = rxPinIn; setPin = setPinIn; baudRate = baudRateIn; }


1

I am also new to this but if I am not mistaken, you seem to have connected the IR module to Arduino Hardware Serial while trying to communicate with the module via SoftwareSerial. Try using Arduino pins 2 and 3 for the SoftwareSerial instead of pins 0 and 1. Forgive me if I got it all wrong.


1

Default baud for module is 9600 unless you previous set it diffrent as per the datasheet A1 F3 ## 00 00 I believe


1

As Majenko wrote in his comment, your problem lies with Serial.readString(). It is generally not a good way to handle Serial data. It reads data from the Serial interface, until the timeout (default 1s) occurs. So it will try to read until 1 second after your last change of the slider and return the whole data as one string. String.toInt() will then start to ...


1

You can much more easily interface your Arduino with an ELM327 in software with the library ELMduino.h. It's downloadable through the Arduino IDE and includes examples.


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