top of page

Sensorflow
K6a4aIRll5uIFCyEE
Product Dashboard
Product Name
Sensorflow Bottle Filler B
Product Type
Hardware
Product ID
T5htPMwxQeRpRatf
Product Info
Heading 5
Properties/ Schema
Check
Product Firmware
Your content has been submitted
An error occurred. Try again later
Production
Device Name
User ID
Lastseen
Sensorflow Bottle Filler B
T5htPMwxQeRpRatf
Sensorflow Bottle Filler B
T5htPMwxQeRpRatf
Sensorflow Bottle Filler B
T5htPMwxQeRpRatf
Sensorflow Bottle Filler B
T5htPMwxQeRpRatf
Sensorflow Bottle Filler B
T5htPMwxQeRpRatf
Sensorflow Bottle Filler B
T5htPMwxQeRpRatf
Sensorflow Bottle Filler B
T5htPMwxQeRpRatf
Sensorflow Bottle Filler B
T5htPMwxQeRpRatf
Sensorflow Bottle Filler B
T5htPMwxQeRpRatf
Sensorflow Bottle Filler B
T5htPMwxQeRpRatf
Sensorflow Bottle Filler B
T5htPMwxQeRpRatf
Sensorflow Bottle Filler B
T5htPMwxQeRpRatf
Sensorflow Bottle Filler B
T5htPMwxQeRpRatf
Sensorflow Bottle Filler B
T5htPMwxQeRpRatf
#include
#include
#include "BluetoothSerial.h"
#include
#include
#include
#include
#include
BluetoothSerial SerialBT;
Preferences preferences;
const int numReadings1 = 10;
const int numReadings2 = 10;
const int pnumReadings1 = 1;
const int pnumReadings2 = 1;
const int pnumReadings1000ml = 1;
const int pnumReadings500ml = 1;
const int pnumReadings250ml = 1;
const int pnumReadings100ml = 1;
volatile int flowPulse1 = 0; // Initialize a variable to count the pulses from the sensor
volatile int flowPulse2 = 0; // Initialize a variable to count the pulses from the sensor
float flowRate1 = 0.0; // Initialize a variable to store the flow rate
float flowRate2 = 0.0; // Initialize a variable to store the flow rate
float totalVolume1 = 0.0; // Initialize a variable to store the total volume
float totalVolume2 = 0.0; // Initialize a variable to store the total volume
float Myvalume1 = 0.0;
float Myvalume2 = 0.0;
const int lcdColumns = 16;
const int lcdRows = 2;
//pushpins
const int PushButton1 = 32;
const int PushButton2 = 33;
const int pushpin1000 = 35;
const int pushpin500 = 34;
const int pushpin250 = 14;
const int pushpin100 = 27;
const int CH1flowPin = 12;
const int CH2flowPin = 13;
// pins
//#define SDA 21
//#define SCL 22
#define TRIGGER_PIN1 5
#define ECHO_PIN1 18
#define TRIGGER_PIN2 26
#define ECHO_PIN2 25
#define CH_1 23
#define CH_2 15
#define MAX_DISTANCE 200
#define buzz 2
LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows);
int SPACE = 0;
int distance1 = 0;
int distance2 = 0;
int bottolecount = 0;
int wifidelay = 0;
int valume1 = 0;
int valume2 = 0;
int start1 = 0;
int start2 = 0;
int pushstate1 = 0;
int pushstate2 = 0;
int button1000ml = 0;
int button500ml = 0;
int button250ml = 0;
int button100ml = 0;
NewPing sonar1(TRIGGER_PIN1, ECHO_PIN1, MAX_DISTANCE);
NewPing sonar2(TRIGGER_PIN2, ECHO_PIN2, MAX_DISTANCE);
String NAME = "
";
String header;
String apikey;
String userid;
String deviceid;
String ssid;
String pass;
int E_delay;
char buffer[10];
char jsonOutput[512];
WiFiServer server(80);
void setup() {
pinMode(CH_1, OUTPUT);
pinMode(CH_2, OUTPUT);
pinMode(buzz, OUTPUT);
pinMode(PushButton1, INPUT);
pinMode(PushButton2, INPUT);
pinMode(pushpin1000, INPUT);
pinMode(pushpin500, INPUT);
pinMode(pushpin250, INPUT);
pinMode(pushpin100, INPUT);
delay(100);
digitalWrite(CH_1, LOW);
digitalWrite(CH_2, LOW);
delay(1000);
preferences.begin("my-app", false);
delay(1000);
Wire.begin();
lcd.begin(lcdColumns, lcdRows);
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Senflow Bottle");
lcd.setCursor(2, 1);
lcd.print(" Filler");
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("--Powered by");
lcd.setCursor(0, 1);
lcd.print("NIKOLAINDUSTRY");
delay(2000);
Serial.begin(115200);
distance1 = sonar1.ping_cm();
distance2 = sonar2.ping_cm();
lcd.clear();
delay(500);
apikey = preferences.getString("apikey");
userid = preferences.getString("userid");
deviceid = preferences.getString("deviceid");
ssid = preferences.getString("ssid");
pass = preferences.getString("pass");
SPACE = preferences.getInt("DISTANCE");
valume1 = preferences.getInt("valume1");
valume2 = preferences.getInt("valume2");
bottolecount = preferences.getInt("BOTCOUNT");
delay(500);
lcd.setCursor(0, 0);
lcd.print("Filler Valume:");
lcd.setCursor(0, 1);
lcd.print(valume1);
lcd.setCursor(6, 1);
lcd.print(valume2);
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Senser Space:");
lcd.setCursor(0, 1);
lcd.print(SPACE);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Apikey:");
lcd.setCursor(0, 1);
lcd.print(apikey);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SSID");
lcd.setCursor(0, 1);
lcd.print(ssid);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("PASS");
lcd.setCursor(0, 1);
lcd.print(pass);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Bottle History");
lcd.setCursor(0, 1);
lcd.print(bottolecount);
delay(1000);
lcd.clear();
// lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Place Bottle");
lcd.setCursor(0, 1);
lcd.print("On Machine");
delay(1000);
//lcd.clear();
WiFi.disconnect();
delay(50);
WiFi.setHostname(NAME.c_str());
WiFi.begin(ssid.c_str(), pass.c_str());
delay(500);
Serial.println("connected to");
Serial.println(ssid);
Serial.println(pass);
Serial.println(WiFi.localIP());
server.begin();
digitalWrite(buzz, HIGH);
delay(500);
digitalWrite(buzz, LOW);
delay(100);
// put your setup code here, to run once:
attachInterrupt(digitalPinToInterrupt(CH1flowPin), flow1, RISING);
delay(20);
attachInterrupt(digitalPinToInterrupt(CH2flowPin), flow2, RISING);
}
void loop() {
while ((WiFi.status() != WL_CONNECTED)) {
startBT();
}
pushbutton1();
pushbutton2();
pushbuttonfor1000ml();
pushbuttonfor500ml();
pushbuttonfor250ml();
pushbuttonfor100ml();
flowrate1();
flowrate2();
runn1();
runn2();
}
void flow1() {
flowPulse1++;
}
void flow2() {
flowPulse2++;
}
void flowrate1() {
flowRate1 = (flowPulse1 / 7.5); // 7.5 is a constant for the sensor you have
// Calculate the volume in milliliters
float deltaTime1 = 1.0; // Change in time (1 second)
float volumeIncrement1 = flowRate1 * deltaTime1;
totalVolume1 += volumeIncrement1;
Myvalume1 = totalVolume1 * 2;
// Check if the total volume has reached the resetVolume
if (Myvalume1 >= valume1) {
totalVolume1 = 0.0;
Myvalume1 = 0.0;
start1 = 0;
bottolecount++;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("BT:");
lcd.setCursor(0, 1);
lcd.print(bottolecount);
lcd.setCursor(4, 0);
lcd.print("V1");
lcd.setCursor(4, 1);
lcd.print(Myvalume1);
lcd.setCursor(9, 0);
lcd.print("V2");
lcd.setCursor(9, 1);
lcd.print(Myvalume2);
pushstate1 = 0;
start1 = 0;
digitalWrite(CH_1, LOW);
wifidelay++;
if (wifidelay == 10) {
wifi();
}
}
// Print the flow rate and total volume to the serial monitor
Serial.print("Flow Rate 1: ");
Serial.print(flowRate1);
Serial.println(" L/min");
Serial.print("Total Volume 1: ");
Serial.print(Myvalume1);
Serial.println(" ml");
// Reset the flowPulse count
flowPulse1 = 0;
// You can add more code here to do other tasks or send the data to IoT platforms.
delay(5);
}
void flowrate2() {
flowRate2 = (flowPulse2 / 7.5); // 7.5 is a constant for the sensor you have
// Calculate the volume in milliliters
float deltaTime2 = 1.0; // Change in time (1 second)
float volumeIncrement2 = flowRate2 * deltaTime2;
totalVolume2 += volumeIncrement2;
Myvalume2 = totalVolume2 * 2;
// Check if the total volume has reached the resetVolume
if (Myvalume2 >= valume2) {
// If so, reset the total volume to zero
totalVolume2 = 0.0;
Myvalume2 = 0.0;
bottolecount++;
start2 = 0;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("BT:");
lcd.setCursor(0, 1);
lcd.print(bottolecount);
lcd.setCursor(4, 0);
lcd.print("V1");
lcd.setCursor(4, 1);
lcd.print(Myvalume1);
lcd.setCursor(9, 0);
lcd.print("V2");
lcd.setCursor(9, 1);
lcd.print(Myvalume2);
// lcd.setCursor(4, 0);
// lcd.print("S1");
// lcd.setCursor(4, 1);
// lcd.print(distance1);
// lcd.setCursor(8, 0);
// lcd.print("S2");
// lcd.setCursor(8, 1);
// lcd.print(distance2);
pushstate2 = 0;
start2 = 0;
digitalWrite(CH_2, LOW);
preferences.putInt("BOTCOUNT", bottolecount);
wifidelay++;
if (wifidelay == 10) {
wifi();
}
}
// Print the flow rate and total volume to the serial monitor
Serial.print("Flow Rate 2: ");
Serial.print(flowRate2);
Serial.println(" L/min");
Serial.print("Total Volume 2: ");
Serial.print(Myvalume2);
Serial.println(" ml");
// Reset the flowPulse count
flowPulse2 = 0;
// You can add more code here to do other tasks or send the data to IoT platforms.
delay(5);
}
void runn1() {
unsigned int totalDistance1 = 0;
for (int i = 0; i < numReadings1; i++) {
totalDistance1 += sonar1.ping_cm();
delay(5);
}
distance1 = totalDistance1 / numReadings1;
if (distance1 < SPACE && distance1 != 0 && pushstate1 == 1 && start1 == 0 && Myvalume1 < valume1) {
start1 = 1;
} else if (pushstate1 == 0 && Myvalume1 < valume1) {
digitalWrite(CH_1, LOW);
//Serial.println("More");
} else {
digitalWrite(CH_1, LOW);
}
if (start1 == 1) {
digitalWrite(CH_1, HIGH);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("BT:");
lcd.setCursor(0, 1);
lcd.print(bottolecount);
lcd.setCursor(4, 0);
lcd.print("V1");
lcd.setCursor(4, 1);
lcd.print(Myvalume1);
lcd.setCursor(9, 0);
lcd.print("V2");
lcd.setCursor(9, 1);
lcd.print(Myvalume2);
delay(5);
}
}
void runn2() {
unsigned int totalDistance2 = 0;
for (int i = 0; i < numReadings2; i++) {
totalDistance2 += sonar2.ping_cm();
delay(5);
}
distance2 = totalDistance2 / numReadings2;
if (distance2 < SPACE && distance2 != 0 && pushstate2 == 1 && start2 == 0 && Myvalume2 < valume2) {
start2 = 1;
//Serial.println("START2 ENTER SHOW Data");
Serial.println(pushstate2);
} else if (pushstate2 == 0 && Myvalume1 SPACE && distance2 == 0
digitalWrite(CH_2, LOW);
// Serial.println("More");
} else {
digitalWrite(CH_2, LOW);
}
if (start2 == 1) {
digitalWrite(CH_2, HIGH);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("BT:");
lcd.setCursor(0, 1);
lcd.print(bottolecount);
// lcd.setCursor(4, 0);
// lcd.print("S1");
// lcd.setCursor(4, 1);
// lcd.print(distance1);
// lcd.setCursor(8, 0);
// lcd.print("S2");
// lcd.setCursor(8, 1);
// lcd.print(distance2);
lcd.setCursor(4, 0);
lcd.print("V1");
lcd.setCursor(4, 1);
lcd.print(Myvalume1);
lcd.setCursor(9, 0);
lcd.print("V2");
lcd.setCursor(9, 1);
lcd.print(Myvalume2);
delay(5);
}
}
void wifi() {
wifidelay = 0;
if ((WiFi.status() == WL_CONNECTED)) {
digitalWrite(CH_1, LOW);
digitalWrite(CH_2, LOW);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Sending Data");
lcd.setCursor(0, 1);
lcd.print("To Server ");
lcd.setCursor(10, 1);
lcd.print(bottolecount);
//delay(50);
Serial.print("Connected to ");
Serial.println(ssid);
Serial.println(apikey);
//delay(50);
String startapi = "https://nikolaindustry.wixsite.com/hyperwisor/_functions/writeandupdatesensordata?apikey=" + apikey + "&BOTCOUNT=" + String(bottolecount); // update api function name
HTTPClient http;
// delay(50);
http.begin(startapi);
int httpPOSTCode = http.POST(startapi);
String payload = http.getString();
Serial.println(httpPOSTCode);
Serial.println(payload);
//delay(50);
http.end();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("BT:");
lcd.setCursor(0, 1);
lcd.print(bottolecount);
lcd.setCursor(4, 0);
lcd.print("V1");
lcd.setCursor(4, 1);
lcd.print(Myvalume1);
lcd.setCursor(9, 0);
lcd.print("V2");
lcd.setCursor(9, 1);
lcd.print(Myvalume2);
//lcd.clear();
} else {
}
}
void pushbutton1() {
int Push_button_state1 = 0;
unsigned int pushb1 = 0;
for (int i = 0; i < pnumReadings1; i++) {
pushb1 += digitalRead(PushButton1);
delay(10);
}
Push_button_state1 = pushb1 / pnumReadings1;
if (Push_button_state1 == HIGH) {
pushstate1 = 1;
} else {
}
}
void pushbutton2() {
int Push_button_state2 = 0;
unsigned int pushb2 = 0;
for (int i = 0; i < pnumReadings2; i++) {
pushb2 += digitalRead(PushButton2);
delay(10);
}
Push_button_state2 = pushb2 / pnumReadings2;
if (Push_button_state2 == HIGH) {
pushstate2 = 1;
} else {
}
}
void pushbuttonfor1000ml() {
int button1000ml = 0;
unsigned int button1000mlvalue = 0;
for (int i = 0; i < pnumReadings1000ml; i++) {
button1000mlvalue += digitalRead(pushpin1000);
delay(10);
}
button1000ml = button1000mlvalue / pnumReadings1000ml;
if (button1000ml == HIGH) {
Serial.println("1HIGH");
int b1v1 = preferences.getInt("B1VALUME1");
int b1v2 = preferences.getInt("B1VALUME2");
preferences.putInt("valume1", b1v1);
preferences.putInt("valume2", b1v2);
delay(500);
ESP.restart();
} else {
Serial.println("1LOW");
}
}
void pushbuttonfor500ml() {
int button500ml = 0;
unsigned int button500mlvalue = 0;
for (int i = 0; i < pnumReadings500ml; i++) {
button500mlvalue += digitalRead(pushpin500);
delay(10);
}
button500ml = button500mlvalue / pnumReadings500ml;
if (button500ml == HIGH) {
Serial.println("2HIGH");
int b2v1 = preferences.getInt("B2VALUME1");
int b2v2 = preferences.getInt("B2VALUME2");
preferences.putInt("valume1", b2v1);
preferences.putInt("valume2", b2v2);
delay(500);
ESP.restart();
} else {
Serial.println("2LOW");
}
}
void pushbuttonfor250ml() {
int button250ml = 0;
unsigned int button250mlvalue = 0;
for (int i = 0; i < pnumReadings250ml; i++) {
button250mlvalue += digitalRead(pushpin250);
delay(10);
}
button250ml = button250mlvalue / pnumReadings250ml;
if (button250ml == HIGH) {
Serial.println("3HIGH");
int b3v1 = preferences.getInt("B3VALUME1");
int b3v2 = preferences.getInt("B3VALUME2");
preferences.putInt("valume1", b3v1);
preferences.putInt("valume2", b3v2);
delay(500);
ESP.restart();
} else {
Serial.println("3LOW");
}
}
void pushbuttonfor100ml() {
int button100ml = 0;
unsigned int button100mlvalue = 0;
for (int i = 0; i < pnumReadings100ml; i++) {
button100mlvalue += digitalRead(pushpin100);
delay(10);
}
button100ml = button100mlvalue / pnumReadings100ml;
if (button100ml == HIGH) {
Serial.println("4HIGH");
int b4v1 = preferences.getInt("B4VALUME1");
int b4v2 = preferences.getInt("B4VALUME2");
preferences.putInt("valume1", b4v1);
preferences.putInt("valume2", b4v2);
delay(500);
ESP.restart();
} else {
Serial.println("4LOW");
}
}
void startBT() {
pushbutton1();
pushbutton2();
pushbuttonfor1000ml();
pushbuttonfor500ml();
pushbuttonfor250ml();
pushbuttonfor100ml();
flowrate1();
flowrate2();
runn1();
runn2();
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
SerialBT.begin(NAME.c_str());
if (SerialBT.available()) {
String btdata = SerialBT.readString();
Serial.println(btdata);
StaticJsonDocument jsonDoc;
DeserializationError error = deserializeJson(jsonDoc, btdata);
if (error) {
Serial.print("deserializeJson() failed: ");
Serial.println(error.c_str());
return;
}
String datatype = jsonDoc["Datatype"];
if (datatype == "wifiupdate") {
String Nssid = jsonDoc["ssid"];
String Npass = jsonDoc["pass"];
preferences.putString("ssid", Nssid);
preferences.putString("pass", Npass);
Serial.println("wifiinfoupdated");
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("WIFI INFO UPDATED");
digitalWrite(buzz, HIGH);
delay(5000);
digitalWrite(buzz, LOW);
delay(10);
ESP.restart();
} else if (datatype == "ALL") {
String Nssid = jsonDoc["ssid"];
String Npass = jsonDoc["pass"];
int NBOTCOUNT = jsonDoc["BOTCOUNT"];
int b1VALUME1 = jsonDoc["B1VALUME1"];
int b1VALUME2 = jsonDoc["B1VALUME2"];
int b2VALUME1 = jsonDoc["B2VALUME1"];
int b2VALUME2 = jsonDoc["B2VALUME2"];
int b3VALUME1 = jsonDoc["B3VALUME1"];
int b3VALUME2 = jsonDoc["B3VALUME2"];
int b4VALUME1 = jsonDoc["B4VALUME1"];
int b4VALUME2 = jsonDoc["B4VALUME2"];
int NDISTANCE = jsonDoc["DISTANCE"];
preferences.putInt("valume1", b1VALUME1);
preferences.putInt("valume2", b1VALUME1);
preferences.putInt("DISTANCE", NDISTANCE);
preferences.putString("ssid", Nssid);
preferences.putString("pass", Npass);
preferences.putInt("BOTCOUNT", NBOTCOUNT);
preferences.putInt("B1VALUME1", b1VALUME1);
preferences.putInt("B1VALUME2", b1VALUME2);
preferences.putInt("B2VALUME1", b2VALUME1);
preferences.putInt("B2VALUME2", b2VALUME2);
preferences.putInt("B3VALUME1", b3VALUME1);
preferences.putInt("B3VALUME2", b3VALUME2);
preferences.putInt("B4VALUME1", b4VALUME1);
preferences.putInt("B4VALUME2", b4VALUME2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("All info Updated");
digitalWrite(buzz, HIGH);
Serial.println("ALL NEW");
delay(5000);
digitalWrite(buzz, LOW);
delay(10);
ESP.restart();
} else if (datatype == "wifiinfo") {
Serial.println("datatype = wifiinfo");
String apikey = jsonDoc["apikey"];
String userid = jsonDoc["userid"];
String deviceid = jsonDoc["deviceid"];
String ssid = jsonDoc["ssid"];
String pass = jsonDoc["pass"];
if (ssid.length() > 0 && pass.length() > 0 && apikey.length() > 0) {
preferences.putString("apikey", apikey);
preferences.putString("userid", userid);
preferences.putString("deviceid", deviceid);
preferences.putString("ssid", ssid);
preferences.putString("pass", pass);
Serial.println(apikey);
Serial.println(userid);
Serial.println(ssid);
Serial.println(pass);
digitalWrite(buzz, HIGH);
delay(2000);
digitalWrite(buzz, LOW);
delay(1000);
digitalWrite(buzz, HIGH);
delay(2000);
digitalWrite(buzz, LOW);
delay(1000);
ESP.restart();
}
}
}
}
/*
© by NIKOLAINDUSTRY Technology infrastructure LLP
*/
Collapsible text is great for longer section titles and descriptions. It gives people access to all the info they need, while keeping your layout clean. Link your text to anything, or set your text box to expand on click. Write your text here...
bottom of page