My first project

I am a complete Noob and thanks a lot of reading on this forum I have just finished my first Adrdiuno project :slight_smile:

I am using a 26PCBFA6D pressure sensor to test the depth of a river and then post the value to a mysql db on my website using a wavecom GPRS Modem and php script.

As the whole unit will be installed in a remote location I am powering the arduino with a 12v lead acid battery connected to a 12w solar panel. Thanks to the nightingale code I am able to put the arduino in and out of sleep mode for about 30 minutes until I read the sensor and post the data.

Thanks again for all the help.


#include <avr/sleep.h>
#include <avr/wdt.h>
#include <SoftwareSerial.h>
#ifndef cbi                                            //copied from nightingale:
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))    
#ifndef sbi                                           
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))     
volatile boolean f_wdt=1;              
int count = 191;        //Set count high so dotest on startup
int pressureSignal = 0; // Pressure signal pin ANALOG-0
int val1 = 0;           // Pressure value 1
int val2 = 0;           // Pressure value 2 
int val3 = 0;           // Pressure value 3
float pressureValue = 0;   // Average Pressure
int relayPin = 13;       // 5v relay connected to DIGITAL-13

void setup()                    // copied from nightingale:
  cbi( SMCR,SE );      // sleep enable, power down mode
  cbi( SMCR,SM0 );     // power down mode
  sbi( SMCR,SM1 );     // power down mode
  cbi( SMCR,SM2 );     // power down mode

void loop()                    
  if (f_wdt==1) {      //copied from nightingale:
  if (count > 190) {   //When count gets to 191 do pressure test
  else {
  count++;              //count +1

void dotest() {
  digitalWrite(relayPin, HIGH);   // Sets the relay on, switches on modem and pressure sensor
  val1 = 0;
  val2 = 0;
  val3 = 0;
  pressureValue = 0;
  pinMode(pressureSignal, INPUT);      // Sets Analog pin to input
  val1 = analogRead(pressureSignal);   // Get value 1
  val2 = analogRead(pressureSignal);   // Get value 2 
  val3 = analogRead(pressureSignal);   // Get value 3 
  pressureValue = ((val1+val2+val3)/3);    // Get average value  
  Serial.print("AT+cpin=####\r\n");      // Input SIM pin   
  Serial.print("at+wipcfg=1\r\n");    //start IP stack
  Serial.print("at+wipbr=1,6\r\n");    //open GPRS bearer
  Serial.print("at+wipbr=2,6,11,\"internet\"\r\n");      //set APN name of GPRS bearer
  Serial.print("at+wipbr=4,6,0\r\n");     //start GPRS bearer
  Serial.print("at+wipcreate=5,1,\"\",80,\"user\",\"password\"\r\n");  //connect to remote HTTP proxy server port 80 with authentication and some header fields
  Serial.print("at+wipopt=5,1,1,51\r\n");     //get size of the TCP send buffer size
  Serial.print("at+wipopt=5,1,2,53,6\r\n");     //set maximum number of redirects
  Serial.print("\"\r\n");   //HTTP GET method(not really what I should be using but it works:-) )
  digitalWrite(relayPin, LOW);   // sets the relay off
  count = 0;                     //set count to 0 to restart sleep loop


void system_sleep() {                  //copied from nightingale:
  cbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter OFF
  set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
  sleep_mode();                        // System sleeps here
    sleep_disable();                     // System continues execution here when watchdog timed out 
    sbi(ADCSRA,ADEN);                    // switch Analog to Digitalconverter ON

void setup_watchdog(int ii) {          //copied from nightingale:

  byte bb;
  int ww;
  if (ii > 9 ) ii=9;
  bb=ii & 7;
  if (ii > 7) bb|= (1<<5);
  bb|= (1<<WDCE);
  MCUSR &= ~(1<<WDRF);
  // start timed sequence
  WDTCSR |= (1<<WDCE) | (1<<WDE);
  // set new watchdog timeout value
  WDTCSR = bb;

ISR(WDT_vect) {
  f_wdt=1;  // set global flag

Sounds interesting, got any pictures of the setup?

No pics unfortunately :-[

sounds nice, which module of wavecom are you choose,Q2686?

I used a Q2406 with Wipsoft activated.

Very interesting. It would be nice to see the website page, too.

We have done some maths server side to show levels relevant to weir markings.


Especially interesting is the use of uP sleep mode to save battery IMHO.

I am trying to do something similar but on my Q2406's all the AT+WIPXXX commands just return a ERROR message.

How did you activate the WIPSOFT command set?