<?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[POECAM and PIR sensor]]></title><description><![CDATA[<p dir="auto">Apologies for what will probably be a very basic question.</p>
<p dir="auto">I have recently got my <a href="https://docs.m5stack.com/en/unit/M5PoECAM-W" target="_blank" rel="noopener noreferrer nofollow ugc">POECAM</a> working with Arduino IDE and an trying to read the sensor value from a [PIR sensor] (<a href="https://shop.m5stack.com/products/pir-module" target="_blank" rel="noopener noreferrer nofollow ugc">https://shop.m5stack.com/products/pir-module</a>).</p>
<p dir="auto">I have read through the scare documention that is available for this device and am at a lose where to start I tried dumping the GPIO pins to serial as I hold my hand over the sensor and inferring which pin was the sensor; but I am guessing that a pin needs to be powered or in read mode as no change occurs  ?</p>
<pre><code>void setup() {
Serial.begin(115200);
}
  
void loop() {

  for(int i=0;i&lt;40;i++)
  {
    int pin = digitalRead(i);

    Serial.print(i);
    Serial.print(':');
    Serial.print(pin);
    Serial.print('|');
    
  }
   Serial.println(' ');
}
</code></pre>
]]></description><link>https://community.m5stack.com/topic/5430/poecam-and-pir-sensor</link><generator>RSS for Node</generator><lastBuildDate>Mon, 04 May 2026 09:45:06 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/5430.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Jun 2023 22:21:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to POECAM and PIR sensor on Wed, 28 Jun 2023 23:22:10 GMT]]></title><description><![CDATA[<p dir="auto">HI <a class="plugin-mentions-user plugin-mentions-a" href="/user/felmue" aria-label="Profile: felmue">@<bdi>felmue</bdi></a> ,</p>
<p dir="auto">Thankyou for your reply :)</p>
<p dir="auto">I had already striped the LCD code its the M5Stack header (and includes) itself that doesn't want to compile.</p>
<p dir="auto">The only samples that compile are the factory test and Ethernet stream which leads me to believe their isn't a board specific header as such.</p>
<p dir="auto">digging through the platform library there is a pin_header</p>
<pre><code>#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include &lt;stdint.h&gt;

#define EXTERNAL_NUM_INTERRUPTS 16
#define NUM_DIGITAL_PINS        40
#define NUM_ANALOG_INPUTS       16

#define analogInputToDigitalPin(p)  (((p)&lt;20)?(esp32_adc2gpio[(p)]):-1)
#define digitalPinToInterrupt(p)    (((p)&lt;40)?(p):-1)
#define digitalPinHasPWM(p)         (p &lt; 34)

static const uint8_t TX = 1;
static const uint8_t RX = 3;

static const uint8_t SDA = 25;
static const uint8_t SCL = 33;

static const uint8_t G23 = 23;
static const uint8_t G25 = 25;
static const uint8_t G27 = 27;
static const uint8_t G22 = 22;
static const uint8_t G26 = 26;
static const uint8_t G21 = 21;
static const uint8_t G32 = 32;
static const uint8_t G35 = 35;
static const uint8_t G34 = 34;
static const uint8_t G5 = 5;
static const uint8_t G39 = 39;
static const uint8_t G18 = 18;
static const uint8_t G36 = 36;
static const uint8_t G19 = 19;
static const uint8_t G15 = 15;

static const uint8_t G2 = 2;
static const uint8_t G33 = 33;

static const uint8_t G13 = 13;
static const uint8_t G4 = 4;

static const uint8_t G0 = 0;

static const uint8_t DAC1 = 25;
static const uint8_t DAC2 = 26;

static const uint8_t ADC1 = 35;
static const uint8_t ADC2 = 36;

#endif /* Pins_Arduino_h */
</code></pre>
<p dir="auto">which of course is one of the many reasons why the example library doesn't compile,my device simply has different pins.</p>
<p dir="auto">In the factory test I see the references to UART Ext_PIN_1 and Ext_PIN_2 :</p>
<pre><code>  Serial.println("UART INIT");
  uart_init(Ext_PIN_1, Ext_PIN_2); 
</code></pre>
<p dir="auto">which is defiend in timer_cam_config.h</p>
<pre><code>#define Ext_PIN_1 33
#define Ext_PIN_2 25
</code></pre>
<p dir="auto">So lets strip off the header and run it with the pure Arduino.</p>
<pre><code>#include &lt;Arduino.h&gt;

void setup() {
   
   pinMode(33, INPUT_PULLUP);
   Serial.begin(115200);
}
  
