Arduino 寻找I2C地址address

参考:http://henrysbench.capnfatz.com/henrys-bench/arduino-projects-tips-and-more/arduino-quick-tip-find-your-i2c-address/

Arduino Quick Tip:  Find Your I2C Address

Contents [show]

Don’t Get Hung Up When You Want to Play

You’ve just received your new module and you want to test it.  You go back the seller’s web page and find instructions that are only slightly clearer than mud.  In fact, one of things you discover as you attempt to unravel the odd form of English that is used is that you can’t seem to figure out what the I2C address is.

You can certainly find the data sheet for the device that the module is built around. With a little work, you should also be able to  identify the address pins.  Then, with a little probing,  you can identify the address.

In fact, at some point in your project development, it may even become necessary.   Alas,  sometimes you only have a few minutes to play and you just want to see the freaking thing work.

If that describes you, then try running the following sketch.  It will scan I2C possible addresses and report the address of the device that responds.

address of the device that responds.

I2C Scanner By Nick Gammon

Copy, Paste, Upload and Run!

// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

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

  // Leonardo: wait for serial port to connect
  while (!Serial)
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

I2C Scanner Results

Run the sketch and you will see a result that looks something like this:

原文地址:https://www.cnblogs.com/MCSFX/p/11774266.html

时间: 2024-10-20 07:56:00

Arduino 寻找I2C地址address的相关文章

通过PEB寻找函数地址

??通过PEB的Ldr参数(结构体定义为_PEB_LDR_DATA),遍历当前进程加载的模块信息链表,找到目标模块. ??摘自PEB LDR DATA: typedef struct _PEB_LDR_DATA { 0x00 ULONG Length; /* Size of structure, used by ntdll.dll as structure version ID */ 0x04 BOOLEAN Initialized; /* If set, loader data section

空格&lt;&amp;nbsp;&gt;、水平横线&lt;hr/&gt;、地址&lt;address&gt;和&lt;code&gt;标签

空格:   水平横线: </hr> 地址: 一般网页中会有一些网站的联系地址信息需要在网页中展示出来,这些联系地址信息如公司的地址就可以<address>标签.也可以定义一个地址(比如电子邮件地址).签名或者文档的作者身份. <address>标签间的字体默认为斜体: 例如: <address>本文的作者:<a href="mailto:[email protected]">lilian</a> <code&

第2章地址Address(WCF全面解析3)

WCF顾明思义,就是在Windows平台下解决通信(C,Communication)的基础框架(F,Foundation)问题. 终结点是WCF最为核心的对象,因为它承载了所有通信功能.服务通过相应的终结点发布出来,客户端通过与之匹配的终结点对服务进行调用.终结点由代表地址.绑定和契约的ABC三要素构成. 作为终结点的三要素之一的地址(Address).在基于WCF的通信中不仅仅用于定位服务,还提供额外的寻址信息.除此之外,终结点还和安全有关系,因为它包含着用于进行服务认证的服务身份信息. 目录

23.实现一个名为Person的类和它的子类Employee,Employee有两个子类Faculty 和Staff。 具体要求如下: (1)Person类中的属性有:姓名name(String类型),地址address(String类型), 电话号码telphone(String类型)和电子邮件地址email(String类型); (2)Employee类中的属性有:办公室office(Stri

package banking; public class Person { private String name; public String address; public String telphone; public String email; } package banking; public class Employee extends Person{ private String office; private double wage; private String hireda

Arduino I2C + AC24C32 EEPROM

主要特性 AC24C32是Atmel的两线制串行EEPROM芯片,根据工作电压的不同,有-2.7.-1.8两种类型.主要特性有: 工作范围:-2.7类型范围4.5~5.5V,-1.8类型1.8~5.5V.本文用的为-2.7类型. 待机功耗:与工作电压有关,见下图 容量:4096 x 8bits,即32k bits 接口:I2C,工作在5V时支持最大时钟频率400kHz,其他电压时100kHz 允许一次写一页(32-byte page write mode) 一次写动作完成的时间:与工作电压有关,

Arduino I2C + 数字式环境光传感器BH1750FVI

BH1750FVI是日本罗姆(ROHM)半导体生产的数字式环境光传感IC.其主要特性有: I2C数字接口,支持速率最大400KHz 输出量为光照度(Illuminance) 测量范围1~65535 lux,分辨率最小到 低功耗(Power down)功能 屏蔽50/60Hz市电频率引起的光照变化干扰 支持两个I2C地址,通过ADDR引脚选择 较小的测量误差(精度误差最大值+-20%) 电路连接 由于模块本身已经带有了3.3V稳压芯片和I2C电平转换电路,因此可将模块直接与UNO板的I2C接口相连

Arduino I2C + 三轴加速度计ADXL345

ADXL345是ADI公司生产的三轴数字加速度计芯片,与ST的LIS3DH功能接近.主要特性有: 工作电压:2.0 ~ 3.6V 功耗:待机功耗0.1μA:工作时与数据输出频率(ODR)有关,如ODR<10 Hz时30μA 接口:I2C:三线/四线制SPI 分辨率:可选择,最大13-bit 内置FIFO single tap/double tap检测 自由落体检测 两个可编程中断输出脚 封装:3 x 5 x 1 mm LGA 管脚定义 与Arduino的连接 用工作于3.3V/8MHz版本的Ar

Arduino调试温湿度传感器AM2321

AM2321是广州奥松电子生产的数字式温湿度传感器.虽是国产品牌,其精度也可以与国外的主流温湿度传感IC媲美. 尺寸:11.3x7.8x4mm(长x宽x高) 封装:0.05 pitch PTH 工作电压:2.6~5V 接口:I2C,最大速率100kbps,有特殊时序要求 分辨率:温度0.1°C,相对湿度0.1%RH 精度:室温时温度误差+/-0.3°C,相对湿度误差+/-3%RH 重复性:温度+/-0.2°C,相对湿度+/-0.1%RH 美中不足:与国外同精度产品相比,AM2321的重复性和漂移

Arduino 与指南针传感器HMC5883L

首先Arduino默认的I2C地址是7位地址,手册上说明有,7位地址为0X1E,读地址为0x3D = (7位地址<<1 +1),写地址为0X3C (7位地址 << 1) 如果要想与HMC5883L进行通信,则需要在HMC5883L上电5ms之后进行. 所以一般写入配置时需要先延时5ms再进行通信.   连入设备后对传感器进行测试.识别的操作与 识别寄存器A. 识别寄存器B.识别寄存器C有关,所以想知道传感器是否正常工作就读取他们的值验证一下,因为他们三个都是只读寄存器,科技静态测试