Contiki-Inga 3.x
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
platform
iris
apps
battery-monitor.c
1
#include "contiki.h"
2
#include "dev/battery-sensor.h"
3
#include "lib/sensors.h"
4
#include <stdio.h>
/* For printf() */
5
/*---------------------------------------------------------------------------*/
6
PROCESS
(battery_monitor_process,
"Battery Voltage Monitor"
);
7
AUTOSTART_PROCESSES(&battery_monitor_process);
8
/*---------------------------------------------------------------------------*/
9
PROCESS_THREAD
(battery_monitor_process, ev, data)
10
{
11
static
struct
etimer
et;
12
13
PROCESS_BEGIN
();
14
15
SENSORS_ACTIVATE
(battery_sensor);
16
17
while
(1) {
18
19
etimer_set
(&et,
CLOCK_SECOND
* 2);
20
PROCESS_WAIT_EVENT_UNTIL
(
etimer_expired
(&et));
21
/*
22
* Battery voltage calculation formula
23
*
24
* V(Battery Voltage) = v(Voltage Reference) * 1024 / ADC
25
*
26
* Where:
27
* v = 1.223
28
*
29
*/
30
printf(
"ADC value : %d\n"
, battery_sensor.
value
(0));
31
}
32
PROCESS_END
();
33
}
34
/*---------------------------------------------------------------------------*/
Generated on Thu Apr 24 2014 16:26:16 for Contiki-Inga 3.x by
1.8.3.1