Stack Exchange Network

Stack Exchange network consists of 175 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.

0
votes
1answer
28 views

Mqtt not subscribe on topic that's converted from String to char array

I am still not sure what should be the exact Title for this question, because I don't know where the problem is. I am using #include <MQTTClient.h> mqtt library to subscribe on a topic. This ...
0
votes
0answers
27 views

String.format(“%i”,i) equivalent

How do I format an arduino String when I do not want to print it? I know that one can use printf() or other methods to print a formated string and unfortunately that's all I find with google. But that'...
0
votes
0answers
23 views

Problem: char string not working with SoftwareSerial.h

I am creating a program to display text on an OLED display and then have it sent to a thermal printer. The issue is my second char string: word_buffer When I try to use word_buffer for any reason it ...
0
votes
1answer
49 views

Parsing Data and Comparing two string in arduino

I am working on my final assignment. The problem is I want to make a prototype tool, with 2 string compare. If I send data "OK DISC DISCLOSED: 341513DB689AOK RSSI: -056 OK NAME: CarBT1 OK DISCE" will ...
1
vote
2answers
33 views

String Comparison Result [closed]

I've following code: char a[5] = "bang"; char b[5] = ""; void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { // put your main code here, to run ...
0
votes
1answer
51 views

Weird behavior with char/uint8 arrays

So I'm trying to read an 8-byte character string from an I2C device and print it to the serial console. This raw 8-char array is not terminated when it comes from the device, so I'm pretty sure I need ...
-1
votes
1answer
51 views

How to parse multi line serial data with an unknown number of lines? [closed]

Here's the example data I've read in H-Term: \r\n \r\n NO:0015\r\n G: 5.97kg\r\n T: 0.00kg\r\n N: 5.97kg\r\n \r\n \r\n How to save the number including "kg" to each variable (NO, G,...
0
votes
1answer
53 views

Large(ish) strings failing to send over WiFi101 using WiFiServer

I've based a sketch off the vanilla WiFi101 server examples. If I define a const char array like this: const char HTML_index[] = "<html><head></head><body>test</body>&...
0
votes
1answer
103 views

Splitting a Serial.readString into string array

I am working on a project where I need to split incoming data from serial (time to be exact, so aa:bb:cc) and need to split it into aa then bb and cc, ideally into an array. I know I could use ...
1
vote
2answers
58 views

How to combine strings and text together?

I'm trying to combine two strings (strings/int) together with text in below code: int foo = String((char*)payload).indexOf(' '); int message1; int message2; message1 = String((char*)payload)....
-1
votes
1answer
69 views

Attempting to read random string from SD card

I was wondering if anyone knew how to read in a random string from a file named "PhraseList.csv" or "PhraseList.xlsx" (whatever is easier)? There is a list of 10k. #include <SD.h> #include <...
1
vote
1answer
30 views

Assign and control Digital pin from String

Here is modified version of Blink example #define D8 13 String p = "D8"; // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin ...
0
votes
0answers
32 views

append a String on ArduinoJson Object value

I've a json string request coming from server and I convert it into json object StaticJsonBuffer<500> jsonStaticBuffer; JsonObject& root = jsonStaticBuffer.parseObject(String(msg)); ...
1
vote
2answers
35 views

Command through Serial monitor does not properly work in Arduino

I am executing a function in Arduino by giving String input to the serial monitor. The issue here is when i enter "SHOW$" (without quotes) the function showData() works but when i enter the same "...
0
votes
0answers
31 views

How to store an array of doubles? As array of doubles, Strings or const char *? Then convert back to use?

This seems like an old, solved problem, but I can't find any simple answers. I'm reading latitude and longitude data as Strings from a file (about 50 points), but they are really double float numbers. ...
0
votes
1answer
32 views

Help to delimit and read specific contents of incoming HTTP string

I am sending strings to an Esp8266 via web browser. The below code returns the following in serial monitor if I send in browser: Send from browser to esp8266 - http://192.168.1.220/s1s2s3s4s5d1 ...
0
votes
2answers
73 views

String compare when using Serial

I try to detect commands given by user in Serial Monitor, but strcmp fails to flag as identical. What do I do wrong ? Is there a better way not reading as String and convert to char for comparison ? ...
3
votes
1answer
47 views

How to define and use a list/array of chars using `Serial.print` [closed]

I wish to define a list of months names and access it when printing a report. Array was defined as follows: const char months []= {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov',...
1
vote
1answer
115 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
422 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
88 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
871 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
56 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
386 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
1k 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
44 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
270 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
431 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
247 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
41 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
36 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
239 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
22 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
64 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
48 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
54 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
106 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
127 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 ...
1
vote
2answers
899 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
38 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
277 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
409 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 <...
2
votes
1answer
992 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
435 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
1k 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
327 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
254 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
2answers
553 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
273 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 ...