Need help on my project

your are right Pete, but if(rpm >=4700 )
that is to say 78 interrupts by seconds …
Am I wrong ?
@awegadget should do calculation every 5 sec and use timer
so, why his project don’t run with blynk ?
did he just forgot to detach interrupt every 5 seconds ?

@awegadget seems unwilling to experiment and feedback results to us, so it’s difficult to give any more guidance.
This is obviously a non-standard scenario and therefore needs a bit of experimentation and trial and error.

Pete.

ok thanks all friend…i in hard way now hahaha…actually i still new in arduino coding and Blynk…
that RPM coding i get from internet and i so happy lean this code (arduino and Blynk)…
i continue study and experiment…thanks to all friend give support…

1 Like

@awegadget

may be …

timer.setInterval(300L, sensorIsr_end); 
.
..
.

void sensorIsr_end(int pin) {
  detachInterrupt(pin);
//do the work
}

hi friend my coding work now…actually no problem at coding but problem with IR module sensitivity setting.
i found this problem when i try power up my project with power adapter my project not work…7 indicator LED also not work but all part have power. IR sensor module also look normal with LED blinking when fan turning.but when i power up using USB cable all work fine. so confuse, at last i try re setting senstivity IR sensor all work fine…hahaha…so happy…
thanks to all friend support…here my coding

// wiring : IR sensor =D2
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
LiquidCrystal_I2C lcd(0x3F,16,2);  // 0x27 or 39 or 0x3F
char auth[] = "xxxxxx";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxx";
char pass[] = "xxxx";
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(4, 5); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

WidgetLED ledv1(V1);
WidgetLED ledv2(V2);
WidgetLED ledv3(V3);
WidgetLED ledv4(V4);
WidgetLED ledv5(V5);
WidgetLED ledv6(V6);
WidgetLED ledv7(V7);

BlynkTimer timer;

//RPM--------------------------------------------------------------
//Configuration for the Tachometer variables
const int sensorPin = 2;
const int sensorInterrupt = 0;
volatile unsigned long lastPulseTime;
volatile unsigned long interval = 0;
//volatile int timeoutCounter;

int rpm;
int rpmlast = 3000;
int led1 = 6;
int led2 = 7;
int led3 = 8;
int led4 = 9;
int led5 = 10;
int led6 = 11;
int led7 = 12;

void PulseLevel()
{
 if(rpm >= 0) {  //Remove the error readings of minus values   
    
    //Let's keep this RPM value under control, between 0 and 9999
    rpm = constrain (rpm, 0, 9999); // make sure value on this range
  
    
   if ((micros() - lastPulseTime) < 5e6 ) {  // micro()= is time since arduino start running program
      rpm = rpm;
    }
 }

   Serial.println(rpm);  
  if(rpm >=499 && rpm<=500){
    digitalWrite(led1,HIGH);
    digitalWrite(led3,LOW);
    digitalWrite(led2,LOW);
    digitalWrite(led4,LOW);
    digitalWrite(led5,LOW);
    digitalWrite(led6,LOW);
    digitalWrite(led7,LOW);
    ledv1.on();
    ledv2.off();
    ledv3.off();
    ledv4.off();
    ledv5.off();
    ledv6.off();
    ledv7.off();
  }
 if(rpm >=500 && rpm<=1000){
    digitalWrite(led2,HIGH);
    digitalWrite(led1,HIGH);
    digitalWrite(led3,LOW);
    digitalWrite(led4,LOW);
    digitalWrite(led5,LOW);
    digitalWrite(led6,LOW);
    digitalWrite(led7,LOW);
    ledv1.on();
    ledv2.on();
    ledv3.off();
    ledv4.off();
    ledv5.off();
    ledv6.off();
    ledv7.off();
    
 }
    if(rpm >=1000 && rpm<=1500){
    digitalWrite(led3,HIGH);
    digitalWrite(led2,HIGH);
    digitalWrite(led1,HIGH);
    digitalWrite(led4,LOW);
    digitalWrite(led5,LOW);
    digitalWrite(led6,LOW);
    digitalWrite(led7,LOW);
    ledv1.on();
    ledv2.on();
    ledv3.on();
    ledv4.off();
    ledv5.off();
    ledv6.off();
    ledv7.off();
 }
 if(rpm >=2500 && rpm<=3000){
    digitalWrite(led3,HIGH);
    digitalWrite(led2,HIGH);
    digitalWrite(led1,HIGH);
    digitalWrite(led4,HIGH);
    digitalWrite(led5,LOW);
    digitalWrite(led6,LOW);
    digitalWrite(led7,LOW);
    ledv1.on();
    ledv2.on();
    ledv3.on();
    ledv4.on();
    ledv5.off();
    ledv6.off();
    ledv7.off();
 }
 if(rpm >=3500 && rpm<=4000 ){
    digitalWrite(led3,HIGH);
    digitalWrite(led2,HIGH);
    digitalWrite(led1,HIGH);
    digitalWrite(led4,HIGH);
    digitalWrite(led5,HIGH);
    digitalWrite(led6,LOW);
    digitalWrite(led7,LOW);
    ledv1.on();
    ledv2.on();
    ledv3.on();
    ledv4.on();
    ledv5.on();
    ledv6.off();
    ledv7.off();
 }
 if(rpm >=4000 && rpm<=4700 ){
    digitalWrite(led3,HIGH);
    digitalWrite(led2,HIGH);
    digitalWrite(led1,HIGH);
    digitalWrite(led4,HIGH);
    digitalWrite(led5,HIGH);
    digitalWrite(led6,HIGH);
    digitalWrite(led7,LOW);
    ledv1.on();
    ledv2.on();
    ledv3.on();
    ledv4.on();
    ledv5.on();
    ledv6.on();
    ledv7.off();
 }
 if(rpm >=4700 ){
    digitalWrite(led3,HIGH);
    digitalWrite(led2,HIGH);
    digitalWrite(led1,HIGH);
    digitalWrite(led4,HIGH);
    digitalWrite(led5,HIGH);
    digitalWrite(led6,HIGH);
    digitalWrite(led7,HIGH);
    ledv1.on();
    ledv2.on();
    ledv3.on();
    ledv4.on();
    ledv5.on();
    ledv6.on();
    ledv7.on();
 }
 else {
   
      rpm =rpm;
   // ledv1.off();
  //  ledv2.off();
   // ledv3.off();
   // ledv4.off();
  //  ledv5.off();
  //  ledv6.off();
  //  ledv7.off();
      
    }
}
    
