Skip to content

Commit fd9b271

Browse files
committed
2 years later...
1 parent fca5ae0 commit fd9b271

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

Bar-Mol Relationship.xlsx

366 KB
Binary file not shown.

SCDF_NodeMCU.ino

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#define BLYNK_PRINT Serial
2+
3+
#include <ESP8266WiFi.h>
4+
#include <BlynkSimpleEsp8266.h>
5+
#include <HP20x_dev.h> //flow sensor hardware library
6+
#include <Arduino.h>
7+
#include <Wire.h>
8+
9+
unsigned char ret = 0;
10+
11+
// You should get Auth Token in the Blynk App.
12+
// Go to the Project Settings (nut icon).
13+
char auth[] = "410e39b34914406dbd0e6470ef4165eb"; //allows connection between hardware and Blynk Cloud
14+
15+
// Your WiFi credentials.
16+
// Set password to "" for open networks.
17+
char ssid[] = "your wifi network";
18+
char pass[] = "password";
19+
20+
unsigned volatile int flow_frequency; // Measures flow sensor pulses
21+
unsigned int l_hour; // Calculated litres/hour
22+
char flowSensor = 2; // Sensor Input
23+
void flow () // Interrupt function
24+
{
25+
flow_frequency++;
26+
}
27+
28+
void setup(){
29+
Serial.begin(9600); // serial data rate is set for 9600 bpa (bits per second)
30+
Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
31+
pinMode(flowSensor, INPUT);
32+
attachInterrupt(flowSensor, flow, RISING); // Setup Interrupt
33+
HP20x.begin();
34+
delay(100);
35+
/* Determine HP20x_dev is available or not*/
36+
ret = HP20x.isAvailable();
37+
if(OK_HP20X_DEV == ret){
38+
Serial.println("HP20x_dev is available.\n");
39+
}
40+
else{
41+
Serial.println("HP20x_dev isn't available.\n");
42+
}
43+
}
44+
45+
BLYNK_READ(V5) //Blynk app has something on V5
46+
{
47+
sei(); // Enable interrupts
48+
delay (1000); //Wait 1 second
49+
cli(); //Disable interrupts
50+
// Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.
51+
l_hour = (flow_frequency / 7.5); // (Pulse frequency) / 7.5Q = flowrate in L/min
52+
Blynk.virtualWrite(V5, flow_frequency/7.5); //sending to Blynk
53+
flow_frequency = 0; // Reset Counter
54+
}
55+
56+
BLYNK_READ(V6){
57+
char display[40];
58+
if(OK_HP20X_DEV == ret)
59+
{
60+
Serial.println("------------------\n");
61+
long Temperature = HP20x.ReadTemperature(); //This is where the Temperature value is obtained
62+
Serial.println("Temperature:");
63+
Temperature = Temperature/100.0;
64+
Blynk.virtualWrite(V6, Temperature);
65+
}
66+
}
67+
68+
BLYNK_READ(V7){
69+
long Pressure = HP20x.ReadPressure(); //This is where the Pressure value is obtained
70+
Serial.println("Pressure:");
71+
Pressure = Pressure/100.0;
72+
Blynk.virtualWrite(V7, Pressure);
73+
}
74+
75+
void loop(){
76+
Blynk.run();
77+
}

0 commit comments

Comments
 (0)