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
-1
votes
2answers
44 views

Convert string to integer

I'm using two ESp32 in a server and client configuration and i'm sending data between them in form of strings but i want to convert the recieved data which is fom of strings but it contains numbers ...
1
vote
1answer
35 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 ...
1
vote
0answers
42 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 ...
0
votes
1answer
22 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 ...
0
votes
0answers
42 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....
1
vote
1answer
35 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 ...
1
vote
1answer
295 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\&...
0
votes
0answers
112 views

How to take a CHAR change it into a int increment and then back to a Char for a clock display

So I'm using the NTP on the arduino. I'm going to only ping the NTP once a day to truth up the clock. however the rest of the time I want just to use incrementing the minute and hour via ints. I'm ...
2
votes
2answers
53 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 ...
2
votes
1answer
288 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 ...
0
votes
1answer
60 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 ...
2
votes
1answer
517 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 ...
0
votes
1answer
59 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; ...
0
votes
1answer
107 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 ...
-3
votes
1answer
215 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 ...
0
votes
1answer
57 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 ...
1
vote
1answer
292 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 =...
1
vote
0answers
103 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 { ...
1
vote
1answer
31 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 ...
0
votes
1answer
471 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 ...
0
votes
1answer
49 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 ...
3
votes
4answers
228 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 ...
-1
votes
1answer
167 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 ...
1
vote
2answers
243 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 ...
1
vote
1answer
849 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 = ...
1
vote
3answers
2k 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 ...
0
votes
2answers
56 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(...
0
votes
1answer
43 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?
0
votes
1answer
35 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
2
votes
1answer
63 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]; ...
0
votes
2answers
288 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 ...
0
votes
1answer
40 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="+...
1
vote
0answers
84 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 ...
0
votes
1answer
137 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 ...
1
vote
1answer
189 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 ...
3
votes
1answer
1k 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 ...
0
votes
2answers
93 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 ...
0
votes
1answer
82 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 <...
0
votes
1answer
983 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 ...
0
votes
2answers
888 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]); ...
-1
votes
1answer
168 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,...
1
vote
0answers
179 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 ...
1
vote
1answer
5k views

Can't create an array of type const char*

I have something being returned as a const char* and would like to save it to an array. I've tried this: const char* book[amtBooks] = ""; and get this error: error: array must be initialized with ...
2
votes
3answers
96 views

Is the strange problem I'm having to do with comparing floats?

I have a timer interrupt that controls a stepper motor, on an UNO board. In the interrupt handler it checks the speed of the motor and compares it to the target speed. This allows the motor to ...
0
votes
3answers
179 views

How to map 6 bytes of raw data to long long type?

I'm trying to solve some problems for a contest, and I have a problem with it. I have to implement a function that has 3 arguments like this: void foo(unsigned char* A, unsigned char* B, unsigned ...
0
votes
1answer
365 views

Casting custom shared_ptr object

I am using custom shared_ptr class for some program on Arduino, and I need to do something like this: shared_ptr<Base_class> b_ptr; shared_ptr<Child_class> ptr((shared_ptr<Child_class&...
0
votes
1answer
395 views

Arduino variables loaded from SD card

I am trying to load some variables from an SD card on the start up of my arduino Uno. I have been given some advice but am unable to communicate at the same hours. Using this advice, I have the ...
0
votes
1answer
2k views

Arduino: load variables with values read from SD card

I am having a bit of trouble loading values stored on an SD card and assigning them to variables within my program. I can achieve this as one big block of data, but would much prefer them to be saved ...
1
vote
2answers
44 views

Comparing custom variable type definitions

In a library I am using with an OBD adapter, they define a public function to get the state of the OBD connection using some strange (and, in my opinion, useless) custom defined variable type: // ...
0
votes
3answers
13k views

How can i get rid of the error “cannot convert 'String' to 'const char*'”

I want to get this code to recognise different commands and be able to parse the rest of the command, fore example I send "/sleep 5", and it will sleep for 5 seconds. However, I keep on getting this ...