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:32]
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_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 128: Line 129:
 \\ \\
  
-=== Temperature and Humidity Sensor ====+===== Temperature and Humidity Sensor ======
  
 Si7021 is an integrated sensor that measures both temperature and relative humidity with good accuracy. The resolution of measured parameters can be selected through software between 8-12 bits for humidity and 12-14 bits for temperature. The sensor uses a digital I2C interface for data transmission, so we can easily interface with it using the Wire library. Si7021 is an integrated sensor that measures both temperature and relative humidity with good accuracy. The resolution of measured parameters can be selected through software between 8-12 bits for humidity and 12-14 bits for temperature. The sensor uses a digital I2C interface for data transmission, so we can easily interface with it using the Wire library.
Line 139: Line 140:
 #include <Wire.h> #include <Wire.h>
 #include <SHT2x.h> #include <SHT2x.h>
 + 
 int controlPin = 7; int controlPin = 7;
 + 
 void setup() void setup()
 { {
Line 148: Line 149:
   Wire.begin();   Wire.begin();
   Serial.begin(9600);   Serial.begin(9600);
-} 
  
 +  digitalWrite(controlPin, LOW); //enable all sensors
 +}
 + 
 void loop() void loop()
 { {
-  digitalWrite(controlPin, LOW); //enable all sensors 
      
 + 
   Serial.print("Humidity(%RH): ");   Serial.print("Humidity(%RH): ");
   Serial.print(SHT2x.GetHumidity());   Serial.print(SHT2x.GetHumidity());
   Serial.print("     Temperature(C): ");   Serial.print("     Temperature(C): ");
   Serial.println(SHT2x.GetTemperature());   Serial.println(SHT2x.GetTemperature());
 + 
 +  //digitalWrite(controlPin, HIGH); //disable all sensors
 + 
 +  delay(1000);
 +}
 +
 +</code>
 +
 +
 +===== Light Sensor =====
 +
 +<imgcaption light | SI1145 ambient light sensor and AVR connection schematic>{{ ::si1145.png |}}</imgcaption>
 +
 +We will use the [[https://learn.adafruit.com/adafruit-si1145-breakout-board-uv-ir-visible-sensor/overview|Adafruit_SI1145]] library to interface with the sensor. Unzip the content of this {{::adafruit_si1145.zip| zip file}} into the //Arduino\libraries// or use Arduino IDE's Add ZIP Library command.
 +
 +
 +<code C>
 +#include <Wire.h>
 +#include "Adafruit_SI1145.h"
 +
 +int controlPin = 7;
 +Adafruit_SI1145 uv = Adafruit_SI1145();
 +
 +void setup() {
 +  pinMode(controlPin, OUTPUT);  //sensor on/off control
 +  delay(100);
 +  digitalWrite(controlPin, LOW);
      
-  digitalWrite(controlPin, HIGH); //disable all sensors+  delay(1000);
      
 +  Serial.begin(9600);
 +  
 +  Serial.println("Adafruit SI1145 test");
 +  
 +  if (! uv.begin()) {
 +    Serial.println("Didn't find Si1145");
 +    while (1);
 +  }
 +
 +  Serial.println("OK!");
 +}
 +
 +void loop() {
 +    
 +  Serial.println("===================");
 +  Serial.print("Vis: "); Serial.println(uv.readVisible());
 +  Serial.print("IR: "); Serial.println(uv.readIR());
 +  
 +  // Uncomment if you have an IR LED attached to LED pin!
 +  //Serial.print("Prox: "); Serial.println(uv.readProx());
 +
 +  float UVindex = uv.readUV();
 +  // the index is multiplied by 100 so to get the
 +  // integer index, divide by 100!
 +  UVindex /= 100.0;  
 +  Serial.print("UV: ");  Serial.println(UVindex);
 +
   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.1444307546.txt.gz · Last modified: 2015/10/08 15:32 by dan.tudose