Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020-105
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2020-105
2020-105
Commits
d7644ca4
Commit
d7644ca4
authored
Nov 05, 2020
by
Perera H.M.D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
525d0b66
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
117 additions
and
0 deletions
+117
-0
Water_Flow.ino
Water_Flow.ino
+117
-0
No files found.
Water_Flow.ino
0 → 100644
View file @
d7644ca4
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPUpdateServer.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <EEPROM.h>
#include "TimeLib.h"
#include "timestamp32bits.h"
const
char
*
ssid_sta
=
"Test"
;
const
char
*
password_sta
=
"Test123"
;
ESP8266WebServer
flow_server
(
80
);
ESP8266HTTPUpdateServer
flow_updater
;
WiFiUDP
ntpUDP
;
NTPClient
timeClient
(
ntpUDP
,
"lk.pool.ntp.org"
,
19800
,
3600000
);
time_t
NTPunixTime
;
timestamp32bits
tstamp
=
timestamp32bits
();
unsigned
long
NTPtime
=
0
;
unsigned
long
rstart_interval
=
1000
*
60
*
60
*
24
*
30
;
//miliseconds per 30 days
int
web_page_refresh_interval
=
1000
*
10
;
//10 seconds
const
char
*
admin_username
=
"admin"
;
const
char
*
admin_password
=
"admin"
;
const
char
*
svr
=
"api.thingspeak.com"
;
String
apiKey
=
"QIFMFT4LJ12XZ4AW"
;
const
char
*
www_realm
=
"Login Required"
;
String
authFailResponse
=
"Login Failed. Please retry."
;
bool
logged_out
;
#define TSENSOR_PIN D6
#define BSENSOR_PIN D7
#define valve_pin D4
unsigned
long
previousMillis
=
0
;
unsigned
long
sendtime
;
unsigned
long
send_interval
=
10000
;
int
interval
=
1000
;
float
calibrationFactor
=
4.5
;
volatile
byte
pulseCount
;
volatile
byte
pulseCount2
;
byte
tpulse1Sec
=
0
;
float
tflowRate
;
unsigned
long
tflowMilliLitres
;
unsigned
int
ttotalMilliLitres
;
float
tflowLitres
;
float
ttotalLitres
;
byte
bpulse1Sec
=
0
;
float
bflowRate
;
unsigned
long
bflowMilliLitres
;
unsigned
int
btotalMilliLitres
;
float
bflowLitres
;
float
btotalLitres
;
bool
valve_stat
=
false
;
WiFiClient
svrv
;
void
IRAM_ATTR
pulseCounter
()
{
pulseCount
++
;
}
void
IRAM_ATTR
pulseCounter2
()
{
pulseCount2
++
;
}
void
setup
()
{
Serial
.
begin
(
115200
);
wifi_init
();
server_init
();
eeprom_init
();
time_init
();
pinMode
(
valve_pin
,
OUTPUT
);
pinMode
(
TSENSOR_PIN
,
INPUT_PULLUP
);
pinMode
(
BSENSOR_PIN
,
INPUT_PULLUP
);
attachInterrupt
(
digitalPinToInterrupt
(
TSENSOR_PIN
),
pulseCounter
,
FALLING
);
attachInterrupt
(
digitalPinToInterrupt
(
BSENSOR_PIN
),
pulseCounter2
,
FALLING
);
delay
(
100
);
Serial
.
println
(
""
);
Serial
.
println
(
"Ready..."
);
}
void
loop
()
{
time_run
();
sensor_run
();
flow_server
.
handleClient
();
rstart
();
}
void
rstart
()
{
if
(
millis
()
>
rstart_interval
)
{
Serial
.
println
(
"Restarting..."
);
ESP
.
restart
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment