What's the deal with Arduino.h?

I am using a sample sketch included with the SoftI2CMaster library at GitHub, linked to from the Adafruit site.

Library at:

The sketch includes the line
#include <Arduino.h>
but there is no Arduino.h in the libraries listing on this site nor at Github, and it is not included in the Arduino IDE.

If I try to compile the sketch without Arduino.h it errors out, no surprise.

What's with this Arduino.h?

Thanks, LesB

// reads out the MLX90614 infrared thermometer
#include <Arduino.h>
#define SDA_PORT PORTD
#define SDA_PIN 3
#define SCL_PORT PORTD
#define SCL_PIN 5
#include <SoftI2CMaster.h>
#define DEVICE (0x5A<<1)
void setup(){
#if (__AVR_ARCH__ == 5) // means ATMEGA
Serial.begin(19200);
Serial.println("Setup...");
#endif
i2c_init();
}
void loop(){
int dev = 0x5A<<1;
int data_low = 0;
int data_high = 0;
int pec = 0;
i2c_start(dev+I2C_WRITE);
i2c_write(0x07);
// read
i2c_rep_start(dev+I2C_READ);
data_low = i2c_read(false); //Read 1 byte and then send ack
data_high = i2c_read(false); //Read 1 byte and then send ack
pec = i2c_read(true);
i2c_stop();
//This converts high and low bytes together and processes temperature, MSB is a error bit and is ignored for temps
double tempFactor = 0.02; // 0.02 degrees per LSB (measurement resolution of the MLX90614)
double tempData = 0x0000; // zero out the data
int frac; // data past the decimal point
// This masks off the error bit of the high byte, then moves it left 8 bits and adds the low byte.
tempData = (double)(((data_high & 0x007F) << 8) + data_low);
tempData = (tempData * tempFactor)-0.01;
float celcius = tempData - 273.15;
float fahrenheit = (celcius*1.8) + 32;
#if (__AVR_ARCH__ == 5) // means ATMEGA
Serial.print("Celcius: ");
Serial.println(celcius);
Serial.print("Fahrenheit: ");
Serial.println(fahrenheit);
#endif
delay(1000); // wait a second before printing again
}
1 Like

It should be in the arduino IDE, ver 1.0 and later.

Look in the program folder(s) where the Arduino software is installed.

arduino.h is in the installation folder of arduino under \hardware\arduino\cores\arduino.

arduino.h is in the installation folder of arduino under \hardware\arduino\cores\arduino.

This was the only place I found it. Other locations didn't have it, either on my desktop or laptop.

Thanks,
LesB

This [...\hardware\arduino\cores\arduino] was the only place I found it.

Why would it be anywhere else? That directory is added to the include file search path when the IDE compiles your code, AND when it compiles any libraries...

Well call me a neat-freak, but what I would consider the logical place is where all the other *.h files are kept, instead of its own special nook.

LesB

1 Like

Al the standard .h files are in their standard places (relative to some root within the Arduino install.) All the AVR-specific .h files are in a standard place "../include/avr"; you can think of those as part of the usual "avr-gcc" install. All the "Arduino core" .h files specific to the Arduino, and are in ...hardware\arduino\cores\arduino. This keeps the compiler directory structure "pure." I suppose you could argue upside and downsides of this vs other possibilities, but it's neither "bad" nor inconsistent...

All of the directories end up added to the Include paths in the compile statement; I'm not sure I understand how you ran into problems Are you implementing some sort of new build environment?

1 Like