This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
sparrow_v4_en [2015/10/08 15:35] dan.tudose [Shades and Colors] |
sparrow_v4_en [2016/11/03 16:34] (current) dan.tudose [Light Sensor] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Sparrow Wireless Sensor Node ====== | ====== Sparrow Wireless Sensor Node ====== | ||
+ | {{: | ||
Sparrow is an excellent platform for IoT, ultra low-power wireless computing and energy harvesting, with state-of-the-art sensing capabilities. It was designed to work with a range of wireless protocols, including IEEE 802.15.4, 6LoWPAN and ZigBee. | Sparrow is an excellent platform for IoT, ultra low-power wireless computing and energy harvesting, with state-of-the-art sensing capabilities. It was designed to work with a range of wireless protocols, including IEEE 802.15.4, 6LoWPAN and ZigBee. | ||
Line 166: | Line 167: | ||
} | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Light Sensor ===== | ||
+ | |||
+ | < | ||
+ | |||
+ | We will use the [[https:// | ||
+ | |||
+ | |||
+ | <code C> | ||
+ | #include < | ||
+ | #include " | ||
+ | |||
+ | int controlPin = 7; | ||
+ | Adafruit_SI1145 uv = Adafruit_SI1145(); | ||
+ | |||
+ | void setup() { | ||
+ | pinMode(controlPin, | ||
+ | delay(100); | ||
+ | digitalWrite(controlPin, | ||
+ | | ||
+ | delay(1000); | ||
+ | | ||
+ | Serial.begin(9600); | ||
+ | | ||
+ | Serial.println(" | ||
+ | | ||
+ | if (! uv.begin()) { | ||
+ | Serial.println(" | ||
+ | while (1); | ||
+ | } | ||
+ | |||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | | ||
+ | Serial.println(" | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | | ||
+ | // Uncomment if you have an IR LED attached to LED pin! | ||
+ | // | ||
+ | |||
+ | float UVindex = uv.readUV(); | ||
+ | // the index is multiplied by 100 so to get the | ||
+ | // integer index, divide by 100! | ||
+ | UVindex /= 100.0; | ||
+ | Serial.print(" | ||
+ | |||
+ | delay(1000); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Barometer ===== | ||
+ | |||
+ | < | ||
+ | |||
+ | The Sparrow nodes are using the [[http:// | ||
+ | |||
+ | <code C> | ||
+ | #include < | ||
+ | #include < | ||
+ | int controlPin = 7; | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | pinMode(controlPin, | ||
+ | delay(100); | ||
+ | | ||
+ | digitalWrite(controlPin, | ||
+ | | ||
+ | Serial.begin(9600); | ||
+ | BaroSensor.begin(); | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | if(!BaroSensor.isOK()) { | ||
+ | Serial.print(" | ||
+ | Serial.println(BaroSensor.getError()); | ||
+ | BaroSensor.begin(); | ||
+ | } | ||
+ | else { | ||
+ | Serial.print(" | ||
+ | Serial.println(BaroSensor.getTemperature()); | ||
+ | Serial.print(" | ||
+ | Serial.println(BaroSensor.getPressure()); | ||
+ | } | ||
+ | delay(1000); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Radio Transmission ===== | ||
+ | |||
+ | We will use the [[https:// | ||
+ | |||
+ | Here's an example code: | ||
+ | |||
+ | <code C> | ||
+ | /* | ||
+ | |||
+ | Run this sketch on two Zigduinos, open the serial monitor at 9600 baud, and type in stuff | ||
+ | Watch the Rx Zigduino output what you've input into the serial port of the Tx Zigduino | ||
+ | |||
+ | */ | ||
+ | |||
+ | #include < | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | ZigduinoRadio.begin(11); | ||
+ | Serial.begin(9600); | ||
+ | |||
+ | ZigduinoRadio.attachError(errHandle); | ||
+ | ZigduinoRadio.attachTxDone(onXmitDone); | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | if (Serial.available()) | ||
+ | { | ||
+ | ZigduinoRadio.beginTransmission(); | ||
+ | |||
+ | Serial.println(); | ||
+ | Serial.print(" | ||
+ | |||
+ | while(Serial.available()) | ||
+ | { | ||
+ | char c = Serial.read(); | ||
+ | Serial.write(c); | ||
+ | ZigduinoRadio.write(c); | ||
+ | } | ||
+ | |||
+ | Serial.println(); | ||
+ | |||
+ | ZigduinoRadio.endTransmission(); | ||
+ | } | ||
+ | |||
+ | if (ZigduinoRadio.available()) | ||
+ | { | ||
+ | Serial.println(); | ||
+ | Serial.print(" | ||
+ | |||
+ | while(ZigduinoRadio.available()) | ||
+ | Serial.write(ZigduinoRadio.read()); | ||
+ | |||
+ | Serial.println(); | ||
+ | Serial.print(" | ||
+ | Serial.print(ZigduinoRadio.getLqi(), | ||
+ | Serial.print(", | ||
+ | Serial.print(ZigduinoRadio.getLastRssi(), | ||
+ | Serial.print(" | ||
+ | Serial.print(ZigduinoRadio.getLastEd(), | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | |||
+ | delay(1000); | ||
+ | } | ||
+ | |||
+ | void errHandle(radio_error_t err) | ||
+ | { | ||
+ | Serial.println(); | ||
+ | Serial.print(" | ||
+ | Serial.print((uint8_t)err, | ||
+ | Serial.println(); | ||
+ | } | ||
+ | |||
+ | void onXmitDone(radio_tx_done_t x) | ||
+ | { | ||
+ | Serial.println(); | ||
+ | Serial.print(" | ||
+ | Serial.print((uint8_t)x, | ||
+ | Serial.println(); | ||
+ | } | ||
</ | </ |