Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:iot-open:remotelab:ume:arancino [2019/10/01 16:01] salvatdien:iot-open:remotelab:ume:arancino [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 5: Line 5:
 ==== Introduction ==== ==== Introduction ====
  
-Its main goal is to provide a single-node testbed consisting of a next-generation “combo” board, a.k.a. Single-Board Computer (SBC) mainly focusing on smart environment monitoring scenarios. To this purpose, 1 node has been equipped and made available to students for practicing in these contexts. This node is a combo SBC which combines onto the same node a so-called “carrier board”, in this case an Arancino™ by smartme.IO, with an Arduino-like MCU (based on an ARM Cortex M0+ @48MHz) built-in, hosting a Raspberry Pi 3 Compute Module (CM3). In this section, we will focus on this Arancino node and its sensors/actuators.+Its main goal is to provide a single-node testbed consisting of a next-generation “combo” board, a.k.a. Single-Board Computer (SBC) mainly focusing on smart environment monitoring scenarios. To this purpose, 1 node has been equipped and made available to students for practicing in these contexts. This node is a combo SBC which combines onto the same node a so-called “carrier board”, in this casean Arancino(TM) by smartme.IO, with an Arduino-like MCU (based on an ARM Cortex M0+ @48MHz) built-in, hosting a Raspberry Pi 3 Compute Module (CM3). In this section, we will focus on this Arancino node and its sensors/actuators.
  
 ==== Prerequisites ==== ==== Prerequisites ====
Line 34: Line 34:
 The BME680 is a (combined) digital gas, humidity, pressure, and temperature sensor based on proven sensing principles. The BME680 is a (combined) digital gas, humidity, pressure, and temperature sensor based on proven sensing principles.
 The humidity sensor provides an extremely fast response time for fast context awareness applications and high overall accuracy over a wide temperature range. The pressure sensor is an absolute barometric pressure sensor with extremely high accuracy and resolution. The humidity sensor provides an extremely fast response time for fast context awareness applications and high overall accuracy over a wide temperature range. The pressure sensor is an absolute barometric pressure sensor with extremely high accuracy and resolution.
-The integrated temperature sensor has been optimized for lowest noise and highest resolution. Its output is used for temperature compensation of the pressure and humidity sensors and can also be used for estimation of the ambient temperature.+The integrated temperature sensor has been optimized for the lowest noise and highest resolution. Its output is used for temperature compensation of the pressure and humidity sensors and can also be used for estimation of the ambient temperature.
 The gas sensor within the BME680 can detect a broad range of gases to measure indoor air quality for personal well being. Gases that can be detected by the BME680 include Volatile Organic Compounds (VOC) from paints (such as formaldehyde), lacquers, paint strippers, cleaning supplies, furnishings, office equipment, glues, adhesives, and alcohol. The gas sensor within the BME680 can detect a broad range of gases to measure indoor air quality for personal well being. Gases that can be detected by the BME680 include Volatile Organic Compounds (VOC) from paints (such as formaldehyde), lacquers, paint strippers, cleaning supplies, furnishings, office equipment, glues, adhesives, and alcohol.
  
Line 58: Line 58:
 ==== Actuators ==== ==== Actuators ====
  
-There are no mechanical actuators or displays in this laboratory. The node is nevertheless equipped with three LEDs, including an MCU-controlled one. By default, i.e., after MCU reset (which may be triggered by quick double-click on the corresponding button) the aforementioned LED starts “breathing”, slowly. The “breathing” effect may be felt when LED turns on and off by fading in and fading out, respectively.+There are no mechanical actuators or displays in this laboratory. The node is nevertheless equipped with three LEDs, including an MCU-controlled one. By default, i.e., after MCU reset (which may be triggered by quick double-click on the corresponding button) the aforementioned LED starts “breathing”, slowly. The “breathing” effect may be felt when an LED turns on and off by fading in and fading out, respectively.
  
 ==== Power supply ==== ==== Power supply ====
 The node is powered by an external DC (5V) power supply over USB. The node is powered by an external DC (5V) power supply over USB.
-Software, libraries and externals+Software, librariesand externals
 The following libraries are required to run the example proposed below for the hands-on labs: The following libraries are required to run the example proposed below for the hands-on labs:
   * SPI   * SPI
Line 151: Line 151:
 The digital pins either give you 5V (when turned HIGH) or 0V (when turned LOW) and the output is a square wave signal.  The digital pins either give you 5V (when turned HIGH) or 0V (when turned LOW) and the output is a square wave signal. 
 PWM stands for Pulse Width Modulation and it is a technique used in controlling the brightness of the LED. The PWM pins are labelled with ~ sign. PWM stands for Pulse Width Modulation and it is a technique used in controlling the brightness of the LED. The PWM pins are labelled with ~ sign.
-The function analogWrite() can be used to generate a PWM signal in those digital pins that are labelled with ~ sign. The frequency of this generated signal for most pins will be about 490Hz and you can give the value from 0-255 using this function. +The function analogWrite() can be used to generate a PWM signal in those digital pins that are labelled with ~ sign.  
-analogWrite(0) means a signal of 0% duty cycle. +The frequency of this generated signal for most pins will be about 490Hz and you can give the value from 0-255 using this function. 
-analogWrite(127) means a signal of 50% duty cycle. +  analogWrite(0) means a signal of 0% duty cycle. 
-analogWrite(255) means a signal of 100% duty cycle.+  analogWrite(127) means a signal of 50% duty cycle. 
 +  analogWrite(255) means a signal of 100% duty cycle.
 The function random() generates pseudo-random numbers. The syntax is random(max) or random(min, max), where min represents the lower bound of the random value, inclusive (optional); and max represents the upper bound of the random value, exclusive. The function returns a long random number between min and max-1. The function random() generates pseudo-random numbers. The syntax is random(max) or random(min, max), where min represents the lower bound of the random value, inclusive (optional); and max represents the upper bound of the random value, exclusive. The function returns a long random number between min and max-1.
    
Line 164: Line 165:
  
 Initialize the LCD screen with the label “rand value”, then calculates a random value. If randomValue is lower than lowThreshold, turn on the LED. If randomValue is upper than highThreshold, turn off the LED. After 1 second, print the random value to the LCD. Then, turn on the LED for 3 seconds, assigning it a value of brightness which corresponds to the random value previously calculated. Note, you can set the two values of the threshold as you prefer. You can modify the brightness of the LED because, although it is connected to a digital pin, the Arduino pin number 3 is labelled with ~ sign (PWM). Initialize the LCD screen with the label “rand value”, then calculates a random value. If randomValue is lower than lowThreshold, turn on the LED. If randomValue is upper than highThreshold, turn off the LED. After 1 second, print the random value to the LCD. Then, turn on the LED for 3 seconds, assigning it a value of brightness which corresponds to the random value previously calculated. Note, you can set the two values of the threshold as you prefer. You can modify the brightness of the LED because, although it is connected to a digital pin, the Arduino pin number 3 is labelled with ~ sign (PWM).
-Result+ 
 +==== Result ==== 
 You should see the LED on or off for 1 second, a second if the value is greater or less than the predefined threshold values. Next, you should see the randomly calculated value between 0 and 255 on the LCD, at that point, the LED should assign a brightness associated with that value, and keep it for 3 seconds. You should see the LED on or off for 1 second, a second if the value is greater or less than the predefined threshold values. Next, you should see the randomly calculated value between 0 and 255 on the LCD, at that point, the LED should assign a brightness associated with that value, and keep it for 3 seconds.
-Start+ 
 +==== Start ==== 
 There are no special steps to be performed. There are no special steps to be performed.
  
-Steps +==== Steps ==== 
-Step 1+ 
 +=== Step 1 === 
 Include required libraries: Include required libraries:
 +<code c>
 #include <Wire.h> #include <Wire.h>
 #include <SPI.h> #include <SPI.h>
Line 177: Line 185:
 #include <Adafruit_BME680.h> #include <Adafruit_BME680.h>
 #include <Arancino.h> #include <Arancino.h>
- +</code>  
 and define a number of directives: and define a number of directives:
 +
 +<code c>
 #define DEBUG true // enable debug #define DEBUG true // enable debug
 #define BME_SCK 13 #define BME_SCK 13
Line 184: Line 195:
 #define BME_MOSI 11 #define BME_MOSI 11
 #define BME_CS 10 #define BME_CS 10
-  
 #define SEALEVELPRESSURE_HPA (1013.25) #define SEALEVELPRESSURE_HPA (1013.25)
- +</code>  
 Declare the sensor(s) object, a number of useful vars and constants, and assign them (e.g., initial) values when required: Declare the sensor(s) object, a number of useful vars and constants, and assign them (e.g., initial) values when required:
-Adafruit_BME680 bme680_sensor; // I2C + 
- +<code c> 
 +Adafruit_BME680 bme680_sensor; // I2C 
 // Used here to set a pin number: // Used here to set a pin number:
-const int ledPin =  LED_BUILTIN; // the number of the LED pin +const int ledPin =  LED_BUILTIN; // the number of the LED pin  
-  +int ledState = LOW; // ledState used to set the LED  
-int ledState = LOW; // ledState used to set the LED +unsigned long previousMillis = 0; // will store last time LED was updated
-  +
-unsigned long previousMillis = 0; // will store last time LED was +
-                                  //updated+
 unsigned long currentMill=0; unsigned long currentMill=0;
-  +const long interval = 150; // interval at which to blink (milliseconds) 
-const long interval = 150; // interval at which to blink +
-                           // (milliseconds) +
- +
 float humidity_read; float humidity_read;
 float temperature_read; float temperature_read;
-float pressure_read; +float pressure_read;  
-  +unsigned long previousMillisTemp = 0; // environment reading interval 
-unsigned long previousMillisTemp = 0; // environment reading  +const long intervalTemp = 400; // interval at which to blink(milliseconds) 
-                                      // interval +</code>
-const long intervalTemp = 400; // interval at which to blink +
-                               // (milliseconds)+
    
 Functions declarations cannot be omitted (when using .cpp extension instead of .ino one): Functions declarations cannot be omitted (when using .cpp extension instead of .ino one):
 +
 +<code c>
 void bme680_begin(); void bme680_begin();
 void bme680_read(); void bme680_read();
 void blink_status(); void blink_status();
 +</code>
    
-Step 2 +=== Step 2 === 
-Functions definitions for: BME680 sensor initialization and settings configuration (bme680_begin()); sample(s) acquisition, and writing into MPU-visible Redis variables (bme680_read()); (diagnostic) LED blinking (blink_status()).+ 
 +Functions definitions for: BME680 sensor initialization and settings configuration (''bme680_begin()''); sample(s) acquisition, and writing into MPU-visible Redis variables (''bme680_read()''); (diagnostic) LED blinking (''blink_status()''). 
 + 
 +<code c>
 void bme680_begin(){ void bme680_begin(){
   if(!bme680_sensor.begin()) {   if(!bme680_sensor.begin()) {
Line 223: Line 233:
     while (1);     while (1);
   }   }
-  
   // Set up oversampling and filter initialization   // Set up oversampling and filter initialization
   bme680_sensor.setTemperatureOversampling(BME680_OS_8X);   bme680_sensor.setTemperatureOversampling(BME680_OS_8X);
Line 261: Line 270:
   }   }
 } }
 +</code>
  
