#include <LiquidCrystal_I2C.h>
#include <FlowSensor.h>
#include <RTClib.h>
#include <DHT.h>
#include <Wire.h>
#include <Keypad.h>
RTC_DS1307 rtc;
char daysOfTheWeek[7][24] = {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
};
const int ROW_NUM = 2;
const int COLUMN_NUM = 2;
char keys[ROW_NUM][COLUMN_NUM] = {
{'1','2'},
{'3','4'},
};
byte pin_rows[ROW_NUM] = {22, 32}; //connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {24, 25}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
LiquidCrystal_I2C lcd(0x27, 20, 4);
// Pressure variables
#define PS A15
float pressure;
unsigned long mpxBuff;
long int mpxAverage;
const int sample = 500;
float V;
// Flow sensor variables
#define type YFS201
FlowSensor Sensor(type, sig);
float volume;
float flowRate;
const byte dip[] = {30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41};
int bin;
// Serial Variables
int address;
char data[64] = {0};
int y100;
int y200;
int y300;
int commandEStop = 91;
int typeIdent = 350;
int requestFlow = 101;
int requestPressure = 102;
int requestLevel = 103;
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Serial: Baud 9600");
delay(1000);
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
if (! rtc.begin()) {
abort();
lcd.setCursor(0,1);
lcd.print("RTC ERROR");
}
else {
lcd.setCursor(0,1);
lcd.print("RTC Begin");
}
delay(1000);
lcd.clear();
Sensor.begin(count);
pinMode(dip[0], INPUT_PULLUP);
pinMode(dip[1], INPUT_PULLUP);
pinMode(dip[2], INPUT_PULLUP);
pinMode(dip[3], INPUT_PULLUP);
pinMode(dip[4], INPUT_PULLUP);
pinMode(dip[5], INPUT_PULLUP);
pinMode(dip[6], INPUT_PULLUP);
pinMode(dip[7], INPUT_PULLUP);
pinMode(dip[8], INPUT_PULLUP);
pinMode(dip[9], INPUT_PULLUP);
pinMode(dip[10], INPUT_PULLUP);
pinMode(dip[11], INPUT_PULLUP);
pinMode(txEnable, OUTPUT);
digitalWrite(txEnable, LOW);
digitalWrite(levelEnable, LOW);
delay(1000);
bin = 101;
if(digitalRead(dip[0]) == LOW) {
bin = bin + 1;
}
delay(10);
if(digitalRead(dip[1]) == LOW) {
bin = bin + 2;
}
delay(10);
if(digitalRead(dip[2]) == LOW) {
bin = bin + 4;
}
delay(10);
if(digitalRead(dip[3]) == LOW) {
bin = bin + 8;
}
delay(10);
if(digitalRead(dip[4]) == LOW) {
bin = bin + 16;
}
delay(10);
address = bin;
Serial.print(address);
Serial.print(",");
Serial.println(typeIdent);
}
void loop() {
// put your main code here, to run repeatedly:
}
void count() {
Sensor.count();
}SVDC
SVDY
Limit 1
Limit 2
D1T
D2T
RCP
RCD
Pressure