Questions tagged [string]

A sequence of characters -- including letters, numbers and symbols -- often used for representing information in a human-readable format.

Filter by
Sorted by
Tagged with
0 votes
1 answer
27 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 ...
Carlos Eduardo Carvalho's user avatar
1 vote
1 answer
137 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-...
Harald Lesan's user avatar
1 vote
0 answers
42 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 ...
Taako's user avatar
  • 111
3 votes
1 answer
503 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() { ...
3kstc's user avatar
  • 221
-1 votes
1 answer
71 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","...
Karan Bawadekar's user avatar
0 votes
2 answers
218 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, ...
Yan Araújo's user avatar
0 votes
1 answer
90 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 ...
Isaac Agatep's user avatar
0 votes
2 answers
51 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("...
Gerge's user avatar
  • 1
2 votes
1 answer
85 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. ...
Isaac Agatep's user avatar
2 votes
0 answers
235 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 ...
Robot12's user avatar
  • 21
0 votes
0 answers
404 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 ...
user2402616's user avatar
0 votes
2 answers
174 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. ...
Ognyan Petkov's user avatar
1 vote
2 answers
172 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 ...
Moose's user avatar
  • 9
1 vote
1 answer
311 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 ...
Bitbang3r's user avatar
  • 451
0 votes
1 answer
120 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() ...
ASAD ALI's user avatar
1 vote
1 answer
6k 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 ...
matmagdt's user avatar
2 votes
2 answers
49 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 "...
Jillian's user avatar
  • 21
0 votes
3 answers
612 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....
Instigator's user avatar
2 votes
2 answers
611 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. ...
user avatar
0 votes
1 answer
797 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 ...
krystof18's user avatar
  • 315
1 vote
1 answer
829 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 ...
Enna's user avatar
  • 13
0 votes
1 answer
121 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 ...
Omar Rai's user avatar
-1 votes
2 answers
519 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 ...
mehmet's user avatar
  • 277
1 vote
1 answer
902 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....
mehmet's user avatar
  • 277
0 votes
1 answer
969 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 ...
dcal's user avatar
  • 1
1 vote
1 answer
280 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(); ...
maxum's user avatar
  • 141
12 votes
6 answers
4k 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'...
Nino's user avatar
  • 411
1 vote
1 answer
5k 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 = &...
Ben Dauphinee's user avatar
1 vote
1 answer
309 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 ...
matthesinator's user avatar
1 vote
1 answer
2k 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 ...
Shushan Abovyan's user avatar
1 vote
1 answer
221 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:...
E_Ja's user avatar
  • 21
0 votes
2 answers
150 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 <...
Neptotech -vishnu's user avatar
0 votes
1 answer
474 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. ...
Ruby's user avatar
  • 15
1 vote
0 answers
51 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 ...
Cem Adatepe's user avatar
0 votes
2 answers
4k 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 ...
Avon97's user avatar
  • 161
1 vote
2 answers
793 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') { ...
sharkyenergy's user avatar
1 vote
2 answers
276 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....
Starter's user avatar
  • 153
1 vote
1 answer
228 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 ...
Starter's user avatar
  • 153
0 votes
1 answer
79 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); ...
Somasundharam Sampath's user avatar
0 votes
0 answers
58 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 ...
Okabe_'s user avatar
  • 17
1 vote
1 answer
4k 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 ...
DV82XL's user avatar
  • 115
2 votes
1 answer
120 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(...
Boba0514's user avatar
-1 votes
1 answer
820 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 ...
Somasundharam Sampath's user avatar
1 vote
0 answers
902 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....
brad's user avatar
  • 201
1 vote
2 answers
2k 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 ...
Chris Schmitz's user avatar
1 vote
1 answer
307 views

Why use \" in arduino code?

While working with JSON parsing I noticed that the char type data string is written like this: char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\&...
Sohan Arafat's user avatar
0 votes
2 answers
119 views

Is there a limitation of how many instances of the `String` class?

Platform Attiny85 with AttinyCores 1306 OLED i2c with Tiny4KDisplay Goal using a joystick for menu navigation up/down choose left enter (not finished yet) right back (not finished yet) inverse ...
River's user avatar
  • 103
0 votes
4 answers
234 views

Properly escaping very large strings

On an ESP8266 I want to create a little webserver that shows me a dashboard with charts and stuff. For this I want to include the echarts-library as it works offline. To access it the only way I can ...
Cowboy_Patrick's user avatar
2 votes
1 answer
812 views

Converting c string to integer to unsigned char

I'm grappling with types between two different libraries. The gist is that I'm using the ArduinoWebsockets library to receive information coming from my API that I then want to render out to an LED ...
Chris Schmitz's user avatar
2 votes
1 answer
765 views

Comparing a String after reading it from Serial fails

I have bought an Arduino starter kit online. Everything seem to work, but when I try for example to use ifs (and other conditional statements), the LEDs do not turn on. Here is the code for a little ...
user avatar

1
2 3 4 5
7