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
1
vote
1answer
48 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
1answer
86 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 ...
3
votes
5answers
7k views

How to compare a string

How to compare a string coming from serial monitor with some predefined text stored as a local variable? If I say: int led = 2; String a = " abcds"; void setup(){ Serial.begin(9600); } void loop(...
4
votes
3answers
2k views

eval() function for Arduino?

I plan to do the following: void setup(){ String term = "12 + (2 * 5)"; int result = eval(term); // eval function (from Python) Serial.println(result); // expecting 22 } However there is no ...
0
votes
3answers
828 views

How to fix memory-leak code in ESP8266/NodeMCU caused by string concenation?

I have following code in loop() in NodeMCU. This part is before setup(): String serial_data_read = ""; // for incoming serial string data String serial_data = ""; // for incoming serial string ...
0
votes
1answer
49 views

How to assign a string-variable to a StackString based on the StackString-library?

I'm trying to use the StackString-library which offers not to eat up RAM over time by re-assigning values to strings. I started from scratch and wrote a very basic democode which works. Then I added ...
1
vote
0answers
37 views

Serial1.readString() on arduino mega returns an empty string

i have been trying to read text message from a sim module over serial1 of arduino mega, when i use the code msg = Serial1.readString(); the readString return an empty string i dont know if this is a ...
1
vote
1answer
45 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
1answer
48 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
2answers
559 views

Reading from SPIFFS - What's the best way to deal with a string (or char) array with undefined length?

I've read that it's best to avoid using String in Arduino so I'm ready to use a char array if it's better. I'm reading the file names from an SD Card and my goal is to store them in an array and then ...
0
votes
1answer
784 views

Convert JSON into string for MQTT

I am trying to publish json object into string with following snippet JSONVar data; data["chipid"] = chipId; data["co2_equivalent"] = co2_equivalent.c_str(); data["tvoc"] = tvoc.c_str(); data["...
1
vote
1answer
49 views

Arduino keypad variables to serial port

I've been trying, for over a week now, to create a program that will store my keypad presses into variable, and with a press of an enter, it will switch to the next variable to store the presses. The ...
-1
votes
2answers
54 views

Convert string to integer

I'm using two ESp32 in a server and client configuration and i'm sending data between them in form of strings but i want to convert the recieved data which is fom of strings but it contains numbers ...
0
votes
2answers
41 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 <...
1
vote
2answers
817 views

Clearing string buffer with memset after a serial read

In using the SerialTransfer.h / pySerialTransfer libraries to send commands between my laptop and an Arduino Mega, I am sending multiple sequential strings between the devices. However, I'm having ...
-1
votes
1answer
595 views

Arduino - Extracting Multiple Strings from Serial Read

I am trying to write an Arduino code that reads a long string, example <11,22,33>, through the Serial Monitor and then stores the 11,22, and 33 into separate bins of a matrix array. So the user ...
0
votes
1answer
40 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
0answers
30 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 ...
50
votes
13answers
246k views

How do I print multiple variables in a string?

Say I have some variables that I want to print out to the terminal, what's the easiest way to print them in a string? Currently I do something like this: Serial.print("Var 1:");Serial.println(var1); ...
0
votes
3answers
229 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
2answers
49 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
2answers
87 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
1answer
119 views

Error initializer-string for array of chars is too long using ESP32 Webserver

i tried to use an asynchronic webserver for a new project with friends using this tutorial. We want to run an FFT while also changing some settings via the webserver. Since the tutorial only put code ...
0
votes
1answer
72 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); ...
1
vote
1answer
103 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 ...
1
vote
0answers
45 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 ...
0
votes
1answer
421 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 ...
0
votes
1answer
120 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 ...
2
votes
1answer
58 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
vote
0answers
53 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....
0
votes
2answers
75 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 ...
1
vote
2answers
93 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 ...
1
vote
3answers
82 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 wanna include the echarts-library as it works offline. To access it the only way I can see ...
1
vote
1answer
296 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\&...
2
votes
1answer
95 views

Converting c string to integer to unsigned char

I'm Trying to grapple 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 ...
2
votes
1answer
233 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 a code for a little ...
0
votes
1answer
96 views

Converting 8 bit binary to a hexadecimal pair as unsigned char

I have a function: void Epd::SendData(unsigned char data) { digitalWrite(dc_pin, HIGH); SpiTransfer(data); } At the moment I am hardcoding data sent to it by calculating on paper and then writing ...
1
vote
2answers
283 views

Read Comma Separated String

I have a string that looks like this "10.00,20.00,-50.00," in which these are angle values and they have 2 decimals and can be negative. I want to separate them into 3 separate floats. Here ...
4
votes
5answers
13k views

formatting strings in Arduino for output

I wander what is the best option for formatting strings in Arduino for output. I mean what's a preferable way in the point of view of performance, memory usage – things like that. I see, people ...
1
vote
1answer
118 views

Cannot compile F() macro with R“string”

I am trying to compile the following code: logger.log_info(F(R"(some text here that may take multiple lines and here it is done.)")); But the compiler exists with the following ...
0
votes
2answers
167 views

Float array to comma separated string

I have a loop command reading temperature sensor data from 8 thermistors and are storing them as floats into an array. Instead of printing to Serial on each iteration, I would like to create a comma ...
1
vote
1answer
171 views

Why isn't this EEPROM.get() working?

I am trying to save a string/char to EEPROM with EEPROM.put() and then get the value, but it doesn't work and I get a blank value when I do a EEPROM.get(). I remember this is how it worked on arduino ...
0
votes
1answer
50 views

Reading Serial String Gives Null Lines with JSSC

I need to send serial data to my Arduino UNO from within a java application. I am using JSSC for this. I wanted to verify that my data actually arrives correctly to the arduino before going to the ...
1
vote
1answer
245 views

How do i improve this Code? (or how to pass a Char String into a Function to behave like a Variable)

Sorry i am a beginner and amateur when it comes to coding, can somebody help me to make the code inside the loop() less "monkey-like" by using a proper function? I have tried a lot and at ...
0
votes
2answers
60 views

How can I copy and compare a string?

I have the following code (I realise String isn't very efficient, but this sketch doesn't have to be) debugOutput gets called every loop, but I only want to spam the serial bus (to debug) if the ...
0
votes
0answers
156 views

HC-12 problem with reading momentarily strings

I'm new here, so I hope my question is not naive. I'm using Arduino mega connected with a pulse sensor and a GPS (and other things that are not related to our problem), pulse sensor and GPS data are ...
1
vote
2answers
440 views

Convert comma-delimited Arduino String of hex values to array of bytes

My apologies if this is a naive question. How do I convert a String which has hex values to a byte array that has those hex values? This: String s = "0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff"...
0
votes
0answers
137 views

arduino split string into an array [duplicate]

i have problem with change srting to array my string input is like this B109DAE1B71B638E it come from Serial.readString and i want to change this string to array byte like this byte in01[] = { 0xB1, ...
0
votes
1answer
636 views

Convert Binary to char

I'm reading a text file saved on my ESP8266 device (using LittleFS). while (myFile.available()) { Serial.write(myFile.read()); } My goal is to save file content ( each line ) to a String /...
1
vote
1answer
62 views

String(int) function stopping the Arduino

Well I am trying make an application with arduino leonardo and GSM Shield. There are conditions if, else if, else .. etc if (smsMetni.indexOf("DURUM") != -1) { Serial.println("SMS ...

1
2 3 4 5
7