====== VREL #8 through #11: General Purpose IoT Laboratory with air chamber for pressure monitoring ====== The laboratory is located at Silesian University of Technology, Gliwice, Poland, Akademicka 16, room 316 There are four nodes of this kind: Node 8,9,10 and 11. Nodes may look different, in particular, nodes 8 and 10 are a mirror to the 9 and 11. ===== Introduction ===== The lab consists of a set of devices presenting various sensors and actuators. Each laboratory is independent of the physical point of view, however, using a combination of different devices connected via the network is advised. Note, you may also use other nodes, 1 through 7, and external services. Each node contains a yellow air chamber with a pressure sensor inside it and a DC fan, able to increase air pressure in the chamber, when on. An airflow limiter located by the other side, opposite to the fan, limits airflow running out of the chamber. ===== Prerequisites ===== The user needs to know: * physical effect of the airflow and air pressure phenomena, * PWM control principals. ===== Sensors ===== Each node contains the following set of sensors: * 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 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 ====
{{:en:iot-open:remotelab:sut:wentylator.png?470|}} Air chamber
{{:en:iot-open:remotelab:sut:vrel8-11_bb.png?470|}} VREL #8-#11 components (circuit)
===== Actuators ===== There are two mechanical actuators in this laboratory: * 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). Please note cameras are running only with some 5-10fps so do not implement quick flashing light as you may not be able to observe it remotely. Same note applies to the quick changes of the LCD contents. Build in LEDs (both) are active with signal LOW so setting HIGH on GPIO 16 or 4 switches them off while setting LOW switches them on. Even if 20x4 LCD displays look same in different nodes, nodes 8 and 9 use 0x3F address while nodes 10 and 11 use 0x27. Using invalid I2C address in your code causes the display to become inoperable. ===== Software, libraries and externals ===== LCD display requires a dedicated library. Of course, you can control it on the low-level programming, writing directly to the I2C registers, but we do suggest using a library first. As there are many universal libraries, and many of them are incompatible with this display, we strongly recommend using [[https://github.com/tonykambo/LiquidCrystal_I2C|''LiquidCrystal_I2C by Tony Kambourakis'']]. ==== LCD Display ==== The LCD I2C control library can be imported to the source code via: #include Then configure your LCD controller for nodes 8 and 9: LiquidCrystal_I2C lcd(0x3F,20,4); // set the LCD address to 0x3F // for a 20 chars and 4 line display // Nodes 8 and 9 or for nodes 10 and 11 LiquidCrystal_I2C lcd(0x27F,20,4); // set the LCD address to 0x3F // 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. #include ... #define servoPin D5 Servo servo; servo.attach(servoPin); ==== Fan ==== Fan operation is controlled via classical PWM. We control fan using ''analogWrite''. Suggested PWM frequency is about 250 Hz: #define PWMFanPin D8 ... pinMode(PWMFanPin,OUTPUT); analogWriteFreq(250); analogWrite(PWMFanPin,0); //stop FAN Setting too high PWM frequency causes fan to operate binary (on/off) and limits controlling range. ===== Communication ===== You can connect your ESP8266 microcontroller via its integrated WiFi interface to the separated IoT network. Then you can communicate with other nodes and players, already connected devices and even provide some information to the cloud. In details, there is a dedicated MQTT broker waiting for you. You can also set up your soft Access Point and connect another node directly to yours. The communication among the devices can be done using MQTT messages, exchanging data among other nodes (M2M) and you can even push them to the Internet via MQTT broker. Using your Node, you can access it and publish/subscribe to the messages once you connect your ESP to the existing wireless network (this network does not provide access to the global internet and is separated but please note there are other developers and IoT nodes connected to this access point: * SSID: internal.IOT * Passkey: IoTlab32768 * Setup your microcontroller for DHCP, to automatically obtain an IP address, your ESP will obtain the address from the 192.168.90.X pool. * MQTT server is available under the fixed address: 192.168.90.5, and the credentials to publish/subscribe are: * User: vrel * Password: vrel2018 The same MQTT server/broker is visible under public IP: 157.158.56.54 port 1883 (non-secure) and 8883 (secure) to let you exchange data with the world and control your devices remotely. ===== 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. ode does not require physical human interaction and is supposed to work continuously, without service breaks. ===== Support ===== 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): #include #include LiquidCrystal_I2C lcd(0x3F,20,4); // set the LCD address to 0x27 for nodes 10 and 11 void setup() { pinMode(4,OUTPUT); pinMode(5, OUTPUT); digitalWrite(4,LOW); digitalWrite(5,LOW); delay(2000); pinMode(5, INPUT); // reset pin pinMode(4, INPUT); delay(2050); lcd.init(D2,D1); lcd.backlight(); lcd.home(); lcd.print("Hello world..."); } void loop() { } Finally, you should see Hello World message on the LCD and I2C bus should be recovered now.