I’m using a switch to advance the screen on a 4×20 LCD. This has to wait until the code gets back (up to 10secs) to check the switch. I have tried the interrupt routine and the ESP crashes and reboots every time. I’m not having much success with the “ESP32 with PIR Motion Sensor” sketch either. I’ve tried it on 3 x ESP32s (both 36 & 30 pin DoIT devices) and every time it reboots. Does anybody have any solutions. Thanks Murray
Did you use my exact code from the ESP32 with PIR Motion sensor using Timers? What’s not working for you? Can you tell me the error message?
Regards,
Rui
Yes I used your code Then got this ….
MOTION DETECTED!!!
MOTION DETECTED!!!
MGuru Meditation Error: Core 0 panic’ed (Interrupt wdt timeout on CPU0)
Core 0 register dump:
PC : 0x40085a11 PS : 0x00060034 A0 : 0x80086077 A1 : 0x3ffc0580
A2 : 0x3ffc1068 A3 : 0x0000cdcd A4 : 0xb33fffff A5 : 0x00000001
A6 : 0x00060021 A7 : 0x0000abab A8 : 0x0000abab A9 : 0x3ffc0580
A10 : 0x00000003 A11 : 0x00060023 A12 : 0x00060021 A13 : 0x00000000
A14 : 0xffffffff A15 : 0x3ffc736c SAR : 0x00000017 EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Core 0 was running in ISR context:
EPC1 : 0x400e6c8e EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x40085a11
Backtrace: 0x40085a11:0x3ffc0580 0x40086074:0x3ffc05b0 0x40086feb:0x3ffc05d0 0x40086cf1:0x3ffc05f0 0x40081616:0x3ffc0600 0x400e6c8b:0x00000000
Core 1 register dump:
PC : 0x40087586 PS : 0x00060e34 A0 : 0x800863b2 A1 : 0x3ffc0ac0
A2 : 0x3ffb21cc A3 : 0x3ffb2050 A4 : 0x00000001 A5 : 0x00000001
A6 : 0x00060e23 A7 : 0x00000000 A8 : 0x3ffb2050 A9 : 0x3ffb2050
A10 : 0x00000018 A11 : 0x00000018 A12 : 0x00000001 A13 : 0x00000001
A14 : 0x00060e21 A15 : 0x00000000 SAR : 0x00000015 EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffb
Backtrace: 0x40087586:0x3ffc0ac0 0x400863af:0x3ffc0ae0 0x40085053:0x3ffc0b00 0x400d10a9:0x3ffc0b40 0x400d0b6d:0x3ffc0b60 0x400d0cca:0x3ffc0b80 0x400d0cf1:0x3ffc0ba0 0x40080df1:0x3ffc0bc0 0x40080e55:0x3ffc0be0 0x4008160d:0x3ffc0c00 0x400d10d1:0x00000000
Rebooting…
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:808
load:0x40078000,len:6084
load:0x40080000,len:6696
entry 0x400802e4
MOTION DETECTED!!!
Motion stopped…
Which PIR motion sensor are you using? Can you tell me the module? does it have potentiometers at the back that you can rotate to adjust the sensitivity? Thanks!
I have tried 2 The one with the pots seems to be ok. The other little one seems to cause the problem.
Maybe it is faulty. I want to use the IRQ routine to detect a Push button switch, turn on the LCD backlight and update the page on a 20×4 I2C LCD
I cant get this to work. I am using
//Backlight Switch – Advance LCD Page
pinMode(BlSw, INPUT_PULLUP); // Backlight Sw
attachInterrupt(digitalPinToInterrupt(BlSw), ScrnAdvance, FALLING); //IRQ Setup
The ESP32 crashes when I earth the BlSw pin. It has a internal pullup on it. I’m using gpio 33
Hi again Murray.
Can you try using the PIR code in another GPIO (like GPIO 27)? I think your PIR is also triggering many times in a row and causes the board to crash.
That’s why I’ve mentioned using the PIR with pots to adjust the sensitivity…
Hi,
I have de same problem. My lcd 20×4 and my sensor is a IR.
Error:
19:34:40.944 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
19:34:40.978 -> configsip: 0, SPIWP:0xee
19:34:40.978 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
19:34:40.978 -> mode:DIO, clock div:1
19:34:40.978 -> load:0x3fff0018,len:4
19:34:40.978 -> load:0x3fff001c,len:1324
19:34:40.978 -> load:0x40078000,len:7788
19:34:40.978 -> ho 0 tail 12 room 4
19:34:40.978 -> load:0x40080400,len:6448
19:34:40.978 -> entry 0x400806e8
My code is litlle diferent, but with same result:
#include <Wire.h> // A biblioteca wire.h é a responsável pela comunicação utilizando o protocolo I2C
#include <LiquidCrystal_I2C.h>
void LCD_Print();
volatile unsigned long timeold; //tempo
volatile int lcdColumns = 20;
volatile int lcdRows = 4;
#define ledPin 23 //GPIO 23.
#define buttonPin 4 //GPIO 4.
#define voltPin 15 //GPIO 15.
#define rpmPin 26 //GPIO 2;
float valor = 0;
int buttonStatus = 0; //Armazena o estado do botão.
volatile
int ledStatus = 0;
volatile int rpmStatus = 0;
LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows);
int timeNow = 0;
long last = 0;
double count = 0.00;
int nBlades = 6; // the number of blades of the propeller
int miliseconds = 5000; // the time it takes each reading
boolean startTimer = false;
void IRAM_ATTR detectsMovement()
{
Serial.println(“MOTION DETECTED!!!”);
startTimer = true;
}
void setup()
{
Serial.begin(115200);
delay(500);
lcd.init(); // initializa LCD
lcd.backlight(); // turn on LCD backlight
pinMode(ledPin, OUTPUT); //Inicializa o pino 23 como saÃda.
pinMode(buttonPin, INPUT);//Inicializa o pino 4 como entrada.
pinMode(rpmPin, INPUT);
attachInterrupt(digitalPinToInterrupt(rpmPin), detectsMovement, RISING);
}
void loop()
{
unsigned long currentMillis = millis(); //Tempo atual em ms
rpmStatus = digitalRead(rpmPin);
if(rpmStatus == HIGH && ledStatus == 0 && startTimer)
{
ledStatus = 1;
count++;
lcd.setCursor(0, 0);
lcd.print(“Led ON “);
digitalWrite(ledPin, HIGH);
startTimer = false;
}
if(rpmStatus == LOW && ledStatus == 1)
{
ledStatus = 0;
lcd.setCursor(0, 0);
lcd.print(“Led OFF”);
digitalWrite(ledPin, LOW);
}
if(currentMillis – last > miliseconds)
{
double rpm= (60.00 * count)/6;
Serial.print(” RPM”);
Serial.print(rpm);
last = currentMillis;
count=0;
lcd.setCursor(0, 3);
lcd.print(rpm);
lcd.print(” RPM “);
}