We’re rewarding the question askers & reputations are being recalculated! Read more.

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
0
votes
1answer
17 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
22 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
59 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
34 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="+...
8
votes
4answers
25k views

Convert to and from Unix Timestamp

What is the best way to convert between date, hours, min, seconds to Unix timestamp in milliseconds in Arduino? I need to have this conversion, since I'm using RTC (date, hours, min, secs etc) and ...
0
votes
0answers
29 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
40 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
64 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
161 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
74 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 ...
1
vote
0answers
142 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 ...
0
votes
1answer
37 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
67 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
125 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]); ...
0
votes
0answers
73 views

Buffer to string

I'm a bit of a noob, so excuse if this is more obvious to me than to you. I want to convert a u16 to a string. The u16 is the data coming in from the sensor. I need it as a string, or anything else ...
-1
votes
1answer
99 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,...
3
votes
2answers
2k views

inttypes vs Arduino defined integral types

In my Arduino projects I use both Arduino types and types defined in the "inttypes.h" file, which #includes stdint.h. So far I've always written code only for the ATmega328P microcontroller (either in ...
8
votes
2answers
27k views

How to retrieve the data type of a variable?

I am using Arduino and I would like to know if there is a function that returns the data type of a variable. That is, I would like to run something as like the following: // Note: 'typeof' is a ...
0
votes
4answers
3k views

Multiplication, division. What is wrong?

const unsigned long C1 = 30 * 1000; const unsigned long C2 = (300 * 1000)/C1; // must be = 10 void setup() { Serial.begin(57600); Serial.println("\n-------"); Serial.print("C1 = "); Serial....
-2
votes
3answers
2k views

What Arduino data type allows decimals?

This probably sounds dumb, but I am not getting any clear answer for this. What data type allows a reasonable amount of decimals?
1
vote
1answer
2k 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
81 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
95 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
92 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
158 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
1k 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 ...
2
votes
3answers
1k views

Sending struct from Arduino to Raspberry Pi - wrong types

I'm using Raspberry Pi and Arduinos for my home automation project where Raspberry Pi is the controler of Arduino nodes. I use nRF24 wireless transceivers to communicate. My problem is that when I ...
1
vote
2answers
29 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
7k 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 ...
1
vote
1answer
73 views

DS18B20 sending variable via Enthernet shield

I am trying to send temperature read from DS18B20 to a web server. I know two things: to read a temperature, and to send something to web server. What I don't know is how to convert float that ...
1
vote
1answer
2k 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 ...
0
votes
1answer
483 views

Store values in array

I'm trying to implement the "BNO055 9 Axes Motion Shield". There is an existing Arduino sketch GitHub that reads out the Euler data, I changed it a bit to print out quaternion data. #include "...
0
votes
2answers
4k views

Converting (char*)variable to int

I have the following code: uint8_t buf[1]; uint8_t buflen = 1; if (driver.recv(buf, &buflen)) // Non-blocking { int i; // Message with a good ...
0
votes
1answer
1k views

RF receiver for integer only, how to cast uint8_t to int?

I'm using the RadioHead library with ASK Driver to transmit/receive data with generic RF modules. It works fine, but I'm lacking some knowledge in programming the code to use the data received. Most ...
1
vote
2answers
883 views

How can I write an integer to a Mifare RFID card using the RFID library?

I'm a beginner to C++ and I'm clearly missing some fundamental knowledge of data types. As such, I'm struggling to adapt the examples in the miguelbalboa/rfid library to my use case. I'm simply trying ...
0
votes
1answer
2k views

Receiving hex data from terminal [closed]

I am trying to transmit serial data from terminal to Arduino and I want to reconfirm that its the same data. But I am not able to get the right answer. I want data to be HEX. I want to check only the ...
1
vote
1answer
110 views

Determine whether a variable is of an arithmetic type

Is there a way to determine whether a variable is of an arithmetic type or not? arithmetic: integer, floating point numbers, boolean values not arithmetic: pointers, references; e.g. strings, and ...
1
vote
2answers
1k views

Const data optimisation for Arduino

I'm taking a course on Arduino Uno programming and on today's talk I heard that the const data is optimized by Arduino, so that it occupies less space than the actual data type (namely, a const int ...
1
vote
3answers
2k views

Why char 0x80 == 0xFFFFFF80?

As far as I know a char is an 8 bit variable void setup() { Serial.begin(9600); } void loop() { char x = 0x80; if(x != 0x80){ Serial.println(x, HEX); } delay(1000); }
0
votes
2answers
128 views

Testing ID and Serial Communication (Update)

Here is my challenge: I have to create a sketch where I would have a prompt asking the user to enter an ID. If it is successful, it would turn on the green LED and response with "Hello, your name is ...
1
vote
2answers
860 views

Unable to compare two integer values in Arduino Mega

I wrote Arduino code (code is given at the end) to compare two integer values. The steps I took was: Give input to DC motor to rotate it using serial port. Input was: G254 Then I store it in XX ...
0
votes
3answers
1k views

Having issues with Arduino + Bluetooth

I am working with a combination of Teensy++ 2.0 and Sparkfun Bluetooth Modem. The Arduino program, inside the loop, continuously reads a sensor value. If the value read is above a threshold, the ...
0
votes
1answer
2k views

String to unsigned long conversion

I'm trying to use strtoul() to convert an Arduino String to an unsigned long (like the return of millis();) using the following code snippet: unsigned long foo (String time) { unsigned long mili; ...
0
votes
1answer
3k views

What is causing this 'narrowing conversion' warning?

Because I'm still figuring out 'Arduino C' I leave all warnings on. Recently I got this one: narrowing conversion of '(int)(((unsigned char)bx_0) | ((unsigned char)bx_1))' from 'int' to 'const byte.....
0
votes
2answers
93 views

Arithmetic types in Arduino

I'm looking for a complete list of the arithmetic types in the Arduino framework. On the Internet I found various incomplete lists: sometimes there is short, sometimes word, but other types are ...
1
vote
2answers
217 views

Is this assignment valid or needs casting?

I have this assignment and while i don't get any error not even warning from the compiler. uint16_t Buffer[40000]; for (int n=0; n<40000 ; n++){ Buffer[n] = (0.99 * cos(((2.0*PI)/40000)*n); } ...
0
votes
2answers
75 views

character input for an integer variable? [duplicate]

Im trying out the code found here , let me quote the section of code that bothers me. // set pin numbers for switch, joystick axes, and LED: const int switchPin = 2; // switch to turn on and off ...
0
votes
1answer
410 views

What datatype is the names of the analog inputs?

I am writing a code for an automatic garden, and for this, I will use an array of sensors. I want to represent each plant as a class, and so one of the private variables will then be the sensorID, the ...
1
vote
1answer
2k views

Modbus slave data into word

I have simple code. The library downloaded from github:smarmengol/Modbus-Master-Slave-for-Arduino. I wanted to store floating point. In the code blow, I type casted to integer value. As I know ...
0
votes
2answers
800 views

Having problems with I2C - Slave is receiving “b ~ ,,,”

so I'm facing a pretty large problem. I'm experimenting with I2C and using one Arduino that acts as a countdown timer to send the current reading on the timer to another Arduino. I'm pretty new to ...