This shows you the differences between two versions of the page.
iotcluj:labs:05 [2016/07/12 14:40] ioana_maria.culic [The setup] |
iotcluj:labs:05 [2016/07/13 12:33] (current) ioana_maria.culic [Exercises] |
||
---|---|---|---|
Line 42: | Line 42: | ||
==== The Setup ==== | ==== The Setup ==== | ||
- | {{ :iotcluj:labs:light_sensor_schematics.png?600 |}} | + | {{ :iot:labs:light_sensor_schematics.png?600 |}} |
The photocell works just like resistor with a variable resistance. Depending on the amount of light it receives, its resistance gets higher or lower. As a result, you can connect it in a voltage divider, as well. | The photocell works just like resistor with a variable resistance. Depending on the amount of light it receives, its resistance gets higher or lower. As a result, you can connect it in a voltage divider, as well. | ||
Line 55: | Line 55: | ||
==== The Code ==== | ==== The Code ==== | ||
- | {{ :iotcluj:labs:street_lights_code.png?400 |}} | + | {{ :iot:labs:street_lights_code.png?400 |}} |
First of all, you need to use an **Arduino in** node in order to read the values from the sensor. This node gets triggered each time the value on the pin it reads from changes. To actually configure the node's behavior you need to set its properties. | First of all, you need to use an **Arduino in** node in order to read the values from the sensor. This node gets triggered each time the value on the pin it reads from changes. To actually configure the node's behavior you need to set its properties. | ||
- | {{ :iotcluj:labs:arduino_in_properties.png?400 |}} | + | {{ :iot:labs:arduino_in_properties.png?400 |}} |
The first property allows you to set the Raspberry Pi connection to the Arduino board so the Raspberry Pi knows the port through which it should send the messages. Usually, the port is **/dev/ttyACM0**. However, in order to make sure, go to the **Shell** tab and type **dmesg**. There you should see messages stating that an FTDI cable has been connected to the board and the port it is connected to. Concatenate that value to **/dev/** and place the value as the first property of the node. | The first property allows you to set the Raspberry Pi connection to the Arduino board so the Raspberry Pi knows the port through which it should send the messages. Usually, the port is **/dev/ttyACM0**. However, in order to make sure, go to the **Shell** tab and type **dmesg**. There you should see messages stating that an FTDI cable has been connected to the board and the port it is connected to. Concatenate that value to **/dev/** and place the value as the first property of the node. | ||
+ | <note>When you configure the Arduino port set the it to **global**</note> | ||
+ | {{ :iotcluj:labs:arduino-global.png?400 |}} | ||
Further on, you need to specify which pin you want to read from. In this case, the pin is 0 and is an analog pin. Afterwards, you will use a **range** node in order to map the read values to values that should light up the LED. For this, you need to adapt the system to your environment. Depending on the regular amount of light, usually you will read a value of around 400. So in this case, the range scales values going from 400 to 1024 to 0 to 255. However, if the regular value is different, you will need to scale a different range. | Further on, you need to specify which pin you want to read from. In this case, the pin is 0 and is an analog pin. Afterwards, you will use a **range** node in order to map the read values to values that should light up the LED. For this, you need to adapt the system to your environment. Depending on the regular amount of light, usually you will read a value of around 400. So in this case, the range scales values going from 400 to 1024 to 0 to 255. However, if the regular value is different, you will need to scale a different range. | ||
- | {{ :iotcluj:labs:range-light.png?400 |}} | + | {{ :iot:labs:range-light.png?400 |}} |
The last node to use is **Arduino out**. This node acts just like the **digital write** node used in the previous chapters. However, you still need to select the port for the Arduino board and you can choose from analog or digital write. As you want to make the LED light up brighter or dimmer, you will set the type to **analog** and the **pin** property has to be 3. | The last node to use is **Arduino out**. This node acts just like the **digital write** node used in the previous chapters. However, you still need to select the port for the Arduino board and you can choose from analog or digital write. As you want to make the LED light up brighter or dimmer, you will set the type to **analog** and the **pin** property has to be 3. | ||
Line 76: | Line 78: | ||
===== Exercises===== | ===== Exercises===== | ||
+ | - Connect a potentiometer and send the read values to the dashboard. | ||
- Display the values coming from the light sensor in the dashboard using the **gauge** graph. | - Display the values coming from the light sensor in the dashboard using the **gauge** graph. | ||
- Connect all the sensors in the kit to the Arduino and display the values you read in the dashboard. **Note:** Do not connect the Hall sensor, which works in a different way. | - Connect all the sensors in the kit to the Arduino and display the values you read in the dashboard. **Note:** Do not connect the Hall sensor, which works in a different way. | ||
- Search the temperature sensor's datasheet online (TMP36) and transform the read values to celsius degrees. | - Search the temperature sensor's datasheet online (TMP36) and transform the read values to celsius degrees. | ||
+ | - Use the gas sensor and display the read value on a graph. | ||