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
373k 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 ...
50
votes
13answers
246k 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
7k 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
446 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 ...
5
votes
2answers
15k 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 ...
5
votes
1answer
3k views

Serial.write and Serial.println return different values? Cannot use correct ones

I have a text file on an SD card, and I am trying to print the lines to the serial monitor. This Code Works: #include <SPI.h> #include <SD.h> File myFile; void setup() { Serial.begin(...
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 ...
2
votes
3answers
19k 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
1answer
814 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
953 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: ...
4
votes
4answers
24k views

What is better: one sprintf() or multiple strcat() and itoa()?

I was creating Arduino function which sends two int and additional chars between them and at the beginning and end of char array - then print that array to the serial port in almost real time. (For ...
4
votes
2answers
5k views

Simple URL decoding

How can I do a readable, small, smart and good URL decoder in Arduino? Now I'm using this code: String GetRidOfurlCharacters(String urlChars) { urlChars.replace("%0D%0A", String('\n')); ...
6
votes
6answers
8k 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
3k 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
48 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:...
1
vote
1answer
3k views

Nothng Written to Serial when using sprintf

I'm using sprintf to use a format specifier myTemplate with some strings. The result will then be written to Serial. Although the sketch compiles fine, it does not write any thing to the serial, ...
1
vote
2answers
19k 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
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
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 ...
1
vote
2answers
3k 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) { ...
0
votes
3answers
665 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
490 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 ...