invalid conversion from 'uint16_t* {aka unsigned int*}' to 'uint16_t {aka unsign

Hello, I'm getting these errors. I need to get at least one reading with this sensor (MLX90640) to prove it works.

In file included from C:\Users\Bruna\Downloads\thermal_cam_mlx90640-master\thermal_cam_mlx90640-master\sensorExample\MLX906040_thermalImaging\MLX906040_thermalImaging.ino:19:0:

sketch\MLX90640_SimpleDriver.h: In function 'int MLX90640_I2CWrite(uint8_t, unsigned int, uint16_t)':

sketch\MLX90640_SimpleDriver.h:40:72: warning: expression list treated as compound expression in initializer [-fpermissive]

uint16_t MLX90640_I2CRead(_deviceAddress, writeAddress, 1, &dataCheck);

^

sketch\MLX90640_SimpleDriver.h:40:72: warning: invalid conversion from 'uint16_t* {aka unsigned int*}' to 'uint16_t {aka unsigned int}' [-fpermissive].

There is the code (but for betting understanding, please download all the items ).

#define I2C_BUFFER_LENGTH 1024

int MLX90640_I2CWrite(uint8_t _deviceAddress, unsigned int writeAddress, uint16_t data)
{
  Wire.beginTransmission((uint8_t)_deviceAddress);
  Wire.write(writeAddress >> 8); //MSB
  Wire.write(writeAddress & 0xFF); //LSB
  Wire.write(data >> 8); //MSB
  Wire.write(data & 0xFF); //LSB
  
  if (Wire.endTransmission() != 0)
  {
    //Sensor did not ACK
    Serial.println("Error: Sensor did not ack");
    return (-1);
  }

  uint16_t dataCheck;
int   MLX90640_I2CRead(_deviceAddress, writeAddress, 1, &dataCheck);
  if (dataCheck != data)
  {
    //Serial.println("The write request didn't stick");
    return -2;
  }

  return (0); //Success
}




int MLX90640_I2CRead(uint8_t _deviceAddress, unsigned int startAddress, unsigned int nWordsRead, uint16_t *data)
{

  //Caller passes number of 'unsigned ints to read', increase this to 'bytes to read'
  uint16_t bytesRemaining = nWordsRead * 2;

  //It doesn't look like sequential read works. Do we need to re-issue the address command each time?

  uint16_t dataSpot = 0; //Start at beginning of array

  //Setup a series of chunked I2C_BUFFER_LENGTH byte reads
  while (bytesRemaining > 0)
  {
    Wire.beginTransmission(_deviceAddress);
    Wire.write(startAddress >> 8); //MSB
    Wire.write(startAddress & 0xFF); //LSB
    if (Wire.endTransmission(false) != 0) //Do not release bus
    {
      Serial.println("No ack read");
      return (0); //Sensor did not ACK
    }

    uint16_t numberOfBytesToRead = bytesRemaining;
    if (numberOfBytesToRead > I2C_BUFFER_LENGTH) numberOfBytesToRead = I2C_BUFFER_LENGTH;

    Wire.requestFrom((uint8_t)_deviceAddress, numberOfBytesToRead);
    if (Wire.available())
    {
      for (uint16_t x = 0 ; x < numberOfBytesToRead / 2; x++)
      {
        //Store data into array
        data[dataSpot] = Wire.read() << 8; //MSB
        data[dataSpot] |= Wire.read(); //LSB

        dataSpot++;
      }
    }

    bytesRemaining -= numberOfBytesToRead;

    startAddress += numberOfBytesToRead / 2;
  }

  return (0); //Success
}

int MLX90640_DumpEE(uint8_t slaveAddr, uint16_t *eeData)
{
     return MLX90640_I2CRead(slaveAddr, 0x2400, 832, eeData);
}



int MLX90640_GetFrameData(uint8_t slaveAddr, uint16_t *frameData)
{
    uint16_t dataReady = 1;
    uint16_t controlRegister1;
    uint16_t statusRegister;
    int error = 1;
    uint8_t cnt = 0;
    Serial.println(".");
    dataReady = 0;
    while(dataReady == 0)
    {
        error = MLX90640_I2CRead(slaveAddr, 0x8000, 1, &statusRegister);
        if(error != 0)
        {
            return error;
        }    
        dataReady = statusRegister & 0x0008;
    }       
        
    while(dataReady != 0 && cnt < 5)
    { 
        error = MLX90640_I2CWrite(slaveAddr, 0x8000, 0x0030);
        if(error == -1)
        {
            return error;
        }
            
        error = MLX90640_I2CRead(slaveAddr, 0x0400, 832, frameData); 
        if(error != 0)
        {
            return error;
        }
                   
        error = MLX90640_I2CRead(slaveAddr, 0x8000, 1, &statusRegister);
        if(error != 0)
        {
            return error;
        }    
        dataReady = statusRegister & 0x0008;
        cnt = cnt + 1;
    }
    
    if(cnt > 4)
    {
        return -8;
    }    
    
    error = MLX90640_I2CRead(slaveAddr, 0x800D, 1, &controlRegister1);
    frameData[832] = controlRegister1;
    frameData[833] = statusRegister & 0x0001;
    
    if(error != 0)
    {
        return error;
    }
    
    return frameData[10];    
}

Thanks for the Help :smiley:

MLX90640_SimpleDriver.cpp (605 Bytes)

MLX90640_SimpleDriver.cpp (605 Bytes)

MLX906040_thermalImaging.ino (3.51 KB)

what's this supposed to do?  int  MLX90640_I2CRead(_deviceAddress, writeAddress, 1, &dataCheck); // WHY THE int AT THE START?

we are missing MLX90640_SimpleDriver**.h** (you gave us the .cpp twice)

I am not sure about programming itself. I got the codes on github. I'm just trying to compile the code without errors, to test the sensor.

and the link to the GitHub is....

I can't click the link... help the forum help you...

GitHub - jamesdanielv/thermal_cam_mlx90640: same as thermal cam project but with mlx90640 sensor SORRY (IDK HOW TO USE FORUMS, BUT I NEED HELP LMFAO)

im trying compile "SENSOR_EXAMPLE"

that's why there are forum rules to read...

that being said, the code is crappy. all in the .h, nothing in the .cpp... does not smell good.

if you want to fix the warning, you just need to remove the int in front of

  int   MLX90640_I2CRead(_deviceAddress, writeAddress, 1, &dataCheck); // GERT RID OF int AT THE START

and just declare your function so that you can use it before it's actual definition by addingint MLX90640_I2CRead(uint8_t _deviceAddress, unsigned int startAddress, unsigned int nWordsRead, uint16_t *data);just after #define I2C_BUFFER_LENGTH 1024 in the .h file

You can also get rid of static byte mlx90640To[10];in the .ino file as it's not used...

proceed with caution.. I would not trust that code... does not feel "clean"

You need to understand the difference between warnings and errors. A warning is the compiler telling you there is something in the code that could possibly cause a problem but doesn't cause the compilation to fail. An error is a problem with the code that causes compilation to fail. In this case you have posted warnings, not errors.

It's very important to use the correct terminology in order to have effective communication with the people you're asking for help.