02. I2C Address

2022. 8. 28. 01:09
Lidar ์„ผ์„œ๋Š” Address ๊ฐ’(0x62)์„ default๋กœ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋ฏ€๋กœ ์ด๋ฅผ ๋ณ€๊ฒฝํ•ด์ฃผ์–ด์•ผ ์—ฌ๋Ÿฌ๊ฐœ๋ฅผ ์‚ฌ์šฉํ–ˆ์„ ๋•Œ ๊ตฌ๋ณ„ ๊ฐ€๋Šฅ

 

๐Ÿ“ LIDAR_Lite_v3 datasheet
1. Read the two byte serial number from 0x96 (High: 0x16 Low: 0x17)
2. Write the serial number high byte to 0x18
3. Write the serial number low byte to 0x19
4. Write the desired new I2C address to 0x1a
5. Write 0x08 to 0x1e to disable the default address

 

โœ”๏ธBegin ์ˆ˜์ •

LIDARLite.cpp (๐Ÿ”Ž line 51)

void LIDARLite::begin(int configuration, bool fasti2c, char lidarliteAddress)

LIDARLite.ino

lidarLite.begin(0, true, 0x62);

 

โœ”๏ธConfigure ์ˆ˜์ •

LIDARLite.cpp (๐Ÿ”Ž line 86)

void LIDARLite::configure(int configuration, char lidarliteAddress)

LIDARLite.ino

lidarLite.configure(0, 0x62);

 

โœ”๏ธsetI2Caddr ์ถ”๊ฐ€

LIDARLite.cpp (๐Ÿ”Ž line 141)

void LIDARLite::setI2Caddr(char newAddress, char disableDefault, char lidarliteAddress)

LIDARLite.ino โ‡จ 0x64๋กœ ๋ณ€๊ฒฝํ•˜๊ณ ์ž ํ•จ

lidarLite.setI2Caddr(0x64, 0x08, 0x62);

 

โœ”๏ธdistance ๋ณ€๊ฒฝ

LIDARLite.cpp (๐Ÿ”Ž line 207)

int LIDARLite::distance(bool biasCorrection, char lidarliteAddress)

LIDARLite.ino โ‡จ 0x64๋กœ ๋ณ€๊ฒฝํ•˜๊ณ ์ž ํ•จ

dist = lidarLite.distance(true, 0x64);

 

โœ”๏ธI2C Address ๋ณ€๊ฒฝํ•˜๋Š” Arduino Code

#include <Wire.h>
#include <LIDARLite.h>

LIDARLite lidarLite;
int cal_cnt = 0;

void setup()
{
  Serial.begin(9600); 

  lidarLite.begin(0, true, 0x62); 
  lidarLite.configure(0, 0x62); 
  lidarLite.setI2Caddr(0x64, 0x08, 0x62);
}

void loop()
{
  int dist;

  if ( cal_cnt == 0 ) {
    dist = lidarLite.distance(true, 0x64);
  } 
  else {
    dist = lidarLite.distance(false, 0x64);
  }

  cal_cnt++;
  cal_cnt = cal_cnt % 100;

  Serial.print(dist);
  Serial.println(" cm");

  delay(10);
}

 

โœ”๏ธI2C Address ๋ณ€๊ฒฝ ํ™•์ธ Arduino Code

#include <Wire.h>
#include <LIDARLite.h>

LIDARLite lidarLite, lidarLite2;
int cal_cnt = 0;
unsigned char read_value[2]; 

void setup()
{
  Serial.begin(9600); 
  
  lidarLite.begin(0, true, 0x62); 
  lidarLite.configure(0, 0x62);
  lidarLite.setI2Caddr(0x64, 0x08, 0x62);
  lidarLite.read((0x1a | 0x80), 1, read_value, false, 0x64);
}

void loop()
{
  int dist;

  if ( cal_cnt == 0 ) {
    dist = lidarLite.distance(true, 0x64); 
  } 
  else {
    dist = lidarLite.distance(false, 0x64); 
  }

  cal_cnt++;
  cal_cnt = cal_cnt % 100;

  Serial.print(dist);
  Serial.println(" cm");
  Serial.print(read_value[0]);

  delay(10);
}

โ–ฒread ๊ฐ’์„ ๋„ฃ์–ด์ฃผ์–ด Serial Monitor์— 0x64๊ฐ’์ธ 100์„ ์ถœ๋ ฅ

 

โœ”๏ธ๋‹จ์ 

์ „์›์„ ๊ป๋‹ค ์ผœ๋ฉด reset ๋จ
โ‡จ ๋งค๋ฒˆ ์ฝ”๋“œ๋ฅผ ์—…๋กœ๋“œ ์‹œ์ผœ์ฃผ์–ด์•ผ ํ•จ

'๐Ÿ’ญ Project > ๐Ÿ“ Lidar-Lite V3' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

04. Power Enable  (0) 2022.08.28
03. Time Stamp  (0) 2022.08.28
01. Survey  (0) 2022.08.28

BELATED ARTICLES

more