Differences

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

Link to this comparison view

iotcluj:labs:06 [2016/07/12 14:35]
ioana_maria.culic
iotcluj:labs:06 [2016/07/13 14:59] (current)
ioana_maria.culic [Exercises]
Line 10: Line 10:
  
 ===== The Setup ===== ===== The Setup =====
-{{ :iotcluj:​labs:​lcd-expander.jpg?​500 |}}+{{ :iot:​labs:​lcd-expander.jpg?​500 |}}
 The LCD in the kit is connected to a port expander (MCP23008). This allows the LCD to be controlled via the I2C protocol, thus reducing the number of pins you need to connect the LCD to. In this case, you just need to connect the expander to GND, 5V, SCL and SDA pins, according to the indicators on the expander. You can find the appropriate pins in the **Pin Layout** tab. You just need to connect the SDA port on the port expander with the SDA pin on the board and so on. The LCD in the kit is connected to a port expander (MCP23008). This allows the LCD to be controlled via the I2C protocol, thus reducing the number of pins you need to connect the LCD to. In this case, you just need to connect the expander to GND, 5V, SCL and SDA pins, according to the indicators on the expander. You can find the appropriate pins in the **Pin Layout** tab. You just need to connect the SDA port on the port expander with the SDA pin on the board and so on.
 ===== The Code ===== ===== The Code =====
-{{ :iotcluj:​labs:​lcd-simple-example.png?​600 |}}+{{ :iot:​labs:​lcd-simple-example.png?​600 |}}
 You go to the Wyliodrin Applications page and create a new application. You name it and select Streams as programming language. Once created, you click on the new application'​s name to open it. You go to the Wyliodrin Applications page and create a new application. You name it and select Streams as programming language. Once created, you click on the new application'​s name to open it.
  
 First of all, you need to initialise the LCD. For this, you drag the **run** node and select **Fire once at start** so you make sure that once you run the application a first message is sent. This is only required to trigger the **init LCD** node, so you can assure there is no other message being sent again. For this, drag the **trigger** node and double click on it. First of all, you need to initialise the LCD. For this, you drag the **run** node and select **Fire once at start** so you make sure that once you run the application a first message is sent. This is only required to trigger the **init LCD** node, so you can assure there is no other message being sent again. For this, drag the **trigger** node and double click on it.
  
-{{ :iotcluj:​labs:​trigger-block.png?​400 |}}+{{ :iot:​labs:​trigger-block.png?​400 |}}
  
 You need to set this node to **wait until reset**. This will make the node to send the first message and then wait until it receives a message containing the property **reset**, which will never happen. ​ You need to set this node to **wait until reset**. This will make the node to send the first message and then wait until it receives a message containing the property **reset**, which will never happen. ​
Line 25: Line 25:
 First of all, you need to require the **wyliodrin** module, which exposes some simple functions in order to control the LCD. Otherwise you would need to implement the protocol in order to control it.  First of all, you need to require the **wyliodrin** module, which exposes some simple functions in order to control the LCD. Otherwise you would need to implement the protocol in order to control it. 
  
-Once you have the **wyliodrin** variable, call the **LiquidCrystal** constructor in order to obtain a **LiquidCrystal** object. The constructer ​receives 0 as parameter.+Once you have the **wyliodrin** variable, call the **LiquidCrystal** constructor in order to obtain a **LiquidCrystal** object. The constructor ​receives 0 as parameter.
  
-Why is the value 0 the parameter of the contructor? This type of LCD communicates with the Raspberry Pi board via that I2C protocol. Taking into account how the I2C protocol behaves, you would need to mention the bus specific to the LCD, that usually is 32. However, in order to be able to connect multiple LCDs at once, they have three jumpers which can be connected in order to represent values from 0 to 7, thus being able to identify eight different LCDs. This is the value you need to pass to the constructor,​ in this case, no jumper is connected so we passed the value 0.+Why is the value 0 the parameter of the constructor? This type of LCD communicates with the Raspberry Pi board via that I2C protocol. Taking into account how the I2C protocol behaves, you would need to mention the bus specific to the LCD, that usually is 32. However, in order to be able to connect multiple LCDs at once, they have three jumpers which can be connected in order to represent values from 0 to 7, thus being able to identify eight different LCDs. This is the value you need to pass to the constructor,​ in this case, no jumper is connected so we passed the value 0.
  
-{{ :iotcluj:​labs:​init-lcd.png?​400 |}}+{{ :iot:​labs:​init-lcd.png?​400 |}}
  
 What is new at the code presented above is the **context.global.lcd** structure. You need to use this because you want the **lcd** variable to be available from other nodes also (Display on LCD node) and **context.global** is a variable accessible to all the nodes, so you just set the lcd property and you will be able to use it from any other node. What is new at the code presented above is the **context.global.lcd** structure. You need to use this because you want the **lcd** variable to be available from other nodes also (Display on LCD node) and **context.global** is a variable accessible to all the nodes, so you just set the lcd property and you will be able to use it from any other node.
  
-{{ :iotcluj:​labs:​display-lcd-simple.png?​400 |}}+{{ :iot:​labs:​display-lcd-simple.png?​400 |}}
  
 The **display LCD** node is another function node which first clears the LCD, then prints a string on it. Notice that the global **lcd** variable is used. The **display LCD** node is another function node which first clears the LCD, then prints a string on it. Notice that the global **lcd** variable is used.
Line 39: Line 39:
 ===== Exercises===== ===== Exercises=====
   - Use a temperature sensor and display the temperature on the LCD.   - Use a temperature sensor and display the temperature on the LCD.
 +  - Together with the temperature computed with the sensor, display the temperature you get using a web service.
 +  - Build a weather station consisting of an LCD, a light sensor, a temperature sensor, a gas sensor and a button. At the press of the button you can change which of the three values is displayed on the LCD.
iotcluj/labs/06.1468323347.txt.gz ยท Last modified: 2016/07/12 14:35 by ioana_maria.culic
CC Attribution-Share Alike 3.0 Unported
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