#include <WaspSensorPrototyping.h>
Public Member Functions | |
| WaspSensorPrototyping () | |
| class constructor | |
| void | setBoardMode (uint8_t mode) |
| It sets board power mode, setting ON/OFF 3v3 and 5V switches. | |
| void | setRelayMode (uint8_t mode) |
| It sets relay power mode, setting ON/OFF its switch. | |
| float | readADC () |
| It reads the Analogic-to-Digital Converter. | |
| void | setLoadResistor (float resistor) |
| It sets the load resistor value. | |
| void | setAmplifierGain (float gain) |
| It sets the amplifier gain. | |
| float | readAnalogSensor (uint8_t pin) |
| It reads an analog sensor and returns its measured value in Volts. | |
WaspSensorPrototyping Class defines all the variables and functions used for managing the Prototyping Sensor Board
Definition at line 72 of file WaspSensorPrototyping.h.
| WaspSensorPrototyping::WaspSensorPrototyping | ( | ) |
class constructor
It initializes the different digital pins
| void |
Definition at line 30 of file WaspSensorPrototyping.cpp.
References digitalWrite(), LOW, OUTPUT, pinMode(), RELAY_PIN, SENS_PW_3V3, and SENS_PW_5V.
00031 { 00032 pinMode(RELAY_PIN,OUTPUT); 00033 pinMode(SENS_PW_3V3,OUTPUT); 00034 pinMode(SENS_PW_5V,OUTPUT); 00035 00036 digitalWrite(RELAY_PIN,LOW); 00037 digitalWrite(SENS_PW_3V3,LOW); 00038 digitalWrite(SENS_PW_5V,LOW); 00039 }

| void WaspSensorPrototyping::setBoardMode | ( | uint8_t | mode | ) |
It sets board power mode, setting ON/OFF 3v3 and 5V switches.
| uint8_t | mode : SENS_ON or SENS_OFF |
Definition at line 43 of file WaspSensorPrototyping.cpp.
References digitalWrite(), HIGH, LOW, RTC, RTC_ON, SENS_OFF, SENS_ON, SENS_PW_3V3, SENS_PW_5V, and WaspRTC::setMode().
00044 { 00045 switch( mode ) 00046 { 00047 case SENS_ON : digitalWrite(SENS_PW_3V3,HIGH); 00048 digitalWrite(SENS_PW_5V,HIGH); 00049 // Sets RTC on to enable I2C 00050 RTC.setMode(RTC_ON); 00051 break; 00052 case SENS_OFF: digitalWrite(SENS_PW_3V3,LOW); 00053 digitalWrite(SENS_PW_5V,LOW); 00054 break; 00055 } 00056 }

| void WaspSensorPrototyping::setRelayMode | ( | uint8_t | mode | ) |
It sets relay power mode, setting ON/OFF its switch.
| uint8_t | mode : SENS_ON or SENS_OFF |
Definition at line 58 of file WaspSensorPrototyping.cpp.
References digitalWrite(), HIGH, LOW, RELAY_PIN, SENS_RELAY_OFF, and SENS_RELAY_ON.
00059 { 00060 switch( mode ) 00061 { 00062 case SENS_RELAY_ON : digitalWrite(RELAY_PIN,HIGH); 00063 break; 00064 case SENS_RELAY_OFF: digitalWrite(RELAY_PIN,LOW); 00065 break; 00066 } 00067 }

| float WaspSensorPrototyping::readADC | ( | ) |
It reads the Analogic-to-Digital Converter.
| void |
Definition at line 69 of file WaspSensorPrototyping.cpp.
References TwoWire::available(), B0010100, TwoWire::begin(), WaspPWR::closeI2C(), PWR, TwoWire::receive(), TwoWire::requestFrom(), and Wire.
00070 { 00071 uint8_t valor[2] = {0, 0}; 00072 float val_def; 00073 uint16_t val; 00074 uint8_t i = 0; 00075 00076 Wire.begin(); 00077 Wire.requestFrom(B0010100, 2); 00078 while(Wire.available()){ 00079 valor[i] = Wire.receive(); 00080 i++; 00081 } 00082 PWR.closeI2C(); 00083 00084 val = int(valor[0])*256 + int(valor[1]); 00085 val_def = (val - 32769)*9; 00086 val_def = val_def/65535; 00087 00088 return val_def; 00089 }

| void WaspSensorPrototyping::setLoadResistor | ( | float | resistor | ) |
It sets the load resistor value.
| float | resistor : the value to set the load resistor to (range [0-100] KOhms) |
Definition at line 91 of file WaspSensorPrototyping.cpp.
References B00000000, B0101000, TwoWire::begin(), TwoWire::beginTransmission(), WaspPWR::closeI2C(), delay(), TwoWire::endTransmission(), PWR, TwoWire::send(), and Wire.
00092 { 00093 uint8_t resist=0; 00094 00095 resist=(uint8_t) 128-(128/100)*resistor; 00096 Wire.begin(); 00097 delay(100); 00098 Wire.beginTransmission(B0101000); 00099 Wire.send(B00000000); 00100 Wire.send(resist); 00101 Wire.endTransmission(); 00102 PWR.closeI2C(); 00103 }

| void WaspSensorPrototyping::setAmplifierGain | ( | float | gain | ) |
It sets the amplifier gain.
| float | gain : the gain to set the amplifier to (range [1-11]) |
Definition at line 105 of file WaspSensorPrototyping.cpp.
References B00010000, B0101000, TwoWire::begin(), TwoWire::beginTransmission(), WaspPWR::closeI2C(), delay(), TwoWire::endTransmission(), PWR, TwoWire::send(), and Wire.
00106 { 00107 uint8_t ampli=0; 00108 00109 gain=(gain-1)*10; 00110 ampli=(uint8_t) 128-(128/100)*gain; 00111 Wire.begin(); 00112 delay(100); 00113 Wire.beginTransmission(B0101000); 00114 Wire.send(B00010000); 00115 Wire.send(ampli); 00116 Wire.endTransmission(); 00117 PWR.closeI2C(); 00118 }

| float WaspSensorPrototyping::readAnalogSensor | ( | uint8_t | pin | ) |
It reads an analog sensor and returns its measured value in Volts.
| uint8_t | pin : specifies the analog pin where the sensor is connected |
Definition at line 120 of file WaspSensorPrototyping.cpp.
References ANALOG1, ANALOG7, and analogRead().
00121 { 00122 uint16_t read_val; 00123 float def_val; 00124 00125 if ( (pin >= ANALOG1) && (pin <= ANALOG7) ) 00126 { 00127 read_val = analogRead(pin); 00128 def_val = (read_val*3.3)/1023; 00129 return def_val; 00130 } 00131 else return -1; 00132 }

1.5.6