You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
5.2 KiB

5 years ago
= Sensor node/mote
5 years ago
Apostolos rootApostolos@swarmlab.io
// Metadata:
:description: IoT Διαδίκτυο των Αντικειμένων
:keywords: iot, imu, AHRS
:data-uri:
:toc: right
:toc-title: Πίνακας περιεχομένων
:toclevels: 4
:source-highlighter: highlight
:icons: font
:sectnums:
include::header.adoc[]
{empty} +
5 years ago
A **sensor node**, also known as a **mote**, is a node in a sensor network that is capable of performing some processing, gathering sensory information and communicating with other connected nodes in the network.
5 years ago
5 years ago
[NOTE]
====
A mote is a node but a node is not always a mote
====
5 years ago
.The typical architecture of the sensor node
5 years ago
image:./sensorNode.jpg[alt="The typical architecture of the sensor node"]
5 years ago
5 years ago
The main components of a sensor node are a **microcontroller**, **transceiver/Communication Module**, **memory**, **power source** and one or more **sensors.**
5 years ago
== Sensor node using IMU sensors
5 years ago
A basic IMU (Intertial Measurement Unit) generally provides raw sensor data, whereas an AHRS takes this data one step further, converting it into heading or direction in degrees, converting the raw altitude data into standard units like feet or meters, etc.
5 years ago
.AHRS (Attitude and Heading Reference System)
[NOTE]
====
An attitude and heading reference system (AHRS) consists of sensors on three axes that provide attitude information for aircraft, including roll, pitch and yaw. These are sometimes referred to as MARG (Magnetic, Angular Rate, and Gravity) sensors and consist of either solid-state or microelectromechanical systems (MEMS) gyroscopes, accelerometers and magnetometers. They are designed to replace traditional mechanical gyroscopic flight instruments.
====
[More Info]https://en.wikipedia.org/wiki/Attitude_and_heading_reference_system[^]
5 years ago
[[cheat-Articles]]
5 years ago
=== IMU
5 years ago
image:./sensors_1604_LRG.jpg[alt="Adafruit 10-DOF IMU Breakout"]
5 years ago
5 years ago
Adafruit's 10DOF https://en.wikipedia.org/wiki/Degrees_of_freedom[(10 Degrees of Freedom)] breakout board allows you to capture ten distinct types of motion or orientation related data.
5 years ago
- LSM303DLHC - a 3-axis accelerometer (up to +/-16g) and a 3-axis magnetometer (up to +/-8.1 gauss) on a single die
- L3GD20 - a 3-axis gyroscope (up to +/-2000 dps)
- BMP180 - A barometric pressure sensor (300..1100 hPa) that can be used to calculate altitude, with an additional on-board temperature sensor
5 years ago
=== Connecting It Up
5 years ago
Basic Setup
- Connect the **SCL** pin on the breakout to the **SCL** pin on your Arduino. On an UNO & '328 based Arduino, this is also known as **A5**
- Connect the **SDA** pin on the breakout to the **SDA** pin on your Arduino. On an UNO & '328 based Arduino, this is also known as **A4**
- Connect the **VIN** pin on the breakout to **3.3V** or **5V** on your Uno (5V is preferred but if you have a 3V logic Arduino 3V is best)
- Connect the **GND** pin on the breakout to the **GND** pin on your Uno
That's it! With those four wires, you should be able to talk to any of the I2C chips on the board and run any of the example sketches.
image:./sensors_10dofwire.jpg[alt="Connecting"]
Advanced Setup
- **GINT** - The interrupt pin on the L3GD20 gyroscope
- **GRDY** - The 'ready' pin on the L3GD20 gyroscope
- **LIN1** - Interrupt pin 1 on the LSM303DLHC
- **LIN2** - Interrupt pin 2 on the LSM303DLHC
- **LRDY** - The ready pin on the LSM303DLHC
These pins are all outputs from the 10-DOF breakout and are all 3.3V logic
5 years ago
=== Downloading Libraries
5 years ago
Place the files in the Arduino Sketch Folder '/libraries' sub-folder. You should end up with a structure like this:
- arduinosketches/libraries/Adafruit_10DOF
- arduinosketches/libraries/Adafruit_BMP085
- arduinosketches/libraries/Adafruit_L3GD20_U
- arduinosketches/libraries/Adafruit_LSM303DLHC
- arduinosketches/libraries/Adafruit_Sensor
.Arduino libraries
[NOTE]
====
Arduino libraries are a convenient way to share code such as device drivers or commonly used utility functions.
5 years ago
https://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use[How to install Arduino libraries]
5 years ago
====
5 years ago
=== Example Sketch
5 years ago
5 years ago
==== pitch & roll
5 years ago
.sketch pitchrollheading
[source,c]
----
sensors_event_t accel_event;
sensors_vec_t orientation;
/* Calculate pitch and roll from the raw accelerometer data */
accel.getEvent(&accel_event);
if (dof.accelGetOrientation(&accel_event, &orientation))
{
/* 'orientation' should have valid .roll and .pitch fields */
Serial.print(F("Roll: "));
Serial.print(orientation.roll);
Serial.print(F("; "));
Serial.print(F("Pitch: "));
Serial.print(orientation.pitch);
Serial.print(F("; "));
}
----
image:./800px-Flight_dynamics_with_text.png[alt="pitchroll"]
5 years ago
5 years ago
Arguments
- event: The **sensors_event_t** variable containing the data from the **accelerometer**
- orientation: The **sensors_vec_t** object that will have its **.pitch** and **.roll** fields populated
Returns
- **true** if the operation was successful,
- **false** if there was an error
image:./piandrroll.png[alt="pitchroll"]
:hardbreaks:
{empty} +
{empty} +
{empty}
:!hardbreaks:
'''
.Reminder
[NOTE]
====
:hardbreaks:
Caminante, no hay camino,
se hace camino al andar.
Wanderer, there is no path,
the path is made by walking.
*Antonio Machado* Campos de Castilla
====