如何将两个I2C传感器连接到Heltec Wifi Kit (V3) ESP32开发板?

huangapple go评论125阅读模式
英文:

How to connect two I2C sensors to the Heltec Wifi Kit (V3) ESP32 board?

问题

I recently bought an ESP32 for my project, which is the Heltec WiFi Kit V3 with the built-in OLED. I can't understand the pinout diagram:

image here

Now, to what pin does the SCL and SDA correspond? And how can I connect two SCL and SDA sensors and configure the built-in OLED at the same time?

Edit: Thank you all for your answers. Actually, I noticed that, following this tutorial, I applied the Espressif drivers and its code on my Heltec. Actually, it worked, but when I tried to declare the pins for the OLED, it doesn't work anymore. According to what @jluu wrote, I would like to change my code by setting the Heltec driver. So, to summarize, if I connect two sensors with different channels on pins 41 and 42 in series, it should work correctly without declaring a personal TwoWire for different pins?

英文:

I recently buied an ESP32 for my project, which is the Heltec WiFi kit V3 with the builtin OLED.
I can't understand the pinout diagram:

image here

Now, to what pin does the SCL and SDA corresponds? and how can I connect two SCL and SDA sensors and configuring the builtin OLED at the same time?

Edit: Thank you all for your answer. Actually, I noticed that, following this tutorial, I applied the espressif drivers and its code on my heltec. Actually, it worked but when I tried to declare the pins for the oled it doesn't work anymore. According to what @jluu wrote, I would like to change my code by setting the Heltec driver. So, to resume, if I connect two sensors with different channels on pins 41 and 42 in series, it should work correctly without declaring a personal TwoWire for different pins?

答案1

得分: 2

芯片上有2个I2C总线,但用于OLED的总线未连接到引脚,您必须使用第二个I2C总线,对于此总线和V3板,I2C引脚分别为GPIO41(SDA)和GPIO42(SCL)。

您必须获取Heltec提供的最新板支持包。
文件 -> 首选项 -> 附加的板管理器网址 ->
https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/releases/download/0.0.7/package_heltec_esp32_index.json

然后选择Heltec_wifi_Lora_32_V3板,因为他们尚未更正wifikit_V3的SCA和SCL的宏定义。

有关Heltec的完整文档,请参考以下链接:
https://docs.heltec.org/en/dev_kits/esp32_arduino/quick_start.html#via-arduino-board-manager

英文:

There are 2 I2C buses on the chip, however the bus used for the Oled is not connected to the pins, you have to use the second I2C bus, for this bus and for the V3 board, the I2C pins are GPIO41 (SDA) and GPIO42 (SCL)

You have to take the lastest release of the boards by heltec
File -> preferences -> Additional board manager Url ->
https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/releases/download/0.0.7/package_heltec_esp32_index.json

Then select the Heltec_wifi_Lora_32_V3 board as they have not yet corrected the macro definitions for SCA and SCL for the wifikit_V3

Full documentation on the Heltec site:
https://docs.heltec.org/en/dev_kits/esp32_arduino/quick_start.html#via-arduino-board-manager

答案2

得分: 0

多个I2C设备可以简单地并联连接。
查看:https://en.wikipedia.org/wiki/I²C 以获取图表。

但要注意:
每个I2C设备都有一个地址,必须确保总线上没有两个具有相同地址的设备。

请查阅设备的数据表以获取地址信息。

英文:

Multiple i2c devices are simply connected in parallel.
See: https://en.wikipedia.org/wiki/I²C for a diagram.

This comes with a but:
every I2C device has an address and you must not have two devices with the same address on the bus.

Check the device data sheet for the address.

答案3

得分: 0

请查看这个Heltec示例,展示了如何使用两个I2C总线来扫描从机设备: https://github.com/HelTecAutomation/Heltec_ESP32/blob/master/examples/ESP32/I2C_Scanner/I2C_Scanner.ino

我认为我的ESP32套件是较新版本,因为它具有用于OLED I2C的外部引脚,但为了使其正常工作,需要将OLED复位设置为输出并拉低50毫秒,然后拉高。

  	pinMode(RST_OLED, OUTPUT);
  	digitalWrite(RST_OLED, LOW);
  	delay(50);
  	digitalWrite(RST_OLED, HIGH);
	Wire.begin(SDA_OLED, SCL_OLED); //通过I2C0扫描OLED的I2C地址
英文:

Have a look at this Heltec sketch which shows how to use both I2C busses to scan for slaves: https://github.com/HelTecAutomation/Heltec_ESP32/blob/master/examples/ESP32/I2C_Scanner/I2C_Scanner.ino

I think my ESP32 kit is a later version as it has external pins for the OLED I2C, however to get it to work it is necessary to set the OLED reset as an output and take low for 50ms then back high.

  	pinMode(RST_OLED, OUTPUT);
  	digitalWrite(RST_OLED, LOW);
  	delay(50);
  	digitalWrite(RST_OLED, HIGH);
	Wire.begin(SDA_OLED, SCL_OLED); //Scan OLED's I2C address via I2C0

A

huangapple
  • 本文由 发表于 2023年3月3日 19:43:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75626663.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定