Error compiling for board Arduino Due (successfully compiled for UNO and MEGA)

Dear all,

I cannot compile a working code for Due. The code is working fine for UNO and MEGA.

Could you please help this out? Thank you for your help.

Here is the error message. Due to the maximum allowed length is exceed, I’ve attached the message as a text.

The official LiDAR Lite library can been found here.

Here is my working code (also see attachment) for UNO.

#include <Wire.h>
#include <I2C.h>
#include <LIDARLite.h>
#define    LIDARLite_ADDRESS     0x62          // Default I2C Address of LIDAR-Lite.
#define    RegisterMeasure       0x00          // Register to write to initiate ranging.
#define    MeasureValue          0x04          // Value to initiate ranging.
#define    RegisterHighLowB      0x8f          // Register to get both High and Low bytes in 1 call.
#define    TCAADDR               0x70
LIDARLite myLidarLite;


void tcaselect(uint8_t i) {
  if (i > 7) return;
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission();
  myLidarLite.begin(1, true); // Set configuration to default and I2C to 400 kHz choice 1 or 4
  myLidarLite.configure(4);  
}



void setup(){
  Serial.begin(115200);       
  I2c.begin(); // Opens & joins the irc bus as master
  tcaselect(0);
  tcaselect(1);
  tcaselect(2);
  tcaselect(3);      
//  tcaselect(4);      
//  tcaselect(5);      
//  tcaselect(6);      
//  tcaselect(7);      
  myLidarLite.configure(4); // Change this number to try out alternate configurations

}

void loop(){
  tcaselect(0);
  Serial.print(myLidarLite.distance()); // Read Distance from Sensor at Channel 0
  Serial.print(",");
  tcaselect(1);
  Serial.print(myLidarLite.distance()); // Read Distance from Sensor at Channel 0
  Serial.print(","); 
  tcaselect(2);
  Serial.print(myLidarLite.distance()); // Read Distance from Sensor at Channel 0  
  Serial.print(",");
  tcaselect(3);
  Serial.print(myLidarLite.distance()); // Read Distance from Sensor at Channel 0  
  Serial.println(",");
//  tcaselect(4);
//  Serial.print(myLidarLite.distance()); // Read Distance from Sensor at Channel 0  
//  Serial.print(",");
//  tcaselect(5);
//  Serial.print(myLidarLite.distance()); // Read Distance from Sensor at Channel 0  
//  Serial.print(",");
//  tcaselect(6);
//  Serial.print(myLidarLite.distance()); // Read Distance from Sensor at Channel 0  
//  Serial.print(",");  
//  tcaselect(7);
//  Serial.print(myLidarLite.distance()); // Read Distance from Sensor at Channel 0  
//  Serial.println("");  
}

ErrorMessage.txt (33.5 KB)

LIDARLite_MultiSensor_w_PCA9544A_Multiplexer.ino (2.05 KB)

(deleted)

Would you mind if you could let me know what I should improve my content or subject line?

Please post the complete error message that you get.

I tried to post the error message. The forum doesn't allow a >9000 characters in the code mode.

I've upload the message as a text file here.

(deleted)

I should read through it more carefully. Sorry. I've attached files in the forum. Thank you.

It seems that there is an issue with LIDARLite.h ('TWCR' was not declared in this scope... of course there is no TWCR register on a DUE), but when I look at this Library (LIDARLite.h V3), it has been adapted for DUE it can be compiled for DUE.

Maybe you have an old version of LIDARLite.h, try to upload the V3 version.

I was using the version 3 library to compile the code. You just give me an idea – I comment out the following two line in my code and it can not compiled for Due. However, I need to use I2C library, because multiple sensors are connected and communicate with Due via the I2C method.

#include <I2C.h>
I2c.begin();

Any thoughts?

I2C on DUE (SDA/SCL or SDA1/SCL1) is usable thru the Wire.h Library which is already included in your sketch.

I looked at I2C.h Library and, yes, is not adapted for DUE but exclusively for an AVR.