Go Down

Topic: [SOLVED... Almost] ideas/help for arduino gsm remote control of engine preheater (Read 19228 times) previous topic - next topic


this simple sketch works...:

Code: [Select]
/* TDGino example
Sketch to test the call function

created 2011
by Boris Landoni

This example code is in the public domain.




#include <GSM.h>
//for enable disable debug rem or not the string       #define DEBUG_PRINT
// definition of instance of GSM class
GSM gsm;

// Set pin numbers:
const int powergsm =  77;
const int ctsgsm   =  39;
const int rtsgsm   =  29;
const int dcdgsm   =  27;
const int dtrgsm   =  28;
const int reset    =  35;
const int ring     =  34;
const int ld1      =  25;
const int ld2      =  26;
const int stato    =  76;
const int rele1    =  36;
const int rele2    =  37;
const int sda      =  20;
const int scl      =  21;
const int in1      =  84;
const int in2      =  83;
const int stddtmf  =  14;
const int q1dtmf   =  72;
const int q2dtmf   =  73;
const int q3dtmf   =  74;
const int q4dtmf   =  75;
const int puls     =  62;
const int sonda    =  63;

void setup() {
  // set the digital pin as output:
  pinMode(powergsm, OUTPUT);     
  pinMode(rtsgsm, OUTPUT);
  pinMode(dtrgsm, OUTPUT);
  pinMode(reset, OUTPUT);
  pinMode(ld1, OUTPUT);
  pinMode(ld2, OUTPUT);
  pinMode(rele1, OUTPUT);
  pinMode(rele2, OUTPUT);
  pinMode(sda, OUTPUT);
  pinMode(scl, OUTPUT);
  // set the digital pin as input:
  pinMode(ctsgsm, INPUT);     
  pinMode(dcdgsm, INPUT);
  pinMode(ring, INPUT);
  pinMode(stato, INPUT);
  pinMode(in1, INPUT);
  pinMode(in2, INPUT);
  pinMode(stddtmf, INPUT);
  pinMode(q1dtmf, INPUT);
  pinMode(q2dtmf, INPUT);
  pinMode(q3dtmf, INPUT);
  pinMode(q4dtmf, INPUT);
  pinMode(puls, INPUT);
  pinMode(sonda, INPUT);
  // start serial port at 9600 bps:
  Serial.println("system startup");
  gsm.InitSerLine(115200);   //initialize serial 1
  gsm.TurnOn(115200);              //module power on
  gsm.InitParam(PARAM_SET_1);//configure the module 
  gsm.Echo(1);               //enable AT echo

void loop()
  int response=0;
  char phone_num[20]; // array for the phone number string
  char string[160];
  // if we get a valid byte, read analog ins:

  if (digitalRead(puls) == 0 ) {
    Serial.println("pulsante premuto"); 



think i have hit a wall so far... have tried to cross check all pinout pages etc and have no idea of what pins my 2 digital inputs are tied to.

are there a way to have a sketch print it? ie print the status of all pins and then i just have to watch for changes.... at least that would help me to narrow it


so seller told me to replace pins_arduino.c with a version from him.... np with that except i cant find it... only pins_arduino.h is there

running on mac os x


Solved the thing... also tested it inside and only need to do a "double real life check"

sketch atached....

relay1 is used to start/stop the heater. In1 is connected to the circulation pump on the heater, this lets me know that it's running (Turning it on does not mean it starts, blown fuses etc) In2 is connected to cabin fan which comes on at about 50 degree C. Then with an optocoupler and 2 resistors I make another Input in3 that connects to the flame sensor so i know the status of the flame sensor.

Only thing not done is the 2nd temp sensor... still need thinker on how to include that in the status msg's... but code for it is in the sketch, just need to get another dallas sensor.

Of course the code needs some cleanup buts it's close to working how I want it to.

PS... IDE needs to be ver 0022 and the pins_arduino.c needs to be overwritten with this file http://www.open-electronics.org/wp-content/uploads/2011/07/pins_arduino.zip

the #include files can be found here: http://tidigino.googlecode.com/files/TiDiGino%20library%20Arduino%201.zip


That seems interesting, never seen them make you change the pins to fit their dvice before


it was what gave me trouble.... no matter what i did i could not activate the 2 inputs allready there.. now i just need to build a "1 extra input shield" on a test wafer/board and i'm done hardware wise, then i just need to thinker with the part of the sketch that sends out temps.

what i'm after for the temps is to send out both temps in 1 sms if either one goes up by X number of degrees


I hate to bring this out from the dead but have one minor issue that i can't figure myself

everything is working but i cant get the arduino to send out sms's when requesting temp's.. but the arduino can locate the 2 dallas chips...


EDIT:This is the part (look at the very buttom) that should give me back a sms with temp

Code: [Select]
          if (inchar=='t')
            if (inchar=='0')                                                                                                                         // If 0 after t then send text with cabin temp
              int temperature1dec=temperature1;
              int temperature1uni=(temperature1*100)-(temperature1dec*100);
              sprintf(string,"Kabinetemperatur %d.%d Grader",temperature1dec,temperature1uni);
              response=gsm.SendSMS("+45********",string);                                                                                            // +********** insert your telephone number
              Serial.print("response ");
            else if (inchar=='1')                                                                                                                    // If 1 after t then send text with coolant temp
              int temperature2dec=temperature2;
              int temperature2uni=(temperature2*100)-(temperature2dec*100);
              sprintf(string,"Kølertemperatur %d.%d Grader",temperature2dec,temperature2uni);
              response=gsm.SendSMS("+45********",string);                                                                                            //+********** insert your telephone number
              Serial.print("response ");


but i cant get the arduino to send out sms's when requesting temp's

What does it do, instead?

That code does something. You want it to do something. That those two somethings are not the same thing is obvious, but what either one of them is is not clear.

What serial output are you seeing?
The art of getting good answers lies in asking good questions.



The problem is that i cant see any serial output as i have to test the unit in the car, the sensors are tied to the coolant hose for the cabin heater.

I would have to take my desktop there and run an extension cord. but it could be the only way out...

But basic what it should do if i send a sms with text: @t1 it should reply with a sms telling me what temp the cabin are and if i send the text: @t0 i should get one with coolant temp in return


In reply #81 you have two consecutive Serial.read, with dependent conditions.
Are you certain you have data to read?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


i should have... last night i actually took my desktop to the backseat of the car to read the device address of the 2 sensors so i know they are there for the arduino to read

and the serial read is just to read the text/sms.... and if the first char is @ it goes on... now i have just been testing it and in fact it only react on @a1 and @a0 which turns relay1 on and off...

and last night i tested that it could turn relay 2 on and off.... but that was inside which do not require the temp sensors.

hmm.... me wondering here


could it be that i have mixed up the }'s in the last part after if(Serial1.available() >0) ?

my head for sure cooking to find whats wrong


changed a bit in the end so the { and } looks more correct.... complete sketch here:



another wonder... could it be that you cant send a text while reading the serial port? just wild guessing here


so been looking at this, sketch looks like this now:


What i know that works:

it can turn on and off relay 1 when i send the text: @a1 or @a0
it can send me back status if the heater in fact turns on and again when it turns off
also i get a text back that tells me when there is a flame and when not.
and last when it turns the cabin fan on and off

on serial output i do get the msg that relay1 is on or off and also a msg for the other 3 inputs

what does not work:

it can not turn on or off relay 2, it should do that when i text either @b1 or @b0
also i do not get a text when i request temps by either text @t0 or @t1, but i know that the sensors are there since i can get the arduino to list the address's of the 2 dallas sensors

So for most i think the code is there, there is just some error that prevents it for checking for the letter b in the text and maybe also the letter t, but i just cant figure it

Go Up