void loop() {

   Serial.println(digitalRead(33));
   delay(1000);
}
</code></pre>
<p dir="auto">It works but only if I set the board to M5Stack-Timer-CAM.</p>
<p dir="auto">Additionally the Ethernet-Stream example needs the network.h header lines 16-17 altered as below else it will not compile</p>
<pre><code>static ip4_addr_t ip_addr; // For platform = espressif32@ ^3.5.0
//static esp_ip4_addr_t ip_addr; // For platform = espressif32@ ^5.1.0
</code></pre>
<p dir="auto">I will post this in the modules forum for other users trying to build the examples, apologies for putting this in FAQ (it was late/early)</p>
]]></description><link>https://community.m5stack.com/post/21371</link><guid isPermaLink="true">https://community.m5stack.com/post/21371</guid><dc:creator><![CDATA[nemsys]]></dc:creator><pubDate>Wed, 28 Jun 2023 23:22:10 GMT</pubDate></item><item><title><![CDATA[Reply to POECAM and PIR sensor on Wed, 28 Jun 2023 21:18:40 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/nemsys" aria-label="Profile: nemsys">@<bdi>nemsys</bdi></a></p>
<p dir="auto">you'll only need the part setting up the input pin in setup():</p>
<pre><code>pinMode(33, INPUT);
</code></pre>
<p dir="auto">and the part in loop() which reads it:</p>
<pre><code>if (digitalRead(33) == 1)
{
  Serial.println("Sensing");
} else {
  Serial.println("Not Sensed");
}
delay(500);
</code></pre>
<p dir="auto">You can ignore the rest which mostly deals with the LCD the POECAM doesn't have.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/21369</link><guid isPermaLink="true">https://community.m5stack.com/post/21369</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Wed, 28 Jun 2023 21:18:40 GMT</pubDate></item><item><title><![CDATA[Reply to POECAM and PIR sensor on Wed, 28 Jun 2023 18:32:27 GMT]]></title><description><![CDATA[<p dir="auto">hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/felmue" aria-label="Profile: felmue">@<bdi>felmue</bdi></a></p>
<p dir="auto">I had tried to compile the PIR example sketch after installing the libraries but I get the following compile error</p>
<pre><code>Arduino/libraries/M5Stack/src/M5Stack.h:112,
Projects/ESP32/M5Stack/examples/Unit/PIR/PIR.ino:16:
.arduino15/packages/m5stack/hardware/esp32/2.0.7/libraries/SD/src/SD.h:31:30: error: 'SS' was not declared in this scope
     bool begin(uint8_t ssPin=SS, SPIClass &amp;spi=SPI, uint32_t frequency=4000000, const char * mountpoint="/sd", uint8_t max_files=5, bool format_if_empty=false);
                              ^~
.arduino15/packages/m5stack/hardware/esp32/2.0.7/libraries/SD/src/SD.h:31:30: note: suggested alternative: 'FS'
     bool begin(uint8_t ssPin=SS, SPIClass &amp;spi=SPI, uint32_t frequency=4000000, const char * mountpoint="/sd", uint8_t max_files=5, bool format_if_empty=false);
                              ^~
                              FS
Multiple libraries were found for "SD.h"
  Used: .arduino15/packages/m5stack/hardware/esp32/2.0.7/libraries/SD
  Not used: .arduino15/libraries/SD
</code></pre>
<p dir="auto">Do we know if the stock M5Stack headers are compatabile with this board ?</p>
<p dir="auto">the ethernet example for the cam-timer board compiles and runs without issue but notably it doesn't make use of the M5Stack header</p>
<p dir="auto">ethernetStream sketch headers</p>
<pre><code>#include &lt;WiFi.h&gt;
#include "esp_task_wdt.h"
#include "esp_camera.h"
#include "PoE_CAM.h"
#include &lt;esp_heap_caps.h&gt;
</code></pre>
<p dir="auto">PoE_Cam.h</p>
<pre><code>#include "./utility/camera_index.h"
#include "./utility/w5500_image.h"
#include "./utility/uart_frame.h"
#include "./utility/timer_cam_config.h"
#include "./utility/cam_cmd.h"
#include "./utility/protocol.h"
#include "./utility/app_httpd.h"
#include "./utility/network.h"
#include "./utility/image_post.h"
</code></pre>
<p dir="auto">I'm not being foolish the wiring is as simple as (ignore the solder) :<br />
<img src="/assets/uploads/files/1687976963348-pir-resized.jpg" alt="0_1687976973125_PIR.JPG" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.m5stack.com/post/21367</link><guid isPermaLink="true">https://community.m5stack.com/post/21367</guid><dc:creator><![CDATA[nemsys]]></dc:creator><pubDate>Wed, 28 Jun 2023 18:32:27 GMT</pubDate></item><item><title><![CDATA[Reply to POECAM and PIR sensor on Tue, 27 Jun 2023 23:06:17 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/nemsys" aria-label="Profile: nemsys">@<bdi>nemsys</bdi></a></p>
<p dir="auto">have a look at the PIR <a href="https://github.com/m5stack/M5Stack/blob/master/examples/Unit/PIR/PIR.ino" target="_blank" rel="noopener noreferrer nofollow ugc">example</a>. Also keep in mind that according to the <a href="https://docs.m5stack.com/en/unit/pir" target="_blank" rel="noopener noreferrer nofollow ugc">documentation</a> it can take up to 2 s for the PIR to react: <em>"Notice: This Unit has 2s delay time."</em></p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/21354</link><guid isPermaLink="true">https://community.m5stack.com/post/21354</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Tue, 27 Jun 2023 23:06:17 GMT</pubDate></item></channel></rss>