Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [string]

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

1
vote
1answer
34 views

Using c_str() on String for IPAddress with NTPClient provides wrong values

Libraries NTPClient Board Olimex ESP32-POE board Behaviour I have written a code that connects the board to a local NTP Server (which is an embedded board). I tried assigning the IP Address of ...
2
votes
2answers
66 views

Problems on convert byte[] to String

I'm reading a RFID Card from RC522 and send the data to my computer. My problem is the conversion of byte[] to String or std::string. #define SIZE_BUFFER 18 #define MAX_SIZE_BLOCK 16 byte ...
0
votes
3answers
47 views

Arduino IDE c++ 11 raw string literal have issues with // in http://, complier thinks // is comment

char webpage[] PROGMEM = R"=====( <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js"></script> </head> <body> &...
7
votes
3answers
825 views

Why is 'n' parameter of snprintf ignored?

I have found that the n parameter of snprintf() seems to be ignored in my code. char asdf[10]; Serial1.println(snprintf(asdf, 2, "hello")); This prints 5 when I would expect it to print 2. What is ...
1
vote
2answers
20 views

ArduinoJSON: Using a reference to a reference when parsing array of arrays

I started to play around with the ArduinoJson library to parse data I got from one of my APIs (the format of the JSON data I get from my API can be improved for sure, but the software I had to ...
0
votes
3answers
59 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 ...
0
votes
1answer
177 views

Arduino Convert std:string to String

I'm working on BLE project with espressif library. And It returns me founded BLE device. std::string getManufacturerData(); std::string getName(); int getRSSI(); BLEScan* getScan(); When ...
0
votes
1answer
40 views

Hex output although I always define integer

Code below is to read 4 thermometers and use values to turn on or off the heaters (I'm stuck at reading). I'm reading and displaying temperature very well, but it comes to the problem, where I want ...
0
votes
2answers
98 views

Memory leakage caused by String Concatenation

In this link, section "Memory, memory, memory" it's been told that doing many String concatenations in sequence, e.g.: using operator+() multiple times, will cause memory fragmentation, which may lead ...
-1
votes
1answer
31 views

Passing out an argument

I can't figure out why test is not passed properly to test1 #include <Arduino.h> char *test1; char *status_reply(char *test) { int ans_rel = 1; int ans_led = 0; int ...
1
vote
4answers
328 views

Local char* - keeps its value [closed]

Sorry for novice question in Arduino, but I'm trying to figure out why res is keeping its value when up_cmd0 is being called again. for example - if num=8 in first run and the result is :up_cmd0_res: ...
1
vote
1answer
48 views

Return a char concatenation

My goal is to create a function that concatenate 2 chars into 1, and return it as MQTT subscribe. I get a difference between the results inside and outside the function ( I'm new to Arduino ), and I ...
1
vote
1answer
32 views

Doubt using character array

I'm trying to make a led sign with a WS2812b ledstrip, using the FastLed library (by the way, this is a great library!), I'm already able to show a text (so far only one, which I leave saved in an ...
0
votes
1answer
27 views

String & Char concatenations

A newbie in Arduino- and I'm trying to concatenate string and chars ( well in python it is quite different ). I'm trying to post a MQTT message- constructed following format to the client.publish(...
1
vote
2answers
86 views

Best practice to declare a 'static' text and save memory

I'm working on a project where I need to create a JSON to send back state of an object. I created the code to achieve it and all works fine, but I used this to declare the JSON fields: static const ...
0
votes
1answer
13 views

Serial string readout analyzed and logged onto an SD card [closed]

I have a sensor that gives me this string, serially read @9600: @T;+019.8;H;043.6;51 This burst arrives automatically about every second. It means: "@" start of the string "T;" means the ...
0
votes
0answers
48 views

How do I send a string after initiatint transmission in Arduino through SPI

I'm trying to send "hello\n" from master to slave but before I want to send qn initialization command like SPI.transfer(1) Example master code. #include <SPI.h> void setup (void) { ...
0
votes
1answer
33 views

String input to character array

I am in between of project where i am getting string like "hello world" via Bluetooth to arduino I want to list this string into individual character so that I can call any of the character when ...
1
vote
2answers
45 views

Error handling strings and chars

I'm having an error in buffers that handle strings and I can not figure out what the problem is. The example below shows what is happening. Can someone help me? void setup() { char* ss1 = ""; ...
0
votes
1answer
40 views

How do I clear previous values while using strcat() to add strings?

Is there any other function to add strings into buffer and updating values as well. This is the problem I am coping with while using strcat() char temp[2] = "A"; char temp_end[2] = "a"; char buf_adc[...
0
votes
2answers
70 views

How do i send ads1115 data over spi to master arduino

I am trying to send ADS 1115 data which is connected with Arduino mega_1 over I2C and arduino Mega_1 is connected with arduino Mega_0 over SPI. Arduino Mega_1 is act as a slave and send ADS 1115 data ...
0
votes
2answers
209 views

Creating formatted String (including floats) in Arduino-compatible C++

I'm using a Mega2560 and a generic SSD1306 OLED display with the Adafruit_SSD1306 (and by extension, Adafruit_gfx) library. I need to print a bunch of float values (ranging between 30.0 and 99.9) to ...
0
votes
1answer
36 views

String class summation disappears the right operand

I intend to create a function to jsify sensors' content and save it on a SD-card or send through a http client. Except for the Serial.println's, the function is transcripted below. String jsonificar(...
0
votes
1answer
203 views

char array comparison

I'm having some issues dealing with strings in a small Arduino app. I wonder why this code works: mqtt.setServer("192.168.1.42", port); and this code doesn't: IPAddress ip = MDNS.queryHost(...); ...
0
votes
1answer
183 views

arduino nodejs serial data chunked and not in synch

I'm trying to get an arduino sending data to node but with no success. I'm connecting to an ar-drone 2.0 as in https://gist.github.com/maxogden/4152815 Here is my Arduino code: #include <...
1
vote
1answer
463 views

How to transmit string data using the rc-switch library?

I am using the rc-switch library for sending and receiving data. In rcswitch library, there is no method to send string data. I am using below method to send the string message in char buffer. ...
0
votes
1answer
217 views

Arduino HTTPClient passing string to variable

For some reason I can't seem to pass a simple string from one variable to another. Below is my code: HTTPClient http; // Declare an object of class HTTPClient http.begin(address); // Specify ...
0
votes
1answer
486 views

How do you convert a formatted print statement into a string variable?

I'm using the following routine to print the current time on the com port. I would like to capture this as a string so I can display it using ePaper. void printLocalTime() { time_t rawtime; ...
0
votes
1answer
182 views

How do string pointers work in Arduino?

To the best of my understanding, when I declare String s = "This is a string."; what happens is that space is allocated on the stack for a pointer which points to some String object which internally ...
2
votes
1answer
169 views

Arduino String: use a non-null-terminated char array?

I'm using a library that takes a String as it's parameter (https://github.com/gmag11/painlessMesh) I want to pass char arrays that is binary (UTF-8) data that also contains null-bytes (0x00). Right ...
1
vote
1answer
264 views

Save Leading Zero HEX into String RFID RC522 Arduino

I'm using RC522 to read RFID card. All is until if the HEX leading by 0 then i can't save it into String. But if i print it to Serial all is well. Here is my code: #include <SPI.h> #include <...
2
votes
2answers
270 views

How do I isolate numbers in text?

I need to separate numbers from the text where my string of numbers will always be of length 8: string text = "77953505HELLO THIS IS A MESSAGE"; //my string of numbers will always be of length 8 My ...
0
votes
1answer
40 views

Can't assign String to Array of String

I have to input 5 words and organize. In order to organize words, I have to get them into Array of String to compare. I succeed to get char[buffer] into String in_str but somehow in_str doesn't get ...
0
votes
1answer
204 views

string.indexOf() always returns a non-zero value

I am developing a hardware project which contains a facility to change the stored password by any user, if he/she knows the current password.The new password is stored in arduino eeprom. In the main ...
1
vote
1answer
154 views

Does the StringObject.reserve() function prevent memory fragmentation/leaks?

I'm currently writing and testing a professional Arduino application, I'm aware of the dangers of using the String class, so I began to implement C-style strings in some places, but it's just way ...
1
vote
2answers
1k views

function returning String-Array

i'm still new to arduino and also to C++ and have a short question. What i want to do is to write a function (in my case to parse the query-string of an URL) to get the parameter names and values (...
1
vote
1answer
387 views

remove weird chars from char array ESP32

When I'm converting a string to a char array there are always some weird chars at the end. I have to do it manualy because the convertTochar function crashes my ESP. String sssid = module.getCssid()...
0
votes
2answers
213 views

Keypad password check issue

I am working on a school project, basically I have to create a lock system that opens a fictive gate when the correct code is entered. We have been asked to simulate our system before actually ...
0
votes
2answers
99 views

Why I get error on string concatination?

exit status 1 invalid operands of types 'const char [5]' and 'const char [2]' to binary 'operator+' String message = "Page not found\n\n"; message += "URI: " + HTTP.uri() + "\n"; message += "...
1
vote
1answer
355 views

Ubuntu class string has no member remove

I am running some code that works fine on my windows system using the .remove method. On Ubuntu 16.04 I get the following errror: error: ‘class String’ has no member named ‘remove’ To see if it ...
0
votes
2answers
56 views

Where can I find the complete list of Arduino Serial Command & Query Strings?

I am planning to use the Arduino as a replacement for a USB-Controlled Digital I/O device, which will be integrated into an existing C++ software package that I created. I understand that the Arduino ...
0
votes
1answer
870 views

Printing char array from array of structs in progmem to serial

(I apologize if this is a c++ question, I'm too green to know if this is unique to the Arduino IDE) I've moved an array of structs into my PROGMEM because I was running into memory issues: #define ...
0
votes
1answer
63 views

Cannot convert Serial String into char

I am trying to write a program to control 4 motors through the Serial port. I planned on achieving this by sending the motors' speed and direction instructions as a string, which is then converted ...
1
vote
1answer
1k views

Put integer and double into char array

I want to print text and numbers mixed in a table with Serial.print(); from a char array. My problem is the conversion between the different data types. My idea is to print the data of the rows in a ...
1
vote
1answer
65 views

SoftwareSerial + Serial.printlen() not working properly

I want to read a SMS message , find it's length and do some "substring();" operation on received SMS. My last two(2) statements do not work . How can I get correct answers? What are correct codes ? ...
0
votes
2answers
6k views

Very Basic Arduino Uno Serial.readString() operation

I am very new to Arduino Programming. I am trying to identify the input string from serial monitor and printing the output to the console accordingly Code is : void setup() { Serial.begin(...
-4
votes
1answer
37 views

Creating String Arrays and passing each index value to a variable after a given period [closed]

Is there a way to take an input string, store it into a array and then pass each index of that array to a variable to hold before being overwritten by the next array index value? For example: A ...
0
votes
2answers
163 views

Strings from serial are not equal

In my code I have that string:String code = rs1 + rs2 + rs3; //rs1=034, rs2=000, rs3=017 It means that code = "034000017". But if I run if (code.equals("034000017")) Serial.println("OK"); There is ...
0
votes
3answers
118 views

How do I combine a variable and characters into a string with Arduino?

I am building some sensors with Arduinos, which each have a unique integer address from 1-9 (This address is an int variable stored in a struct 'Matrix', the variable name is Matrix.Address). The ...
0
votes
2answers
33 views

Issue with length of string value

I have been getting some weird issues with a sketch I put together(apart from memory low warnings, it was working fine) When im about to post data to my php server - it seems not all the information ...