Category Archives: #gsm

Arduino GSM Expandable Vehicle Connection Project


Working late last night, I managed to figure out got to take apart my seat covers and insert my capacitance sensor.

Oh ya also, note to future self, don’t use 10 awg ground wire … I had to change all the wire routing in my car because it was to hard to work with.

I’ve also placed my Arduino in a protective case. Attached behind my rear view mirror with Velcro.

I’ve t-tapped into my constant-on 12v line from my ceiling light. This way I can have my vehicle constantly monitoring. I’ll be purchasing a lithium battery booster today until I can assess the power used by my system … I also haven’t setup any safeguards against battery drain in my code yet … I’ll have to look into that.

Today, I have school. So tomorrow I’ll have to go to Lee’s again to get a new LCD display. I would have had this done by now but my first one burnt out during the original accidental short (read: blowup). Also, when I bought my second one I didn’t read that it was for the raspberry pi.

Arduino GSM Expandable Vehicle Connection Project


Today, since I’m pretty hung over, we decided to go grab lunch at our newest craft beer place. So many choices…

Using our newest member of the group, Luca, we tested the functioning of my device with a baby seat with baby and all.

We filmed him left in my car in the baby seat. He cried, I got a text saying that he may be in danger. It was awesome!

So not only did the project work beautifully, I got some feedback from some awesome friends who actually have a baby.

Now time to make the project nicer looking and “wife friendly”. What I mean by that is that you don’t want to install a device in you car that will create a constant nagging that you have wires sticking out everywhere.

And just a little advertisement for a new tool I just purchased. The 8pk-371 write stripper and crimper tool. This thing is amazing all metal construction. Made with quality and reliability in mind … All of this time I was stripping my wires with my front teeth. My dentist will appreciate.

Arduino GSM Expandable Vehicle Connection Project


So today I installed the remaining portion on the project in my car. I rooted the second wrote that goes to the driver seat. This was a little harder than the rear seat cable ad I had to take apart most of the car’s ceiling.

Now that all the routing is done, I will focus on adding an LCD display and mounting the Arduino in back of my rear view mirror. I also need to t-tap into my overhead light power source (i should also check to confirm that it is 12v).

Arduino LED light showing that I’m sitting in the driver seat.
Currently these aluminum on leather sensors are above the seat. I plan on placing them under the material.
One thing to note on this type of sensor. Since the Arduino measures the time it take the RC circuit to discharge after it is fully charged, the longer the cable that connects the sensor to the Arduino is, the longer it will take to circuit to discharge. This the sensor will take a little longer to register than during my initial tests.

Arduino GSM Expandable Vehicle Connection Project


/* This sketch is created for use of a GSM board with an arduino. The sensors utilized are 1x DHT11 + 2x BOCHEN 3386 Potentiometer + 5k resistor +
5V solar Array + 2 aluminum foils connected to 10k OHM resistors.
Copyright: Bobby Lumia, may be used and modified for personal use only. No resale.
Please reference my project blog: http://bobbobblogs.blogspot.ca/ if useing this sketch in your work.
*/

#include // Library Needed for our capacitance readings
#include // Library Needed for the tempeature readings

dht11 DHT11; // Declare our sensor, I bid thee dht11 … the first

//============================= \/ DEFINE PINS \/ ==============

//Do Not use Pins A4 & A5 … reserved for LCD
//Do not use Pins 0 & 1 (digital pins) these are used for GSM data transmission

int LED_1 = 4;                 // BABY Led
int LED_2 = 9;                 // DAD Led

int sol = A0;         // analogue pin 0
#define DHT11PIN A1   // analogue pin 1
int pot1 = A2;        // analogue pin 2
int pot2 = A3;        // analogue pin 3

CapacitiveSensor   cs_DAD = CapacitiveSensor(11,12);    // 10M resistor between pins 11 & 12, pin 12 is sensor pin, add a wire and or foil if desired
CapacitiveSensor   cs_BABY = CapacitiveSensor(6,7);    // 10M resistor between pins 6 & 7, pin 7 is sensor pin, add a wire and or foil if desired

//============================= \/ DEFINE VARIABLES \/ ==============

int const SAMPLES = 5;                         // number of samples taken to average out capacitance
int s_val[SAMPLES];                            //array to store the 5 samples to average
int const Initial_SAMPLES = 20;                // number of samples to initilize capacitance with
float RAW_initializer_VALS[Initial_SAMPLES];   // Array to hold initial Capacitance Values

int HIGH_Thresh;     // Threshold to trigger Capacitace 1 HIGH
int LOW_Thresh;      // Threshold to trigger Capacitace 1 LOW
int HIGH_Thresh_2;   // Threshold to trigger Capacitace 2 HIGH
int LOW_Thresh_2;    // Threshold to trigger Capacitace 2 LOW

int i;              // loop counter
int triggered = 0;  // Baby text trigger … don’t want to send out too many texts

long start;         // Start the timer for performance monitoring
float Where_DAD;      // Start the Where’s DAD counter
float Cap_1;        // Capacitance Sensor – 1
float Cap_2;        // Capacitance Sensor – 2
float SolVolt;      // Solar Voltage value (0-5 Volt)
float Amb_Temp;     // Ambient temperature Variable
int chk;            // Checks the Temperature sensor status and possible faults
int pot1Value;      // Potentiometer 1 value — Used to calibrate Capacitor 1 Trigger sensitivity
int pot2Value;      // Potentiometer 1 value — Used to calibrate Capacitor 2 Trigger sensitivity
int T_multi = 4;    // Scaling factor for threshold (1 = 1024, 2 = 2048 MAX)

char str1[]={‘A’,’T’,’+’,’C’,’S’,’C’,’S’,’=’,'”‘,’G’,’S’,’M’,'”‘};  // AT+CSCS=”GSM”  — This sets:  GSM default alphabet
char str2[]={‘A’,’T’,’+’,’C’,’M’,’G’,’S’,’=’,'”‘,’1′,’7′,’7′,’8′,’8′,’8′,’2′,’1′,’8′,’6′,’7’,'”‘};  // AT+CMGS=”17788821867″  — This sets Phone number to Text
char hex1[]={0x1A};  // Stop Character used to signify the end of a Text Msg

void setup()                  
{
   Serial.begin(115200);
 
   pinMode(LED_1, OUTPUT);           // set pin to output
   pinMode(LED_2, OUTPUT);           // set pin to output
   pinMode(LED_1+1, OUTPUT);           // set pin to output
   pinMode(LED_2+1, OUTPUT);           // set pin to output
 
   Serial.println();
   Serial.println(“Starting GSM Communication…”); //Just an FYI … not really chacking anything
   Serial.println();
}

void loop()                  
{

    ReadSensors();               // All sensor readings grouped in a function
    Print_Sensor_Vals_Serial();  // Now print these values on the screen for all to see!
 
    if (Cap_2 > HIGH_Thresh_2) LED_1_ON();
    else LED_1_OFF();
 
    if (Cap_1 > HIGH_Thresh) LED_2_ON();
    else LED_2_OFF();
 
    delay(200); // no use reading less than half a second … it just confuses the sensors (mostly temp)
 
    if (Cap_2 > HIGH_Thresh_2){ // If Baby is in seat
      if (Cap_1 < LOW_Thresh) { // If daddy in not there
         if (triggered == 0){
           Where_DAD = millis(); // DAD, your timer has begin
           triggered = 1; // Level 1 trigger
           Serial.println();Serial.println();Serial.println(“Countdown Begins! Where are you dad?”);Serial.println();
         }
       
         if ((millis() – Where_DAD > (5.0 * 1000.0)) && triggered == 1){ // If daddy is still not there after 120 seconds
           Serial.println();
           SendTXT();  // Send dad a text to tell him that something is wrong
           triggered = 2; // Level 2 trigger
           Serial.println();Serial.println();Serial.println(“Baby on Board! Where are you dad? THIS IS AN ALARM”);Serial.println();
         }
      }
   
      if (triggered == 1){
         Serial.print((millis() – Where_DAD)/1000.0,1);Serial.print(” Seconds .. “);Serial.println();
         LED_1_OFF();
       }
     
       if ((millis() – Where_DAD > (5.0 * 1000.0)) && triggered == 1){ // If daddy is still not there after 120 seconds
         Serial.println();
         SendTXT();  // Send dad a text to tell him that something is wrong
         triggered = 2; // Level 2 trigger
         Serial.println();Serial.println();Serial.println(“Baby on Board! Where are you dad? THIS IS AN ALARM”);Serial.println();
       }
     
    }
 
    if ((Cap_2 HIGH_Thresh&& (triggered == 2 || triggered == 1))){ // Stop panic if, Baby is removed, or Dad has arrived … after an even was triggered
      triggered = 0;
      Serial.println();Serial.println();Serial.println(“Baby SAFE!”);Serial.println();
    }
}

void ReadSensors()
{
    start = millis();  
 
    Cap_1 = avg(); // DAD Read capacitor time constant 1
    Cap_2 = avg2(); // BABY Read capacitor time constant 2
 
    SolVolt = analogRead(sol) * (5.0 / 1023.0); // Read output voltage created by the SUN!
 
    pot1Value = analogRead(pot1);
    pot2Value = analogRead(pot2);
 
    chk = DHT11.read(DHT11PIN);
    Amb_Temp = DHT11.temperature;
 
    HIGH_Thresh = T_multi*pot1Value;
    LOW_Thresh = T_multi*pot1Value-100;
    HIGH_Thresh_2 = T_multi*pot2Value;
    LOW_Thresh_2 = T_multi*pot2Value-100;    
}

void Print_Sensor_Vals_Serial()
{
  if (triggered != 1){
    Serial.print(“performance:   “);
    Serial.print(millis() – start);        // check on performance in milliseconds
    Serial.print(“\t”);Serial.print(“\t”); // tab character for debug windown spacing

    Serial.print(“C1: “);
    Serial.print(Cap_1);Serial.print(“/”); // print sensor output 1 / Threshold
    Serial.print(HIGH_Thresh);
    if (Cap_1 > HIGH_Thresh) Serial.print(“*PROXI*”);
    else Serial.print(”       “);
    Serial.print(“\t”);                    // tab character for debug windown spacing
 
    Serial.print(“C2: “);
    Serial.print(Cap_2);Serial.print(“/”); // print sensor output  / Threshold
    Serial.print(HIGH_Thresh_2);
    if (Cap_2 > HIGH_Thresh_2) Serial.print(“*PROXI*”);
    else Serial.print(”       “);
    Serial.print(“\t”);                    // tab character for debug windown spacing
 
    switch (chk){
      case 0: Serial.print(“Temperature: “); Serial.print(Amb_Temp); Serial.print(” oC”); if (Amb_Temp > 38.0) Serial.println(“*TEMP*”); break;
      case -1: Serial.print(“Checksum ERR: data was received but may not be correct”); break;
      case -2: Serial.print(“Timeout ERR: communication has failed”); break;
      default: Serial.print(“Unknown ERR: this is the catch-all bucket … S.O.L. buddy”); break;
    }

    Serial.print(“\t”);                    // tab character for debug windown spacing
    Serial.print(“Solar Voltage: “);
    Serial.print(SolVolt, 2);
    if (SolVolt > 4.0) Serial.print(“*SUN*”);
    Serial.println();
  }
}

float avg()
{
  float sampleSum = 0;
  for(int i = 0; i < SAMPLES; i++) {
    s_val[i] = cs_DAD.capacitiveSensor(15);
    sampleSum += s_val[i];
    delay(1); // set this to whatever you want
  }
  float meanSample = sampleSum/float(SAMPLES);
  return meanSample;
}

float avg2()
{
  float sampleSum = 0;
  for(int i = 0; i < SAMPLES; i++) {
    s_val[i] = cs_BABY.capacitiveSensor(15);
    sampleSum += s_val[i];
    delay(1); // set this to whatever you want
  }
  float meanSample = sampleSum/float(SAMPLES);
  return meanSample;
}

void SendTXT()
{
      for(i=0;i<13;i++)
        Serial.print(str1[i]);//AT+CSCS=”GSM”  ==> It must be done this way due to double quotes
      Serial.println();
   
      for(i=0;i<21;i++)
        Serial.print(str2[i]);//AT+CMGS=”17788821867″  ==> It must be done this way due to double quotes
      Serial.println();
   
      Serial.print(“Baby may be in danger!”);
      delay(1000);
      Serial.print(hex1);
      delay(1000);
      Serial.println();
}

void LED_1_ON(){
  digitalWrite(LED_1, HIGH);       // turn on
  digitalWrite(LED_1+1, LOW);       //
}

void LED_1_OFF(){
  digitalWrite(LED_1, LOW);       // turn off
  digitalWrite(LED_1+1, LOW);       //
}

void LED_2_ON(){
  digitalWrite(LED_2, HIGH);       // turn on
  digitalWrite(LED_2+1, LOW);       //
}

void LED_2_OFF(){
  digitalWrite(LED_2, LOW);       // turn off
  digitalWrite(LED_2+1, LOW);       //
}

Arduino GSM Expandable Vehicle Connection Project


So I’ve completed my initial concept to check to see if all this works. It does! Really well too.

One thing to note, since I shorted the Arduino the last time, I went to Lee’s electronics the next day. Bought myself 2 Arduino’s this time. 

Turns out that I must have weakened the GSM shield. It worked perfectly well all the way up until I get to school and plug it in the outlet to get it ready for presentation… Uhh.

Back to Lee’s electronics to purchase another GSM board. Maybe this time I’ll get a proper 12 volt 3 amp power supply with a ground pin. VERY IMPORTANT! capacitance sensors must be grounded. When used to sense humans at a distance (3-5 inches) you need a reference voltage. The human body is at a fairly constant voltage compared to ground. A power source from the wall will vary without a reference, but with ground feedback. This variation is eliminated.
For the next post, I will upload my Arduino code.

Arduino GSM Expandable Vehicle Connection Project


So my newest project started as a School Industrial Design project. It is yet unfinished and will be forever a work in progress but I think posting it here may help someone with the difficulties of combining the Arduino with the GSM network.

So far I have an Arduino board, a linksprite GSM shield, an LCD, a temp sensor, a solar cell, 2 capacitance sensors (metal sheets), and 2 pots.

Yesterday, I shorted my arduino while making a custom board for all these sensors… I was sad. Mostly because I’ve been working hard trying to figure out the GSM board … I’ve even added my project as a contact in my phone book. This alone gave the project some life … I could text it, call it … Love it?

Today is a day off for me. My arduino is fried and my local electronics store is closed on Sundays.