This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| en:iot-open:remotelab:sut:generalpurpose3 [2020/04/26 21:15] – created pczekalski | en:iot-open:remotelab:sut:generalpurpose3 [Unknown date] (current) – external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 14: | Line 14: | ||
| ===== Sensors ===== | ===== Sensors ===== | ||
| Each node contains the following set of sensors: | Each node contains the following set of sensors: | ||
| - | * DHT sensor measuring temperature and humidity | + | * DHT sensor measuring temperature and humidity DHT11, connected to the D4/GPIO2. |
| - | * Bosch BMP280 air pressure sensor, reporting absolute air pressure measurements in Pa, located inside of the yellow air chamber (operating of the fan changes pressure reported by the sensor when the fan is off, it measures absolute air pressure - please note, the laboratory is located at the 3rd floor + base floor, so it is not a ground-level pressure). This sensor uses I2C protocol and is connected to the D1 and D2 GPIOs (D2 is SDA, D1 is SCL). | + | * Bosch BMP280 air pressure sensor, reporting absolute air pressure measurements in Pa, located inside of the yellow air chamber (operating of the fan changes pressure reported by the sensor when the fan is off, it measures absolute air pressure - please note, the laboratory is located at the 3rd floor + base floor, so it is not a ground-level pressure). This sensor uses the I2C protocol and is connected to the D1 and D2 GPIOs (D2 is SDA, D1 is SCL). The sensor I2C address is 0x76. |
| ==== Technical overview of the node and air pressure chamber overview ==== | ==== Technical overview of the node and air pressure chamber overview ==== | ||
| Line 26: | Line 26: | ||
| <figure VREL8_9_10_11> | <figure VREL8_9_10_11> | ||
| {{: | {{: | ||
| - | < | + | < |
| </ | </ | ||
| - | |||
| ===== Actuators ===== | ===== Actuators ===== | ||
| - | There are no mechanical actuators in this laboratory.\\ | + | There are two mechanical actuators in this laboratory: |
| - | LCD Display is 4x20 characters. LCD is controlled via I2C extender: LCM1602. The I2C extender address is 0x3F and the I2C bus is connected to the pins D1/GPIO5 and D2/GPIO4 (D1 is SCL and D2 is SDA).\\ As you do not have any access to the serial console, use LCD to visually trace the progress of your program, connection status, etc. By the LCD display, there are two LEDs that can be used to trace status. One LED is connected to the pin GPIO 16 while the other one to the GPIO pin 2. The former one (GPIO 2) is connected to the Serial Port TX as well so expect it flashing when communicating over serial protocol (i.e. flashing new firmware that is beyond the control of your code). | + | * Classical servo (180 degrees) controlled via pin D5 with arrow presenting its position. |
| + | * DC fan, located in the inlet of the air chamber, controlled with pin D8. | ||
| + | |||
| + | LCD Display is 4x20 characters. LCD is controlled via I2C extender: LCM1602. The I2C extender address is 0x3F for nodes 8 and 9 and 0x27 for nodes 10 and 11. The I2C bus is connected to the pins D1/GPIO5 and D2/GPIO4 (D1 is SCL and D2 is SDA).\\ As you do not have any access to the serial console, use LCD to visually trace the progress of your program, connection status, etc. By the LCD display, there are two LEDs that can be used to trace status. One LED is connected to the pin GPIO 16 while the other one to the GPIO pin 2. The former one (GPIO 2) is connected to the Serial Port TX as well so expect it flashing when communicating over serial protocol (i.e. flashing new firmware that is beyond the control of your code). | ||
| <note important> | <note important> | ||
| <note tip> | <note tip> | ||
| + | <note important> | ||
| ===== Software, libraries and externals ===== | ===== Software, libraries and externals ===== | ||
| LCD display requires a dedicated library. Of course, you can control it on the low-level programming, | LCD display requires a dedicated library. Of course, you can control it on the low-level programming, | ||
| + | |||
| + | ==== LCD Display ==== | ||
| The LCD I2C control library can be imported to the source code via: | The LCD I2C control library can be imported to the source code via: | ||
| <code c> | <code c> | ||
| #include < | #include < | ||
| </ | </ | ||
| - | Then configure your LCD controller: | + | Then configure your LCD controller |
| <code c> | <code c> | ||
| LiquidCrystal_I2C lcd(0x3F, | LiquidCrystal_I2C lcd(0x3F, | ||
| // for a 20 chars and 4 line display | // for a 20 chars and 4 line display | ||
| + | // Nodes 8 and 9 | ||
| </ | </ | ||
| + | or for nodes 10 and 11 | ||
| + | <code c> | ||
| + | LiquidCrystal_I2C lcd(0x27F, | ||
| + | // for a 20 chars and 4 line display | ||
| + | // Nodes 10 and 11 | ||
| + | </ | ||
| + | |||
| + | ==== Servo ==== | ||
| + | The easiest way to control a servo it is using a dedicated library. Still, low-level PWM programming is possible. | ||
| + | <code c> | ||
| + | #include < | ||
| - | === Platformio.ini === | + | ... |
| - | < | + | |
| - | ; PlatformIO Project Configuration File | + | |
| - | ; | + | |
| - | ; Build options: build flags, source filter | + | |
| - | ; | + | |
| - | ; | + | |
| - | ; | + | |
| - | ; | + | |
| - | ; Please visit documentation for the other options and examples | + | |
| - | ; http://docs.platformio.org/ | + | |
| - | [env: | + | #define servoPin D5 |
| - | platform = espressif8266 | + | |
| - | board = d1_mini | + | |
| - | framework = arduino | + | |
| - | lib_deps = Wire, EmonLib, Adafruit NeoPixel, Encoder,DHT sensor library, | + | |
| - | Adafruit Unified Sensor, | + | |
| - | LCD, PubSubClient, | + | |
| </ | </ | ||
| + | |||
| + | <code d> | ||
| + | Servo servo; | ||
| + | servo.attach(servoPin); | ||
| + | </ | ||
| + | |||
| + | ==== Fan ==== | ||
| + | Fan operation is controlled via classical PWM. We control fan using '' | ||
| + | <code c> | ||
| + | #define PWMFanPin D8 | ||
| + | | ||
| + | ... | ||
| + | | ||
| + | pinMode(PWMFanPin, | ||
| + | analogWriteFreq(250); | ||
| + | analogWrite(PWMFanPin, | ||
| + | </ | ||
| + | |||
| + | <note important> | ||
| ===== Communication ===== | ===== Communication ===== | ||
| Line 85: | Line 105: | ||
| ===== Limits ===== | ===== Limits ===== | ||
| - | At the same time, only one user can be programming the controller, although analysing the signal by others (unlimited number) the user has sense. | + | At the same time, only one user can be programming the controller, although analysing the signal by others (unlimited number) the user has sense. |
| ===== Support ===== | ===== Support ===== | ||
| - | gabriel.drabik@polsl.pl | + | In case the LCD display hangs and you are sure that your code should work but it does not, it may be the case the I2C bus is stuck and hang the I2C to LCD controller converter.\\ |
| + | In this case, please use the following code to reset the I2C bus (you can embed it to your source code or run separately, then run your original code, again). Mind to use appropriate I2C address, regarding the node booked (nodes 8 and 9 are using 0x3F, nodes 10 and 11 use 0x27): | ||
| + | <code c> | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | LiquidCrystal_I2C lcd(0x3F, | ||
| + | |||
| + | void setup() | ||
| + | { | ||
| + | pinMode(4, | ||
| + | pinMode(5, OUTPUT); | ||
| + | digitalWrite(4, | ||
| + | digitalWrite(5, | ||
| + | delay(2000); | ||
| + | pinMode(5, INPUT); | ||
| + | pinMode(4, INPUT); | ||
| + | delay(2050); | ||
| + | lcd.init(D2, | ||
| + | lcd.backlight(); | ||
| + | lcd.home(); | ||
| + | lcd.print(" | ||
| + | } | ||
| + | void loop() | ||
| + | { | ||
| + | |||
| + | } | ||
| + | </ | ||
| + | Finally, you should see Hello World message on the LCD and I2C bus should be recovered now. | ||