hi guys
can u help me with my program?
i would like to send 3 data from 3 different sensors , via GSM module . but my program didn't work , when i see the serial monitor of the arduino there are many different readings that i cannot understand.
PLEASE HELP ME FIXED IT
here's my program
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);
float conductivity =A0;
float meter = 0;
float sensorValue = 0; // value read from the pot
float outputValue = 0; // value output to the PWM (analog out)
float turbidity =A1;
float sensorValuet = 0; // value read from the pot
float outputValuet = 0;
float chlorine =A2;
float sensorValuec = 0; // value read from the pot
float outputValuec = 0;
void setup()
{
Serial.begin(57600);
Serial.println(" \t\t WATER QUALITY MONITORING");
// set the data rate for the SoftwareSerial port
mySerial.begin(19200);
//mySerial.println("Hello, world?");
}
void loop()
{
delay(10000);
SendTextMessage();
//reading = analogRead(conductivity);
}
///SendTextMessage()
///this function is to send a sms message
void SendTextMessage()
{
//reading();
delay(1000);
sensorValue = analogRead(conductivity);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 7, 0);
// change the analog out value:
//analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("\t reading ph = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
//turbidity
sensorValuet = analogRead(turbidity);
// map it to the range of the analog out:
outputValuet = map(sensorValuet, 0, 1023, 0, 255);
// change the analog out value:
//analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("\t reading turbidity = " );
Serial.print(sensorValuet);
Serial.print("\t output = ");
Serial.println(outputValuet);
//chlorine
sensorValuec = analogRead(chlorine);
// map it to the range of the analog out:
outputValuec = map(sensorValuec, 0, 1023, 0, 255);
// print the results to the serial monitor:
Serial.print("\t reading residual= " );
Serial.print(sensorValuec);
Serial.print("\t output = ");
Serial.println(outputValuec);
delay(100);
mySerial.print("AT+CMGF=1\r"); //Because we want to send the SMS in text mode
delay(100);
mySerial.println("AT+CMGS ="+639996385881"");//send sms message, be careful need to add a country code before the cellphone number
delay(100);
mySerial.println(outputValue);//the content of the message
mySerial.println(" ph ");
//delay(100);
//mySerial.print(outputValuet);//the content of the message
//mySerial.print("NTU");
// delay(100);
//mySerial.print(outputValuec);//the content of the message
//mySerial.print("mg/l");
//delay(100);
// mySerial.println((char)26);//the ASCII code of the ctrl+z is 26
delay(1000);
//mySerial.println();
}
void reading()
{
sensorValue = analogRead(conductivity);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 7, 0);
// change the analog out value:
//analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("\t reading ph = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
//turbidity
sensorValuet = analogRead(turbidity);
// map it to the range of the analog out:
outputValuet = map(sensorValuet, 0, 1023, 0, 255);
// change the analog out value:
//analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("\t reading turbidity = " );
Serial.print(sensorValuet);
Serial.print("\t output = ");
Serial.println(outputValuet);
//chlorine
sensorValuec = analogRead(chlorine);
// map it to the range of the analog out:
outputValuec = map(sensorValuec, 0, 1023, 0, 255);
// change the analog out value:
//analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("\t reading residual= " );
Serial.print(sensorValuec);
Serial.print("\t output = ");
Serial.println(outputValuec);
}