Unable to count Drops/Second

I have been using an IR sensor to calculate the drop count through it . I have written a code which works fine on arduino calculating drops/sec but the same code doesnt work on photon. May i know the reason for it and how to make it work.
Any help is appreciated. Thanks

Screenshots of code are usually discouraged when copying and pasting is possible.

1 Like

What does this mean exactly? Does pulse remain at 0? It would help to know what sensor you’re using, and how you have it hooked up.

1 Like

Like an Uno? => 5V logic

Photon => 3.3V


sorry for it… here is the code:

int pin=D5;
volatile unsigned int pulse;

void setup()
 void loop()
  String myString = String(pulse);
void count_pulse()

So i am using a photoelectric IR through beam sensor (HC-89) connected to D5 of photon to measure the drops passing through it per second. when i run this code it shows me just 0 every second tried both on serial monitor and the console it just shows me 0 all the time.
May i know whats the problem?

Hard to say without the actual setup at hand. AFAICT it should (normally) work.
But to narrow down the cause of it (is it the interrupt, is it the wiring, is it the power supply for the sensor, …).
I’d start of without interrupts and just have a very fast loop() polling the pin and see if the sensor picks a signal up at all.
You could even use D7 to get a visual feedback on signal.

Next you could try INPUT_PULLDOWN (if the sensor actually signals HIGH on detection).

However, I’d advise against the use of noInterrupts() in that way.
The docs state

You are using Serial.print(), Particle.publish() and when falling out of loop() the system wants to do some cloud house keeping before the next iteration of loop() follows, with noInterrupts() you impact all of that.

1 Like