GSM & Microcontroller

Hello,

This is my first post and I am an absolute beginner.

I am looking to put an Arduino, GSM shield, Microswitch and a mobile power source inside a box and have it set up so that when the box is picked up i am sent a text message.

has anyone done anything similar and what exact products should I purchase? (I am in England)

Thank you Thank you

Oliver

Start here: http://arduino.cc/en/Tutorial/GSMExamplesSendSMS

The sketch will require modification to read an input port which has a switch (senses the box being lifted.) The texting stuff and other GSM settings should map fairly closely to the final need.

Ray

Thank you very much :slight_smile:

Is it possible to power the arduino and GSM shield from a battery for around a week? if so what sort of battery do i need?

@botcecat:

Is it possible to power the arduino and GSM shield from a battery for around a week?

With the right power management, perhaps. Like my smartphone requires recharging every night so extrapolate that into a week and it would be a large battery, right? But if both are sleeping most of the time...

For the Arduino, Nick Gammon has an excellent article on low-power coding:

A response of GSM shield and associated power saving techniques is being left open in hopes that other informed members with experience will have input.

Ray

boycecat:
Is it possible to power the arduino and GSM shield from a battery for around a week?

You mean this?

Maybe.

boycecat:
if so what sort of battery do i need?

A BIG one.

Think in terms of six D cells ... and even then you might not make it to 7 days.

Be sure to read pages like this:

http://comoyo.github.io/blog/2013/08/09/How_to_efficiently_operate_the_Arduino_GSM_shield_with_a_battery_pack/

I have got the below working so that when the gsm turns on it sends a me a text. could someone help me putting it in to a debounce circuit to trigger on a microswitch release. please.

 */

// Include the GSM library
#include <GSM.h>


// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;

void setup()
{
  
    if(gsmAccess.begin()==GSM_READY)

      Serial.println("Not connected");
      delay(1000);
  sms.beginSMS("07565684371");
  sms.print("win");
  sms.endSMS(); 
  Serial.println("\nCOMPLETE!\n");
  while (1);
}



void loop()
{
while (1);
}

Add to your defines:

const byte MSWITCH = 2;

in setup:

pinMode(MSWITCH, INPUT_PULLUP); // Default will be high, will drag down to low when switch closed

In loop:

if (digitalRead(MSWITCH)==LOW)
{
    when digital read is low then the switch has been closed.
}

Then connect your micro switch (N.O. contacts) between pin 2 and ground, add a 100nF capacitor across the switch terminals to handle debounce.

Obviously if you are using pin 2 for something else simply substitute another pin!

thank you very much, will i be ok using the standard debounce tutorial file as a template?

The capacitor will handle debounce for you. No need to do it in software.

Like this?

 */

// Include the GSM library
const byte MSWITCH = 2;
#include <GSM.h>


// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;

void setup()
{
  
  pinMode(MSWITCH, INPUT_PULLUP); // Default will be high, will drag down to low when switch closed
    if(gsmAccess.begin()==GSM_READY)

      Serial.println("Not connected");
      delay(1000);
  sms.beginSMS("07565684371");
  sms.print("win");
  sms.endSMS(); 

  while (1);
}



void loop()
{
  
if (digitalRead(MSWITCH)==LOW)
{

}
}

I was thinking more along the lines of:

// Include the GSM library
const byte MSWITCH = 2;
#include <GSM.h>

// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;

void setup()
{
   pinMode(MSWITCH, INPUT_PULLUP); // Default will be high, will drag down to low when switch closed
}



void loop()
{
  if (digitalRead(MSWITCH)==LOW)
  {
    if(gsmAccess.begin()==GSM_READY)
       Serial.println("Not connected");
    delay(1000);
    sms.beginSMS("07565684371");
    sms.print("win");
    sms.endSMS(); 
    while (1);
  }
}

I’ve just moved your code around and not tested it but basically you use setup() to set the system up, then just loop() until someone picks up the box. I presume it won’t actually be tethered to a computer with a USB cable so you don’t need the Serial.print in there. If you do intend doing any Serial.prints for debugging then you need Serial.begin in setup.

And I don’t think that you can use pin 2 as it is used by the shield (as is 3), so go with pin 4 upwards.

thank you so so much. you have be a massive massive help. I have been sitting at this desk for 3 days its so good to have it working. :slight_smile: