I am looking to see if anyone has some simple coding for monitoring RPMS with Blynk.
While there are many examples for driving LCDs and displays with Arduino, the majority of them use a lot of code in void loop. There are 2 other instances of people asking for assistance on here
I have read through them, and it does not appear that the working code was posted once the issue was resolved. I’m not a good coder. I can learn and modify code if I have a working example. Materials science is where my strength lies.
I have example code for an engine tach, and although it does kind of seem to report the elapsed time between interrupts, I never get a reading on the RPMS.
Of course it would be great to gather as many samples per second as possible, I’d be happy to start with anywhere between 4 and 2 per second to start.
I’m kind of surprised there isn’t a function for measuring RPMs, or any other types of interrupts per second already written into Blynk. It would seem to be something a lot of others would be interested in having access to.
Thanks in Advance for any insight you may have!
This is my sample code
My interrupt pin on my project is D14 which I am simply grounding for now by stabby stabbying the lead in and out of my breadboard to simulate the RPM sensor.
/*
Code done by Gerald Just Projects
gerald@geraldjustprojects.com
MIT License
Copyright (c) 2018 geraldjust
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*/
unsigned long start;
unsigned long elapsed;
unsigned long RPM;
int numOfCyl = 4 ; //4 banger
int pin = 14; //attach interupt for atmega328p / atmega32u4 (arduino Mapped.
void setup()
{
Serial.begin(9600);
pinMode(pin, INPUT);
digitalWrite(pin, HIGH);
attachInterrupt(digitalPinToInterrupt(pin), speedCalc, FALLING);
start = micros();
}
void speedCalc() {
elapsed = micros() - start;
start = micros();
//RPM = ((120 * (1000000 / elapsed)) / numOfCyl); //MS to RPM +-30RPM Res
RPM = ((12*(10,000,000/elapsed)) /numOfCyl); //uS +- 3RPM resolution
}
void loop()
{
Serial.print(int(RPM));
Serial.print(" rpm ");
Serial.print(" ");
Serial.println(elapsed);
Serial.println(" ms/rev ");
Serial.println(int(start));
Serial.println(" start ");
delay(50);
if ((micros()-start) >= 500000){
RPM=0;//if RPM times out then RPM = 0
}
delay (1000);
}
Why is this Blynk’s responsibility? Reading such impulses has nothing to do with Blynk.
Rather, one would use already existing and varying interrupt & counter code, along with whatever formulas needed to break it down into RPM or RPS, etc., as used in many Arduino projects floating around the web. See here for example - Arduino Playground - ReadingRPM
Blynk is predominantly an IoT GUI, thus can already easily be used to take the resulting values from aforementioned code functions and display it across your IoT needs.
Secondly…
I would recommend keeping the function called from the interrupt as lean as possible… just a simple counter increment will do.
Then using a timer controlled function, you can call up the counter value, run your calculations for the final displayable variable, send it to Blynk’s App, clear the counter and carry on.
I don’t think it’s their responsibility. As an IOT interface one of the things I would think it would be handy to have is a tachometer interface, since so many of the gauges are tachometer like.
It just seemed like it might be a handy feature to be able to display a number of pulses per minute.
Pardon my misunderstanding. It seems my question was mis-placed.
There is already the Gauge and Level widgets that can easily be used for exactly such… and my example above for more advanced use of the Image Widget.
If what you are describing is more like “Why can’t Blynk make all the code to translate a simple incoming RPM signal into a ready made display widget”… well, that could go the same for “…RPM or Temperature or Weight or Phone sensor (Accelerometer, etc) or whatever”… well, the Blynk Widget list would be huge … and then someone would surly complain because the built in function didn’t do it just the way they wanted