<?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[Using G19, G21, G22, G23, G25 or G33 as I2C pin on Atom Lite]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I'm trying to attach a DS18B20 (<a href="https://www.amazon.ca/DS18B20-Waterproof-Temperature-Digital-118-1inch/dp/B07782SXCZ" target="_blank" rel="noopener noreferrer nofollow ugc">5 pcs, 3 meter</a>), temperature sensors working with <code>oneWire</code>.  I can't seem to get any reading on an Atom Matrix.</p>
<p dir="auto">Here's a short version of my code.</p>
<pre><code class="language-C++">#include &lt;Arduino.h&gt;
#include &lt;OneWire.h&gt;
#include &lt;DallasTemperature.h&gt;

// GPIO where the DS18B20 is connected to
const uint8_t oneWireBus = ONEWIREBUS;

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(oneWireBus);

// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&amp;oneWire);

float DS18B20_temperature = -100.0;

void setup() {
  sensors.begin();
}

void loop() {
  sensors.requestTemperatures();
  const float temperature = sensors.getTempCByIndex(0);
  Serial.println(temperature);
  const unsigned int num_DS18B20 = sensors.getDeviceCount();
  Serial.printf("Number of DS18B20: %d\n", num_DS18B20);
  for (unsigned int i=0; i&lt;num_DS18B20; ++i) {
    DeviceAddress mac;
    sensors.getAddress(mac, i);
    const float temperature = sensors.getTempCByIndex(i);
    Serial.println(temperature);
  }
}
</code></pre>
<p dir="auto">I have tested my breadboard setup and the code with a NodeMCU and using a NodeMCU I can get the temperatures.  When using my NodeMCU, I make sure to use the default SDA pin for it to work.</p>
<p dir="auto">I googled around and I can find multiple posts that claim that we can use almost any pin as SDA so I wonder how I can change GPIO25 to be SDA on an Atom Lite?</p>
<p dir="auto">In this post, <a href="https://forum.m5stack.com/topic/1820/ext-io-unit-and-uiflow-1-4-5-1" target="_blank" rel="noopener noreferrer nofollow ugc">EXT.IO Unit and UIFlow 1.4.5.1</a>, there is comment hinting that 3 meter long wires could be too long and that 100cm is the longest at most.</p>
]]></description><link>https://community.m5stack.com/topic/2406/using-g19-g21-g22-g23-g25-or-g33-as-i2c-pin-on-atom-lite</link><generator>RSS for Node</generator><lastBuildDate>Thu, 12 Mar 2026 23:36:53 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/2406.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 24 Oct 2020 15:49:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Using G19, G21, G22, G23, G25 or G33 as I2C pin on Atom Lite on Wed, 28 Oct 2020 01:13:55 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for all the great responses.</p>
<p dir="auto">I actually figure it out.  I knew that my sensors were working because I could get the same code to work when using a ESP8266.  I'm currently using GPIO25 for my 5 DS18B20 temperature sensors and I'm also using a 4.7 Ohm resistor as suggested by Dallas.  At first, I could not see any sensor.  After some thinkering, I was able to get the mac addresses of all 5 sensors with the Atom Lite but the temperature was ALWAYS 85.  Googling for 85, someone said that we have to wait <code>750 ms</code> after calling <code>sensors.requestTemperatures();</code></p>
<pre><code class="language-c++">  sensors.requestTemperatures();
  delay(750);  // This seems critical to get the sensors to work with AtomLite
</code></pre>
<p dir="auto">Then I can proceed to get the temperatures like so.  Note that this only illustrates the spirit of what needs to be done and I haven't tested the exact code that follows.</p>
<pre><code class="language-c++">#include &lt;M5Atom.h&gt;
#include &lt;OneWire.h&gt;
#include &lt;DallasTemperature.h&gt;

// GPIO where the DS18B20 is connected to
const uint8_t oneWireBus = GPIO_NUM_25;

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(oneWireBus);

// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&amp;oneWire);

void setup() {
  M5.begin(true, false, true);  // But I need to test without this line.
  sensors.begin();
}


