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
62
votes
12answers
384k views

How do I split an incoming string?

I am sending a list of servo positions via the serial connection to the arduino in the following format 1:90&2:80&3:180 Which would be parsed as: servoId : Position & servoId : Position ...
51
votes
13answers
250k 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); ...
3
votes
5answers
8k 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
2answers
1k 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 ? ...
1
vote
2answers
576 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
1answer
1k views

Storing latitude and longitude floats as chars with specified precision

I am receiving lat and long data from a GPS and want to store these numbers in the middle of a sequence of chars. E.g. lat = -23.123456 long = 135.123456 I am after something like "Your coordinates ...
3
votes
3answers
21k views

DateTime to string

For some reason I can't use the Time.h lib. Can you guys tell me how to create a string from the datetime into a format like this: yyyy.MM.dd:hh.mm.ss 2014.10.29:07.12.33 Seems odd that I can't ...
3
votes
2answers
2k views

What is the memory expense of creating a String from a char array?

I'm writing a little API for processing email messages in Arduinos. Obviously, I need to keep memory use down, but I also want to allow the end user to use the String functions (like indexOf) to ...
3
votes
1answer
834 views

Using UART to Set RTC

I'm using an Adafruit NRF8001 Low Energy Bluetooth module and a Real Time Clock module with my Arduino board. I want to connect to the BLE module using UART to set the clock. I'll also be using UART ...
1
vote
1answer
6k views

Implementing DES or AES Encryption with DateTime Synchronization on Uno

We are trying to implement AES or DES encryption using an Arduino Uno. We have a keypad module attached that will be used to input integers. A String should be generated based on the entered data and ...
1
vote
4answers
958 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: ...
6
votes
6answers
9k views

Understanding why should avoid “String” and alternative solutions

Why “Strings” are bad for Arduino? Which is the most efficient and fastest solution to read and store the data from Accelerometer and GPS? Stings are evil for Arduino An Uno or other ATmega328-...
3
votes
2answers
3k views

Concatenation of non constant character array with a string

I have an Arduino Duemilanove. I read this page on string concatenation. Yet, it didn't include my case. I have a non constant character array, that later gets a value. char clat[11]; dtostrf(gps....
2
votes
1answer
211 views

How to convert a String to Hex array

I am trying use a HMI display. If I want to send a data, for example I want to write "TOPWAY" to 0x00000080 address it should like that: Serial.write(0xaa); // packet head Serial....
2
votes
1answer
271 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 ...
2
votes
1answer
58 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:...
2
votes
1answer
4k 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. ...
1
vote
1answer
5k 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
5k views

strtok problem while parsing String

Here is my code. The incoming string is "*CRB12344,Temp25,Humidity55,CC5#" I am unable to get value of Temp which is 25 and Humidity which is 55 and CC which 5. It only display the value of CR i.e ...
1
vote
2answers
20k views

float precision in arduino

I am reading a string which i have to convert into a float with a maximum of precision.I didn't want to use toFloat() function since it make a truncation so i made my own code. My problem is that the ...
1
vote
2answers
4k views

Get strings from Serial.read()

I want to read strings from Serial.read() to send them later. To get the data from the Serial monitor I'm doing this: String stringOne = ""; int incomingByte; if (Serial.available() > 0) { ...
1
vote
1answer
5k views

how to send large strings (> 100 characters) from arduino serial monitor

I am a newbie to arduino programming. I wish to send big strings which are in range of 100 to 1000 characters to my arduino uno. I saw that arduino cannot read more than 63 characters at a time. The ...
0
votes
3answers
803 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
502 views

Reading a 10-byte buffer out of a PROGMEM string stored in a string table

I'm storing a large snippet of text in three separate PROGMEM char arrays: const char script1[] PROGMEM = "...."; const char script2[] PROGMEM = "...."; const char script3[] PROGMEM = "...."; The ...