How to return int array

I made a class named as Sensor, in which I made a struct to store the sensor values,

struct sensor_reading {
int time = 0;
double temperature = 0;
double humidity = 0;

sensor_reading reading;

How can another file to get access to the struct value in the Sensor class ?

If it doesn’t work, I am thinking to make a function and store the sensor values in a array and return the sensor values .

You can place your struct in a header file (e.g call it names.h). Place that file in the directory that contains your .ino file before you attempt to compile.

Add #include "names.h" to your .ino file.

by default it will be public.

1 Like