SquidBee as a SONAR mote : Detecting presence and measuring distance
Víctor Gracia - July 29, 2008


Important: Libelium has launched a new sensor device: Waspmote. It is ready for research and market applications. You can discover the differences between both platforms in the document: Waspmote vs SquidBee.


0

The SONAR mote is built in a SquidBee box but, instead of the three usual sensors, the heart of the case is an ultrasound device containing a piezo-transducer mounted onto a dedicated PCB.

This kind of sensor is designed to work by emitting 42kHz mechanical waves and detecting the reflected pulses from a distant object after a few milliseconds; the on-board circuit processes this signal and outputs both analog and digital data, which are proportionally dependant upon the distance to the detected object.

Three ports from the sensor PCB and a standard blue LED are solded to the following Arduino pins:

+5 connected to the 5Vdc output (red)

GND connected to one of the GND outputs (black)

AN connected to the ANALOG-0 input (yellow)

LED connected through a 500Ω resistor to the DIGITAL-11 and GND outputs (blue)

Once soldered, the transducer and the LED are placed through two holes in the box. A 9Vdc transformer from a constant 220Vac power supply feeds the main board  and the mote is hung on a wall in front of the door at a distance of 5m.

2

The mote is programmed to periodically read the analog output from the sensor and calculate the actual distance to an object with a multiplicative factor of 1.27, since the output is directly proportional to the measured distance (see datasheet). Whenever this value is modified, which means the object is moving within the sensor range, the LED turns on and an alert is sent; in addition, the closer to the sensor the object is, the higher the frequency the LED blinks with.

 

1

Due to the fact that the distance between the mote and the door is 5m and the sensor is capable of measuring up to 6.45m, we firstly tested the mote with an alarm threshold for any distance below 5m in order to detect motion from every object coming in or coming out. When we opened the door or moved close to the mote, it seemed to work fine since the alarm appeared, but it started sending more warns constantly even if there was nothing moving; the problem lied in the sensor intrinsic error, which is around 15-20cm depending upon the environmental conditions, so the calculated distance was always a number between 4.8 - 5m and the alarm was consequently shot at any time. This issue was fixed by reducing the threshold to 4.8m. The mote works and sends a warn everytime we cross the monitored zone or anybody opens the door. Therefore, this is a very good and cheap choice for a domestic alarm.

/*
* Copyright (C) 2008 Libelium Comunicaciones Distribuidas S.L.
*
* This file is part of SquidBee code examples
* squidbee_sonarMote.pde is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*You should have received a copy of the GNU General Public License
*along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/

/* Name: squidbee_sonarMote.pde
* Version 0.0.1
* Desc: A sonar sensor is attached to SquidBee and we can meassure distance to objects
* Author: Marcos Yarza <m.yarza"at/removethis"libelium.com>
*/

/*

- AN Output connected to ANALOG-0 input in Arduino

- Meauserement accuracy: 9.8mV/2.5cm = 1.27cm/whole number (10bits)

- Blue LED connected to DIGITAL-13 output, which blinks with a frequency proportional to distance

*/

int AN = 0; // AN -> pin ANALOG-0

int d = 0; // Distance variable = d

int distance = 0;

int distance_aux = 0;

int ledPin = 10;

int ledProximity = 11;

int margin = 15;

int led = 8;

int time = 0;

 

void setup() {

 

Serial.begin(19200);

pinMode(led, OUTPUT); // DIGITAL-out 10

pinMode(ledProximidad, OUTPUT); // DIGITAL-out 11

}

 

void loop() {

d = analogRead(AN); // signal value -> d (not corrected)

distance = d * 1.27;

if (distance < 480){

while ((distance >= (distance_aux + margin))||(distance <= (distance_aux - margin))){

 

Serial.print("Somebody's entering!!!! ...");

Serial.print(" Distance from the wall: ");

Serial.println(distance);


d = analogRead(AN); // signal value -> d (not corrected)

distance = d * 1.27; //distance measured in cm (corrected)

distance_aux = distance;

time = distance *2;

digitalWrite(led,HIGH);

delay(time);

digitalWrite(led,LOW);

delay(time);

}

}

/*

d = analogRead(AN); // signal value -> d (not corrected)

distance = d * 1.27; //distance measured in cm (corrected)

 

Serial.print("Somebody's entering!!!! ...");

Serial.print(" Distance from the wall: ");

Serial.println(distance);

delay (500);*/

 

}

gallery.png
theGroup.png

barra_lateral/rss
Research
  • Enclosure
  • Energy Management
  • GPS Mesh Networks
  • Hardware Node
  • Manager Platform
  • Mesh Routing Protocols
  • Securing the Mesh
  • Sensor Integration
  • System and Communications
  • System and Manager Platform
barra_lateral/techM