<?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[unable to read from DS18B20 sensors]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I want to read temperature from two DS18B20 sensors hooked up to my Core2. The following code does not work on the Core2 but works on NodeMCU after removing the two lines specific for the M5 core2 and changing the data pin from 19 to 2.</p>
<pre><code>/*
 * minimal sketch to communicate with DS18B20 sensors on a M5Stack Core2
*/
#include &lt;M5Core2.h&gt;
#include &lt;OneWire.h&gt;
#include &lt;DallasTemperature.h&gt; 

#define ONE_WIRE_BUS 19
OneWire oneWire(ONE_WIRE_BUS); 
DallasTemperature DS18B20_sensors(&amp;oneWire); 
int no_sensors = 99;

void setup(){
  M5.begin();
  // locate DS18B20 sensors
  DS18B20_sensors.begin();
  no_sensors = DS18B20_sensors.getDeviceCount();
  Serial.println("Number of connected sensors: " + String(no_sensors));
  delay(5000);  
}

void loop() {
}
</code></pre>
<p dir="auto">I have connected the DS18B20 "DQ-pin" to the pin marked as GPIO19 on the bottom of the Core2. Wiring is identical between NodeMCU and Core2 except for the different GPIO pin.</p>
<p dir="auto">Serial output is</p>
<pre><code>20:07:00.206 -&gt; axp: gpio1 init
20:07:00.206 -&gt; axp: gpio2 init
20:07:00.206 -&gt; axp: rtc battery charging enabled
20:07:00.206 -&gt; axp: esp32 power voltage was set to 3.35v
20:07:00.206 -&gt; axp: lcd backlight voltage was set to 2.80v
20:07:00.206 -&gt; axp: lcd logic and sdcard voltage preset to 3.3v
20:07:00.206 -&gt; axp: vibrator voltage preset to 2v
20:07:00.704 -&gt; E (1458) ledc: ledc_channel_config(369): gpio_num argument is invalid
20:07:00.704 -&gt; touch: FT6336 ready (fw id 0x10 rel 1, lib 0x300E)
20:07:01.300 -&gt; OK
20:07:01.333 -&gt; Number of connected sensors: 0

</code></pre>
<p dir="auto">It shows "Number of connected sensors: 0" even though I have connected 2 on the same pins.</p>
<p dir="auto">What am I doing wrong?</p>
]]></description><link>https://community.m5stack.com/topic/4159/unable-to-read-from-ds18b20-sensors</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Apr 2026 15:16:28 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/4159.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 28 Mar 2022 18:49:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to unable to read from DS18B20 sensors on Thu, 31 Mar 2022 17:23:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/felmue" aria-label="Profile: felmue">@<bdi>felmue</bdi></a> This was it: works with work(around)!<br />
Thanks so much.<br />
Steve.</p>
]]></description><link>https://community.m5stack.com/post/17066</link><guid isPermaLink="true">https://community.m5stack.com/post/17066</guid><dc:creator><![CDATA[2ndsteve]]></dc:creator><pubDate>Thu, 31 Mar 2022 17:23:43 GMT</pubDate></item><item><title><![CDATA[Reply to unable to read from DS18B20 sensors on Tue, 29 Mar 2022 05:15:02 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/2ndsteve" aria-label="Profile: 2ndsteve">@<bdi>2ndsteve</bdi></a></p>
<p dir="auto">I don't think you're doing anything wrong. On ESP32 there seems to be an issue with the function to count devices. See <a href="https://github.com/PaulStoffregen/OneWire/issues/57" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>.</p>
<p dir="auto">A simple solution seems to be calling <code>sensors.begin()</code> twice.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/17042</link><guid isPermaLink="true">https://community.m5stack.com/post/17042</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Tue, 29 Mar 2022 05:15:02 GMT</pubDate></item></channel></rss>