Hi,
I'm using Telosb, I Like get the values of Temperature and Humidity values.
I use many codes to obtain this values (I wired channels and Oscope with
variables). But I
can't obtain this values. the compilation run successfully but the oscilloscope
don't work and no graph.
This is my code
// The Module file:
module OscilloscopeM
{
provides interface StdControl;
uses {
interface Timer;
interface Leds;
interface SplitControl as HumidityControl;
interface ADC as Humidity;
interface ADC as Temperature;
interface ADC as TSR;
interface ADC as PAR;
interface ADCSingle as InternalTemperature;
interface ADC as InternalVoltage;
interface ADC as Voltage12;
interface Oscope as OHumidity;
interface Oscope as OTemperature;
interface Oscope as OTSR;
interface Oscope as OPAR;
interface Oscope as OInternalTemperature;
interface Oscope as OInternalVoltage;
interface Oscope as OVoltage12;
interface ADCError as HumidityError;
interface ADCError as TemperatureError;
}
}
implementation
{
enum {
OSCOPE_DELAY = 10,
};
enum {
HUMIDITY,
TEMPERATURE,
TSRSENSOR,
PARSENSOR,
VOLT12,
ITEMP,
IVOLT
};
norace uint16_t humidity, temperature, tsr, par, volt12, itemp, ivolt;
norace int state;
norace bool chg;
/**
* Used to initialize this component.
*/
command result_t StdControl.init() {
TOSH_MAKE_ADC3_INPUT();
TOSH_MAKE_GIO0_OUTPUT();
TOSH_CLR_GIO0_PIN();
chg = FALSE;
call Leds.init();
call Leds.set(0);
state = HUMIDITY;
//turn on the sensors so that they can be read.
call HumidityControl.init();
return SUCCESS;
}
event result_t HumidityControl.initDone() {
return SUCCESS;
}
/**
* Starts the SensorControl component.
* @return Always returns SUCCESS.
*/
command result_t StdControl.start() {
call HumidityControl.start();
return SUCCESS;
}
event result_t HumidityControl.startDone() {
call HumidityError.enable();
call TemperatureError.enable();
call Timer.start( TIMER_ONE_SHOT, 250 );
return SUCCESS;
}
/**
* Stops the SensorControl component.
* @return Always returns SUCCESS.
*/
command result_t StdControl.stop() {
call HumidityControl.stop();
call Timer.stop();
return SUCCESS;
}
event result_t HumidityControl.stopDone() {
call HumidityError.disable();
call TemperatureError.disable();
return SUCCESS;
}
event result_t Timer.fired() {
// set a timeout in case a task post fails (rare)
call Timer.start(TIMER_ONE_SHOT, 100);
switch(state) {
case HUMIDITY:
call Humidity.getData();
break;
case TEMPERATURE:
call Temperature.getData();
break;
case TSRSENSOR:
call TSR.getData();
break;
case PARSENSOR:
call PAR.getData();
break;
// case VOLT12:
// call Voltage12.getData();
// break;
case ITEMP:
call InternalTemperature.getData();
break;
case IVOLT:
call InternalVoltage.getData();
break;
default:
call Timer.start(TIMER_ONE_SHOT, 10);
}
return SUCCESS;
}
task void putHumidity() {
call OHumidity.put(humidity);
call Leds.yellowOn();
call Timer.start(TIMER_ONE_SHOT, OSCOPE_DELAY);
}
task void putTemperature() {
call OTemperature.put(temperature);
call Leds.greenOn();
call Timer.start(TIMER_ONE_SHOT, OSCOPE_DELAY);
}
task void putTSR() {
call OTSR.put(tsr);
call Timer.start(TIMER_ONE_SHOT, OSCOPE_DELAY);
}
task void putPAR() {
call OPAR.put(par);
call Leds.redOn();
call Timer.start(TIMER_ONE_SHOT, OSCOPE_DELAY);
}
task void putVolt12() {
call OVoltage12.put(volt12);
call Timer.start(TIMER_ONE_SHOT, OSCOPE_DELAY);
}
task void putIntTemp() {
call OInternalTemperature.put(itemp);
call Timer.start(TIMER_ONE_SHOT, OSCOPE_DELAY);
}
task void putIntVoltage() {
call OInternalVoltage.put(ivolt);
call Leds.set(0);
chg = !chg;
if (chg)
TOSH_SET_GIO0_PIN();
else
TOSH_CLR_GIO0_PIN();
call Timer.start(TIMER_ONE_SHOT, OSCOPE_DELAY);
}
async event result_t Humidity.dataReady(uint16_t data) {
humidity = data;
post putHumidity();
state = TEMPERATURE;
return SUCCESS;
}
event result_t HumidityError.error(uint8_t token) {
humidity = 0;
post putHumidity();
state = TEMPERATURE;
return SUCCESS;
}
async event result_t Temperature.dataReady(uint16_t data) {
temperature = data;
post putTemperature();
state = TSRSENSOR;
dbg(DBG_TEMP|DBG_USR1, "Oscilloscope Temperature C°: Value is %i\n",
(int)temperature); //Walid
return SUCCESS;
}
event result_t TemperatureError.error(uint8_t token) {
temperature = 0;
post putTemperature();
state = TSRSENSOR;
return SUCCESS;
}
async event result_t TSR.dataReady(uint16_t data) {
tsr = data;
post putTSR();
state = PARSENSOR;
return SUCCESS;
}
async event result_t PAR.dataReady(uint16_t data) {
par = data;
post putPAR();
state = VOLT12;
return SUCCESS;
}
async event result_t Voltage12.dataReady(uint16_t data) {
volt12 = data;
post putVolt12();
state = ITEMP;
return SUCCESS;
}
async event result_t InternalTemperature.dataReady(adcresult_t result, uint16_t
data) {
itemp = data;
post putIntTemp();
state = IVOLT;
return SUCCESS;
}
async event result_t InternalVoltage.dataReady(uint16_t data) {
ivolt = data;
post putIntVoltage();
state = HUMIDITY;
return SUCCESS;
}
}
// The Configuration file:
configuration Oscilloscope { }
implementation
{
components Main
, OscilloscopeM
, TimerC
, LedsC
, HumidityC
, HamamatsuC
, InternalTempC
, InternalVoltageC
//, Voltage12C
, OscopeC
, GenericComm as Comm
;
Main.StdControl -> TimerC;
Main.StdControl -> Comm;
Main.StdControl -> OscopeC;
Main.StdControl -> HamamatsuC;
Main.StdControl -> InternalTempC;
Main.StdControl -> InternalVoltageC;
//Main.StdControl -> Voltage12C;
Main.StdControl -> OscilloscopeM;
OscilloscopeM.Timer -> TimerC.Timer[unique("Timer")];
OscilloscopeM.Leds -> LedsC;
OscilloscopeM.HumidityControl -> HumidityC;
OscilloscopeM.Humidity -> HumidityC.Humidity;
OscilloscopeM.Temperature -> HumidityC.Temperature;
OscilloscopeM.TSR -> HamamatsuC.TSR;
OscilloscopeM.PAR -> HamamatsuC.PAR;
OscilloscopeM.InternalTemperature -> InternalTempC.ADCSingle;
OscilloscopeM.InternalVoltage -> InternalVoltageC;
// OscilloscopeM.Voltage12 -> Voltage12C;
OscilloscopeM.HumidityError -> HumidityC.HumidityError;
OscilloscopeM.TemperatureError -> HumidityC.TemperatureError;
OscilloscopeM.OHumidity -> OscopeC.Oscope[0];
OscilloscopeM.OTemperature -> OscopeC.Oscope[1];
OscilloscopeM.OTSR -> OscopeC.Oscope[2];
OscilloscopeM.OPAR -> OscopeC.Oscope[3];
OscilloscopeM.OInternalTemperature -> OscopeC.Oscope[4];
OscilloscopeM.OInternalVoltage -> OscopeC.Oscope[5];
// OscilloscopeM.OVoltage12 -> OscopeC.Oscope[6];
}
______________________________
BOUZAYANI Walid
Student Researcher
CES Laboratory, ENIS Tunisia
[email protected]
GSM: (00216) 94 306 603
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help