<?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[About sensors and GPIO]]></title><description><![CDATA[<p dir="auto">Hello.<br />
I want to connect the sensors DHT22 and DS18B20 and the capacitive soil moisture sensor to Core 2 for operation.<br />
Below is the sketch.　However, when I wrote the sketch with the pin stuck,  fatal error occurred.And after that, I couldn't write.</p>
<p dir="auto">Core 2 has been lucky enough to come back, but it's scary.Therefore, I would like to know the GPIO that should point to the sensor. Please let me know.<br />
Thank you.</p>
<pre><code>//#include &lt;M5Stack.h&gt;
#include &lt;M5Core2.h&gt;

#include "DHT.h"  
//#define DHTPIN 13  // Basic.DHT22.
#define DHTPIN 27  // Core2.DHT22 .19.27
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

#include &lt;OneWire.h&gt;  //DS18B20
#include &lt;DallasTemperature.h&gt;  //DS18B20
//#define ONE_WIRE_BUS 0 // Basic.DS18B20. 
#define ONE_WIRE_BUS 26 // Core2.DS18B20.25.26.27
OneWire oneWire(ONE_WIRE_BUS); //　OneWire
DallasTemperature sensors(&amp;oneWire);//  Dallas Temperature sensor

#define PinSoilMoist 35  //CapSoilMoistSensor
  const int dry = 3700;   
  const int wet = 1400; 

int inttemp , inthumid ;  
int intsoilmoist , soilval , intsoiltemp;  
float temperature, humidity, soilMoist, soilTemp;  

void getData() {
delay(2000);
dht.begin();
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
if (isnan(temperature) || isnan(humidity) ) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
}
  inttemp = int ( temperature ); 
  inthumid = int ( humidity );
  Serial.print( inttemp ); Serial.println(" *C, ");  
  Serial.print( inthumid ); Serial.println(" RH% ");

  soilMoist = analogRead(PinSoilMoist);  
  soilval = map(soilMoist, dry, wet, 0, 100); 
  if(soilval &gt;= 99)
{
  intsoilmoist = 99;
}
else if(soilval &lt;=20)
{
  intsoilmoist = 20;
}
else if(soilval &gt;21 &amp;&amp; intsoilmoist &lt; 99)
{
  intsoilmoist = soilval ;  
}
//  Serial.print( soilMoist ); Serial.println(" Pin ");  
  Serial.print( intsoilmoist ); Serial.println(" soil% ");  
  delay(250);

  sensors.requestTemperatures();  
  float soilTemp = sensors.getTempCByIndex(0);
  intsoiltemp = int ( soilTemp );  
  Serial.print( intsoiltemp ); Serial.println(" soil*C, ");  
}

void sendSigfox() {
  String msg = String (inttemp, HEX)    
               + String (inthumid, HEX)
               + String (intsoilmoist, HEX)
               + String (intsoiltemp, HEX);

   Serial2.println("AT$SF=" + msg);
  Serial.println("AT$SF=" + msg);
}

void setup() {
  M5.begin(true, false, true);  
//  M5.Speaker.write(0); 
//  M5.Axp.SetSpkEnable(0);  

//  Serial2.begin(9600, SERIAL_8N1, 16, 17);  
  Serial2.begin(9600, SERIAL_8N1, 13, 14);  
//  Serial.begin(9600);  
}

void loop() {
  getData();
  sendSigfox();  

//  M5.Power.deepSleep(SLEEP_SEC(60*15)); 
  M5.Axp.DeepSleep(SLEEP_SEC(60*0.5)); 
}
</code></pre>
]]></description><link>https://community.m5stack.com/topic/2840/about-sensors-and-gpio</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 01:47:29 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/2840.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 27 Jan 2021 07:20:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to About sensors and GPIO on Sat, 30 Jan 2021 11:23:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zontex" aria-label="Profile: zontex">@<bdi>zontex</bdi></a> Thank you.<br />
DHT, DS18B20 and Soil Moisture Sensor are not M5 products. Use Arduino.<br />
Thank you.</p>
]]></description><link>https://community.m5stack.com/post/12186</link><guid isPermaLink="true">https://community.m5stack.com/post/12186</guid><dc:creator><![CDATA[takero]]></dc:creator><pubDate>Sat, 30 Jan 2021 11:23:39 GMT</pubDate></item><item><title><![CDATA[Reply to About sensors and GPIO on Thu, 28 Jan 2021 15:02:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/takero" aria-label="Profile: takero">@<bdi>takero</bdi></a> hello, is the DHT, DS18B20 and soil moisture sensor are M5 products? have you tried to use UIFlow for this or you'd prefer Arduino instead?</p>
]]></description><link>https://community.m5stack.com/post/12101</link><guid isPermaLink="true">https://community.m5stack.com/post/12101</guid><dc:creator><![CDATA[Zontex]]></dc:creator><pubDate>Thu, 28 Jan 2021 15:02:43 GMT</pubDate></item></channel></rss>