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:59] dan.tudose [Light Sensor] |
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 187: | Line 188: | ||
delay(100); | delay(100); | ||
digitalWrite(controlPin, | digitalWrite(controlPin, | ||
- | + | ||
+ | delay(1000); | ||
+ | | ||
Serial.begin(9600); | Serial.begin(9600); | ||
| | ||
Line 223: | Line 226: | ||
< | < | ||
+ | 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(); | ||
+ | } | ||
+ | </ |