I compiled my sketch and there were no errors. I added an additional Water_Level_Sensor and recompiled the sketch and received the error - 'Check_Water_Flow' was not declared in this scope. I not sure how much detail is needed to help me solve this issue. Therefore, I will include the entire sketch.
Perhaps a little background as to the purpose of the sketch. I'm building a CNC machine that will have a water cooled spindle for the cutter. I had a router and the noise was deafening. Water is critical to keep the spindle at a safe operating temperature. To ensure this is accomplished I have 5 sensors on the machine to monitor the operation. The sensors are as follows:
1. Flow_Sensor - verifies water is being pumped through the cooling tubing.
2. Water_Pressure_Sensor - verifies pressure is at the proper level.
3. Water_Level_Sensor - verifies adequate water is in cooling reservoir.
4. Water_Level_Sensor_2 - verifies adequate water is in pumping reservoir.
5. Water_Temp - reports the temperature of the water.
I have a LCD display attached for showing current status of the CNC Machine. There are comments throughout the sketch. Some are for future functionality and others for sketch documentation.
Sketch:
/* Arduino DS18B20 temp sensor and YF ‐ S201 Water Flow Sensor
for Openbuilds 1515 CNC machine with 220V water cooled spindle
Water Flow Sensor output processed to read in "bool".
HIGH = Water Flow, LOW = No Water Flow.
Plastic PP Float Switch Tank Liquid Water Level Sensor, Model: DP5200
1/4" DC 24V Low Pressure Switch for Water Filter System 0.01MPa
SunFounder 2004 20x4 LCD Module IIC I2C Interface Adapter Blue Backlight */
/* Arduino DS18B20 temp sensor and YF ‐ S201 Water Flow Sensor
for Openbuilds 1515 CNC machine with 220V water cooled spindle
Water Flow Sensor output processed to read in "bool". HIGH = Water Flow, LOW = No Water Flow.
Plastic PP Float Switch Tank Liquid Water Level Sensor, Model: DP5200
1/4" DC 24V Low Pressure Switch for Pump Water Filters for Water Filter System 0.01MPa
SunFounder 2004 20x4 LCD Module IIC I2C Interface Adapter Blue Backlight */
//Include libraries
//Temperature sensor libraries
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
// #include "Keyboard.h"
//Configure LCD display
LiquidCrystal_I2C lcd(0x27, 20, 4);
//Define Constants
const int Buzzer = 2; //Assign buzzer to Arduino pin 2
const int Flow_Sensor = 3; //Assign Water Flow Sensor Input to Arduino pin 3
#define ONE_WIRE_BUS 4 //Assign ONE_WIRE_BUS to Arduino pin 4
const int Overheat_Fan = 5; //Assign Overheat_Fan to Arduino pin 5
const int Red_STOP = 6; //Assign Red_STOP to Arduino pin 6
const int Amber_CAUTION = 7; //Assign Caution to Arduino pin 7
const int Green_GO = 8; //Assign All_Systems_Go to Arduino pin 8
const int Water_Pressure_Sensor = 9; //Assign Water Level Sensor Input to Arduino pin 9
const int Water_Level_Sensor = 10; //Assign Water Level Sensor Input to Arduino pin 10
const int Water_Level_Sensor_2 = 11; //Assign Water Level Sensor Input to Arduino pin 11
//Configure Variables
float Water_Temp; // Variable to store temperature in Fahrenheit
bool Water_Flow;
bool Water_Level;
bool Water_Level_2;
bool Water_Pressure;
bool Displayed_All_Systems_Go;
bool TempOK;
//Configure ONE_WIRE_BUS
OneWire oneWire(ONE_WIRE_BUS); //Setup a oneWire instance to communicate with any OneWire device
DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature.
void setup() {
//Configure I/O Pins
pinMode(Flow_Sensor, INPUT);
pinMode(Water_Pressure_Sensor, INPUT);
pinMode(Water_Level_Sensor, INPUT);
pinMode(Water_Level_Sensor_2, INPUT);
pinMode(Buzzer, OUTPUT); //Buzzer to Arduino pin 2
pinMode(Overheat_Fan, OUTPUT); //Overheat fan Arduino pin 5
pinMode(Red_STOP, OUTPUT); //RED WARNING LED Arduino pin 6
pinMode(Amber_CAUTION, OUTPUT); //AMBER WARNING LED Arduino pin 7
pinMode(Green_GO, OUTPUT); //ALL SYSTEMS OK! GREEN LED Arduino pin 8
// digitalWrite(Water_Pressure_Sensor, 1); //Set pullup for Check_Water_Pressure High
digitalWrite(Water_Level_Sensor, 1); //Set pullup for Water_Level_Sensor High
digitalWrite(Water_Level_Sensor_2, 1); //Set pullup for Water_Level_Sensor High
lcd.begin();
lcd.clear();
//Initate Serial Communicatioon.
Serial.begin(9600);
}
void loop(){
// ADD KEYBOARD INPUT LATER TO TURN-ON DEBUG OPTIONS
//Write code to check temperature BEFORE displaying ALL GOOD!
//Check for water flow
*************************************************************
* *
**Water_Flow = Check_Water_Flow(); //THIS IS WHERE THE ERROR OCCURS**
* *
*************************************************************
Water_Pressure = Check_Water_Pressure();
Water_Level = Check_Water_Level();
Water_Level_2 = Check_Water_Level_2();
Water_Temp = Check_Water_Temp();
Serial.print("Water_Level = ");
Serial.print(Water_Level);
Serial.print("\n");
Serial.print("Water_Level_2 = ");
Serial.print(Water_Level_2);
Serial.print("\n");
Serial.print("Water_Pressure = ");
Serial.print(Water_Pressure);
Serial.print("\n");
Serial.print("Water_Temp = ");
Serial.print(Water_Temp);
Serial.print("\n\n");
/*
lcd.setCursor(0,3);
lcd.print("CWTRL = ");
lcd.print(Water_Level);
*/
if (Water_Temp>90){
Temp_Over_90(); //GOSUB Temp Over 90
}
else if (Water_Temp >= 80 && Water_Temp <= 90){
Temp_Between_80_and_90(); //GOSUB Temp_Between_80_and_90
Serial.print("TempOK = ");
Serial.print(TempOK);
Serial.print("\n\n");}
//Is Water_Flow Good
else if(Water_Flow == 1){
Display_All_Good();
Serial.print("********************* \n"); //Print Openbuilds 1515 message
Serial.print("* Openbuilds 1515 * \n"); //Print Openbuilds 1515 message
Serial.print("* CNC MACHINE *\n"); //Print CNC MACHINE message
Serial.print("* All Systems Good! *\n"); //Print CNC MACHINE message
Serial.print("********************* \n"); //Print Openbuilds 1515 message
Serial.print("\n");
// delay(1000);}
else{
//NO Water_Flow
//Call Warning Function for NO WATER FLOW
lcd.clear();
NO_WATER_FLOW();
Serial.print("******************* \n"); //Print WARNING message
Serial.print("* W A R N I N G *\n");
Serial.print("* N O W A T E R *\n");
Serial.print("* F L O W *\n");
Serial.print("******************* \n"); //Print WARNING message
Serial.print("\n");
delay(500);}
if (Water_Level == 1){
// lcd.clear();
// lcd.setCursor(10,3);
// lcd.print("DWL = ");
// lcd.print(Detect_Water_Level);}
//Read Temperature sensor
/*
// if (Water_Temp >= 76 && Water_Temp < 80){
// Temp_Over_76_and_Under_80(); //GOSUB Temp_Over_76_and_Under_80
// }
if (Water_Temp < 76){
Temp_Under_76(); //GOSUB Temp_Under_76
}
//*/
}
}
**int Check_Water_Flow(){** This is where I receive the error c
// bool result;
Water_Flow = digitalRead(Flow_Sensor);
return Water_Flow;
}
int Check_Water_Level(){
Water_Level = digitalRead(Water_Level_Sensor);
return Water_Level;
}
int Check_Water_Level_2(){
Water_Level_2 = digitalRead(Water_Level_Sensor_2);
return Water_Level_2;
}
int Check_Water_Pressure(){
Water_Pressure = digitalRead(Water_Pressure_Sensor);
return Water_Pressure;
}
float Check_Water_Temp(){
sensors.requestTemperatures(); //Read temperature sensor
Water_Temp = sensors.getTempFByIndex(0);
// Serial.print("Water_Temp = ");
// Serial.print(Water_Temp);
// Serial.print("\n\n");
return Water_Temp;
}
void Display_All_Good(){
if(Displayed_All_Systems_Go == 0){
lcd.clear();
lcd.setCursor(3,0);
lcd.print("Openbuilds 1515"); //Print Openbuilds 1515 message
lcd.setCursor(5,1);
lcd.print("CNC MACHINE"); //Print CNC MACHINE message
lcd.setCursor(2,2);
lcd.print("All Systems Good!"); //Print CNC MACHINE message
digitalWrite(Green_GO, HIGH);
digitalWrite(Buzzer, 0);
digitalWrite(Red_STOP, 0);
Displayed_All_Systems_Go = 1;}
else{
lcd.setCursor(3,0);
lcd.print("Openbuilds 1515"); //Print Openbuilds 1515 message
lcd.setCursor(5,1);
lcd.print("CNC MACHINE"); //Print CNC MACHINE message
lcd.setCursor(2,2);
lcd.print("All Systems Good!"); //Print CNC MACHINE message
digitalWrite(Green_GO, !HIGH);
digitalWrite(Red_STOP, 0);
digitalWrite(Buzzer, 0);
Displayed_All_Systems_Go = 1;}
return 0;
}
void NO_WATER_FLOW(){
lcd.clear();
lcd.setCursor(3, 2);
lcd.print(" ");
delay(1000);
lcd.setCursor(3, 2);
lcd.print("NO WATER FLOW");
// delay(1000);
digitalWrite(Green_GO, HIGH);
digitalWrite(Buzzer, 1);
digitalWrite(Amber_CAUTION, 0);
digitalWrite(Red_STOP, 1);
digitalWrite(Overheat_Fan, 0);
//Remove // below to run Debug code for no water flow
//Debug_NO_WATER_FLOW(); //GOSUB Debug_NO_WATER_FLOW
//^^^End Troubleshooting Volume and Flow Rate^^^^^
return 0;
}
void Good_Water_Flow(){
Serial.println("Entering Good_Water_Flow \t");
lcd.clear();
Display_All_Good();
return 0;
}
void Debug_NO_WATER_FLOW(){
//Debug code
lcd.setCursor(0,0);
lcd.print("DEBUG NO WATER FLOW");
return 0;
}
void Temp_Over_90(){
/*
lcd.clear();
lcd.setCursor(0,2);
lcd.print("Temp is > 90");
*/
digitalWrite(Overheat_Fan, 1);
digitalWrite(Amber_CAUTION, 1);
digitalWrite(Red_STOP, 1);
lcd.setCursor(3, 3);
lcd.print("Water_Temp = ");
lcd.print(Water_Temp);
TempOK = 0;
return TempOK;
}
void Temp_Between_80_and_90(){
lcd.clear();
lcd.setCursor(0,2);
lcd.print("80 < Temp < 90");
digitalWrite(Overheat_Fan, 1);
digitalWrite(Amber_CAUTION, 1);
lcd.setCursor(3, 3);
lcd.print("Water_Temp = ");
lcd.print(Water_Temp);
TempOK = 1;
return TempOK;
}
What do you think that '**' in front of Water_Flow does?
Same question here. Why are you trying to return a pointer to a pointer to an int?
I was trying to make that line show up as BOLD to mark where the error is. I'm not familiar with is forum.
That is irrelevant, it is C/C++ code you are writing, so use C/C++ syntax.
There is no way to make a line bold in the C/C++ language, so don't even try.
Not sure about that error, but you are trying to return an awful lot of values from void functions.
It looks like LiquidCrystal_I2C .begin() takes 3 values, you are giving 0.
All of your function definitions are inside loop(). Use ctrl+t and make sure all function definitions start at the left hand column. Check your { and } to make sure they match.
Make sure all comments start with // not *
Your loop function doesn't end - missing at least one closing brace: }
Also, don't put garbage like this inside the Code Tags without making it a proper comment. That's just multiple lines of junk we have to fix before we attempt to compile it:
I compiled my sketch and there were no errors. I added an additional Water_Level_Sensor and recompiled the sketch and received the error - 'Check_Water_Flow' was not declared in this scope. I not sure how much detail is needed to help me solve this issue. Therefore, I will include the entire sketch.
Perhaps a little background as to the purpose of the sketch. I'm building a CNC machine that will have a water cooled spindle for the cutter. I had a router and the noise was deafening. Water is critical to keep the spindle at a safe operating temperature. To ensure this is accomplished I have 5 sensors on the machine to monitor the operation. The sensors are as follows:
1. Flow_Sensor - verifies water is being pumped through the cooling tubing.
2. Water_Pressure_Sensor - verifies pressure is at the proper level.
3. Water_Level_Sensor - verifies adequate water is in cooling reservoir.
4. Water_Level_Sensor_2 - verifies adequate water is in pumping reservoir.
5. Water_Temp - reports the temperature of the water.
I have a LCD display attached for showing current status of the CNC Machine. There are comments throughout the sketch. Some are for future functionality and others for sketch documentation.
Sketch:
Commenting out a line with a '}' is going to cause problems.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.