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
0answers
28 views

i keep getting this error (expected `;' before “else” ) at the else if statement am i doing something wrong? [on hold]

#include <iostream> #include <string> using namespace std; int main () { string name; cout<<" Enter your name "; cin>> name; cout<< " Hi " << ...
1
vote
2answers
78 views

How do I implement reverse enumeration?

Basically I'm trying to output a string based upon a value in an array, the following code is what I have come up with to achieve my desired result, but I have a feeling that there is a better way to ...
0
votes
0answers
29 views

How to create parametric variable in class decleration

I hope the subject of this question if correct. in timeOUT constructor, 3 more instances of other class are defined: endTimeOUT_inFlash(key1), inCodeTimeOUT_inFlash(key2), updatedTimeOUT_inFlash(...
0
votes
1answer
28 views

Update `char* `

I have a class containing few char* variables: char* msgTopic = "myHome/MSGS"; char* groupTopic = "myHome/All"; char* errorTopic = "myHome/Err"; but, I wish to have it defined outside the ...
0
votes
1answer
39 views

From Strings to int problem

I create applications for a computer that is to be used to control the robot arm. I wanted to make the first attempt to run the application not on the motor, but on the diode and check if it will ...
0
votes
2answers
34 views

Parsing Arduino Receiving Strings

I'm currently using google geolocation to get location data to one nodemcu and sending it through serial to another Arduino. The serial command I'm getting right now is, 1.450187T103.824745 I'm ...
1
vote
1answer
53 views

How to stringtok this long string? [closed]

I have a string, "id,port,password,ssid,delay,flag,class,category" Please tell me how can stringtok this and find out the "flag" value(0 or 1)? Here is what I tried: void setup() { char input[]...
1
vote
1answer
41 views

Change data-type String

I'm currently working with an ESP8266 NodeMCU V3 and an IR transmitter breakout board. The module receives NEC IR commands trough a HTTP request and then sends them trough the IR transmitter. Getting ...
0
votes
0answers
28 views

BLE splitting string data

I am working with BLE 4.2 (ESP32) that sends IMU (accel, gyro, mag) data to my mobile app (Android). Unfortunately, I can send only 20 bytes in one packet. This is the code I have: (I am connecting ...
0
votes
0answers
29 views

Sensor to detect whether string is in tension?

I need a sensor to detect whether there is tension on a string or not. I do not need an accurate measurement of the amount of tension- just whether the string is being pulled on or is taut. ...
1
vote
2answers
64 views

Compute SHA256 of string and output to string

In my Arduino project I want to compute the SHA256 hash of a string and store the result to a string, and do this recursively many times (i.e. compute hash of hash of hash etc...). So my goal is to ...
0
votes
0answers
66 views

string.charAt() is not returning the correct value

I know this is a super basic question, and I did try debugging, but somehow I think I am missing the way variable stores value in Arduino. int enablePin = 2; // ebanble pin for slave String ...
0
votes
1answer
87 views

How to compose an HTTP GET request URL with key/value parameters

I am experimenting with some code running on an ESP8266 board to retrieve data using a web API. I would like to store the host address and key/value parameters (API key etc.) of the GET request as ...
0
votes
1answer
75 views

Send Strings via SPI both ways using two Arduino UNOs(Master to Slave & Slave to Master)

I need to create a two way String exchanger via SPI with two Arduino UNOs. Strings and their lengths are independent variables of the main loop and they can change with every iteration. I need both of ...
0
votes
0answers
55 views

Compare barcode scanner string with existed string

I have a project which is reading barcode scanner result then compare with an existed string. I have used the library USB host shield in order to read data from barcode scanner then I would like to ...
0
votes
1answer
64 views

ESP8266 crashes when trying to copy a string into a big char

I'm trying to parse with tinyxml2 a modest XML (3.4kb) to retrieve some data. My ESP8266 crashes every time I try to use the toCharArray method. here's my code // here I'm getting an http request ...
0
votes
1answer
47 views

Problem with String& argument of a function

I am trying to send SMSs using a GSM module with Arduino Mega. I have followed a tutorial and downloaded the SIM908IDE100 library. I am using the function SendSMS(String&, const char [27]);. It ...
2
votes
4answers
180 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(...
0
votes
1answer
95 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 ...
1
vote
0answers
303 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
31 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
78 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
41 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
166 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
72 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
90 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
819 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
149 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
188 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
35 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
84 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
41 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
65 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. ...
1
vote
1answer
43 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
267 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
52 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
316 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
2k 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
182 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> &...
8
votes
3answers
924 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
98 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
1k 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 ...
2
votes
1answer
3k 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
46 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
422 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
33 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
605 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
739 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
44 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
67 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(...