redefinition of class error

I am getting this error and I am not sure how to fix it. I have attached the code itself, a screenshot of the code and the error message.

Error message :

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

In file included from sketch\Adafruit_MLX90614.cpp:19:0,

from C:\Users\ekraatz2\Downloads\Adafruit-MLX90614-Library-master\examples\mlxtest\mlxtest.ino:21:

Adafruit_MLX90614.h:50:7: error: redefinition of 'class Adafruit_MLX90614'

class Adafruit_MLX90614 {

^~~~~~~~~~~~~~~~~

In file included from C:\Users\ekraatz2\Downloads\Adafruit-MLX90614-Library-master\examples\mlxtest\mlxtest.ino:20:0:

sketch\Adafruit_MLX90614.h:50:7: note: previous definition of 'class Adafruit_MLX90614'

class Adafruit_MLX90614 {

^~~~~~~~~~~~~~~~~

exit status 1

redefinition of 'class Adafruit_MLX90614'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Adafruit-MLX90614-Library-master (1).zip (12.6 KB)

Pictures of code are near worthless. Members do not like to open zip files. Read the forum guidelines to see how to properly post code.

Sorry about that, thank you for your help.

/***************************************************
  This is a library for the MLX90614 Temp Sensor

  Designed specifically to work with the MLX90614 sensors in the
  adafruit shop
  ----> https://www.adafruit.com/products/1748
  ----> https://www.adafruit.com/products/1749

  These sensors use I2C to communicate, 2 pins are required to
  interface
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruied in any redistribution
 ****************************************************/

#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "Wire.h"

#define MLX90614_I2CADDR 0x5A

// RAM
#define MLX90614_RAWIR1 0x04
#define MLX90614_RAWIR2 0x05
#define MLX90614_TA 0x06
#define MLX90614_TOBJ1 0x07
#define MLX90614_TOBJ2 0x08
// EEPROM
#define MLX90614_TOMAX 0x20
#define MLX90614_TOMIN 0x21
#define MLX90614_PWMCTRL 0x22
#define MLX90614_TARANGE 0x23
#define MLX90614_EMISS 0x24
#define MLX90614_CONFIG 0x25
#define MLX90614_ADDR 0x2E
#define MLX90614_ID1 0x3C
#define MLX90614_ID2 0x3D
#define MLX90614_ID3 0x3E
#define MLX90614_ID4 0x3F

/**
   @brief Class to read from and control a MLX90614 Temp Sensor

*/
class Adafruit_MLX90614 {
  public:
    Adafruit_MLX90614(uint8_t addr = MLX90614_I2CADDR);
    bool begin();

    double readObjectTempC(void);
    double readAmbientTempC(void);
    double readObjectTempF(void);
    double readAmbientTempF(void);
    uint16_t readEmissivityReg(void);
    void writeEmissivityReg(uint16_t ereg);
    double readEmissivity(void);
    void writeEmissivity(double emissivity);

  private:
    float readTemp(uint8_t reg);

    uint16_t read16(uint8_t addr);
    void write16(uint8_t addr, uint16_t data);
    byte crc8(byte *addr, byte len);
    uint8_t _addr;
};
Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"





















In file included from sketch\Adafruit_MLX90614.cpp:19:0,

                 from C:\Users\ekraatz2\Downloads\Adafruit-MLX90614-Library-master\examples\mlxtest\mlxtest.ino:21:

Adafruit_MLX90614.h:50:7: error: redefinition of 'class Adafruit_MLX90614'

 class Adafruit_MLX90614 {

       ^~~~~~~~~~~~~~~~~

In file included from C:\Users\ekraatz2\Downloads\Adafruit-MLX90614-Library-master\examples\mlxtest\mlxtest.ino:20:0:

sketch\Adafruit_MLX90614.h:50:7: note: previous definition of 'class Adafruit_MLX90614'

 class Adafruit_MLX90614 {

       ^~~~~~~~~~~~~~~~~

exit status 1

redefinition of 'class Adafruit_MLX90614'



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Thanks for using code tags.

I don't think that the code that you posted (Adafruit_MLX90614.h) caused the error that you posted. Post the code that caused the error.

The mlxtest.ino example compiles fine for me. Did you modify mlxtest.ino or the library?

Adafruit_MLX90614.h:50:7:
In file included from sketch\Adafruit_MLX90614.cpp:19:0,
from Adafruit-MLX90614-Library-master\examples\mlxtest\mlxtest.ino:21:

sketch\Adafruit_MLX90614.h:50:7:
\Adafruit-MLX90614-Library-master\examples\mlxtest\mlxtest.ino:20:0:
sketch\Adafruit_MLX90614.h:50:7: note: previous definition of 'class Adafruit_MLX90614'

So from the error mesages it looks like Line 20 of mlxtest.ino says something like:

#include <Adafruit_MLX90614.h>

That include file (starting on line 50) defines the object class.

Then, the next line of mlxtest.ino (line 21) says something like:

#include <Adafruit_MLX90614.cpp>

That makes no sense at all. The error comes when Line 19 of Adafruit_MLX90614.cpp says something like:

#include <Adafruit_MLX90614.h>

That inserts Adafruit_MLX90614.h a second time and the file again (starting on line 50) defines the object class.