From de601c9523bb9b63aa155b283384ea2a3e61b60e Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Mon, 10 Nov 2008 21:14:20 +0000 Subject: [PATCH] Added battery voltage level readout & SHT11 low-voltage indicator --- examples/sky-shell/sky-shell.c | 7 ++++- .../sics/contiki/collect/CollectServer.java | 31 +++++++++++++++++-- .../se/sics/contiki/collect/SensorData.java | 14 +++++++-- .../se/sics/contiki/collect/SensorInfo.java | 10 +++--- 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/examples/sky-shell/sky-shell.c b/examples/sky-shell/sky-shell.c index ec62ddb18..7ea41ad37 100644 --- a/examples/sky-shell/sky-shell.c +++ b/examples/sky-shell/sky-shell.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: sky-shell.c,v 1.5 2008/08/15 18:46:28 adamdunkels Exp $ + * $Id: sky-shell.c,v 1.6 2008/11/10 21:14:20 adamdunkels Exp $ */ /** @@ -50,6 +50,7 @@ #include "dev/leds.h" #include "dev/light.h" #include "dev/sht11.h" +#include "dev/battery-sensor.h" #include "net/rime/timesynch.h" @@ -157,6 +158,8 @@ struct sky_alldata_msg { uint16_t best_neighbor; uint16_t best_neighbor_etx; uint16_t best_neighbor_rtmetric; + uint16_t battery_voltage; + uint16_t battery_indicator; }; /*---------------------------------------------------------------------------*/ PROCESS_THREAD(shell_sky_alldata_process, ev, data) @@ -197,6 +200,8 @@ PROCESS_THREAD(shell_sky_alldata_process, ev, data) msg.best_neighbor_etx = neighbor_etx(n); msg.best_neighbor_rtmetric = n->rtmetric; } + msg.battery_voltage = battery_sensor.value(0); + msg.battery_indicator = sht11_sreg() & 0x40? 1: 0; shell_output(&sky_alldata_command, &msg, sizeof(msg), "", 0); PROCESS_END(); } diff --git a/examples/sky-shell/src/se/sics/contiki/collect/CollectServer.java b/examples/sky-shell/src/se/sics/contiki/collect/CollectServer.java index 3d523074a..5c2082f7a 100644 --- a/examples/sky-shell/src/se/sics/contiki/collect/CollectServer.java +++ b/examples/sky-shell/src/se/sics/contiki/collect/CollectServer.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: CollectServer.java,v 1.8 2008/09/03 13:35:21 nifi Exp $ + * $Id: CollectServer.java,v 1.9 2008/11/10 21:14:20 adamdunkels Exp $ * * ----------------------------------------------------------------- * @@ -34,8 +34,8 @@ * * Authors : Joakim Eriksson, Niclas Finne * Created : 3 jul 2008 - * Updated : $Date: 2008/09/03 13:35:21 $ - * $Revision: 1.8 $ + * Updated : $Date: 2008/11/10 21:14:20 $ + * $Revision: 1.9 $ */ package se.sics.contiki.collect; @@ -271,6 +271,31 @@ public class CollectServer { return data.getTemperature(); } }, + new TimeChartPanel(this, "Battery Voltage", "Battery Voltage", + "Time", "Volt") { + { + setRangeTick(1); + setRangeMinimumSize(4.0); + setGlobalRange(true); + setMaxItemCount(defaultMaxItemCount); + } + protected double getSensorDataValue(SensorData data) { + return data.getBatteryVoltage(); + } + }, + new TimeChartPanel(this, "Battery Indicator", "Battery Indicator", + "Time", "Indicator") { + { + chart.getXYPlot().getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + setRangeTick(5); + setRangeMinimumSize(10.0); + setGlobalRange(true); + setMaxItemCount(defaultMaxItemCount); + } + protected double getSensorDataValue(SensorData data) { + return data.getBatteryIndicator(); + } + }, new TimeChartPanel(this, "Relative Humidity", "Humidity", "Time", "%") { { setMaxItemCount(defaultMaxItemCount); diff --git a/examples/sky-shell/src/se/sics/contiki/collect/SensorData.java b/examples/sky-shell/src/se/sics/contiki/collect/SensorData.java index f2f763242..081b6e66f 100644 --- a/examples/sky-shell/src/se/sics/contiki/collect/SensorData.java +++ b/examples/sky-shell/src/se/sics/contiki/collect/SensorData.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: SensorData.java,v 1.4 2008/08/29 10:00:23 nifi Exp $ + * $Id: SensorData.java,v 1.5 2008/11/10 21:14:20 adamdunkels Exp $ * * ----------------------------------------------------------------- * @@ -34,8 +34,8 @@ * * Authors : Joakim Eriksson, Niclas Finne * Created : 3 jul 2008 - * Updated : $Date: 2008/08/29 10:00:23 $ - * $Revision: 1.4 $ + * Updated : $Date: 2008/11/10 21:14:20 $ + * $Revision: 1.5 $ */ package se.sics.contiki.collect; @@ -169,6 +169,14 @@ public class SensorData implements SensorInfo { return -39.6 + 0.01 * values[TEMPERATURE]; } + public double getBatteryVoltage() { + return values[BATTERY_VOLTAGE] * 2 * 2.5 / 4096.0; + } + + public double getBatteryIndicator() { + return values[BATTERY_INDICATOR]; + } + public double getRadioIntensity() { return values[RSSI]; } diff --git a/examples/sky-shell/src/se/sics/contiki/collect/SensorInfo.java b/examples/sky-shell/src/se/sics/contiki/collect/SensorInfo.java index 6d7e96fd8..51479c031 100644 --- a/examples/sky-shell/src/se/sics/contiki/collect/SensorInfo.java +++ b/examples/sky-shell/src/se/sics/contiki/collect/SensorInfo.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: SensorInfo.java,v 1.1 2008/08/29 09:00:15 nifi Exp $ + * $Id: SensorInfo.java,v 1.2 2008/11/10 21:14:20 adamdunkels Exp $ * * ----------------------------------------------------------------- * @@ -34,8 +34,8 @@ * * Authors : Joakim Eriksson, Niclas Finne * Created : 20 aug 2008 - * Updated : $Date: 2008/08/29 09:00:15 $ - * $Revision: 1.1 $ + * Updated : $Date: 2008/11/10 21:14:20 $ + * $Revision: 1.2 $ */ package se.sics.contiki.collect; @@ -76,7 +76,9 @@ public interface SensorInfo { public static final int BEST_NEIGHBOR = 20; public static final int BEST_NEIGHBOR_ETX = 21; public static final int BEST_NEIGHBOR_RTMETRIC = 22; + public static final int BATTERY_VOLTAGE = 23; + public static final int BATTERY_INDICATOR = 24; - public static final int VALUES_COUNT = 23; + public static final int VALUES_COUNT = 25; }