Hi,
I'm trying to send the voltage of a battery (12V) with a voltage sensor but i'm struggling and I can't find why.
In my Serial I can properly see my voltage but nothing happens with my GSM (no SMS received). I'm using an arduino MEGA + GSM module SIM900, I know the wire is good because i can send normal text throught SMS.
But when the part bellow is on the code my GSM module won't send anything,
"value = analogRead(A1);
vout = (value * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
VoltageString = String(vin,2);
delay(500);"
So I'm asking you if anyone knows where it can come from and maybe how to solve it.
#include <SoftwareSerial.h>
SoftwareSerial SIM900(10, 11);
float vout = 0.0;
float vin = 0.0;
float R1 = 30002.0;
float R2 = 7501.0;
int value = 0;
String VoltageString;
String voltagemessage;
void setup()
{
Serial.begin(9600);
SIM900.begin(9600);
delay(1000);
Serial.println("GSM start...");
}
void loop()
{
value = analogRead(A1);
vout = (value * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
VoltageString = String(vin,2);
delay(500);
String voltagemessage = "Voltage = " + VoltageString;
Serial.println(voltagemessage);
SIM900.println("at+cmgf=1\r"); // use full functionality (calls, sms, gprs) - see app note
delay(500);
SIM900.println("at+clip=1\r"); // enable presentation number
delay(500);
SIM900.println("at+cscs=\"GSM\"\r"); // configure sms as standard text messages
delay(500);
SIM900.println("at+cnmi=1,2,0,0,0\r"); // alert our GSM shield and now whenever it will receive message
delay(500);
SIM900.println("AT+CMGS=\"+33XXXXXXXXX\"");
delay(500);
SIM900.println(voltagemessage);
delay(2000);
SIM900.println((char)26);
delay(10000);
}
Thanks in advance,
NawaeK