User Tools

Site Tools


sparrow_v4_en

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
sparrow_v4_en [2015/10/08 15:40]
dan.tudose [Temperature and Humidity 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_small.png?70 |}}
 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 180: Line 181:
 #include "Adafruit_SI1145.h" #include "Adafruit_SI1145.h"
  
-int controlPin 7;+int controlPin 7;
 Adafruit_SI1145 uv = Adafruit_SI1145(); Adafruit_SI1145 uv = Adafruit_SI1145();
  
Line 186: Line 187:
   pinMode(controlPin, OUTPUT);  //sensor on/off control   pinMode(controlPin, OUTPUT);  //sensor on/off control
   delay(100);   delay(100);
 +  digitalWrite(controlPin, LOW);
 +  
 +  delay(1000);
      
   Serial.begin(9600);   Serial.begin(9600);
Line 215: Line 219:
  
   delay(1000);   delay(1000);
 +}
 +</code>
 +
 +===== Barometer =====
 +
 +<imgcaption barometer |  MS5637 barometer/altimeter>{{ ::ms5637-30ba_600.jpg |}}</imgcaption>
 +
 +The Sparrow nodes are using the [[http://www.meas-spec.com/product/pressure/MS5637-02BA03.aspx|MS5637]] pressure sensor for barometric and altimeter measurements. We will use the [[https://github.com/freetronics/BaroSensor|Freetronics]] library to interface with it.
 +
 +<code C>
 +#include <Wire.h>
 +#include <BaroSensor.h>
 +int controlPin = 7;
 +
 +void setup()
 +{
 +  pinMode(controlPin, OUTPUT);  //sensor on/off control
 +  delay(100);
 +  
 +  digitalWrite(controlPin, LOW);
 +  
 +  Serial.begin(9600);
 +  BaroSensor.begin();
 +}
 +
 +void loop()
 +{
 +  if(!BaroSensor.isOK()) {
 +    Serial.print("Sensor not Found/OK. Error: "); 
 +    Serial.println(BaroSensor.getError());
 +    BaroSensor.begin(); // Try to reinitialise the sensor if we can
 +  }
 +  else {
 +    Serial.print("Temperature: "); 
 +    Serial.println(BaroSensor.getTemperature());
 +    Serial.print("Pressure:    ");
 +    Serial.println(BaroSensor.getPressure());
 +  }
 +  delay(1000);
 +}
 +</code>
 +
 +===== Radio Transmission =====
 +
 +We will use the [[https://code.google.com/p/zigduino-radio/|ZigduinoRadio]] library in order to send data between two or more Sparrow nodes. You can download the library from {{::zigduinoradio_201111130010.zip|here}}.
 +
 +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 <ZigduinoRadio.h>
 + 
 +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("Tx: ");
 + 
 +    while(Serial.available())
 +    {
 +      char c = Serial.read();
 +      Serial.write(c);
 +      ZigduinoRadio.write(c);
 +    }
 + 
 +    Serial.println(); 
 + 
 +    ZigduinoRadio.endTransmission();
 +  }
 + 
 +  if (ZigduinoRadio.available())
 +  {
 +    Serial.println();
 +    Serial.print("Rx: ");
 + 
 +    while(ZigduinoRadio.available())
 +      Serial.write(ZigduinoRadio.read());
 + 
 +    Serial.println();
 +    Serial.print("LQI: ");
 +    Serial.print(ZigduinoRadio.getLqi(), 10);
 +    Serial.print(", RSSI: ");
 +    Serial.print(ZigduinoRadio.getLastRssi(), 10);
 +    Serial.print(" dBm, ED: ");
 +    Serial.print(ZigduinoRadio.getLastEd(), 10);
 +    Serial.println("dBm");
 +  }
 + 
 + 
 +  delay(1000);
 +}
 + 
 +void errHandle(radio_error_t err)
 +{
 +  Serial.println();
 +  Serial.print("Error: ");
 +  Serial.print((uint8_t)err, 10);
 +  Serial.println();
 +}
 + 
 +void onXmitDone(radio_tx_done_t x)
 +{
 +  Serial.println();
 +  Serial.print("TxDone: ");
 +  Serial.print((uint8_t)x, 10);
 +  Serial.println();
 } }
 </code> </code>
sparrow_v4_en.1444308032.txt.gz · Last modified: 2015/10/08 15:40 by dan.tudose