I have a precision pulse flow meter connected onto pin D4 of my ESP32 and am programming in the Arduino IDE environment. The following libraries are used:
/* Libraries */
// Include WiFi Library
#include <WiFi.h>
#include <HTTPClient.h>
// Include Serial Peripheral Interface library
#include <SPI.h>
// Include WiFi UDP Protocol
#include <WiFiUdp.h>
// Include ESP32 Time Library
#include <ESP32Time.h>
// Include Firebase ESP32 library (this library)
#include <FirebaseESP32.h>
// Provide the token generation process info.
#include <addons/TokenHelper.h>
// Provide the RTDB payload printing info and other helper functions.
#include <addons/RTDBHelper.h>
#include <pwmWrite.h>
I also have 2 Pulse Dosing Pumps connected to pins D2 and D15 respectively.
Currently, I am recording the intervals between pulses or every 10L of "Flow". This is happening through an ISR I have created which involves millis().
For some reason, when I output to (only dosing pump 2, be it a PWM signal or a simple on and off) the output of the dosing pump will trigger the ISR.
This causes the flow meter intervals to change unexpectedly.
I have tried connecting 10k Ohm resistors to the GPIO's of the dosing pumps and ground but to no avail. I am using just the NodeMCU-ESP32 to work this problem and separating my cloud processing on core 1 and operational processing on core 0.
This is due to me trying to remove latency of the system by separating operational processing and cloud processing.
My ISR is as follow:
void IRAM_ATTR inPulse(){
button_time = millis();
intervalPulse = button_time - last_button_time;
if(button_time - last_button_time > 250){
state = !state;
prevTrail = HIGH;
pulseDetect = 1;
last_button_time = button_time;
dailyFlow = dailyFlow + fMLPP;
}
}
The system is designed using a state machine approach, where core 1 is constantly receiving information from Google RTFB and is populating global variables which core 0 will then use.
All dosing pumps and the flow meter share a common ground. It works with just 1 dosing pump alone but as soon as I connect the second pump (only the second pump) it will start triggering the ISR. Could it be that there is reflections when the output signal from the ESP gets sent to the one dosing pump causing some sort of EMI ?
Any advice or knowledge as to why this may be happening will help so much. Thanks a lot in advance!