Hi, i need help. My blynk app do not display any data . When i upload the coding , there is no error ? Please someone help me . Thank you
first you have to post your sketch
else nobody can help you.
don’t forget to use backticks
1 Like
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <ESP8266WebServer.h>
#include <SimpleTimer.h>
// Variable init
const int buttonPin = D2; // variable for D2 pin
const int ledPin = D7;
int addr = 0; //endereço eeprom
byte sensorInterrupt = 0; // 0 = digital pin 2
char auth[] = "ed76b860e42d4e818a531957ca5792f2";
char ssid[] = "Lutfil's iPhone";
char pass[] = "hadi123456";
float calibrationFactor = 4.5;
volatile byte pulseCount;
float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;
unsigned long oldTime;
float totalLitres;
SimpleTimer timer;
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.println();
flowRate = 0.0;
flowMilliLitres = 0;
totalMilliLitres = 0;
oldTime = 0;
totalLitres = 0;
timer.setInterval(1000L, showFlow);
attachInterrupt(digitalPinToInterrupt(buttonPin), pulseCounter, RISING);
}
void showFlow()
{
detachInterrupt(sensorInterrupt);
flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
oldTime = millis();
flowMilliLitres = (flowRate / 60) * 1000;
totalMilliLitres += flowMilliLitres;
totalLitres = totalMilliLitres/1000;
unsigned int frac;
// Print the flow rate for this second in litres / minute
Serial.print("Flow rate: ");
Serial.print(int(flowRate)); // Print the integer part of the variable
Serial.print("."); // Print the decimal point
// Determine the fractional part. The 10 multiplier gives us 1 decimal place.
frac = (flowRate - int(flowRate)) * 10;
Serial.print(frac, DEC); // Print the fractional part of the variable
Serial.print("L/min");
// Print the number of litres flowed in this second
Serial.print(" Current Liquid Flowing: "); // Output separator
Serial.print(flowMilliLitres);
Serial.print("mL/Sec");
// Print the cumulative total of litres flowed since starting
Serial.print(" Output Liquid Quantity: "); // Output separator
Serial.print(totalMilliLitres);
Serial.println("mL");
// Print the cumulative total of litres flowed since starting
Serial.print(" Output Liquid Quantity: "); // Output separator
Serial.print(totalLitres/1000);
Serial.println("L");
Blynk.virtualWrite(V4, int(flowRate));
Blynk.virtualWrite(V5, int(flowMilliLitres));
Blynk.virtualWrite(V6, int(totalMilliLitres));
Blynk.virtualWrite(V7, float(totalLitres));
pulseCount = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
void pulseCounter()
{
// Increment the pulse counter
pulseCount++;
}
void loop()
{
Blynk.run();
timer.run();
}
What does your serial monitor show?
Serial monitor also did not display data
so attachInterrupt don’t work.
1 Like
Do you have your serial monitor set to the correct baud rate?
JustBertC no
you need to see serial monitor.
else we can’t help you.
Okay. I’ll try
2 Likes
At the serial monitor, it says isr not in iram! What is that mean ?
Seems it is interrupt issue !
if you are using ESP core 2.5.1 try to downgrade to 2.4.2 or 2.5.0 beta
1 Like
Omg! It works. Thank you so much…
3 Likes
you’re welcome
1 Like