battery-monitor.c
00001 #include "contiki.h"
00002 #include "dev/battery-sensor.h"
00003 #include "lib/sensors.h"
00004 #include <stdio.h>
00005
00006 PROCESS(battery_monitor_process, "Battery Voltage Monitor");
00007 AUTOSTART_PROCESSES(&battery_monitor_process);
00008
00009 PROCESS_THREAD(battery_monitor_process, ev, data)
00010 {
00011 static struct etimer et;
00012
00013 PROCESS_BEGIN();
00014
00015 SENSORS_ACTIVATE(battery_sensor);
00016
00017 while(1) {
00018
00019 etimer_set(&et, CLOCK_SECOND * 2);
00020 PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 printf("ADC value : %d\n", battery_sensor.value(0));
00031 }
00032 PROCESS_END();
00033 }
00034