# Folks, I am new to Arduino. Need help to automate water tank (water quantity)

**URL:** <https://forum.arduino.cc/t/folks-i-am-new-to-arduino-need-help-to-automate-water-tank-water-quantity/482150>\
**Category:** General Guidance\
**Created:** [September 24, 2017, 7:01am UTC](https://forum.arduino.cc/t/folks-i-am-new-to-arduino-need-help-to-automate-water-tank-water-quantity/482150 "2017-09-24T07:01:26Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![somairm](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@somairm](https://forum.arduino.cc/u/somairm)\
**Post date:** [October 2, 2017, 10:29am UTC](https://forum.arduino.cc/t/folks-i-am-new-to-arduino-need-help-to-automate-water-tank-water-quantity/482150/21 "2017-10-02T10:29:27Z")

</div>

Hello

Based on the below code how to connect the sensor to microprocessor

\</\>

_-----( Setup function )-----_/  
void setup() {  
Serial.begin(9600);  
pinMode(8, INPUT\_PULLUP);  
}

/_-----( Loop function )-----_/  
void loop() {  
boolean run\_cycle = true;  
const int lowerSersor = digitalRead(8); // lower float sensor on digital pin 8

if (lowerSersor == LOW) { // float sensor has dropped down - tank empty  
// Toggle on  
if (run\_cycle) {  
sendSMS();  
run\_cycle = false;  
}  
}  
if (lowerSensor == HIGH) { // tank now full  
// Toggle off  
if (run\_cycle == false) {  
run\_cycle = true;  
}  
}  
}

void sendSMS() {  
// Some code here to send a sms  
Serial.println("AT");  
delay(1000);  
Serial.println("AT+CMGF=1"); // send SMS in text mode  
delay(1000);  
Serial.println("AT+CMGS="+01XXXX""); //CHANGE TO Number , you'd like to receive message  
delay(1000);  
Serial.print("Water level is low in underground tank (attention required)"); // content of the message  
Serial.write(26); // ctrl+z ASCII code  
}

---

<div class="post-metadata">

**Author:** ![wvmarle](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/wvmarle/32/1013044_2.png) [@wvmarle](https://forum.arduino.cc/u/wvmarle)\
**Post date:** [October 3, 2017, 2:36am UTC](https://forum.arduino.cc/t/folks-i-am-new-to-arduino-need-help-to-automate-water-tank-water-quantity/482150/22 "2017-10-03T02:36:20Z")

</div>

Please add code tags when posting code (the \</\> button in the editor) as there are smileys in the code.

Anyway based on what I can read: sensor is expected to connect to pin 8, and just acts like a regular switch, active LOW.

---

<div class="post-metadata">

**Author:** ![somairm](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@somairm](https://forum.arduino.cc/u/somairm)\
**Post date:** [October 12, 2017, 6:14am UTC](https://forum.arduino.cc/t/folks-i-am-new-to-arduino-need-help-to-automate-water-tank-water-quantity/482150/23 "2017-10-12T06:14:50Z")

</div>

Hello..

when i copy past the code to UNO it give me following error

Arduino: 1.8.4 (Mac OS X), Board: "Arduino/Genuino Uno"

/Users/Omair/Downloads/F1ILXY7IDIN9JKB/F1ILXY7IDIN9JKB.ino: In function 'void loop()':  
F1ILXY7IDIN9JKB:15: error: 'sendSMS' was not declared in this scope  
sendSMS();  
^  
F1ILXY7IDIN9JKB:19: error: 'lowerSensor' was not declared in this scope  
if (lowerSensor == HIGH) { // tank now full  
^  
/Users/Omair/Downloads/F1ILXY7IDIN9JKB/F1ILXY7IDIN9JKB.ino: In function 'void setup()':  
F1ILXY7IDIN9JKB:33: error: redefinition of 'void setup()'  
void setup()  
^  
/Users/Omair/Downloads/F1ILXY7IDIN9JKB/F1ILXY7IDIN9JKB.ino:2:6: note: 'void setup()' previously defined here  
void setup() {  
^  
/Users/Omair/Downloads/F1ILXY7IDIN9JKB/F1ILXY7IDIN9JKB.ino: In function 'void loop()':  
F1ILXY7IDIN9JKB:41: error: redefinition of 'void loop()'  
void loop()  
^  
/Users/Omair/Downloads/F1ILXY7IDIN9JKB/F1ILXY7IDIN9JKB.ino:8:6: note: 'void loop()' previously defined here  
void loop() {  
^  
exit status 1  
'sendSMS' was not declared in this scope

This report would have more information with  
"Show verbose output during compilation"  
option enabled in File -\> Preferences.

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [October 12, 2017, 7:19am UTC](https://forum.arduino.cc/t/folks-i-am-new-to-arduino-need-help-to-automate-water-tank-water-quantity/482150/24 "2017-10-12T07:19:02Z")

</div>

Hi,  
Please read the first post in any forum entitled how to use this forum.  
[http://forum.arduino.cc/index.php/topic,148850.0.html](http://forum.arduino.cc/index.php/topic,148850.0.html) then look down to item #7 about how to post your code.  
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... 🙂

---

<div class="post-metadata">

**Author:** ![somairm](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@somairm](https://forum.arduino.cc/u/somairm)\
**Post date:** [October 12, 2017, 8:23am UTC](https://forum.arduino.cc/t/folks-i-am-new-to-arduino-need-help-to-automate-water-tank-water-quantity/482150/25 "2017-10-12T08:23:16Z")

</div>

Hello.

Somehow I am not able to see this \<\> in the editor.

---

<div class="post-metadata">

**Author:** ![somairm](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@somairm](https://forum.arduino.cc/u/somairm)\
**Post date:** [October 12, 2017, 8:29am UTC](https://forum.arduino.cc/t/folks-i-am-new-to-arduino-need-help-to-automate-water-tank-water-quantity/482150/26 "2017-10-12T08:29:32Z")

</div>

Hello... Need some help Getting error message when verifying the code.  
Error message attached as attachment.

```cpp
/*-----( Setup function )-----*/
void setup() {
  Serial.begin(9600);
  pinMode(8, INPUT_PULLUP);
}

/*-----( Loop function )-----*/
void loop() {
  boolean run_cycle = true;
  const int lowerSersor = digitalRead(8); // lower float sensor on digital pin 8

  if (lowerSersor == LOW) { // float sensor has dropped down - tank empty
    // Toggle on
    if (run_cycle) {
      sendSMS();
      run_cycle = false;
    }
  }
  if (lowerSensor == HIGH) { // tank now full
    // Toggle off
    if (run_cycle == false) {
      run_cycle = true;
    }
  }
}

//ERFINDER CODE
#include <SoftwareSerial.h>

SoftwareSerial mySerial(9, 10);

void setup()
{
  mySerial.begin(9600);  // Setting the baud rate of GSM Module  
  Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)
  delay(100);
}

void loop()
{
  if (Serial.available()>0)
  switch(Serial.read())
  {
    case 's':
      SendMessage();
      break;
    case 'r':
      RecieveMessage();
      break;
  }

 if (mySerial.available()>0)
  Serial.write(mySerial.read());
}

 void SendMessage()
{
  mySerial.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
  delay(1000);  // Delay of 1000 milli seconds or 1 second
  mySerial.println("AT+CMGS=\"+923400008550\"\r"); // Replace x with mobile number
  delay(1000);
  mySerial.println("I am SMS from GSM Module");// The SMS text you want to send
  delay(100);
  mySerial.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
}

 void RecieveMessage()
{
  mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to recieve a live SMS
  delay(1000);
 }

```

 ![Screen Shot 2017-10-12 at 13.28.32.png](https://europe1.discourse-cdn.com/arduino/original/4X/8/9/e/89e6b937b69a1cf23ec9899e5482684369f32d65.png)

---

<div class="post-metadata">

**Author:** ![wvmarle](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/wvmarle/32/1013044_2.png) [@wvmarle](https://forum.arduino.cc/u/wvmarle)\
**Post date:** [October 12, 2017, 8:44am UTC](https://forum.arduino.cc/t/folks-i-am-new-to-arduino-need-help-to-automate-water-tank-water-quantity/482150/27 "2017-10-12T08:44:53Z")

</div>

The error message:

> 'sendSMS()' was not declared in this scope.

True.  
Maybe you forgot to write that function?

---

<div class="post-metadata">

**Author:** ![somairm](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@somairm](https://forum.arduino.cc/u/somairm)\
**Post date:** [October 12, 2017, 9:54am UTC](https://forum.arduino.cc/t/folks-i-am-new-to-arduino-need-help-to-automate-water-tank-water-quantity/482150/28 "2017-10-12T09:54:12Z")

</div>

Hello Edison.

Still it is giving me error.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 6:21pm UTC](https://forum.arduino.cc/t/folks-i-am-new-to-arduino-need-help-to-automate-water-tank-water-quantity/482150/29 "2021-05-05T18:21:08Z")

</div>



[Previous page](https://forum.arduino.cc/t/folks-i-am-new-to-arduino-need-help-to-automate-water-tank-water-quantity/482150.md?page=1)
