User Tools

Site Tools


No ACL setup yet! Denying access to everyone.
en:edu:zmitac:s2:iot:aih

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:edu:zmitac:s2:iot:aih [2021/01/08 09:58] – [Laboratory on the Internet of Things - Advanced IoT Hardware] pczekalskien:edu:zmitac:s2:iot:aih [2022/11/15 15:49] (current) – Pczekalski
Line 5: Line 5:
  
 You can access the distant laboratory (VREL) interface here: [[http://distance.roboticlab.eu/]].\\ You can access the distant laboratory (VREL) interface here: [[http://distance.roboticlab.eu/]].\\
-You need to register an account (unless you have one, already). A short video presenting the account creation process and first steps is here: [[https://youtu.be/0R6oUWkBrpQ]]+You need to register an account (unless you have one already). A short video presenting the account creation process and first steps is here: [[https://youtu.be/0R6oUWkBrpQ]]
  
 ===== Hardware ===== ===== Hardware =====
Line 14: Line 14:
 Below we present hardware details on the two modules: Below we present hardware details on the two modules:
 ==== ESP32 WROVER DEVKIT ==== ==== ESP32 WROVER DEVKIT ====
-This board is double-sided, on one side you will find an LCD screen (so-called **back**) on the other side (**front**) there are GPIOs connectors you connect sensors and actuators to, TF (microSD) card slot with SPI reader and an RGB LED diode (among others).\\ Please note you can directly observe only the **back** side of the module via VREL node's camera.+This board is double-sided; on one side, you will find an LCD screen (so-called **back**) on the other side (**front**) there are GPIOs connectors you connect sensors and actuators to, TF (microSD) card slot with SPI reader and an RGB LED (among others).\\ Please note you can directly observe only the **back** side of the module via the VREL node's camera.
  
 <figure ESPWRoverDevKitFront> <figure ESPWRoverDevKitFront>
Line 28: Line 28:
 ESP32 provides a number of GPIOs to the developers, but some of them are hard-bound to their features as connected on the development board. ESP32 provides a number of GPIOs to the developers, but some of them are hard-bound to their features as connected on the development board.
  
-<note important>Some of the GPIOs are dedicated to implementing a limited number of features while on this development board, some of them are dedicated to using a particular protocol. As this development board contains some peripherals (RGB LED, LCD display, TF card reader) do not use GPIOs that are controlling them.</note> +<note important>Some of the GPIOs are dedicated to implementing a limited number of features, while some are dedicated to using a particular protocol on this development board. As this development board contains some peripherals (RGB LED, LCD, TF card reader), do not use GPIOs that are controlling them.</note> 
-Following list present GPIOs used with the integrated hardware:+The following list presents GPIOs used with the integrated hardware:
 <table tabWROVER> <table tabWROVER>
 <caption>ESP32 WROVER DEVKIT GPIO and features</caption> <caption>ESP32 WROVER DEVKIT GPIO and features</caption>
Line 49: Line 49:
 === Configuring VREL - platformio.ini === === Configuring VREL - platformio.ini ===
 Correct configuration is necessary to build and deploy your code.\\ Correct configuration is necessary to build and deploy your code.\\
-For ESP32 WROVER DEVKIT, a good starting point is the following content for ''platformio.ini'' file:+For ESP32 WROVER DEVKIT, a good starting point is the following content for the ''platformio.ini'' file:
 <code> <code>
 [env:d1_mini] [env:d1_mini]
Line 55: Line 55:
 board = esp-wrover-kit board = esp-wrover-kit
 framework = arduino framework = arduino
-upload_port = /dev/ttyUSB1 +lib_ldf_mode = deep+ 
-lib_deps =  +lib_deps = 
- adafruit/Adafruit-GFX-Library +   adafruit/Adafruit GFX Library 
- Wire +   Wire 
-  espressif/WROVER_KIT_LCD+   espressif/WROVER KIT LCD @ ^1.0.3
 </code> </code>
  
 == Practice: handling LCD display ==  == Practice: handling LCD display == 
 Write Hello World on the LCD screen. \\ Write Hello World on the LCD screen. \\
-Using LCD display and a camera, you can observe it through, are your only interface to the devkit. Get familiar with handling LCD screen and give it a short practice, as present below.+Using an LCD and a camera, you can observe it through, are your only interface to the devkit. Therefore, please get familiar with handling LCD screens and give it a short practice, as presented below.
  
-Type textual "Hello World" on the screen. You're welcome to decorate it, change colours, size, orientation, etc.+Type textual "Hello World" on the screen. Then, you're welcome to decorate it, change colours, size, orientation, etc.
  
-To use LCD you must include libraries. Beginning of your ''.cpp'' source code file should then look more-less following way:+To use LCD, you must include libraries. The beginning of your ''.cpp'' source code file should then look more-less following way:
 <code c> <code c>
 ... ...
Line 74: Line 74:
 #include <SPI.h> #include <SPI.h>
 #include <Adafruit_GFX.h> #include <Adafruit_GFX.h>
-#include <Adafruit_I2CDevice.h> 
 #include <WROVER_KIT_LCD.h> #include <WROVER_KIT_LCD.h>
 ... ...
Line 83: Line 82:
 ... ...
 WROVER_KIT_LCD tft; WROVER_KIT_LCD tft;
 +...
 +</code>
 +
 +Remember to initiate the LCD controller class:
 +<code c>
 +...
 +  tft.begin();
 ... ...
 </code> </code>
Line 92: Line 98:
   tft.setCursor(0, 0); //Set upper left corner   tft.setCursor(0, 0); //Set upper left corner
   tft.setTextColor(WROVER_WHITE);  //Set text colour   tft.setTextColor(WROVER_WHITE);  //Set text colour
-  tft.setTextSize(1); //Set font size+  tft.setTextSize(2); //Set font size
   tft.println("Hello World!"); // Print the text   tft.println("Hello World!"); // Print the text
 ... ...
Line 99: Line 105:
  
 ==== TTGO T5 v.2.2 e-Paper ==== ==== TTGO T5 v.2.2 e-Paper ====
-TTGO (aka LILYGO) ESP32 module with integrated e-Paper 2.9-inch display is a robust solution for e-Paper development. Here you will learn basics on handling the e-Paper (e-Ink). The display is two coloured (black/white) with 296x128 pixels resolution. The display is connected and operated via SPI bus\\+TTGO (aka LILYGO) ESP32 module with integrated e-Paper 2.9-inch display is a robust solution for e-Paper development. Here you will learn the basics of handling the e-Paper (e-Ink). The display is two coloured (black/white) with 296x128 pixels resolution. The display is connected and operated via SPI bus\\
 The TTGO T5 module also contains a speaker (buzzer), SPI TF card reader, and a limited GPIO. It is advertised as an electronic badge. The TTGO T5 module also contains a speaker (buzzer), SPI TF card reader, and a limited GPIO. It is advertised as an electronic badge.
  
Line 114: Line 120:
 ESP32 provides a number of GPIOs to the developers, but some of them are hard-bound to their features as connected on the development board. ESP32 provides a number of GPIOs to the developers, but some of them are hard-bound to their features as connected on the development board.
  
-<note important>Some of the GPIOs are dedicated to implementing a limited number of features while on this development board, some of them are dedicated to using a particular protocol. As this development board contains some peripherals (RGB LED, LCD display, TF card reader) do not use GPIOs that are controlling them.</note>+<note important>Some of the GPIOs are dedicated to implementing a limited number of features, while some are dedicated to using a particular protocol on this development board. This development board contains some peripherals (RGB LED, LCD, TF card reader) that do not use GPIOs that are controlling them.</note>
  
 <table tabTTGO> <table tabTTGO>
Line 126: Line 132:
  
 === Built-in integrated e-Paper display === === Built-in integrated e-Paper display ===
-The e-Paper (e-Ink) display is a bi-coloured, 296x128 pixels with SPI interface module, manufactured by Waveshare. It has an integrated SPI controller ((https://www.waveshare.com/wiki/2.9inch_e-Paper_Module)). \\ There are various software libraries able to handle e-Paper displays but the most advanced one at the moment is GxEPD library that includes device drivers for the majority of manufactured displays [[https://github.com/lewisxhe/GxEPD | Github GxEPD library]]. The exact model (as to be included in the code is GDEH029A1 [[https://github.com/lewisxhe/GxEPD/tree/master/src/GxGDEH029A1|https://github.com/lewisxhe/GxEPD/tree/master/src/GxGDEH029A1]].+The e-Paper (e-Ink) display is a bi-coloured, 296x128 pixels with an SPI interface module, manufactured by Waveshare. It has an integrated SPI controller ((https://www.waveshare.com/wiki/2.9inch_e-Paper_Module)). \\ There are various software libraries able to handle e-Paper displays. Still, the most advanced one at the moment is the GxEPD library that includes device drivers for the majority of manufactured displays [[https://github.com/lewisxhe/GxEPD | Github GxEPD library]]. The exact model (as to be included in the code is GDEH029A1 [[https://github.com/lewisxhe/GxEPD/tree/master/src/GxGDEH029A1|https://github.com/lewisxhe/GxEPD/tree/master/src/GxGDEH029A1]].
  
 === Configuring VREL - platformio.ini === === Configuring VREL - platformio.ini ===
 Correct configuration is necessary to build and deploy your code.\\ Correct configuration is necessary to build and deploy your code.\\
-For ESP32 TTGO T5 v2.2, a good starting point is the following content for ''platformio.ini'' file:+For ESP32 TTGO T5 v2.2, a good starting point is the following content for the ''platformio.ini'' file:
 <code> <code>
 [env:d1_mini] [env:d1_mini]
Line 136: Line 142:
 board = esp-wrover-kit board = esp-wrover-kit
 framework = arduino framework = arduino
-lib_deps =  +lib_deps = adafruit/Adafruit-GFX-Library
- adafruit/Adafruit-GFX-Library+
  Wire  Wire
  zinggjm/GxEPD  zinggjm/GxEPD
Line 144: Line 149:
 == Practice: handling e-Paper display ==  == Practice: handling e-Paper display == 
 Write Hello World on the e-Paper screen. \\ Write Hello World on the e-Paper screen. \\
-Using e-Paper display and a camera, you can observe it through, are your only interface to the TTGO. Get familiar with handling e-Paper and give it a short practice, as present below.+Using an e-paper display and a camera, you can observe it through, are your only interface to the TTGO. Therefore, please get familiar with handling e-Paper and give it a short practice, as presented below.
  
-Type textual "Hello World" on the screen. You're welcome to decorate it, change the size, orientation, experiment with bitmap displaying, partial updates and so on.+Type textual "Hello World" on the screen. Then, you're welcome to decorate it, change the size, orientation, experiment with bitmap displaying, partial updates and so on.
  
-To use e-Paper you must include libraries. Beginning of your ''.cpp'' source code file should then look more-less following way:+To use e-Paper, you must include libraries. The beginning of your ''.cpp'' source code file should then look more-less following way:
 <code c> <code c>
 ... ...
 #include <Arduino.h> #include <Arduino.h>
-#include <GxEPD.h>+#include <GxEPD.h>
 #include <Adafruit_I2CDevice.h> #include <Adafruit_I2CDevice.h>
 #include "SPI.h" #include "SPI.h"
Line 171: Line 176:
 </code> </code>
  
-Note, by the e-Paper related display drivers there is also a font definition library should be included:+Note, by the e-Paper related display drivers; there is also a font definition library that should be included:
 <code c> <code c>
 ... ...
Line 210: Line 215:
 </code> </code>
  
-Note, for ease, there are predefined values that present black and white colour display: ''GxEPD_WHITE'' and ''GxEPD_BLACK''.+Note, for ease, predefined values present black and white colour display: ''GxEPD_WHITE'' and ''GxEPD_BLACK''.
  
-<note tip>You need to use a font to draw on the e-Ink screen. Use one of the definitions provided along with GxEPD library.</note>+<note tip>You need to use a font to draw on the e-Ink screen. Use one of the definitions provided along with the GxEPD library.</note>
  
 <note tip>In the laboratory node #25, the e-ink display has been mounted landscape. It means, to keep text horizontal, you need to use: <note tip>In the laboratory node #25, the e-ink display has been mounted landscape. It means, to keep text horizontal, you need to use:
Line 221: Line 226:
  
 ==== A special notes on PWM in ESP32 ==== ==== A special notes on PWM in ESP32 ====
-PWM is frequently used to control analogue-style, efficient voltage on the GPIO pin. Instead of using resistance driver, PWM uses pulses to change effective power, delivered to the actuator. It applies to motors, but also to LEDs, bulbs, heaters and indirectly to the servos (but that works actually another way, see lectures).\\ +PWM is frequently used to control analogue-style, efficient voltage on the GPIO pin. Instead of using a resistance driver, PWM uses pulses to change adequate power, delivered to the actuator. It applies to motors, but also to LEDs, bulbs, heaters, and indirectly to the servos (but that works actually another way, see lectures).\\ 
-Classical ''analogWrite'' method as known from Arduino (Uno, Mega) and ESP8266 does not work here.\\ +The classical ''analogWrite'' method known as Arduino (Uno, Mega) and ESP8266 do not work here.\\ 
-ESP32 has sixteen (0 to 15) PWM channels (controllers) that can be freely bound to any of the regular GPIOs.\\ ESP32 can use various "resolutions" of the PWM: from 8 bit (0..255) to 15bit (0..32767) while regular Arduino uses only 8 bit one.+ESP32 has sixteen (0 to 15) PWM channels (controllers) that can be freely bound to any of the regular GPIOs. Moreover, \\ ESP32 can use various "resolutions" of the PWM: from 8 bit (0..255) to 15bit (0..32767), while regular Arduino uses only 8 bit one.
  
-To use PWM in ESP32 one must perform the following steps:+To use PWM in ESP32, one must perform the following steps:
   * Configure GPIO pin as ''OUTPUT''   * Configure GPIO pin as ''OUTPUT''
   * Initiate PWM controller with fixing PWM frequency and resolution   * Initiate PWM controller with fixing PWM frequency and resolution
Line 232: Line 237:
  
 ===== Laboratory scenarios ===== ===== Laboratory scenarios =====
-In general, you will program using the Arduino framework, remotely via a web interface with the use of the VREL system. Note, your only output is to use the web camera, so results are to be presented this way.\\ +In general, you will program using the Arduino framework, remotely via a web interface using the VREL system. Note that your only output uses the web camera, so results are to be presented this way.\\ 
-You will also use FreeRTOS functions to handle multicore parallel programming to perform tasks, as presented during the lecture.+As presented during the lecture, you will also use FreeRTOS functions to handle multicore parallel programming to perform tasks, as demonstrated during the lecture.
  
-<note important>ESP32 framework uses C++ optimiser while compiling the source code. It is common that C++ traces unused code and removes/optimises it, to minimise CPU effort. As your tasks to be completed involve integer and floating-point performance evaluation it is essential to use the result somewhere, i.e. do a dummy display of the final value on the screen. Otherwise, the C++ compiler may remove this section of the code and you won't be able to obtain reasonable results, because your code may be already trunked and not executed at all!</note>+<note warning>ESP32 framework uses C++ optimiser while compiling the source code. It is common that C++ traces unused code and removes/optimises it, to minimise CPU effort. As your tasks to be completed, involve integer and floating-point performance evaluation, it is essential to use the result somewhere, i.e. do a dummy display of the final value on the screen. Otherwise, the C++ compiler may remove this section of the code, and you won't be able to obtain reasonable results, because your code may be already trunk and not executed at all!</note>
  
 +<note important>FreeRTOS, once the task is created and scheduled for execution, executes the task infinitely! It means, your function implementing the task will be executed again and again. If you intended to run a looped task, that is pretty OK. If you intended to run the one-off task, then you need explicitly call:
 +<code c>
 +...
 +vTaskDelete(NULL);
 +...
 +</code>
 + as a last line of your function implementing the task.</note>
 ==== Task 1 ==== ==== Task 1 ====
-Evaluate single-core performance for integer computation. Perform two experiments: with task bound to the APP core and separately to the PRO core. Observe if there is a difference in measurements. Propose an algorithm that is able to generate a complexity of integer computation observable and measurable.  +Evaluate single-core performance for integer computation. Perform two experiments: with task bound to the APP core and separately to the PRO core. First, observe if there is a difference in measurements. Then, propose an algorithm that can generate a complexity of integer computation observable and measurable.  
-Perform at least 10 measurements for each experiment. Consider using parts of code for Dhrystone benchmark [[https://en.wikipedia.org/wiki/Dhrystone|https://en.wikipedia.org/wiki/Dhrystone]].+Perform at least 10 measurements for each experiment. Consider using parts of code for the Dhrystone benchmark [[https://en.wikipedia.org/wiki/Dhrystone|https://en.wikipedia.org/wiki/Dhrystone]].
  
 ==== Task 2 ==== ==== Task 2 ====
-Evaluate multi-core performance for integer computation. Perform single-core computation, running at least 4 times (any even number works here) your algorithm. Then execute in parallel (2x2). Observe if there is a difference in measurements. Propose an algorithm that is able to generate a complexity of integer computation observable and measurable.  +Evaluate multicore performance for integer computation. Perform single-core computation, running at least 4 times (any even number works here) your algorithm. Then execute in parallel (2x2). Observe if there is a difference in measurements. Propose an algorithm that can generate a complexity of integer computation observable and measurable.  
-Perform at least 20 measurements for each experiment (10 serial + 10 parallel). Consider using parts of code for Dhrystone benchmark [[https://en.wikipedia.org/wiki/Dhrystone|https://en.wikipedia.org/wiki/Dhrystone]].+Perform at least 20 measurements for each experiment (10 serial + 10 parallel). Consider using parts of code for the Dhrystone benchmark [[https://en.wikipedia.org/wiki/Dhrystone|https://en.wikipedia.org/wiki/Dhrystone]].
  
 ==== Task 3 ==== ==== Task 3 ====
-Evaluate single-core performance for floating-point computation. Perform two experiments: with task bound to the APP core and separately to the PRO core. Observe if there is a difference in measurements. Propose an algorithm that is able to generate a complexity of floating-point computation observable and measurable. +Evaluate single-core performance for floating-point computation. Perform two experiments: with task bound to the APP core and separately to the PRO core. First, observe if there is a difference in measurements. Then, propose an algorithm that can generate a complex-enough floating points computation that is observable and measurable.  
 Perform at least 10 measurements for each experiment. Consider using FP parts of code for Whetstone benchmark [[https://en.wikipedia.org/wiki/Whetstone_(benchmark)|https://en.wikipedia.org/wiki/Whetstone_(benchmark)]]. Perform at least 10 measurements for each experiment. Consider using FP parts of code for Whetstone benchmark [[https://en.wikipedia.org/wiki/Whetstone_(benchmark)|https://en.wikipedia.org/wiki/Whetstone_(benchmark)]].
  
 ==== Task 4 ==== ==== Task 4 ====
-Evaluate multi-core performance for floating-point computation. Perform single-core computation, running at least 4 times (any even number works here) your algorithm. Then execute in parallel (2x2). Propose an algorithm that is able to generate a complexity of floating-point computation observable and measurable. +Evaluate multicore performance for floating-point computation. First, perform single-core computation, running your algorithm at least 4 times (any even number works here) your algorithm. Then execute in parallel (i.e. 2x2). Finally, propose an algorithm that can generate a complex-enough floating-point computation that is observable and measurable. 
 Perform at least 20 measurements for each experiment (10 serial + 10 parallel). Consider using FP parts of code for Whetstone benchmark [[https://en.wikipedia.org/wiki/Whetstone_(benchmark)|https://en.wikipedia.org/wiki/Whetstone_(benchmark)]]. Perform at least 20 measurements for each experiment (10 serial + 10 parallel). Consider using FP parts of code for Whetstone benchmark [[https://en.wikipedia.org/wiki/Whetstone_(benchmark)|https://en.wikipedia.org/wiki/Whetstone_(benchmark)]].
  
  
 ==== Report ==== ==== Report ====
-Include algorithm definition and measurements, along with statistical analysis of the results (at least average and standard deviation) and summary.+Include algorithm definition and measurements, along with statistical analysis of the results (at least average and standard deviation) and a summary.
  
  
-==== Resources ====+===== Resources =====
   - [[https://www.espressif.com/en/products/hardware/esp-wrover-kit/resources|ESP32 WROVER kit starting page]]   - [[https://www.espressif.com/en/products/hardware/esp-wrover-kit/resources|ESP32 WROVER kit starting page]]
   - [[https://docs.espressif.com/projects/esp-idf/en/latest/hw-reference/get-started-wrover-kit.html|Hardware definition (pinouts, gpios, etc.)]]    - [[https://docs.espressif.com/projects/esp-idf/en/latest/hw-reference/get-started-wrover-kit.html|Hardware definition (pinouts, gpios, etc.)]] 
   - [[https://dl.espressif.com/dl/schematics/ESP-WROVER-KIT_V4_1.pdf|ESP-WROVER-KIT V4.1 schematic]]   - [[https://dl.espressif.com/dl/schematics/ESP-WROVER-KIT_V4_1.pdf|ESP-WROVER-KIT V4.1 schematic]]
-  - [[https://www.instructables.com/id/Arduino-37-in-1-Sensors-Kit-Explained/Sensor kit]] 
   - [[https://github.com/LilyGO/TTGO-Electronic-Badge]]   - [[https://github.com/LilyGO/TTGO-Electronic-Badge]]
   - [[https://github.com/lewisxhe/TTGO-EPaper-Series]]   - [[https://github.com/lewisxhe/TTGO-EPaper-Series]]
Line 268: Line 279:
   - [[https://github.com/lewisxhe/GxEPD]]   - [[https://github.com/lewisxhe/GxEPD]]
   - [[https://javl.github.io/image2cpp/|On-line bitmap (image) to memory content (cpp) converter]]   - [[https://javl.github.io/image2cpp/|On-line bitmap (image) to memory content (cpp) converter]]
 +  - [[https://savjee.be/2020/01/multitasking-esp32-arduino-freertos/|FreeRTOS - multitasking with ESP32 explained]]
en/edu/zmitac/s2/iot/aih.1610096327.txt.gz · Last modified: by pczekalski