Source Code: Evaluating Power consumption of Arduino Uno with Tinysine GSM/GPRS Shield

Arduino Source Code for Evaluating Power consumption of Arduino Uno with Tinysine GSM/GPRS Shield implemented with Arduino Ice 1.6.13:

[code language="cpp"]
* Evaluation of the power consumption off the TinySine GSM shield in combination with Arduino UNO
 sketch: _201612_TinySinePowerUpDown.ino
 
 created: 23.12.2016 Cademis
 

 Reserved Arduino Pins for TinySine GSM/GPRS shield
 D2, D3 for Rx, Tx
 D7 for Ring Indicator
 D8 power
 D9 reset
*/


// Includes
#include "SIM900.h" // enable hardware features of SIM900 chip one TinySine Shield
#include <SoftwareSerial.h> //display system and debug output on PC
#include "inetGSM.h" // enable board as http client
//#include "sms.h" // enable SMS features of SIM900
//#include "call.h" // enable phone call features of SIM900

// Constants and Vars
const String versionStr = "AUT R1 001"; // firmware version
int LED_PIN = 13; // onboard LED

// TinySine GSM shield
const int gsmPowerPin = 8; //switch on/off power on D8
bool gsmON = false; // current power state of GSM shield

void setup()
{
 Serial.begin(9600); //Serial connection.
 Serial.println(versionStr);
 
 Serial.println("Setup OK");
};


void loop ()
{
 Serial.println("Start Power up");
 powerUpGSM(2400);
 Serial.println("Power up GSM");
 delay(10000);
 digitalWrite(LED_PIN, HIGH); 
 Serial.println("Power up GSM and LED ON");
 delay(10000);
 Serial.println("Start Power down");
 powerDownGSM();
 Serial.println("Power down completed - LED ON");
 delay(10000);
 digitalWrite(LED_PIN, LOW); 
 Serial.println("Power down - LED OFF");
 delay(10000);
}

// enable power supply for GSM board
bool powerUpGSM(int baudRate) {
 if (!gsmON)
 {
 digitalWrite(gsmPowerPin, LOW);
 delay(1000);
 digitalWrite(gsmPowerPin, HIGH);
 delay(2000);
 digitalWrite(gsmPowerPin, LOW);
 delay(3000);
 if (gsm.begin(baudRate)) {
 Serial.println("\nstatus=READY");
 gsmON = true;
 }
 else {
 Serial.println("\nstatus=IDLE");
 gsmON = false;
 }
 delay(1000);
 }
 return gsmON;
} // end powerUpGSM

// switch off GSM board
bool powerDownGSM() {
 while (gsmON) {
 digitalWrite(gsmPowerPin, LOW);
 delay(1000);
 digitalWrite(gsmPowerPin, HIGH);
 delay(2000);
 digitalWrite(gsmPowerPin, LOW);
 delay(3000);
 gsmON = false;
 }
 return gsmON;
} // end powerDownGSM
[/code]