<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Tab5 I2C on Arduino works, same code does not work on PlatformIO]]></title><description><![CDATA[<p dir="auto">Tab5 uses internally I2C for example for RTC and Battery-status. I can add I2C devices on the I2C port in this way:<br />
setup():</p>
<pre><code>  // Start I2C
  if (!M5.Ex_I2C.begin(I2C_NUM_0, 31, 32)) {
		Serial.println("Ex_I2C initialization failed!");
  } else {
    exI2CInitialized = true;
    Serial.println("Ex_I2C ok! ");
  }

</code></pre>
<p dir="auto">In the modified I2C sensor code:</p>
<pre><code>uint8_t TON_BME280::read8(byte reg) {
	return M5.Ex_I2C.readRegister8(BME280_ADDRESS, reg, 400000U);
}
</code></pre>
<p dir="auto">This works on Arduino, RTC (internal) and BME280 (external) are available.</p>
<p dir="auto">However, on PlatformIO same code, it does not work. The first call to battery status returns zeroes and subsequent I2C calls hang the system.</p>
<p dir="auto">Why use PlatformIO then? It compiles quicker, more control over libraries possible (lvgl 8 or 9 etc)</p>
<p dir="auto">Why use the same pins as internal for external I2C instead of two fresh ones?<br />
Modules like relays or stepper controllers all use the 31 and 32 pins for I2C</p>
<p dir="auto">platformio.ini:</p>
<pre><code>[env:m5stack-tab5-p4]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
board = m5stack-tab5-p4
framework = arduino

upload_port = COM12
monitor_port = COM12
upload_speed = 1500000
monitor_speed = 115200
build_type = debug
board_build.partitions = partitions.csv

lib_deps =
  lvgl/lvgl@^8.3.11
  paulstoffregen/OneWire@^2.3.8
  milesburton/DallasTemperature@^4.0.5
</code></pre>
]]></description><link>https://community.m5stack.com/topic/7997/tab5-i2c-on-arduino-works-same-code-does-not-work-on-platformio</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 23:07:00 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/7997.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 05 Jan 2026 12:02:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Tab5 I2C on Arduino works, same code does not work on PlatformIO on Fri, 20 Feb 2026 10:04:39 GMT]]></title><description><![CDATA[<p dir="auto">Update on this one:<br />
Changing to other pins for external I2C makes it work for both Arduino and PlatformIO.<br />
So with arduino you can lay external I2C over the internal I2C, but in PlatformIO that does not work. Anybody an idea why not?</p>
]]></description><link>https://community.m5stack.com/post/30661</link><guid isPermaLink="true">https://community.m5stack.com/post/30661</guid><dc:creator><![CDATA[tonaug58]]></dc:creator><pubDate>Fri, 20 Feb 2026 10:04:39 GMT</pubDate></item></channel></rss>