No ACL setup yet! Denying access to everyone.
en:edu:zmitac:macro:embedeed:lab:esp
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:edu:zmitac:macro:embedeed:lab:esp [2020/11/25 12:39] – [Connecting to the nodes] pczekalski | en:edu:zmitac:macro:embedeed:lab:esp [2021/12/21 14:33] (current) – [Connecting to the nodes] pczekalski | ||
|---|---|---|---|
| Line 10: | Line 10: | ||
| You can book for use nodes 1 through 4 and 8 through 11 at the moment. | You can book for use nodes 1 through 4 and 8 through 11 at the moment. | ||
| - | Every node contains sensors and actuators. Every node has 4x20 (4 lines, 20 characters) LCD display, you can observe via web camera, and also at least a DHT (temperature + humidity) sensor. | + | Every node contains sensors and actuators. Every node has a 4x20 (4 lines, 20 characters) LCD display, |
| <note important> | <note important> | ||
| - | <note important> | + | |
| ==== Actuators ==== | ==== Actuators ==== | ||
| Here we focus on the 4x20 LCD screen solely. | Here we focus on the 4x20 LCD screen solely. | ||
| This type of LCD can display 4 rows, 20 characters each, and is controlled via the I2C interface. \\ | This type of LCD can display 4 rows, 20 characters each, and is controlled via the I2C interface. \\ | ||
| - | The I2C bus is connected to D1/GPIO5 and D2/GPIO4 pins of the ESP microcontroller (D1 is SCL and S2 is SDA). All nodes share the same connection configuration.\\ | + | The I2C bus is connected to D1/GPIO5 and D2/GPIO4 pins of the ESP microcontroller (D1 is SCL and D2 is SDA). All nodes share the same connection configuration.\\ |
| __There is a difference in the addressing__, | __There is a difference in the addressing__, | ||
| Line 25: | Line 25: | ||
| * Nodes 10 and 11 use 0x27; | * Nodes 10 and 11 use 0x27; | ||
| - | You need to provide appropriate initialisation in the software library that controls LCD regarding the note you've booked. | + | You need to provide appropriate initialisation in the software library that controls |
| ==== Sensors ==== | ==== Sensors ==== | ||
| In the following scenarios, you will use a DHT, integrated temperature-humidity sensor. \\ | In the following scenarios, you will use a DHT, integrated temperature-humidity sensor. \\ | ||
| - | Sensor types vary between nodes (Figure {{ref> | ||
| - | * Nodes 1 through 4 all use DHT 22 (white sensor); | ||
| - | * Nodes 8 through 11 all use DHT 11 (a blue one); | ||
| <figure dhtsensors> | <figure dhtsensors> | ||
| Line 38: | Line 35: | ||
| </ | </ | ||
| - | You need to initiate related software library with appropriate sensor type, depending | + | All of our laboratory nodes use DHT11 sensors(blue one on the Figure {{ref> |
| Regarding DHTs, all nodes share the same configuration on the connection level: your DHT is always connected to the D4/GPIO2 pin of the ESP microcontroller. | Regarding DHTs, all nodes share the same configuration on the connection level: your DHT is always connected to the D4/GPIO2 pin of the ESP microcontroller. | ||
| - | <note important> | + | <note important> |
| ===== Connecting to the nodes ===== | ===== Connecting to the nodes ===== | ||
| Line 49: | Line 46: | ||
| Please follow instructions and remember to fix your theme for Revolution! Your environment should look like in Figure {{ref> | Please follow instructions and remember to fix your theme for Revolution! Your environment should look like in Figure {{ref> | ||
| - | __**Do not book a device for more than 30 minutes in a row (Figure {{ref> | + | __**Do not book a device for more than 30 minutes in a row (Figure {{ref> |
| + | You can continue working with devices out of regular working hours, see the supervisor' | ||
| - | The URL for accessing VREL lab is: [[[[http:// | + | The URL for accessing |
| <figure registeraccount> | <figure registeraccount> | ||
| Line 95: | Line 93: | ||
| board = d1_mini | board = d1_mini | ||
| framework = arduino | framework = arduino | ||
| - | lib_deps = Wire, 1574, PubSubClient, | + | lib_ldf_mode = deep+ |
| + | lib_deps = Wire, 1574, PubSubClient, | ||
| </ | </ | ||
| Obviously, this contains all hardware and software libraries, even more than is necessary to use in case of the following two scenarios, but you will have it ready for future experimentation. | Obviously, this contains all hardware and software libraries, even more than is necessary to use in case of the following two scenarios, but you will have it ready for future experimentation. | ||
| + | |||
| + | <note warning> | ||
| + | |||
| + | <note important> | ||
| + | |||
| + | **Remember to save the file!**</ | ||
| ==== Software libraries ==== | ==== Software libraries ==== | ||
| In general, you need to use two software libraries: for DHT and LCD.\\ | In general, you need to use two software libraries: for DHT and LCD.\\ | ||
| The LCD library is [[https:// | The LCD library is [[https:// | ||
| - | And obviously, if you use some preconfigured values (i.e. as when you refer to the D1 and D0 when initialising I2C communication library), you need to include the '' | + | And obviously, if you use some preconfigured values (i.e. as when you refer to the D1 and D0 when initialising |
| <code c> | <code c> | ||
| Line 118: | Line 123: | ||
| ==== Scenario 1: Basic operations on the 4x20 LCD screen ==== | ==== Scenario 1: Basic operations on the 4x20 LCD screen ==== | ||
| - | Whatever you do, you expect to have some output of the system. Sometimes there is a blinking LED, sometimes information about connected/ | + | Whatever you do, you expect to have some output of the system. Sometimes there is a blinking LED, sometimes information about connected/ |
| <note important> | <note important> | ||
| === Prerequisites === | === Prerequisites === | ||
| - | There are no other prerequisites than LCD I2C library. Mind, LCD is controlled via the I2C bus. LCD Display is 4×20 characters. LCD is controlled via I2C extender: | + | There are no other prerequisites than the LCD I2C library. Mind, LCD is controlled via the I2C bus. LCD Display is 4×20 characters. LCD is controlled via an I2C extender: |
| + | PCF8574. | ||
| <note important> | <note important> | ||
| - | * Nodes 1 through | + | * Nodes 1 through |
| * Nodes 10 and 11 use 0x27 address | * Nodes 10 and 11 use 0x27 address | ||
| </ | </ | ||
| === Scenario === | === Scenario === | ||
| - | Initialize LCD screen, clear it then write some fancy text on it, i.e. " | + | Initialize |
| === Result === | === Result === | ||
| Line 148: | Line 154: | ||
| </ | </ | ||
| == Step 2 == | == Step 2 == | ||
| - | Instantiate software | + | Instantiate software |
| <code c> | <code c> | ||
| LiquidCrystal_I2C lcd(0x3F, | LiquidCrystal_I2C lcd(0x3F, | ||
| Line 176: | Line 182: | ||
| lcd.home(); | lcd.home(); | ||
| lcd.print(" | lcd.print(" | ||
| - | lcd.setCursor(0, | ||
| - | lcd.print(" | ||
| - | lcd.setCursor(0, | ||
| - | lcd.print(" | ||
| ... | ... | ||
| </ | </ | ||
| + | |||
| + | The '' | ||
| + | <code c> | ||
| + | ... | ||
| + | lcd.setCursor(0, | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | Indexing is zero-based and the upper left corner is (0,0). | ||
| == Step 5 == | == Step 5 == | ||
| Implement '' | Implement '' | ||
| Line 196: | Line 207: | ||
| === Result validation === | === Result validation === | ||
| - | Observe text, its position and counter ticking in lower, right corner. | + | Observe text, its position and counter ticking in the lower, right corner. |
| ==== Scenario 2: Presenting temperature and humidity on the LCD ==== | ==== Scenario 2: Presenting temperature and humidity on the LCD ==== | ||
| - | In this scenario, you will present temperature and humidity as read by the attached | + | In this scenario, you will present temperature and humidity as read by the attached DHT11 sensor, on the LCD screen. |
| === Prerequisites === | === Prerequisites === | ||
| Line 208: | Line 219: | ||
| #include < | #include < | ||
| </ | </ | ||
| - | The temperature and humidity sensor is all-in-one, | + | The temperature and humidity sensor is all-in-one, DHT11 (blue), connected to the pin D4. Observe your camera to check which sensor is equipped with your lab and consult node documentation.\\ |
| To read data you may use a dedicated library (libraries): | To read data you may use a dedicated library (libraries): | ||
| <code c> | <code c> | ||
| Line 241: | Line 252: | ||
| == Step 2 == | == Step 2 == | ||
| - | Instantiate software | + | Instantiate software |
| <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 | ||
| - | DHT dht(DHTpin, | + | DHT dht(DHTpin, |
| - | //DHT dht(DHTpin, | + | |
| </ | </ | ||
| == Step 3 == | == Step 3 == | ||
| Line 286: | Line 296: | ||
| ... | ... | ||
| </ | </ | ||
| - | <note tip>'' | + | <note tip>'' |
| === Result validation === | === Result validation === | ||
| Observe temperature and humidity readings on the LCD. The temperature in our lab usually ranges between 20-30C (not, we observed over 30C during really hot summer!) while humidity is usually between 35-60%Rh. | Observe temperature and humidity readings on the LCD. The temperature in our lab usually ranges between 20-30C (not, we observed over 30C during really hot summer!) while humidity is usually between 35-60%Rh. | ||
| + | ===== FAQ ===== | ||
| + | **Q: Help, my LCD seems to be frozen!**\\ | ||
| + | A1: Check the I2C address is correct, regarding the laboratory node you're using. Consult details in the hardware section, as above.\\ | ||
| + | A2: Still not working? And you're sure the I2C address is correct so ... It is rare, but may happen that the I2C bus becomes in an inconsistent state. In such case run the following program (in the separate source file, eventually merge with your code): | ||
| + | <code c> | ||
| + | #include < | ||
| + | #include < | ||
| + | LiquidCrystal_I2C lcd(0x3F, | ||
| + | |||
| + | void setup() | ||
| + | { | ||
| + | pinMode(4, | ||
| + | pinMode(5, OUTPUT); | ||
| + | digitalWrite(4, | ||
| + | digitalWrite(5, | ||
| + | delay(2000); | ||
| + | pinMode(5, INPUT); // reset pin | ||
| + | pinMode(4, INPUT); | ||
| + | delay(50); | ||
| + | delay(2000); | ||
| + | lcd.init(D2, | ||
| + | lcd.backlight(); | ||
| + | lcd.home(); | ||
| + | lcd.print(" | ||
| + | } | ||
| + | |||
| + | void loop() | ||
| + | { | ||
| + | |||
| + | } | ||
| + | </ | ||
en/edu/zmitac/macro/embedeed/lab/esp.1606304399.txt.gz · Last modified: by pczekalski
