Questions tagged [data-type]

Identifies the size and nature of information held by a variable in a program. It is language-dependent. Examples for C/C++ include: `int`, `float`, and `char`.

Filter by
Sorted by
Tagged with
2 votes
2 answers
527 views

Read one byte from file and convert to decimal

Ok, I'm fairly new to Arduino and I'm trying to read bytes from a file in an SD card and convert to integer values (0-255). I have a file, with 1 byte on it (128 int value, created in Python, can ...
melev's user avatar
  • 71
0 votes
4 answers
409 views

How to send multiple bytes with Wire without copying

When I need to send multiple bytes via Wire, for example a long int, I cast it to a byte array and specify a length long int i; Wire.write((byte*)&i, 4); But if I want to send bytes from more ...
user88434's user avatar
1 vote
1 answer
541 views

Wire.write invalid conversion from ‘char*’ to ‘const uint8_t*

I have written this code: char message[4]; memcpy(message, &delta, 4); Wire.write(message, 4); When I try to compile I get this warning: warning: invalid conversion from ‘char*’ to ‘const ...
user88434's user avatar
0 votes
1 answer
101 views

Conversion from `const char* datac="0x21,0x10,0xfa,0x7a,0xff";` to `uint8_t datat[]={0x21, 0x10, 0xfa, 0x7a, 0xff}`

The below reading data from API: #include <WiFi.h> #include <HTTPClient.h> #include <ArduinoJson.h> const char* ssid = "****"; const char* pass = "****"; void ...
Just doin Gods work's user avatar
0 votes
2 answers
187 views

String() vs char for simple flow control

I am newbie in Arduino and writing a program where I want to control the flow by using Serial monitor input (PI controller). I've read that using String() although easier it is slower than using char. ...
Ognyan Petkov's user avatar
0 votes
1 answer
122 views

What's the difference between CloudTemperature, CloudTemperatureSensor and Float data types?

I have a SHT30 sensor for Wemos and I am learning to use Arduino IOT Cloud. I use float data type for my temperature variable but I see two more data types: CloudTemperature CloudTemperatureSensor ...
Roby Sottini's user avatar
1 vote
1 answer
558 views

How to know the data type of constant in arduino IDE?

For example constant of MSBFIRST, It used to as input in SPI.setBitOrder(MSBFIRST). But sadly i don't know the type data of MSBFIRST. This is applied to like SPI_MODE0 and other.
Muhammad Ikhwan Perwira's user avatar
2 votes
1 answer
250 views

Arduino data-types

(Im new to the arduino side of stackexchange). Im working on a worksheet for to begin with arduino. I have prior experiences working with arduinos, but problem is new for my field of expertise. Any ...
UnfreeHeX's user avatar
1 vote
1 answer
615 views

Store Integer Value of Money on an RFID Tag

I am working on making an Arduino based arcade. I want each user of the arcade to have an RFID card that stores the amount of credits (basically money) they have. I know that RFID tags have 1028 bytes ...
Rowan McAlpin's user avatar
2 votes
1 answer
144 views

Conditional compilation depending on sizeof(double)

Is there a macro (#define ...) somewhere in the bowels of Arduino IDE or core header files which tells me at compile time(!), if the double data type for a given platform/board is a true double ...
Andy's user avatar
  • 123
-2 votes
1 answer
497 views

Converting an int to an unsigned char for display on a Nokia 5110

I've been working on a small project getting some images displayed in a Nokia 5110 screen via an Arduino. I've been getting it working, but one of the issues I have is that I would like to have a list ...
Snuh's user avatar
  • 105
1 vote
0 answers
738 views

converting int or float into bytes array in arduino

I am trying to send data from one arduino to another over ethernet using udp protocol. In arduino writing data over udp is like this UDP.write(buffer, size); where buffer is an array to send as a ...
eToll Systems's user avatar
0 votes
1 answer
157 views

What is the purpose of putting a data type in brackets before a calculation?

sorry for the nooby question but I can't seem to find the answer to this anywhere, probably because I'm unsure what to search for with this problem! I'm just wondering what the reason is for including ...
Elliot P's user avatar
1 vote
0 answers
940 views

incompatible types in assignment of 'const String' to 'char [32] using server.arg

I am trying to create a class and getting getting the error incompatible types in assignment of 'const String' to 'char [32] when I declare char inString[32]; and try to set it as inString = server....
brad's user avatar
  • 201
1 vote
1 answer
93 views

Import into Arduino a vintage data bus from TMS1000

For experimentation I want to import or receive into Arduino the output data from a TMS1000 (1980s) data bus. For model train controller Hornby Zero1, and the bus sends data to receivers, for loco ...
sswcharlie's user avatar
1 vote
1 answer
307 views

Why use \" in arduino code?

While working with JSON parsing I noticed that the char type data string is written like this: char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\&...
Sohan Arafat's user avatar
2 votes
2 answers
559 views

Not output on serial monitor, sending string on serial.print

I get two 10-bit values from analog pins. These two values in a string, ";" combine with. for ex: 515; 510 I am sending it to another arduino via Serial.print. I cannot display this string ...
Enes Orhan's user avatar
2 votes
2 answers
2k views

Own type definition using a struct does not name a type

I need to initialize several buttons and LEDs connected to my Arduino. To store data related to an individual button or LED, I decided to define my own data type using two different structs. One for a ...
albert's user avatar
  • 205
-1 votes
1 answer
203 views

storing 600 unsigned int values in an array and find minimum and maximum values

I am reading an ASCII serial data values from a sensor and storing it in an unsigned integer variable. The values are ~45000 to 50000 range. I need to store 600 values and then find the minimum and ...
srikanth's user avatar
2 votes
1 answer
10k views

Need help: Cast from 'char*' to 'uint8_t {aka unsigned char}' loses precision [-fpermissive]

I'm trying to convert the string that I receive from the Websocket to uint8_t that I can copy to the data bytes of CAN protocol frame. I'm using an ESP32 chip and programming it on an Arduino IDE. The ...
ObviousActivity936's user avatar
0 votes
1 answer
295 views

Assigning value to a struct byte order

So i have struct: typedef struct sendPacketStruct { byte header = headerByte;//0x55 unsigned int time;//2 bytes int height;//2 bytes }; And i do this: sendPacketStruct sendPacket; ...
Hayden Thring's user avatar
0 votes
1 answer
439 views

AccelStepper library advanced codes!

I was trying to find out how this library can run multiple stepper motors at the same time, and I saw this important function called... void AccelStepper::setOutputPins(uint8_t mask) { uint8_t ...
2012User's user avatar
  • 149
-3 votes
1 answer
1k views

Any limitation on array size in Arduino Mega 2560?

I am writing an Arduino code with 3 arrays. Two of those are double and other one is int. Further first two arrays have nearly 420 elements for each. Now I noticed that with more that 89 elements on ...
e1065273's user avatar
1 vote
1 answer
351 views

What else is consuming Data Segment reported by avr-size?

I am facing a low memory available problem in arduino. I am compiling a big sketch for arduino mega 2560. Analysing a .elf file, the avr-size tool gives: text data bss dec hex filename ...
LeandroIP's user avatar
1 vote
1 answer
947 views

Int64_t aka long long acts as int32_t and overflows at 2^31

I have an int64_t variable. When I add another int64_t variable and convert it to a double to print it on the serial monitor, it acts as if it was a int32_t variable. This is the program: int64_t a =...
LukasFun's user avatar
  • 295
1 vote
0 answers
344 views

ModbusMaster - Read 64 Bit integer

i'm using ModbusMaster library (Repo) to read from a device some registers. Many of them are float and i've no problem to read them using the following code: //for float conversation union { ...
SardoMan's user avatar
  • 167
1 vote
1 answer
160 views

Data type explanation regarding analogRead of a photoresistor

This is a fundamental question - very new (1st post) and trying to learn. I have a photocell connected in series with a 10kOhm resistor between 5v & Gnd (to make a voltage divider) and the ...
bsmntdweller's user avatar
0 votes
1 answer
2k views

How to convert four uint16_t to double float IEEE754?

I am working in a Modbus project where I have to read modbus Holding and Input registers using ESP8266, I am using ModbusMaster232 library. I returns a response buffer array of uint16_t. I need to ...
Mr.B's user avatar
  • 67
0 votes
1 answer
117 views

Boolean function call with character pointer input - dont understand how to get updated pointer value

Thank you for everyone's help in trying to find a solution. This library I'm working with was prewritten and is one of the most buggy hardware libraries I've had the misfortune to use. I have now ...
AidenDawn's user avatar
3 votes
4 answers
628 views

Can I use 1-byte datatypes to store digital input?

I am reading the docs on DigitalRead() and wondering why it stores seemingly boolean HIGH and LOW inputs in int data type variable. I have two issues with that: int is 2-byte, while bool and ...
Arthur Tarasov's user avatar
-1 votes
1 answer
388 views

Keyboard.write writing ASCII integer value as a String

I have the following code: #include <SoftwareSerial.h> #include <Keyboard.h> SoftwareSerial ttySerial(10, 11); // RX, TX void setup() { // Open serial communications and wait for port ...
Sterling Butters's user avatar
1 vote
2 answers
988 views

Why does Arduino IDE recommend storing 0-255 numbers in "byte" instead of "char"?

I bumped into byte datatype recently. My knowledge of C/C++ is shallow, but I know char and I couldn't find much on byte in C++ docs. I looked it up in the Arduino docs: It’s recommended to only ...
Arthur Tarasov's user avatar
1 vote
1 answer
1k views

cast double to long leads to unexpected results

I wrote a little program to show my problem: void setup() { Serial.begin(9600); double K=39.85; double a=K*100; Serial.print("a= "); Serial.println(a); long val_long = 0; val_long = ...
Hardy72's user avatar
  • 19
1 vote
3 answers
4k views

Set and extract individual bytes of a number (lowByte() and highByte())

You can extract the low-order (rightmost) byte of a variable or the high-order (leftmost) byte of a word with the functions lowByte() and highByte() respectively (the quotes are from the ...
LukasFun's user avatar
  • 295
0 votes
2 answers
348 views

What is the best data type to be used through i2C

i'm trying to send multiple commands to multiple slaves controlling motors. Slave Controller(Arduino Nano) will receive the command, and returns the current position of the motors to the Master(...
Julius's user avatar
  • 91
0 votes
1 answer
159 views

What kind of data type can be use store a binary bit-stream which is more than 64-bits?

I'm wondering if one needs to assign a bit-stream of 78 bits to a variable(later on to be processed), what datatype can be used? What is the max bit can be stored into a variable in C?
floppy380's user avatar
  • 245
0 votes
2 answers
147 views

What are the sizes of each primitive datatype on a Metro M4 Express SAMD51?

What are the data sizes of all the primitive datatypes on a Metro M4 Express SAMD51 C++ implementation? In some C++ implementations, int has 16 bits and in other implementations it has 32 bits. Is
Jonathan Wheeler's user avatar
2 votes
1 answer
124 views

double to char* conversion. Weird results from dtostrf

Here’s the code: void setup() { Serial.begin(9600); delay(300); double lat = 1111.11; double lon = 4444.44; const byte len{10}; char sLat[len]; char sLon[len]; ...
zhekaus's user avatar
  • 439
1 vote
2 answers
514 views

SoftwareSerial receives beginning of data mangled

I'm using SoftwareSerial to communicate with a Sigfox module. Documentation for the read function assigns its value to a char. However using it I get mangled characters and also have read in other ...
Marki555's user avatar
  • 129
0 votes
1 answer
43 views

arithmetic operation outcome differs from the expected outcome

I am writing a function void Sound_Play(int frequency,int millisec) A part of this function is: counting=(millisec*frequency/1000); //counting is type int Serial.println((String)"millisec="+...
Bhuvnesh's user avatar
  • 105
1 vote
0 answers
168 views

Data Structures and Color Data Types in FastLED

So i'm doing something wrong but i don't exactly know what and hope somebody can give me a quick pointer: I declared a starting color for my fastled animation: CHSV startcolor(100, 255, 255); and ...
Julian Finn's user avatar
0 votes
1 answer
996 views

Unexpected results when creating 32-bit int from byte array

I'm having problems creating a 32-bit integer from a 4-byte array. In the following complete, minimal, and verifiable example, converting a byte array containing 0x00, 0x04, 0x04F, 0x45 results in ...
You'reAGitForNotUsingGit's user avatar
1 vote
1 answer
334 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 ...
Rick's user avatar
  • 61
3 votes
1 answer
3k views

Print unsigned long long in ESP8266

I need to print an unsigned long long variable: unsigned long long t = 1559072327000ULL; I have tried the following: Serial.println(t); // call of overloaded 'println(uint64_t&)' is ambiguous ...
Yván Ecarri's user avatar
0 votes
2 answers
199 views

Problem in defining a variable as multiplication

I have a simplest code to turn on and off a led. The variable holding time definition is onTime, using Arduino Nano. When it is written as: onTime=1000*30, all is good. When onTime is greater than ...
guyd's user avatar
  • 993
0 votes
1 answer
181 views

Data type conversion problem

I have a Wemos D1 board with a OLED display using the u8g2 library. I am printing my MAC-adress on the serial port & would like to print the same information on the OLED: #include <...
Rhino's user avatar
  • 41
0 votes
1 answer
3k views

invalid conversion from 'uint16_t* error when creating an array of uint16_t items

I'd like to create an array of remote control codes provided by the raw read feature of the irlib2 library. irlib2 provides the following uint16t arrays using the following format: #define ...
Aaron Ciuffo's user avatar
0 votes
2 answers
2k views

What data type are the analog pin labels (A0, A1, etc)?

Arduino Mega I would like to have an array containing analog pin labels something like... int analog_pins[] = {A0, A1, A2, A3}; int num_analog_pins = sizeof(analog_pins) / sizeof(analog_pins[0]); ...
DrBwts's user avatar
  • 161
0 votes
1 answer
392 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,...
El Kazma's user avatar
1 vote
0 answers
213 views

Integer corruption

I use a sensor to measure the temperature. This is returned as float. I feed this float using typecasting (int) to a blink function. This works fine. But the next is step is using this same unchanged ...
Thijs's user avatar
  • 422