3

A CPP file isn't an Arduino file. It doesn't know about anything Arduino-esque unless you tell it about it. The simplest way is to just add, at the top of the file: #include <Arduino.h>


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 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 ...


2

First, a few general notes: The difference between char str[2] and char* str = (char*) malloc(2) is irrelevant to you problem. It changes the place where the array is stored, the meaning of sizeof str, and malloc() will blow up your RAM if you call it repeatedly and forget to free(). In your code, sizeof(txt) is the constant 2: the actual size in bytes of ...


1

For the hardware serial port, the buffer is 64 and I was reading at least 100 times. Every read will clear one byte of data from the serial buffer at a time. For the software serial port, you do a dummy read and then check whether the buffer is empty or not using while(mySerial.available()>0) { dummy = mySerial.read(); } So, in ...


1

Try Google Protobuf it's really awsome. I use it every time when I connect C# app to STM but it can be used in this case as well. U use Protobuf to encode your message and COBS do remove zeros from message so you can slap it on the end to know when the packet ends


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

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.


1

Can I use a ATtiny85 board (eg Digispark) as a USB CDC device? Yes! If I have got this right, to be able to communicate with a USB serial device you need to have USB CDC support and if you want it to fake a keyboard/mouse you need HID. The Digispark have a CDC library https://digistump.com/wiki/digispark/tutorials/digicdc But it has its limitations, take ...


1

I guess the main problem is, that you write your commands from the bluetooth app, but the HC-05 module is connected to BTSerial. Here you are reading from it and forwarding the data to Serial (serial monitor on your PC): if (BTSerial.available()){ Serial.write(BTSerial.read()); Serial.write('\n'); } You are not doing anything else with the ...


1

The datasheet states: Requires 5-9VDC @ 1.5Amp power supply during print. In my experience this printer provides best results when operated at its upper limit. I am using a 9V 2A power supply for that. A bettery is definitiverly not enough.


1

You can use the one provided by generating it with STMCubeMx. This is going beyond arduino though. But it is highly feasible.


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

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 ...


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