Hi,
I’m trying to us particle variable function.
However, it never transfer the data into my monitor. It just keep refreshing.
When I click refresh, it showed this image.
The following is the code I have. I found this online and add the particle variable function in it.
The data showed out fine through serial.
Thanks guys!
*The particle desktop IDE version is 1.18. I checked the update, it said it’s the latest.
int flowPin = D1; //This is the input pin on the Arduino
double flowRate = 0; //This is the value we intend to calculate.
volatile int count; //This integer needs to be set as volatile to ensure it updates correctly during the interrupt process.
void setup() {
// put your setup code here, to run once:
pinMode(flowPin, INPUT); //Sets the pin as an input
attachInterrupt(D1, Flow, RISING); //Configures interrupt 0 (pin 2 on the Arduino Uno) to run the function "Flow"
Serial.begin(9600); //Start Serial
Particle.variable("Flow Rate", &flowRate, DOUBLE);
}
void loop() {
// put your main code here, to run repeatedly:
count = 0; // Reset the counter so we start counting from 0 again
interrupts(); //Enables interrupts on the Arduino
delay (1000); //Wait 1 second
noInterrupts(); //Disable the interrupts on the Arduino
//Start the math
flowRate = (count * 2.25); //Take counted pulses in the last second and multiply by 2.25mL
//flowRate = flowRate * 60; //Convert seconds to minutes, giving you mL / Minute
//flowRate = flowRate / 1000; //Convert mL to Liters, giving you Liters / Minute
Serial.println(flowRate); //Print the variable flowRate to Serial
}
void Flow()
{
count++; //Every time this function is called, increment "count" by 1
}