Post a new topicPost a reply Page 1 of 1   [ 2 posts ]
Author Message
 Post subject: Hibernate
PostPosted: Wed Feb 01, 2012 2:46 pm 

Joined: Tue Aug 02, 2011 10:05 am
Posts: 29
How I can include Hibernate in my code? The documentation explains the alarms, but not linked. I want the motes hibernate for 1 hour, but I can not get it.
Can anyone help me?
This is my code.
Thanks.


packetXBee* paq_sent;
int8_t state=0;
long previous=0;
char aux[200];
char* macHigh=" ";
char* macLow=" ";
int aux_1 = 0;
int aux_2 = 0;

char sd_data[800];
char sd_data2[800];
float temperature=0;
float ozone=0;
float valor=0;
float valozone=0;
char aux2[200];
char tabla[20];
char tabla2[20];
char tabla3[20];


#define key_access "LIBELIUM"

uint8_t direccion[8]={0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF};

void setup(){

// Store key access in EEPROM
for(int i=0;i<8;i++){
Utils.writeEEPROM(i+107,key_access[i]);
}

RTC.ON();

ACC.ON();

XBee.setMode(XBEE_ON);
XBee.begin(9600);
delay(1000);
XBee.print("+++");
delay(2000);
XBee.println("ATBD5,AP2,WR,CN");
delay(150);

XBee.setMode(XBEE_OFF);
XBee.close();

Utils.setLED(LED0, LED_ON);
Utils.setLED(LED1, LED_ON);
delay(5000);
Utils.setLED(LED0, LED_OFF);
Utils.setLED(LED1, LED_OFF);
for (int i=0;i<24;i++){
Utils.blinkLEDs(125);
}

// Inits the XBee 868 library
xbee868.init(XBEE_868,FREQ868M,NORMAL);

// Powers XBee
xbee868.ON();

// Get the XBee MAC address

delay(500);

int counter = 0;
while(xbee868.getOwnMac()==1&&counter<4){
xbee868.getOwnMac();
counter++;
}

Utils.hex2str(xbee868.sourceMacHigh,macHigh,4);
Utils.hex2str(xbee868.sourceMacLow,macLow,4);

//ACTIVACIÓN DE SENSORES
SensorGas.setBoardMode(SENS_ON);
SensorGas.configureSensor(SENS_SOCKET2B, 1, 10);//PLACA CONECTADA A LOS PINES 2B, NO PUEDE PRODUCIR SALIDA SIMULTÁNEA POR LA 2A, POR LO TANTO, AIR POLUTION POR LA 3
SensorGas.setSensorMode(SENS_ON, SENS_SOCKET2B);

SensorGas.configureSensor(SENS_SOCKET3A, 1, 10);//AIR POLUTION CONECTADO A MÓDULO 3, segundo empezando por abajo
SensorGas.setSensorMode(SENS_ON, SENS_SOCKET3A);

//INICIALIZACIÓN DEL RTC. ver primero los valores que da sin inicializar.RTC: year, month, date, day, hour, minute, second.
//Siendo day: Mo(2), Tu(3), We(4), Th(5), Fr(6), Sa(7), Su(1).

RTC.setTime("12:01:31:03:09:20:00");

delay(2000);

sprintf(aux,"\n DIA_SEMANA,FECHA,HORA,MAC,BATTERY,TEMPERATURE,OZONO,POLUTION\n");
paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee));
paq_sent->mode=BROADCAST;
paq_sent->MY_known=0;
paq_sent->packetID=0x52;
paq_sent->opt=0;
xbee868.hops=0;
xbee868.setOriginParams(paq_sent,MAC_TYPE);
xbee868.setDestinationParams(paq_sent, direccion, aux, MAC_TYPE, DATA_ABSOLUTE);
xbee868.sendXBee(paq_sent);

free(paq_sent);
paq_sent = NULL;

SD.create("Data.txt");
SD.ls();
Utils.strCp(aux,sd_data);
if(SD.appendln("Data.txt" ,sd_data));
SD.ls();

}

void loop(){

temperature = ( SensorGas.readValue(SENS_TEMPERATURE) - 0.5 ) /0.01;
ozone = SensorGas.readValue(SENS_SOCKET2B);

valor=((ozone+7.56)/1.86);
valozone= exp(valor);

Utils.float2String(temperature, tabla, 2);//el valor de temperatura se guarda en tabla
Utils.float2String(valozone, tabla2, 2); //el valor de ozono se guarda en tabla2

delay(11000);

float airpolution=0;
airpolution = SensorGas.readValue(SENS_SOCKET3A);
Utils.float2String(airpolution, tabla3, 4); //el valor de air polution se guarda en tabla3


//PAQUETE DE DATOS CON MAC, COORDENADAS, TEMPERATURA DEL DISPOSITIVO Y NIVEL DE BATERÍA

sprintf(aux2,"\n %s %s%s %d %s %s %s \n",RTC.getTime(),macHigh,macLow,PWR.getBatteryLevel(),tabla, tabla2, tabla3,'\r','\n');

paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee));
paq_sent->mode=BROADCAST;
paq_sent->MY_known=0;
paq_sent->packetID=0x52;
paq_sent->opt=0;
xbee868.hops=0;
xbee868.setOriginParams(paq_sent,MAC_TYPE);
xbee868.setDestinationParams(paq_sent, direccion, aux2, MAC_TYPE, DATA_ABSOLUTE);
xbee868.sendXBee(paq_sent);

free(paq_sent);
paq_sent = NULL;

delay(1000);


//TRATAMIENTO DE LA TARJETA SD.

SD.ls();
Utils.strCp(aux2,sd_data2);
SD.appendln("Data.txt" ,sd_data2);
}


Top
 Profile  
 
 Post subject: Re: Hibernate
PostPosted: Wed Feb 01, 2012 8:09 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 12263
Hello,

Did you read the examples?

You have plenty of examples explaining most of the features. Please study this one:
http://www.libelium.com/development/waspmote/example035

Best regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 2 posts ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use