This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:iot-open:remotelab:ume:smartme:u1 [2019/09/27 17:56] – salvatdi | en:iot-open:remotelab:ume:smartme:u1 [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== U1: Showing temperature, | + | ==== IU1: Showing temperature, |
| - | ===== Target group ===== | + | === Target group === |
| This hands-on lab guide is intended for the Undergraduate but other target groups may benefit from it, treating it as basics for advanced projects. | This hands-on lab guide is intended for the Undergraduate but other target groups may benefit from it, treating it as basics for advanced projects. | ||
| - | ===== Prerequisites | + | === Prerequisites === |
| - | ==== Liquid Crystal | + | == Liquid Crystal == |
| For this library, you may refer to the [[en: | For this library, you may refer to the [[en: | ||
| - | ==== DHT ==== | + | == DHT == |
| For this library, you may refer to the [[en: | For this library, you may refer to the [[en: | ||
| - | ==== PMS7003 | + | == PMS7003 == |
| All the SmartME Network Laboratory Arduino nodes are equipped with a PMS7003 sensor. | All the SmartME Network Laboratory Arduino nodes are equipped with a PMS7003 sensor. | ||
| - | This sensor allows measuring the air quality by taking into account the PMx concentration. The working principle of such a sensor | + | This sensor allows measuring the air quality by taking into account the PMx concentration. The working principle of such a sensor |
| So, the values of PM1.0, PM2.5, and PM10, will be available for our scopes. | So, the values of PM1.0, PM2.5, and PM10, will be available for our scopes. | ||
| Line 29: | Line 28: | ||
| [3]https:// | [3]https:// | ||
| - | ==== Arduino Serial | + | == Arduino Serial == |
| This function is used for communication between the Arduino board and a computer or other devices. All Arduino boards have at least one serial port. On Uno pins 0 and 1 are used for communication with the computer. Serial communication on pins TX/RX uses TTL logic levels (5V or 3.3V depending on the board) [4]. | This function is used for communication between the Arduino board and a computer or other devices. All Arduino boards have at least one serial port. On Uno pins 0 and 1 are used for communication with the computer. Serial communication on pins TX/RX uses TTL logic levels (5V or 3.3V depending on the board) [4]. | ||
| Line 39: | Line 38: | ||
| [5] https:// | [5] https:// | ||
| - | ===== Scenario | + | === Scenario === |
| First, initialize LCD screen with the labels of temperature (“T”), relative humidity (“H”), and dust particles (“PM10”). | First, initialize LCD screen with the labels of temperature (“T”), relative humidity (“H”), and dust particles (“PM10”). | ||
| Then, after the sensor detection, next to the labels, the sensor values will be displayed, every 1 second. | Then, after the sensor detection, next to the labels, the sensor values will be displayed, every 1 second. | ||
| - | Notice that, by enabling the serialprint | + | Notice that, by enabling the serial print section, data will be available to the serial monitor too. |
| - | The sensor is able to measure three types of dust particles: PM1.0, PM2.5 and PM10. | + | The sensor is able to measure three types of dust particles: PM1.0, PM2.5, and PM10. |
| It may take several seconds to have more precious values about these values. | It may take several seconds to have more precious values about these values. | ||
| Such values are represented by two bytes: the MSB and the LSB one, as shown in [6] (appendix I). | Such values are represented by two bytes: the MSB and the LSB one, as shown in [6] (appendix I). | ||
| Line 50: | Line 49: | ||
| [6]https:// | [6]https:// | ||
| - | ===== Result | + | === Result === |
| You should see the values of temperature, | You should see the values of temperature, | ||
| - | ===== Start ===== | + | === Start === |
| There are no special steps to be performed. | There are no special steps to be performed. | ||
| - | ===== Steps ===== | + | === Steps === |
| - | ==== Step 1 ==== | + | == Step 1 == |
| Include LCD driver library, DHT library and Software Serial library: | Include LCD driver library, DHT library and Software Serial library: | ||
| Line 67: | Line 66: | ||
| </ | </ | ||
| - | ==== Step 2 ==== | + | == Step 2 == |
| Instantiate the software controller component for the LCD display. Then set up: | Instantiate the software controller component for the LCD display. Then set up: | ||
| - 1) the DHTPIN (which refers to the digital pin we use to get the signal); | - 1) the DHTPIN (which refers to the digital pin we use to get the signal); | ||
| Line 82: | Line 81: | ||
| SoftwareSerial mySerial(9, | SoftwareSerial mySerial(9, | ||
| </ | </ | ||
| - | + | === Step 3 == | |
| - | ==== Step 3 ==== | + | |
| Initialize display. | Initialize display. | ||
| Initialize the DHT sensor. | Initialize the DHT sensor. | ||
| Line 107: | Line 105: | ||
| </ | </ | ||
| - | ==== Step 4 ==== | + | == Step 4 == |
| Implement loop() to sample and display the values of the temperature, | Implement loop() to sample and display the values of the temperature, | ||
| Line 134: | Line 132: | ||
| | | ||
| - | | + | |
| - | static int pm_add[3][5]={0, | + | |
| - | static int pm_old[3]={0, | + | |
| - | | + | |
| - | | + | |
| if(mySerial.available()> | if(mySerial.available()> | ||
| for(int j=0; j<32 ; j++){ | for(int j=0; j<32 ; j++){ | ||
| - | pms[j]=mySerial.read(); | + | pms[j]=mySerial.read(); |
| - | if(j< | + | |
| - | chksum+=pms[j]; | + | |
| } | } | ||
| - | if(pms[30] != (unsigned char)(chksum>> | + | if(pms[30] != (byte)(chksum>> |
| - | || pms[31]!= (unsigned char)(chksum) ){ | + | || pms[31] != (byte)(chksum) ){ |
| - | + | ||
| } | } | ||
| } | } | ||
| Line 155: | Line 149: | ||
| lcd.print(" | lcd.print(" | ||
| lcd.print(pms[15]); | lcd.print(pms[15]); | ||
| - | | + | lcd.print(" |
| - | lcd.print(" | + | |
| - | lcd.setCursor(11, | + | |
| - | | + | |
| } | } | ||
| </ | </ | ||
| - | ===== Result validation | + | === Result validation === |
| Observe the temperature, | Observe the temperature, | ||
| - | ===== Platformio.ini | + | === Platformio.ini === |
| < | < | ||
| [env:uno] | [env:uno] | ||
| Line 184: | Line 175: | ||
| </ | </ | ||
| - | ===== U1.cpp ===== | + | === IU1.cpp === |
| <code c> | <code c> | ||
| #include < | #include < | ||
| Line 236: | Line 227: | ||
| | | ||
| - | static int CheckFirst=0; | + | int chksum=0; |
| - | | + | byte pms[32]={0, |
| - | | + | |
| - | int chksum=0,res=0;; | + | |
| - | unsigned char pms[32]={0, | + | |
| | | ||
| for(int j=0; j<32 ; j++){ | for(int j=0; j<32 ; j++){ | ||
| - | pms[j]=mySerial.read(); | + | pms[j]=mySerial.read(); |
| - | if(j< | + | |
| - | chksum+=pms[j]; | + | |
| } | } | ||
| - | if(pms[30] != (unsigned char)(chksum>> | + | if(pms[30] != (byte)(chksum>> |
| - | || pms[31]!= (unsigned char)(chksum) ){ | + | || pms[31] != (byte)(chksum) ){ |
| - | + | ||
| } | } | ||
| } | } | ||
| | | ||
| - | | + | |
| | | ||
| | | ||
| | | ||
| - | lcd.setCursor(9, | + | |
| - | | + | |
| - | | + | |
| - | lcd.print(" | + | |
| } | } | ||
| </ | </ | ||