This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:iot-open:remotelab:ume:smartme [2019/10/29 13:17] – salvatdi | en:iot-open:remotelab:ume:smartme [2020/07/20 12:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== SmartMe Network Laboratory: Arduino Nodes 1-5 ====== | ||
| + | The SmartMe lab is located at the Engineering building of the University of Messina, in Messina, Italy. | ||
| + | ===== Introduction | ||
| + | Its main goal is to provide a simple testbed of a smart city, mainly focusing on smart environment application scenarios. To this purpose, 6 nodes have been equipped and made available to students for practising in these contexts. These nodes can be framed into the MCU (Arduino) + MPU (Raspberry Pi) category: 5 out of 6 combine an Arduino Uno with a Raspberry Pi 3 b+, the last node is a combo board developed by a spinoff company (SmartMe.io), | ||
| + | |||
| + | ===== Prerequisites ===== | ||
| + | To approach this laboratory, the student should grasp: | ||
| + | * basic MQTT concepts like topics, broker, subscribing and publishing; | ||
| + | * quantities and metrics related to the physical quantities that can be detected using DHT and PMS sensors: temperature (°C and F), relative humidity (%), air quality (PMx concentration). | ||
| + | |||
| + | |||
| + | ===== Technical details ===== | ||
| + | 4 Arduino nodes are Internet-connected by a router through ETH, while the 5th is reachable only by the IoT gateway (RaspPi). | ||
| + | The Lab configuration is shown in the figure below | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | |||
| + | ==== Node schematic ==== | ||
| + | All Arduino nodes are configured as reported in the following schematic | ||
| + | |||
| + | {{: | ||
| + | |||
| + | |||
| + | ===== Sensors ===== | ||
| + | |||
| + | Each node is equipped with either a DHT11 or DHT22 sensor and a PMS7003 sensor. | ||
| + | The DHT sensors allow measuring temperature and relative humidity, while the PMS7003 sensor allows measuring the air quality through the PMx concentration. | ||
| + | |||
| + | / | ||
| + | ^ Parameter ^ DHT11 ^ DHT22 ^ | ||
| + | |Operating Voltage | 3 to 5V| 3 to 5V | | ||
| + | |Operating Current | 0.3mA (measuring) 60uA (standby) | 0.3mA (measuring) 60uA (standby) | | ||
| + | |Humidity Range | 20-80% / 5% | 0-100% / 2-5%| | ||
| + | |Temperature Range|0-50°C / ± 2°C|-40 to 80°C / ± 0.5°C| | ||
| + | |Sampling Rate | 1 Hz (reading every second) |0.5 Hz (reading every 2 seconds) | | ||
| + | |Body size|15.5mm x 12mm x 5.5mm |15.1mm x 25mm x 7.7mm | | ||
| + | |Advantage |Ultra low cost |More Accurate | | ||
| + | |Resolution | 16-bit | ||
| + | |Accuracy| ±1°C and ±1% |±0.5°C and ±1%| | ||
| + | |Sampling period|1 second|2 second | | ||
| + | |Price|$1 to $5|$4 to $10 | | ||
| + | |||
| + | |||
| + | Some nodes of the lab are equipped with " | ||
| + | |||
| + | The PMS7003 consists of a digital and universal particle concentration sensor, which can be used to obtain the number of suspended particles in the air, i.e. the concentration of particles, and output them in the form of a digital interface. The working principle of such a sensor consists into produce scattering by using a laser to radiate suspending particles in the air, then collect scattering light to a certain degree, and finally obtain the curve of scattering light change with time. In the end, the equivalent particle diameter and the number of particles with different diameters per unit volume can be calculated [3]. So, the values of PM1.0, PM2.5, and PM10, will be available for our scopes. In order to physically interface the 10 bus lines of the sensor with Arduino Uno, the PMS7003 connector shown in the previous figure was employed [4]. By supplying the adapter at 5V, the particle sensor will operate correctly and the data will be available at RX and TX pins. However, the serial voltage level is 3.3V typical, while Arduino Uno needs 5V. For this reason, a bi-directional level converter was introduced [5]: by supplying the HV (High Voltage) side at 5V and the LV (Low Voltage) side at 3.3V, the serial levels will be correct on both sides (Arduino at 5V, PMS7003 at 3.3V). Since is not possible to deploy the code by using, at the same time, the default RX, TX pins (0,1) of Arduino Uno, the PMS7003 is connected to pins 9 and 10: by using the < | ||
| + | |||
| + | [1]https:// | ||
| + | |||
| + | [2]http:// | ||
| + | |||
| + | [3]https:// | ||
| + | |||
| + | [4]https:// | ||
| + | |||
| + | [5]https:// | ||
| + | |||
| + | ===== Actuators ===== | ||
| + | There are no mechanical actuators in this laboratory. | ||
| + | Each node is equipped with a 2x16 LCD screen and with an RGB led, but it is possible to use only the green light component. | ||
| + | The green led of the RGB is connected to the Arduino pin 3. Since such a pin supports the PWM, the led brilliance can be set. Moreover, the led can be used for blinking or to indicate when a threshold is reached. | ||
| + | The 2x16 LCD is a Displaytech 162B based on the HD44780 standard. Such standard means that the display supports almost all characters of the ASCII character table. Therefore, it is possible to display the most important characters. The display controller, which is integrated into the display, can generate these characters and send them to the matrix. In addition to the already 208 known characters, it is also possible to draw any other characters and signs. The display controller handles most of the operations, so the code for the microcontroller is very short [6]. Both 8 bit or 4-bit mode can be used to drive the display. The < | ||
| + | |||
| + | [6] https:// | ||
| + | |||
| + | === Power supply === | ||
| + | Each node is equipped with a Breadboard Power Supply Module MB120. | ||
| + | The MB102 is able to provide up to 700 mA, with a voltage of 3.3V and/or 5V. It can be supplied with an external DC power supply, in the range of 6.5 - 12V. The required voltage can be selected by properly choice the onboard jumper position. Both 3.3V and 5V are required in the project. | ||
| + | |||
| + | |||
| + | ===== Software, libraries and externals ===== | ||
| + | The following libraries are required to run the example proposed below for the hands-on labs: | ||
| + | * Liquid Crystal | ||
| + | * DHT sensor Library (mandatory version 1.3.0) | ||
| + | * Adafruit Unified Sensor | ||
| + | * PMS | ||
| + | * Ethernet | ||
| + | * MQTT | ||
| + | |||
| + | LCD display requires a dedicated library. Of course, you can control it on the low-level programming, | ||
| + | The LCD control library can be imported to the source code via: | ||
| + | <code c> | ||
| + | #include < | ||
| + | </ | ||
| + | |||
| + | Then configure your LCD controller: | ||
| + | |||
| + | <code c> | ||
| + | // initialize the library with the numbers of the interface pins | ||
| + | LiquidCrystal lcd(7, 6, 5, 4, 13, 2); | ||
| + | </ | ||
| + | |||
| + | |||
| + | DHT11 and DHT22 sensors require some dedicated library. We strongly recommend using the "DHT sensor library" | ||
| + | The DHT sensor library can be imported to the source code via: | ||
| + | <code c> | ||
| + | #include < | ||
| + | </ | ||
| + | |||
| + | Configure your DHT sensor: | ||
| + | <code c> | ||
| + | #define DHTPIN 8 // Digital pin connected to the DHT sensor | ||
| + | // Uncomment whatever type you're using! | ||
| + | //#define DHTTYPE DHT11 // DHT 11 | ||
| + | #define DHTTYPE DHT22 | ||
| + | // Initialize DHT sensor. | ||
| + | DHT dht(DHTPIN, DHTTYPE); | ||
| + | </ | ||
| + | |||
| + | PMS sensor requires a dedicated library. The Arduino library for Plantower PMS sensors, also “PMS” library, supports PMS x003 sensors (1003, 3003, 5003, 6003, 7003). | ||
| + | The PMS sensor library can be imported to the source code via: | ||
| + | <code c> | ||
| + | #include " | ||
| + | </ | ||
| + | |||
| + | The PMS sensor is connected to pins 9 and 10: by using the ''< | ||
| + | <code c> | ||
| + | #include < | ||
| + | SoftwareSerial mySerial(9, | ||
| + | </ | ||
| + | |||
| + | |||
| + | Arduino Ethernet Shield requires a dedicated library. With the Arduino Ethernet Shield, the '' | ||
| + | The Arduino Ethernet Shield library can be imported to the source code via: | ||
| + | <code c> | ||
| + | #include < | ||
| + | </ | ||
| + | |||
| + | Then configure your Ethernet Shield: | ||
| + | <code c> | ||
| + | // Enter a MAC address and IP address for your controller below. | ||
| + | byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEF}; | ||
| + | byte ip[] = {192, 168, 0, 99}; // <- change to match your network | ||
| + | </ | ||
| + | |||
| + | MQTT connectivity protocol requires a dedicated library. The '' | ||
| + | The Arduino Ethernet Shield library can be imported to the source code via: | ||
| + | <code c> | ||
| + | #include < | ||
| + | </ | ||
| + | |||
| + | === “platformio.ini” (Project Configuration File) === | ||
| + | The Project configuration file is named platformio.ini. | ||
| + | < | ||
| + | [env:uno] | ||
| + | platform = atmelavr | ||
| + | board = uno | ||
| + | framework = arduino | ||
| + | |||
| + | lib_ldf_mode=deep+ | ||
| + | lib_compat_mode=strict | ||
| + | |||
| + | lib_deps = | ||
| + | DHT sensor library@1.3.0 | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | lib_deps_external = | ||
| + | | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ===== Communication ===== | ||
| + | The user can connect and program the controller of each node by using the Distancelab environment by booking it for the time he needs. The user can use the MQTT protocol. MQTT stands for Message Queuing Telemetry Transport. | ||
| + | |||
| + | MQTT is a machine-to-machine (M2M) connectivity protocol usable for “Internet of Things” solutions. MQTT is a simple messaging protocol, designed for constrained devices with low-bandwidth. So, it’s the perfect solution for Internet of Things applications. | ||
| + | |||
| + | This publish/ | ||
| + | So a client must connect to a broker in order to: | ||
| + | * publish messages specifying a topic so that other clients that have subscribed to that topic will be able to receive those messages; | ||
| + | * receive messages subscribing to a specific topic. | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | |||
| + | ===== Limits ===== | ||
| + | At the same time, only one user can program the controller. But all users connected to the Distancelab MQTT broker can read the values if they are being transmitted over MQTT. | ||
| + | |||
| + | |||
| + | ===== Support ===== | ||
| + | gmerlino@unime.it, | ||