void sensorIsr() 
{
  unsigned long now = micros();
  interval = now - lastPulseTime;
  if (interval > 5000) //{
     rpm = 61000000UL/(interval * 2);
     lastPulseTime = now;
  }  

void setup()
{  
   Serial.begin(9600);
   EspSerial.begin(ESP8266_BAUD);
  delay(10);

 Blynk.begin(auth, wifi, ssid, pass);
    
  attachInterrupt(sensorInterrupt, &sensorIsr, RISING);  //Isr = interrupt service routine
  lastPulseTime = 0;
  
    pinMode(sensorPin, INPUT);
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
    pinMode(led3, OUTPUT);
    pinMode(led4, OUTPUT);
    pinMode(led5, OUTPUT);
    pinMode(led6, OUTPUT);
    pinMode(led7, OUTPUT);
    
    digitalWrite(led1,HIGH);
    digitalWrite(led3,LOW);
    digitalWrite(led2,LOW);
    digitalWrite(led4,LOW);
    digitalWrite(led5,LOW);
    digitalWrite(led6,LOW);
    digitalWrite(led7,LOW);

//timer.setInterval(10000L, PulseLevel); // every 10 seconds you can change that  
timer.setInterval(500L, PulseLevel); // every 1 seconds you can change that  
} 
   
void loop()
{
  Blynk.run();
  timer.run();
}

1 Like

you never detach Interrupt and it runs well ?

yes friend…i just follow what u teach me…without detach interrupt is run well

ok friend.
Ask me if you need help

thanks for your support friend…
1 have 1 question ;
what meaning 5e6 in my coding?

void loop()
{
  if(rpm >= 0) {  //Remove the error readings of minus values   
    
    //Let's keep this RPM value under control, between 0 and 9999
    rpm = constrain (rpm, 0, 9999); // make sure value on this range  // Constrains a number to be within a range.
  
    
   if ((micros() - lastPulseTime) < 5e6 ) {  // micro()= is time since arduino start running program
      rpm = rpm;
    }

I believe it is Scientific Notation… or 5000 (or 5000000?) to us mere mortals who count on our toes for advanced math (I had to Google it… so not positive :stuck_out_tongue: )

1 Like

yes…i aslo think 5e10 = 5 X (10 x 1000000)

you are right
5e10 means 50 000 000 000
:wink:

1 Like

@awegadget I’d had used a different approach. Because you’re dealing with only one input and viewing the results over the internet, then just use the ESP, no need to use displays nor the Uno board. Connect the sensor to the ESP directly. BTW, your IR lines are far from the electronics and may pick up ambient noise. You may want to clean them up if it’s the case.

1 Like

hi Emilio…
thanks for your advise…so far it run fine now…i also still level beginner hahaha…
later more project with blynk coming soon…so interested with Blynk hahaha…


suddenly i can’t log in into my Blynk acc…error “You have no internet connection”.
my internet ok not problem at all…my iphone also ok connection with my route.
actually what the problem?

is it the local server ?

i not sure…before this i just install from app store and run not selection for server…until today i try log in error…
any problem with Blynk server now?

what do you see when you clic on this :

I’m at local server

15-019267

so i need use same ip address 192.168.0.1 443?