Hello, i am trying to make an infrared based thermometer, but i am getting an error message that i don't know the meaning of since i am new to arduino. If you can help me i would be thankful!
#include <i2cmaster.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd (8, 9, 4, 5, 6, 7);
int address = 0xb4; // Sensor address MLX90614
int data1 = 0; // The second byte of data
int data2 = 0; // The first byte of data
double temperature = 0; // Variable holding the temperature
void setup() {
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
i2c_init (); // Initialization of the I2C bus
lcd.begin (16, 2); // Initialize the display
}
void loop() {
digitalWrite(10,HIGH); //Turns on the Laser Pointer for accurate aiming
i2c_start_wait (address + I2C_WRITE); // Start I2C communication in write mode
i2c_write (0x07); // Write the value 0x07 (select the register Tobj1)
i2c_rep_start (address + I2C_READ); // Restart I2C communication at the read address
data1 = i2c_readAck (); // Read the first byte of data
data2 = i2c_readAck (); // Read the second byte of data
i2c_stop (); // End of I2C transmission
temperature = (double) (((data1 & 0x007F) << 8) + data2); // Create a 16-bit variable consisting of two one-byte variables
temperature = temperature * 0.02; // To change from the value read to Temperature in Kelvin
temperature = temperature - 273.15; // Conversion to Celsius degrees
lcd.setCursor (0,0); // Display (first LCD line)
lcd.print ("Object =");
lcd.print (temperature);
lcd.print ("");
lcd.write (0xDF); // Degree sign
lcd.print ("C");
delay (200);
if(temperature > 38) //Turns on the red LED if the temperature read is more than 38 degrees celsius
digitalWrite(11,HIGH);
else digitalWrite(11,LOW);
delay (200);
}
This is the error message:
Arduino: 1.8.12 (Windows 10), Board: "Arduino Nano, ATmega328P"
C:\Users\JADBAA~1\AppData\Local\Temp\ccp5fJrZ.ltrans0.ltrans.o: In function `setup':
C:\Users\Jad Baalbaki\Downloads\Laser_Temp_Gun/Laser_Temp_Gun.ino:16: undefined reference to `i2c_init()'
C:\Users\JADBAA~1\AppData\Local\Temp\ccp5fJrZ.ltrans0.ltrans.o: In function `loop':
C:\Users\Jad Baalbaki\Downloads\Laser_Temp_Gun/Laser_Temp_Gun.ino:22: undefined reference to `i2c_start_wait(unsigned char)'
C:\Users\Jad Baalbaki\Downloads\Laser_Temp_Gun/Laser_Temp_Gun.ino:23: undefined reference to `i2c_write(unsigned char)'
C:\Users\Jad Baalbaki\Downloads\Laser_Temp_Gun/Laser_Temp_Gun.ino:24: undefined reference to `i2c_rep_start(unsigned char)'
C:\Users\Jad Baalbaki\Downloads\Laser_Temp_Gun/Laser_Temp_Gun.ino:25: undefined reference to `i2c_readAck()'
C:\Users\Jad Baalbaki\Downloads\Laser_Temp_Gun/Laser_Temp_Gun.ino:26: undefined reference to `i2c_readAck()'
C:\Users\Jad Baalbaki\Downloads\Laser_Temp_Gun/Laser_Temp_Gun.ino:27: undefined reference to `i2c_stop()'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Nano.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.