Pages: 1 ... 4 5 [6] 7 8   Go Down
Author Topic: [SOLVED... Almost] ideas/help for arduino gsm remote control of engine preheater  (Read 8266 times)
0 Members and 1 Guest are viewing this topic.
Odense, Denmark
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

this simple sketch works...:

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

 created 2011
 by Boris Landoni

 This example code is in the public domain.

http://www.open-electronics.org

http://www.futurashop.it

 */
 
 
#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.begin(9600);
  //Serial1.begin(115200);
  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"); 
     digitalWrite(rele1,HIGH);   
     delay(2000);
     digitalWrite(rele2,HIGH);
     delay(2000);
     digitalWrite(rele1,LOW);   
     delay(2000);
     digitalWrite(rele2,LOW);
     delay(2000);

 
 
Logged

Odense, Denmark
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Odense, Denmark
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Odense, Denmark
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

* sketch_feb15c.pde (15.54 KB - downloaded 12 times.)
« Last Edit: February 16, 2012, 03:08:51 pm by boelle » Logged

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Odense, Denmark
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Odense, Denmark
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...

http://pastebin.com/FqA5s8pz


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

Code:
inchar=Serial1.read(); 
          if (inchar=='t')
          {
              inchar=Serial1.read();
            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);
              Serial.println(string);
              response=gsm.SendSMS("+45********",string);                                                                                            // +********** insert your telephone number
              Serial.print("response ");
              Serial.println(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);
              Serial.println(string);
              response=gsm.SendSMS("+45********",string);                                                                                            //+********** insert your telephone number
              Serial.print("response ");
              Serial.println(response);
« Last Edit: October 24, 2012, 01:39:01 pm by boelle » Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 654
Posts: 50931
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Odense, Denmark
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi...

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
« Last Edit: October 24, 2012, 02:06:17 pm by boelle » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In reply #81 you have two consecutive Serial.read, with dependent conditions.
Are you certain you have data to read?
Logged

"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.

Odense, Denmark
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Odense, Denmark
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Odense, Denmark
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://pastebin.com/ueELQUwC
« Last Edit: October 24, 2012, 02:50:45 pm by boelle » Logged

Odense, Denmark
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Odense, Denmark
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://pastebin.com/HQcdtmWZ

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
Logged

Pages: 1 ... 4 5 [6] 7 8   Go Up
Jump to: