Questions tagged [string]
A sequence of characters -- including letters, numbers and symbols -- often used for representing information in a human-readable format.
325 questions
0
votes
1
answer
119
views
Accessing invalid key in ArduinoJson causes ESP32 to reboot [closed]
I am running a project where I have multiple ESP32s communicate over WebSockets and I am using the Arduino IDE 2.3.4 for it. The communication primarily uses JSON and sends it as strings. To work with ...
5
votes
1
answer
239
views
MQTT connection fails when using String objects
On my ESP32 I am trying to connect to my HomeAssistant server using ArduinoHA library.
I can easily connect when hard-coding the credentials: mqtt.begin("server", "username", "...
-1
votes
1
answer
46
views
Fail to discard the character T from my transmitter Arduino
I wrote code for my transmitter Arduino. I want to send the data to the receiver Arduino through Tx and Rx serial.
The issue is that I could not discard the char "T" and it appears as output ...
0
votes
1
answer
534
views
String or unsigned char to uint8_t
I'm attempting to save a string to EEPROM of an ESP8266 radio and then read it back before I encrypt the data (evenutally I would like to save the encrypted data but I'm simplifing things at the ...
0
votes
1
answer
2k
views
Construct Strings with UTF-8 characters from data
I am printing some ASCII art to the Serial monitor from Arduino UNO, with some success. However, using string literals uses more memory than I would like. I wanted to try constructing the strings/...
-1
votes
1
answer
102
views
Reading a string from the serial port and comparing to another string
I'm using an Arduino Mega 2560 and writing a really simple piece of code that doesn't work.
String a, letra;
#define led 13
void setup() {
Serial.begin(9600); // opens serial port, sets data rate ...
1
vote
1
answer
1k
views
Parse char* mac-string to uint8_t array
I have to handle a String coming in over UART containing a bunch of information, part of it is a MAC-address that I get by using String.substring(a, b) returning a 12-char String representing a mac-...
1
vote
0
answers
128
views
Serial does not receive all chars
I'm trying to follow Serial Input Basics to build a program which receives commands over serial like "<led:12,34,21>" but i'm stuck on receiving the characters from serial...
I have ...
3
votes
1
answer
2k
views
if statement with string comparison
Code Snippet:
String a;
const int red_led_pin = 13;
void setup()
{
Serial.begin(115200);
Serial.println("Hello, ESP32-S2!");
pinMode(red_led_pin, OUTPUT);
}
void loop() {
...
-1
votes
1
answer
668
views
How can i separate values from the full string, incoming string always changes its positions?
String str = {"timestamp": "2023-02-08 16-37-31" ,"cpcb_device": [{"Station" : "832","Para": [{"tag_name": "COD","...
0
votes
2
answers
479
views
Problem cleaning string read from serial buffer
I am trying to move a stepper motor when a specific command is send to Arduino Mega 2560. This command is read character by character and stored in a string variable. Whenever a new command is sent, ...
0
votes
1
answer
167
views
Replace char based on user input
I am developing a hangman game on tinyduino(tinycircuits) and I am currently stuck on how to properly replace a char based on user input within a for loop. My current code does actually replace the ...
0
votes
2
answers
104
views
generate x item long list for gyverportal drop-down selection
I am trying to make a drop down selection with gyverportal. The issue is that I don't know how many items there are so the list cannot be hard coded. Here is an example from github:
GP.SELECT("...
2
votes
1
answer
140
views
for loop crashes program
Just started out with tinyduino(tinycircuits) and I am trying to develop a hangman game. I have this chunk of code that randomly picks a word from my array. I've omitted some code for readability.
...
2
votes
0
answers
361
views
Arduino filling serial buffer with nulls
I just wrote some code that just sends a string from Arduino to Processing.
Processing prints the string and displays the number of characters in the buffer...
After uploading the sketch to the ...
0
votes
0
answers
730
views
String of raw data to Char Hex Array for Bitmap
I'm trying to transfer a monochrome ~4kb image file over WebBT to an ESP32 via BLE.
The EPD display looks for an unsigned char array to represent a bitmap. So..it should be in the format of something ...
0
votes
2
answers
856
views
String() vs char for simple flow control
I am newbie in Arduino and writing a program where I want to control the flow by using Serial monitor input (PI controller).
I've read that using String() although easier it is slower than using char. ...
1
vote
2
answers
383
views
Novice learning Serial.readString()
New to Arduino, getting into String variables and reading them from serial monitor.
Basically what I'm trying to do is have the user input either red, green, yellow. Whichever String they enter the ...
2
votes
1
answer
1k
views
Enable full float-capable snprintf() library with PlatformIO
I want to use snprintf() to format floats to a string.
I know the "normal" version of Arduino's avrlibc had all the float-formatting code removed to make it smaller.
I also know that at some ...
0
votes
1
answer
264
views
String Comparison [closed]
I am trying to compare two string but each time i am getting awkward results. When i use Equals() function i always get the wrong answer and never satisfy the IF statement. When i use compareTo() ...
1
vote
1
answer
9k
views
Conversion from ASCII uint8_t to string
I am sending a string from a Raspberry Pi to an ESP32 via BT. I am getting one ASCII value per line. How to convert it into one whole String? I tried as follows, but I get an error while running the ...
2
votes
2
answers
83
views
How do I fix my code so that it reads text from the serial monitor?
I have created a code that should print out "Enter true to deactivate alarm" in the serial monitor, then store the user's answer and print "alarm off" if they enter true and "...
0
votes
3
answers
1k
views
String type replace function can't replace with no char
I want to replace the ":"(colon) in the MAC address with no char (remove the ":").
But I can't find any good solution.
String.replace(), can't replace with (void).
Note: String....
2
votes
2
answers
1k
views
Read & Write to EEPROM
I need to implement EEPROM Read & Write functionality to my project.
I've been learning how to use the EEPROM on the last few days, however I'm struggling to Read & Write Strings to EEPROM.
...
0
votes
1
answer
2k
views
Optimised random alphanumeric string generator
I'm trying to build arduino nonce generator, but the only thing I found is this question on arduino forum but I can't find out how to make it work for me. I checked and Serial.available() is always 0 ...
1
vote
1
answer
1k
views
What's is the best way to convert std::string to String?
Pardon me, I am a novice programmer. I was trying to use the toInt() function for a std::string but I noticed that toInt() only works for the String class. So, I have an std::string sliderValue and ...
0
votes
1
answer
148
views
String Split Issue
I am getting multiple messages from a GPS device at different frequencies. After getting strings I have to save this data on the SD card. It works well when we have the same frequencies messages but ...
-1
votes
2
answers
1k
views
İs that possible to a function return String OR Int depends on address
Well, I'm trying to use a HMI display and this HMI storing datas in separeta addreses. Such as integers addr. is between 0x80000 to 0x9ffff and also for string's addr is between 0 to 0x1ffff.
At this ...
1
vote
1
answer
2k
views
How to convert a String to Hex array
I am trying use a HMI display. If I want to send a data, for example I want to write "TOPWAY" to 0x00000080 address it should like that:
Serial.write(0xaa); // packet head
Serial....
0
votes
1
answer
2k
views
Using index of to search for multiple characters
In my Arduino project, a string will be received. I understand using .indexof to find the placement of a certain character in the string. My problem is that I need to find the first occurrence of any ...
1
vote
1
answer
399
views
Find OK or ERROR in serial string
I am trying to figure out how to capture the OK or the ERROR from a SIM800l.
I have tried
mySerial.println("AT");
while (mySerial.available() > 0 ) {
String str = mySerial.readString();
...
12
votes
6
answers
5k
views
Using String instead of C string, yet another attempt to touch a loaded issue
I've been reading a lot over the years why we should not use the notorious String class and how heap fragmentation is bad practice and not professional and we should never use it in our programs or we'...
1
vote
1
answer
7k
views
invalid conversion from 'char' to 'const char*' [-fpermissive] on a string
I am compiling some code I didn't write, and it bombs out with the error message
invalid conversion from 'char' to 'const char*' [-fpermissive]
on the line
if (loginPassword == '\0') loginPassword = &...
1
vote
1
answer
631
views
How to properly handle the Arduino String
I've read that the Arduino String is bad as it causes memory fragmentation, so I try to avoid them mostly. But I still have some occurences where I'm not quite sure if they are ok after all.
The first ...
1
vote
1
answer
3k
views
Arduino Serial.readString() trouble
Hello everyone I write my code and have some troubles.
When I write on in my serial monitor my buzzer condition wasn't changed.
Can you help me realize the reason. I wrote code with int type and it ...
1
vote
1
answer
484
views
Substring: What is causing my output to be truncated?
I suspect that I might be using too many resources, because of the strings, but I am new to Arduino, so not sure where I am going wrong. Any help would be appreciated.
What it should do when complete:...
0
votes
2
answers
243
views
Get a specific item from comma separated text
I use bluetooth (works like serial monitor).
Let me say i send a text to my hc-05 (same as sending to serial monitor)
My current code is displaying text from serial monitor/HC-05 TO LCD
#include <...
0
votes
1
answer
739
views
Remove unwanted characters from char type
I'm working on an ESP8266 module that needs to fetch date data from worldtimeapi, everything works fine but the problem is How do I strip of the time field off the datetime JSON response without loop.
...
1
vote
0
answers
77
views
Can't test for equality with string received from bluetooth module
I am trying to keep the program within a loop until the user inputs "ok" on the Bluefruit Connect App. I use the readString() function on the bluetooth object (ble) to read from it. Before ...
0
votes
2
answers
7k
views
How to read incoming HEX values from Serial.read() method?
Brief description about the problem History
Communicating with a old VersaStat II used GPIB port but the GPIB ports PCI card stopped working but there was a another port 25 pin rs232 Serial ...
1
vote
2
answers
1k
views
Arduino - Function -> return Cstr instead of string
I have following function for my Arduino:
String readLine() {
String received = "";
char ch;
while (myFile.available()) {
ch = myFile.read();
if (ch == '\n' or ch == '\r') {
...
1
vote
2
answers
383
views
Firmata.SendString doesn't work with specific `char` variables
I have a Firmata sketch, that accepts string messages, partitions them and sends its' parts back to a Firmata client program. My problem is certainly at the sketch's side. The problem is that Firmata....
1
vote
1
answer
327
views
String comparison problem
I have this callback function in my Firmata sketch. It receives a string as a character array and does something with it. The problem is, that the string is being sent to the Arduino in T\0h\0i\0s\0 ...
0
votes
1
answer
81
views
Any explanation for this behavior?
For the below code snippet
const char* fr_fbdb(char tag[30]) // fn for retrieving data
{
char full_path[120];
const char *_dt ;
strcpy(full_path , base_path);
strcat(full_path , tag);
...
0
votes
0
answers
86
views
Erratic behavior in String based functions
I've been working on a cipher based project, and I wanted to prep the encrypted string for use with the RF24 library. Since the payload size for the RF24 module is 32 bytes, I wanted to stick with ...
3
votes
1
answer
6k
views
What is the purpose of F() and FPSTR() in ESP8266WebServer -> FSBrowser?
I found this code sample from the FSBrowser (Flash File System) example in the ESP8266WebServer library:
replyServerError(FPSTR(FS_INIT_ERROR));
replyBadRequest(F("DIR ARG MISSING"));
I was ...
2
votes
1
answer
169
views
Why are characters with value above 127 "padded" with 1s to be 16 bits long, while ones with values 0-127 aren't?
I am using the Arduino IDE to run and monitor, with an Arduino Nano clone.
This code shows what I mean by the question:
char foo = 127;
char bar = 128;
Serial.println(String(foo, BIN));
Serial.println(...
-1
votes
1
answer
1k
views
Reading a string from Firebase and storing it as a CString
I have a mobile app (done using MIT App Inventor) storing some values to a Firebase database. App inventor stores all the values as strings (i.e. with quotes, and strings have quotes enclosed within ...
1
vote
0
answers
1k
views
incompatible types in assignment of 'const String' to 'char [32] using server.arg
I am trying to create a class and getting getting the error
incompatible types in assignment of 'const String' to 'char [32]
when I declare
char inString[32];
and try to set it as
inString = server....
1
vote
2
answers
3k
views
strcmp doesn't seem to work
I'm trying to compare a char array that I'm assembling to a string and I'm having trouble comparing the strings.
I'm getting the data for the char array as a set of bytes and I'm compiling it into a ...