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
2answers
33 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
22 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 ...
0
votes
0answers
39 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
63 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
58 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 ...
0
votes
1answer
48 views

Convert string to array

I have a project and i need to convert string (contain numbers and letters) to array String name = "s111, s222, bbbb,cccc "; and i want array[0] = s111; array[1] = s222; array[2] = bbbb; ...
0
votes
2answers
44 views

How to use “+” character as a String

Well I am trying to save phone number as a string. For ease of use I want to add "+" character programmatically. Like this: String cepNo ="+" + "901234567"; But program ...
0
votes
0answers
44 views

Arduino blocks when serving web pages

I have an Arduino sketch that serves an HTML web page using the standard Ethernet library (https://github.com/arduino-libraries/Ethernet) and the Ethernet Web Server library (https://github.com/khoih-...
1
vote
1answer
31 views

.toFloat() giving incorrect anwsers

I am broadcasting a fixed value float over a HC-12 radio which is then received by another HC-12 radio. I am then trying to convert that String to a Float which requires 6 decimal places. However, ...
0
votes
2answers
41 views

Add char at intervals in a String

I'm trying to create a function that will take a String as an input, and at every 20 characters, it will instert "\n" so that the string doesn't go off the side of my screen (I'm using an ...
0
votes
1answer
53 views

Having trouble with sprintf function and string class

in my code, I was using string class to make an array to store my menu items String menu[2] = {{"Menu 1"}, {"Menu2"}}; How do I convert this into char arrays and how do I call ...
0
votes
1answer
29 views

How do you make a Class variable array bigger?

I am making an infrared macro-keyboard, I want to store Unicode for the Keyboard class in an array inside a class I made called Keybindand to allow the user to program as many outputs as they want, I ...
0
votes
3answers
53 views

Formatting variables from a variadic function

I have a function that concatenates a print line, however I am having trouble getting some of the strings to format correctly. Using Serial.print formats the output from keypad.getKey() correctly, ...
0
votes
1answer
25 views

ESP32 Cannot assign value to string. Getting wrong value

Hello I have problems with strings in my sketch. I assingn values to my string (for example tempStrReturn) in the functions setNr1, setNr2. If i pass the value 1 to the function i get "" or "...
0
votes
0answers
33 views

LiquidCrystal swap lines with interrupt

#include <Wire.h> #include <LiquidCrystal.h> int temp; const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 = 9, d7 = 8; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); char Nick[15] = {' ', ' ', '...
1
vote
2answers
48 views

Nothing received from function returning array of strings

My read function returns an array of strings. i.e ssid and password String* configuration::read() { String rw_ssid = ""; String rw_pswd = ""; const int keys = 2; String read_ssid_pswd ...
0
votes
1answer
78 views

Possibility of clean the code?

Good night! Based on stuff I get a bit here and there, came up with a program for an Arduino Audio Selector with shift registers and some features. Working as expected, only missing connecting the ...
0
votes
2answers
36 views

Does toCharArray prevent a String being created on the heap?

I know it's bad to use Strings due to the memory problems that can occur. I've tried to remove all instances of strings from my code. But I'm not sure about this line: http.getString().toCharArray(...
0
votes
2answers
109 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
0answers
26 views

conver UUID to string for mqtt publish

I am trying to publish jason to mqtt. Following is just a snippet of a code.When i try to add data["uuid"] to json data doesn't get published to MQTT, if I omit data["uuid"] everything works. UUID is ...
1
vote
2answers
100 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
3answers
95 views

How to replace String objects with char arrays while still using string methods

I am running the following code on my ESP8266 (AI-Thinker ESP8266MOD). I send an HTTP GET request and a pin is set to high for a 1/2 second. However, after some time (sometimes 1hr, 2hrs, 12hrs, ...
0
votes
1answer
55 views

Scrolling an I2C text

I want tried to make a programm to display a text on an I2C LCD-Display. The text should be scrolled for one position every time the function is called. On the internet I saw a lot of solutions but ...
1
vote
1answer
36 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 ...
0
votes
2answers
34 views

Regarding Strings and assignments

I have this code which works : String ErrorMsg; ....... if(!UploadPacketError) { ErrorMsg="OK"; } else { ErrorMsg="NOK"; } String creates a dynamically allocated array which I want to avoid. ...
0
votes
2answers
83 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 ...
2
votes
0answers
35 views

Split string using a delimiter then saving to different variables [duplicate]

I have a string that looks something like this "43;27;42;27". It is the data from 4 DHT22 temperature sensors, i need to splice this string every ";" and save the number to a variable. In the end, I ...
0
votes
2answers
56 views

Unpredictable behavior on parsing key-value delimited input from serial

I am having trouble with a "simple" command parser; I'm guessing I'm doing something wrong with memory allocation - appreciate any pointers :) For context: I'm running on an Arduino Uno (if it ...
0
votes
3answers
130 views

Copying String into another String

I have an array of Strings in my code: String BitSequence [257]; Each string will have 23~64 characters. At one point in my code, I have to use "myString.remove()" command and I don't want to apply ...
0
votes
2answers
186 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
214 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["...
0
votes
0answers
32 views

ESP8266 EEPROM Reading extra character

I am very very new to ESP Programming. I am trying to store Strings into EEPROM of ESP8266. I am storing the string into eeprom successfully but while reading it from EEPROM extra character 'd' is ...
0
votes
1answer
40 views

Running commands from string

I have a string: string s="digitalWrite(8,LOW);" Is there any way to run it as a code?
0
votes
1answer
176 views

Scroll Left to Right on MAX7219 Display

For scrolling from left to right (Arabic letters) I need a function to print words/sentences on the MAX7219 display. [By setpixel(x, y) function] I did a lot of searching and my efforts failed. I ...
0
votes
4answers
354 views

String to float on Arduino

I'm trying to convert a String to a float but I'm running into issues with precision, even with the Arduino's own String example I'm getting bad results. Example 0: Input string: 1.234567 After ...
1
vote
2answers
57 views

Mixed structure with int and string

I want to create a structure like this: struct commands { int cmd; char descr[25]; }; commands cmds[] = { {16, "Hammond Organ"}, {17, "Percussive Organ"}, {18, "Rock Organ"}, { 0, "" ...
1
vote
1answer
41 views

Comparing a text string to text output (DHT22)

Lately I've received a DHT22 sensor. I've started to create a small temperature and humidity monitor station. One of the things I noticed was if you pulled out the sensor while in use, it displayed "...
0
votes
1answer
55 views

String generator not working as expected

I'm trying to build a random string, save it to EEPROM as int, then read it back and output it. If I give it a predefined string then it works fine. But Something is wrong with the random string ...
0
votes
0answers
37 views

How to compare an incoming byte from cool terminal as modbus hex value and compare it with a predefined value in set in the program?

My Input from Cool terminal is 05 03 00 01 00 02 94 4F I should be able to read this input 05 03 00 01 00 02 94 4F compare with the same(05 03 00 01 00 02 94 4F). If the incoming value(05 03 00 ...
0
votes
1answer
489 views

Convert float to hexadecimal value

I am trying to convert a float value to a 4-byte hexadecimal value. For example my input is: 58.5. My expected output is: 426A0000 or like 0x42 0x6A 0x00 0x00. My program is: void setup() { ...
0
votes
0answers
46 views

Arduino Lib doesn't recognize String type

I use the following code snippet in a library I wrote: int MyClass::Send(MyMessage* message) { String rev = func(); // Do Work } And in a different library I wrote: String func(){ ...
1
vote
1answer
23 views

I can't receive string that I have sent through nrf correctly

I'm using arduino uno and nrf24l01. to monitor sensor data. But this is the message that master receives: ⸮ this is my slave code. void monitoring() { delay(10); radio.stopListening(); ...
0
votes
1answer
294 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
2answers
137 views

Yet another basic and silly question about C++ strings

I made a sketch like this: void setup() { // put your setup code here, to run once: Serial.begin(9600); char str1[64] = "test with spaces"; char str2[32] = "test with spaces"; Serial....
0
votes
0answers
80 views

First sprintf-call works, second (identical) does not

In my current project I'm using an Arduino Nano, an RTC-Module, SD-Module and an OLED-Display to log time-values. I'm currently trying to implement following function: char *onString = (char*)...
0
votes
2answers
261 views

How to Sort a String with Number by Ascending

I have trouble figuring out how to sort a String that has a Number in it. The String im sending looks like 112:AAAA and 111:EEEE, how would I sort it so that the 111 will be the first in an array but ...
0
votes
1answer
111 views

How to decrease delay for String concatenation + Arduino Due

In my project I need to add a delimiter between integer numbers. In the following code. I add a "," between integer numbers obtained from inputsig matrix. The problem is that concatenation of these ...
0
votes
0answers
107 views

Have ESP8266 read 'text/event-stream` from flask in single request

I have a route in Flask which serves an event-stream: @app.route('/input/<string:blah>') def index(blah): def generate_random_data(): while True: r = random.random() * ...
2
votes
1answer
801 views

char buffer to String in Arduino UNO

String getAPIData() { char res_buffer[450]; int numdata = inet.httpGET("myserver.com", 80, "/call.php?id=1&q=1&code=1001", res_buffer, 450); String result = String(res_buffer); Serial....
0
votes
1answer
240 views

Second item in array not gets assigned from struct object, ArduinoJson

I got the below code generated this amazing tool. const size_t capacity = JSON_ARRAY_SIZE(2) + JSON_OBJECT_SIZE(1) + JSON_OBJECT_SIZE(4) + 2*JSON_OBJECT_SIZE(7); DynamicJsonDocument doc(capacity); ...

1
2 3 4 5 6