-     Step 3 +=== Step 3 ===
  
-Initialize the Redis structures (Arancino.begin()), initialize/setup the (e.g., I2C) communication logic (Wire.begin()) and sensor(s) (bme680_begin()), declare the LED pin as OUTPUT - we suggest to perform those steps within the setup() function:+Initialize the Redis structures (Arancino.begin()), initialize/setup the (e.g., I2C) communication logic (''Wire.begin()'') and sensor(s) (''bme680_begin()''), declare the LED pin as OUTPUT - we suggest to perform those steps within the setup() function:
  
 +<code c>
 void setup(void) void setup(void)
 { {
Line 276: Line 286:
   pinMode(ledPin, OUTPUT);   pinMode(ledPin, OUTPUT);
 } }
 +</code> 
    
-  +=== Step 4 === 
-Step 4 + 
-Implement loop() to do in the order:  +Implement ''loop()'' to do in the order:  
-perform the readings (see Step 2 for more details);  +  perform the readings (see Step 2 for more details);  
-blink the led (see Step 2 for more details).+  blink the led (see Step 2 for more details).
    
    
 +<code c>
 void loop() void loop()
 { {
Line 289: Line 301:
   blink_status();   blink_status();
 } }
 +</code>
 +
 +==== Result validation ====
  
-Result validation 
 Observe the state of the LED for 1 second, this status will depend on the random number calculated and the threshold values that have been set. Observe the random value calculated on the display monitor. Observe how the random value affects the LED brightness for 3 seconds. Observe the state of the LED for 1 second, this status will depend on the random number calculated and the threshold values that have been set. Observe the random value calculated on the display monitor. Observe how the random value affects the LED brightness for 3 seconds.
    
-Platformio.ini +==== Platformio.ini ====
  
 +<code c>
 [env:uno] [env:uno]
 platform = atmelsam platform = atmelsam
Line 312: Line 326:
   -Wno-reorder   -Wno-reorder
   -Wno-return-type   -Wno-return-type
 +</code>
  
 +==== aran.cpp ====
  
-aran.cpp +<code c>
 #include <Wire.h> #include <Wire.h>
 #include <SPI.h> #include <SPI.h>
Line 416: Line 431:
   blink_status();   blink_status();
 } }
 +</code>
  
en/iot-open/remotelab/ume/arancino.1569945687.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0