void loop() {
  sensors.requestTemperatures();
  delay(750);  // This seems critical to get the sensors to work with AtomLite

  const unsigned int num_DS18B20 = sensors.getDeviceCount();

  for (unsigned int i=0; i&lt;num_DS18B20; ++i) {
    DeviceAddress mac;
    sensors.getAddress(mac, i);
    delay(10);
    const float temperature = sensors.getTempCByIndex(i);
    send_MQTT(mac, temperature);
    }
  }
  delay(10000);
}
</code></pre>
<p dir="auto">I hope that this information will be useful for someone else trying to hookup some DS18B20 to an Atom Lite.</p>
]]></description><link>https://community.m5stack.com/post/10497</link><guid isPermaLink="true">https://community.m5stack.com/post/10497</guid><dc:creator><![CDATA[Balta]]></dc:creator><pubDate>Wed, 28 Oct 2020 01:13:55 GMT</pubDate></item><item><title><![CDATA[Reply to Using G19, G21, G22, G23, G25 or G33 as I2C pin on Atom Lite on Tue, 27 Oct 2020 11:14:24 GMT]]></title><description><![CDATA[<p dir="auto">before you start the I2C communication.  you could scan the I2C bus,  check does the device address exist.</p>
<p dir="auto">and also you could try use other pins. like 21, 22.</p>
<p dir="auto">make sure the sensor sda and scl has pull up resistor. (because atom pins don't have pullup resistor)</p>
]]></description><link>https://community.m5stack.com/post/10471</link><guid isPermaLink="true">https://community.m5stack.com/post/10471</guid><dc:creator><![CDATA[m5stack]]></dc:creator><pubDate>Tue, 27 Oct 2020 11:14:24 GMT</pubDate></item><item><title><![CDATA[Reply to Using G19, G21, G22, G23, G25 or G33 as I2C pin on Atom Lite on Tue, 27 Oct 2020 07:15:49 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/4809">@Balta</a></p>
<p dir="auto">you are absolutely correct - as long as you don't call <code>Wire.begin(25,21,10000)</code> GPIO25 or GPIO21 should be available for OneWire.</p>
<p dir="auto">Unfortunately I only have one DS18B20 so I cannot fully recreate your setup. Did you try your M5Atom Lite setup with only one sensor?</p>
<p dir="auto">Good luck!<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/10469</link><guid isPermaLink="true">https://community.m5stack.com/post/10469</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Tue, 27 Oct 2020 07:15:49 GMT</pubDate></item><item><title><![CDATA[Reply to Using G19, G21, G22, G23, G25 or G33 as I2C pin on Atom Lite on Tue, 27 Oct 2020 04:51:01 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/4809">@Balta</a>,</p>
<p dir="auto">If you don't need the I2C bus at all, you can disable it like this:</p>
<pre><code class="language-cpp">Wire.~TwoWire();
</code></pre>
<p dir="auto">Try it to see if it solves your problem.</p>
]]></description><link>https://community.m5stack.com/post/10483</link><guid isPermaLink="true">https://community.m5stack.com/post/10483</guid><dc:creator><![CDATA[m1cr0lab]]></dc:creator><pubDate>Tue, 27 Oct 2020 04:51:01 GMT</pubDate></item><item><title><![CDATA[Reply to Using G19, G21, G22, G23, G25 or G33 as I2C pin on Atom Lite on Mon, 26 Oct 2020 21:23:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/4037">@felmue</a> Thanks for your help.<br />
I've tried your suggestion of adding</p>
<pre><code>#include &lt;M5Atom.h&gt;
...
M5.begin(true, false, true);
</code></pre>
<p dir="auto">And I was getting <code>85</code> which, according to a google search, means there is an error but I can see the mac addresses of all my 5 probes.  What bothers me is that looking at the code of <code>M5.begin(true, false, true);</code> and according to your previous comment, I skip the I2C initialization which I was already doing before adding that line since I wasn't calling <code>Wire.begin(25,21,10000);</code>.  I really don't see what would help my I2C problem.  By adding <code>M5.begin(true, false, true);</code>, the only thing I add is initializing the display which I don't have on my atom lite.</p>
<p dir="auto">I've tried essentially the same code with my nodemcu, the same DS18B20 sensors and I can read the mac addresses and all 5 temperature no problem.</p>
<p dir="auto">I also have a Feather Huzzah esp8266 and a Feather Huzzah 32 esp32 that I will try out later.</p>
<p dir="auto">Could it be that the atom lite is not providing enough mA to the sensors?</p>
]]></description><link>https://community.m5stack.com/post/10466</link><guid isPermaLink="true">https://community.m5stack.com/post/10466</guid><dc:creator><![CDATA[Balta]]></dc:creator><pubDate>Mon, 26 Oct 2020 21:23:11 GMT</pubDate></item><item><title><![CDATA[Reply to Using G19, G21, G22, G23, G25 or G33 as I2C pin on Atom Lite on Sun, 25 Oct 2020 14:04:13 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/4809">@Balta</a></p>
<p dir="auto">I think you missed enabling Serial on your M5Atom. Try including:</p>
<pre><code>#include &lt;M5Atom.h&gt;
</code></pre>
<p dir="auto">then in <code>setup()</code> enable Serial and disable I2C to have GPIO25 and GPIO21 freed up for use with OneWire:</p>
<pre><code>// Enable Serial, disable I2C, enable Display
M5.begin(true, false, true);
</code></pre>
<p dir="auto">and I would add some delay in your <code>loop()</code>:</p>
<pre><code>delay(1000);
</code></pre>
<p dir="auto">BTW: In my M5Atom setup I've verified all available GPIOs (19, 22, 23, 33, 21 and 25) successfully to work with OneWire.</p>
<p dir="auto">Good luck<br />
Felix</p>
<p dir="auto">For reference - full code using GPIO25:</p>
<pre><code>#include &lt;M5Atom.h&gt;
#include &lt;OneWire.h&gt;
#include &lt;DallasTemperature.h&gt;

// GPIO where the DS18B20 is connected to
const uint8_t oneWireBus = GPIO_NUM_25;

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(oneWireBus);

// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&amp;oneWire);

float DS18B20_temperature = -100.0;

void setup() {
  // Enable Serial, disable I2C, enable Display
  M5.begin(true, false, true);
  sensors.begin();
}

void loop() {
  sensors.requestTemperatures();
  const float temperature = sensors.getTempCByIndex(0);
  Serial.println(temperature);
  delay(1000);
}
</code></pre>
]]></description><link>https://community.m5stack.com/post/10454</link><guid isPermaLink="true">https://community.m5stack.com/post/10454</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Sun, 25 Oct 2020 14:04:13 GMT</pubDate></item></channel></rss>