Hello everyone,
i have been working on a small task for a while now, and i am sure i have gotten the hardware connections right, but i have had a lot of trouble writing the code because i am relatively new to arduino. the task i have been working on is described below:
i am trying to create a connection between an arduino uno, a potentiometer, and a gsm sim 808, so that i can send a simple command text message from my mobile phone to the gsm sim 808 which will say "read voltage " , the current voltage reading from the potentiometer which can be displayed on the serial monitor will be the reply which the gsm sim 808 will send as a text message back to my mobile phone. i have been unable to fix my code for this task to work properly so i really need some help and would really appreciate feed back and solutions from anyone willing to help me. thank you, the code is displayed below
type or #include <SoftwareSerial.h>
SoftwareSerial GPRS(7,8);
int VoltPin = A2;
int readVal;
float V2;
String incoming_char;
void setup() {
// put your setup code here, to run once:
GPRS.begin(9600);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
GPRS.println("AT+CMGS=\"08130359477\"");
delay(1000);
readVal = analogRead(VoltPin);
V2 = (5./1023.)*readVal;
Serial.println(V2);
delay(1000);
if (GPRS.available() > 0){
incoming_char = GPRS.read();
if (incoming_char = "read voltage"){
Serial.print(V2);
}
}
delay(1000);
if (Serial.available() > 0){
incoming_char = Serial.read();
GPRS.print(V2);
}
}