This is the code what i found and trying to get it works.
What should i change to get this work with A6 serial pro module.
What is real differences between sim900 and A6?
Pinouts ofcourse but what Else?
This code was made to control aquarium, but it seems to be possible to my project as Wells.
#include <SoftwareSerial.h>
char inchar; // Will hold the incoming character from the GSM shield
#include <OneWire.h>
SoftwareSerial SIM900(7, 8);
OneWire ds(2); // on pin 2 (a 4.7K resistor is necessary)
int led1 = 10;
int led2 = 11;
int led3 = 12;
int led4 = 13;
void setup()
{
Serial.begin(19200);
// set up the digital pins to control
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
SIM900.begin(19200);
SIM900power();
delay(20000); // give time to log on to network.
SIM900.print(“AT+CMGF=1\r”); // set SMS mode to text
delay(100);
SIM900.print(“AT+CNMI=2,2,0,0,0\r”);
// blurt out contents of new SMS upon receipt to the GSM shield’s serial out
delay(100);
Serial.println(“Ready…”);
}
void SIM900power()
// software equivalent of pressing the GSM shield “power” button
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(7000);
}
void sendSMS()
{
SIM900.print(“AT+CMGF=1\r”); // AT command to send SMS message
delay(100);
SIM900.println(“AT + CMGS = "+49xxxxxxxxxxx"”); // recipient’s mobile number, in international format
delay(100);
SIM900.println(" hello."); // message to send
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
SIM900power(); // turn off module
}
void loop()
{
//If a character comes in from the cellular module…
if(SIM900.available() >0)
{
inchar=SIM900.read();
if (inchar==‘#’)
{
delay(10);
inchar=SIM900.read();
if (inchar==‘a’)
{
delay(10);
inchar=SIM900.read();
if (inchar==‘0’)
{
digitalWrite(led1, LOW);
}
else if (inchar==‘1’)
{
digitalWrite(led1, HIGH);
}
delay(10);
inchar=SIM900.read();
if (inchar==‘b’)
{
inchar=SIM900.read();
if (inchar==‘0’)
{
digitalWrite(led2, LOW);
}
else if (inchar==‘1’)
{
digitalWrite(led2, HIGH);
}
delay(10);
inchar=SIM900.read();
if (inchar==‘c’)
{
inchar=SIM900.read();
if (inchar==‘0’)
{
digitalWrite(led3, LOW);
}
else if (inchar==‘1’)
{
digitalWrite(led3, HIGH);
}
delay(10);
inchar=SIM900.read();
if (inchar==‘d’)
{
delay(10);
inchar=SIM900.read();
if (inchar==‘0’)
{
digitalWrite(led4, LOW);
}
else if (inchar==‘1’)
{
digitalWrite(led4, HIGH);
}
delay(10);
}
}
SIM900.println(“AT+CMGD=1,4”); // delete all SMS
}
}
}
}
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius, fahrenheit;
if ( !ds.search(addr)) {
SIM900.print(“AT+CMGF=1\r”); // AT command to send SMS message
delay(100);
SIM900.println(“AT + CMGS = "+49xxxxxxxxxxxxx"”); // recipient’s mobile number, in international format
delay(100);
SIM900.println(" Thank You "); // message to send
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
SIM900power(); // turn off module
ds.reset_search();
delay(10000);
return;
}
switch (addr[0]) {
case 0x28:
SIM900.print(“AT+CMGF=1\r”); // AT command to send SMS message
delay(100);
SIM900.println(“AT + CMGS = "+49xxxxxxxxxxx"”); // recipient’s mobile number, in international format
delay(100);
SIM900.println(" Temperature report"); // message to send
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
SIM900power(); // turn off mod
type_s = 0;
break;
return;
}
ds.reset();
ds.select(addr);
ds.write(0x44); // start conversion, use ds.write(0x44,1) with parasite power on at the end
delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.
present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
for ( i = 0; i < 9; i++) { // we need 9 bytes
data = ds.read();
}
int16_t raw = (data[1] << 8) | data[0];
if (type_s) {
raw = raw << 3; // 9 bit resolution default
if (data[7] == 0x10) {
// “count remain” gives full 12 bit resolution
raw = (raw & 0xFFF0) + 12 - data[6];
}
} else {
byte cfg = (data[4] & 0x60);
// at lower res, the low bits are undefined, so let’s zero them
if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
//// default is 12 bit resolution, 750 ms conversion time
}
celsius = (float)raw / 16.0;
fahrenheit = celsius * 1.8 + 32.0;
SIM900.print(“AT+CMGF=1\r”); // AT command to send SMS message
delay(100);
SIM900.println(“AT + CMGS = "+49xxxxxxxxxxx."”); // recipient’s mobile number, in international format
delay(100);
SIM900.println(" Temp= "); // message to send
SIM900.println(celsius);
SIM900.println(" Cel, "); // message to send
SIM900.println(fahrenheit);
SIM900.println(" Fah");
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(10000); // give module time to send SMS
SIM900power();
}