Added battery voltage level readout & SHT11 low-voltage indicator

This commit is contained in:
adamdunkels 2008-11-10 21:14:20 +00:00
parent ceb2554d2f
commit de601c9523
4 changed files with 51 additions and 11 deletions

View file

@ -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();
}

View file

@ -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);

View file

@ -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];
}

View file

@ -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;
}