Répertoire projet Interfaçage SESAM IUT Cachan. Interface Graphique Capteur HIH6030-021-001 Humidité & Température
L'objectif de ce projet à pour but d'afficher la température et l'humidité du capteur HIH6030-021-001 de Honeywell.
Capteur HIH6030-021-001 :
Lien Farnell : https://fr.farnell.com/honeywell/hih6030-021-001/capteur-humidite-temperature-num/dp/2356755
« Datasheet » du composant : http://www.farnell.com/datasheets/1927619.pdf?_ga=2.84320473.1584398624.1549960629-263764023.1527238100
Le HIH6030-021-001 de Honeywell est un capteur d'humidité / température numérique humidIcon dans un boîtier SOIC-8. Ce capteur fournit un niveau de précision de ±4,5% de HR pour les performances d'humidité et ±1,0°C pour la performance de la température. Les applications typiques comprennent HVAC/R, les compresseurs d'air, les stations météorologiques, les armoires de télécommunication, les thérapies respiratoires et les incubateurs industriels / micro environnements.
• Plage d'alimentation de 2.3VDC à 5.5VDC • Disponible sans filtre et sans condensation • Stabilité à long terme de l'industrie jusqu'à ± 1,2% HR et ± 0,05 ° C / an • La fiabilité leader de l'industrie • Haute résolution • Sortie I2C Température réelle • Faible consommation • Gamme de température d'utilisation de -40°C à 100°C • Plage d'humidité de 0%RH à 100%RH • Courant d'alimentation de 1mA
A l’aide de l’écran tactile de la carte STM32F746G-DISCO, nous pouvons choisir différentes options pour les 2 modes.
Pour le mode température, il y a une option entre Degrés Celsius, Kelvin et Fahrenheit. Pour le mode humidité, l’option permettant de savoir, si nous sommes dans un taux d’humidité faible, modéré ou élevée est disponible.
main.cpp@0:553477233cd5, 2019-06-04 (annotated)
- Committer:
- jpally
- Date:
- Tue Jun 04 13:01:02 2019 +0000
- Revision:
- 0:553477233cd5
Interfacage SESAM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jpally | 0:553477233cd5 | 1 | #include "mbed.h" |
jpally | 0:553477233cd5 | 2 | #include "F746_GUI.hpp" |
jpally | 0:553477233cd5 | 3 | |
jpally | 0:553477233cd5 | 4 | //RESOLUTION 480x272 |
jpally | 0:553477233cd5 | 5 | |
jpally | 0:553477233cd5 | 6 | LCD_DISCO_F746NG lcd; //Affichage LCD |
jpally | 0:553477233cd5 | 7 | TS_DISCO_F746NG ts; //Touch Screen |
jpally | 0:553477233cd5 | 8 | |
jpally | 0:553477233cd5 | 9 | DigitalOut myled(LED1); |
jpally | 0:553477233cd5 | 10 | |
jpally | 0:553477233cd5 | 11 | I2C i2c(D14, D15); //Liaison I2C |
jpally | 0:553477233cd5 | 12 | |
jpally | 0:553477233cd5 | 13 | const int addr = 0x27; |
jpally | 0:553477233cd5 | 14 | |
jpally | 0:553477233cd5 | 15 | Button button1(15, 110, 80, 40, "Celsius"); |
jpally | 0:553477233cd5 | 16 | Button button2(15, 160, 80, 40, "Kelvin"); |
jpally | 0:553477233cd5 | 17 | Button button3(15,210, 80, 40, "Fahrenheit"); |
jpally | 0:553477233cd5 | 18 | Button button4(260,125, 200, 50, "Connaitre taux d'humidite"); |
jpally | 0:553477233cd5 | 19 | Button cache1(100,110, 140, 40, ""); |
jpally | 0:553477233cd5 | 20 | Button cache2(100,160, 140, 40, ""); |
jpally | 0:553477233cd5 | 21 | Button cache3(100,210, 140, 40, ""); |
jpally | 0:553477233cd5 | 22 | Button cache4(245,180, 230, 90, ""); |
jpally | 0:553477233cd5 | 23 | |
jpally | 0:553477233cd5 | 24 | int main() |
jpally | 0:553477233cd5 | 25 | { |
jpally | 0:553477233cd5 | 26 | float valeur_celsius=0.00; |
jpally | 0:553477233cd5 | 27 | double valeur_kelvin; |
jpally | 0:553477233cd5 | 28 | float valeur_fara; |
jpally | 0:553477233cd5 | 29 | float valeur_hum; |
jpally | 0:553477233cd5 | 30 | |
jpally | 0:553477233cd5 | 31 | char valeur[4]; |
jpally | 0:553477233cd5 | 32 | |
jpally | 0:553477233cd5 | 33 | char buffer[50]; |
jpally | 0:553477233cd5 | 34 | char buffer2[50]; |
jpally | 0:553477233cd5 | 35 | char buffer3[50]; |
jpally | 0:553477233cd5 | 36 | char buffer4[50]; |
jpally | 0:553477233cd5 | 37 | |
jpally | 0:553477233cd5 | 38 | lcd.Init(); |
jpally | 0:553477233cd5 | 39 | lcd.Clear(LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 40 | lcd.SetBackColor(LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 41 | lcd.SetTextColor(LCD_COLOR_BLACK); |
jpally | 0:553477233cd5 | 42 | lcd.SetFont(&Font20); |
jpally | 0:553477233cd5 | 43 | lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"CAPTEUR HIH6030-021-001", CENTER_MODE); |
jpally | 0:553477233cd5 | 44 | lcd.SetFont(&Font12); |
jpally | 0:553477233cd5 | 45 | lcd.DisplayStringAt(0, LINE(4), (uint8_t *)"Julien PALLY LPRO SESAM", CENTER_MODE); |
jpally | 0:553477233cd5 | 46 | lcd.DrawLine(240, 65, 240, 260); |
jpally | 0:553477233cd5 | 47 | lcd.SetFont(&Font24); |
jpally | 0:553477233cd5 | 48 | lcd.DisplayStringAt(25, LINE(3), (uint8_t *)"Temperature", LEFT_MODE); |
jpally | 0:553477233cd5 | 49 | lcd.SetFont(&Font24); |
jpally | 0:553477233cd5 | 50 | lcd.DisplayStringAt(290, LINE(3), (uint8_t *)"Humidite", LEFT_MODE); |
jpally | 0:553477233cd5 | 51 | |
jpally | 0:553477233cd5 | 52 | while(1) |
jpally | 0:553477233cd5 | 53 | { |
jpally | 0:553477233cd5 | 54 | ///////////////////////////////////////////////////// PARTIE I2C ////////////////////////////////////////////////////////////////// |
jpally | 0:553477233cd5 | 55 | |
jpally | 0:553477233cd5 | 56 | |
jpally | 0:553477233cd5 | 57 | i2c.write(addr<<1,0,0); |
jpally | 0:553477233cd5 | 58 | i2c.read(addr<<1, valeur, 4); |
jpally | 0:553477233cd5 | 59 | |
jpally | 0:553477233cd5 | 60 | float lecture_hum = (valeur[0]<< 8) + valeur[1]; |
jpally | 0:553477233cd5 | 61 | float humidite = lecture_hum / 163382 * 100; |
jpally | 0:553477233cd5 | 62 | |
jpally | 0:553477233cd5 | 63 | float lecture_temp = (valeur[2] << 6) + (valeur[3] >> 2); |
jpally | 0:553477233cd5 | 64 | float temperature = lecture_temp / 16382 * 165 - 40; |
jpally | 0:553477233cd5 | 65 | |
jpally | 0:553477233cd5 | 66 | ///////////////////////////////////////////////////// AFFICHAGE DES BOUTONS ////////////////////////////////////////////////////////////////// |
jpally | 0:553477233cd5 | 67 | |
jpally | 0:553477233cd5 | 68 | button1.Draw(LCD_COLOR_GRAY, LCD_COLOR_WHITE); //Dessin des boutons |
jpally | 0:553477233cd5 | 69 | button2.Draw(LCD_COLOR_GRAY, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 70 | button3.Draw(LCD_COLOR_GRAY, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 71 | button4.Draw(LCD_COLOR_GRAY, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 72 | |
jpally | 0:553477233cd5 | 73 | |
jpally | 0:553477233cd5 | 74 | ///////////////////////////////////////////////////// PARTIE TRAITEMENT ///////////////////////////////////////////////////////////////////// |
jpally | 0:553477233cd5 | 75 | |
jpally | 0:553477233cd5 | 76 | |
jpally | 0:553477233cd5 | 77 | |
jpally | 0:553477233cd5 | 78 | wait_ms(100); |
jpally | 0:553477233cd5 | 79 | |
jpally | 0:553477233cd5 | 80 | valeur_celsius = temperature; |
jpally | 0:553477233cd5 | 81 | valeur_kelvin = temperature + 273.15; |
jpally | 0:553477233cd5 | 82 | valeur_fara = temperature * 1.8 + 32; |
jpally | 0:553477233cd5 | 83 | valeur_hum = humidite; |
jpally | 0:553477233cd5 | 84 | |
jpally | 0:553477233cd5 | 85 | |
jpally | 0:553477233cd5 | 86 | if (valeur_celsius >= 999){valeur_celsius = 999;} |
jpally | 0:553477233cd5 | 87 | if (valeur_kelvin >= 999){valeur_kelvin = 999;} |
jpally | 0:553477233cd5 | 88 | if (valeur_fara >= 999){valeur_fara = 999;} |
jpally | 0:553477233cd5 | 89 | if (valeur_hum >= 999){valeur_hum = 999;} |
jpally | 0:553477233cd5 | 90 | |
jpally | 0:553477233cd5 | 91 | sprintf(buffer, "%.2f", valeur_celsius); |
jpally | 0:553477233cd5 | 92 | sprintf(buffer2, "%.2f", valeur_kelvin); |
jpally | 0:553477233cd5 | 93 | sprintf(buffer3, "%.2f", valeur_fara); |
jpally | 0:553477233cd5 | 94 | sprintf(buffer4, "%.2f", valeur_hum); |
jpally | 0:553477233cd5 | 95 | |
jpally | 0:553477233cd5 | 96 | if(button1.IsOnButton()) //si on touche le bouton Celsius |
jpally | 0:553477233cd5 | 97 | { |
jpally | 0:553477233cd5 | 98 | cache2.Draw(LCD_COLOR_WHITE, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 99 | cache3.Draw(LCD_COLOR_WHITE, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 100 | cache4.Draw(LCD_COLOR_WHITE, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 101 | |
jpally | 0:553477233cd5 | 102 | |
jpally | 0:553477233cd5 | 103 | lcd.SetBackColor(LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 104 | lcd.SetTextColor(LCD_COLOR_BLACK); |
jpally | 0:553477233cd5 | 105 | lcd.SetFont(&Font24); |
jpally | 0:553477233cd5 | 106 | lcd.DisplayStringAt(100, LINE(5), (uint8_t *)buffer, LEFT_MODE); |
jpally | 0:553477233cd5 | 107 | lcd.DisplayStringAt(210, LINE(5), (uint8_t *)"C" , LEFT_MODE); |
jpally | 0:553477233cd5 | 108 | } |
jpally | 0:553477233cd5 | 109 | |
jpally | 0:553477233cd5 | 110 | if(button2.IsOnButton()) //si on touche le bouton Kelvin |
jpally | 0:553477233cd5 | 111 | { |
jpally | 0:553477233cd5 | 112 | cache1.Draw(LCD_COLOR_WHITE, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 113 | cache3.Draw(LCD_COLOR_WHITE, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 114 | cache4.Draw(LCD_COLOR_WHITE, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 115 | |
jpally | 0:553477233cd5 | 116 | |
jpally | 0:553477233cd5 | 117 | lcd.SetBackColor(LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 118 | lcd.SetTextColor(LCD_COLOR_BLACK); |
jpally | 0:553477233cd5 | 119 | lcd.SetFont(&Font24); |
jpally | 0:553477233cd5 | 120 | lcd.DisplayStringAt(100, LINE(7), (uint8_t *)buffer2, LEFT_MODE); |
jpally | 0:553477233cd5 | 121 | lcd.DisplayStringAt(210, LINE(7), (uint8_t *)"K", LEFT_MODE); |
jpally | 0:553477233cd5 | 122 | } |
jpally | 0:553477233cd5 | 123 | |
jpally | 0:553477233cd5 | 124 | |
jpally | 0:553477233cd5 | 125 | if(button3.IsOnButton()) //si on touche le bouton Fahrenheit |
jpally | 0:553477233cd5 | 126 | { |
jpally | 0:553477233cd5 | 127 | cache1.Draw(LCD_COLOR_WHITE, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 128 | cache2.Draw(LCD_COLOR_WHITE, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 129 | cache4.Draw(LCD_COLOR_WHITE, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 130 | |
jpally | 0:553477233cd5 | 131 | lcd.SetBackColor(LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 132 | lcd.SetTextColor(LCD_COLOR_BLACK); |
jpally | 0:553477233cd5 | 133 | lcd.SetFont(&Font24); |
jpally | 0:553477233cd5 | 134 | lcd.DisplayStringAt(100, LINE(9), (uint8_t *)buffer3, LEFT_MODE); |
jpally | 0:553477233cd5 | 135 | lcd.DisplayStringAt(210, LINE(9), (uint8_t *)"F", LEFT_MODE); |
jpally | 0:553477233cd5 | 136 | } |
jpally | 0:553477233cd5 | 137 | |
jpally | 0:553477233cd5 | 138 | |
jpally | 0:553477233cd5 | 139 | if(button4.Touched()) //si on touche le bouton de l'Humidité |
jpally | 0:553477233cd5 | 140 | |
jpally | 0:553477233cd5 | 141 | { |
jpally | 0:553477233cd5 | 142 | cache1.Draw(LCD_COLOR_WHITE, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 143 | cache2.Draw(LCD_COLOR_WHITE, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 144 | cache3.Draw(LCD_COLOR_WHITE, LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 145 | |
jpally | 0:553477233cd5 | 146 | lcd.SetBackColor(LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 147 | lcd.SetTextColor(LCD_COLOR_BLACK); |
jpally | 0:553477233cd5 | 148 | lcd.SetFont(&Font24); |
jpally | 0:553477233cd5 | 149 | lcd.DisplayStringAt(295, LINE(10), (uint8_t *)buffer4, LEFT_MODE); |
jpally | 0:553477233cd5 | 150 | lcd.DisplayStringAt(410, LINE(10), (uint8_t *)"%", LEFT_MODE); |
jpally | 0:553477233cd5 | 151 | |
jpally | 0:553477233cd5 | 152 | |
jpally | 0:553477233cd5 | 153 | if(valeur_hum < 40) |
jpally | 0:553477233cd5 | 154 | { |
jpally | 0:553477233cd5 | 155 | lcd.SetBackColor(LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 156 | lcd.SetTextColor(LCD_COLOR_BLACK); |
jpally | 0:553477233cd5 | 157 | lcd.SetFont(&Font20); |
jpally | 0:553477233cd5 | 158 | lcd.DisplayStringAt(250, LINE(10), (uint8_t *)"Humidite Faible", LEFT_MODE); |
jpally | 0:553477233cd5 | 159 | } |
jpally | 0:553477233cd5 | 160 | |
jpally | 0:553477233cd5 | 161 | else if((valeur_hum > 40) && (valeur_hum < 70)) |
jpally | 0:553477233cd5 | 162 | { |
jpally | 0:553477233cd5 | 163 | lcd.SetBackColor(LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 164 | lcd.SetTextColor(LCD_COLOR_BLACK); |
jpally | 0:553477233cd5 | 165 | lcd.SetFont(&Font20); |
jpally | 0:553477233cd5 | 166 | lcd.DisplayStringAt(250, LINE(10), (uint8_t *)"Humidite Moyenne", LEFT_MODE); |
jpally | 0:553477233cd5 | 167 | } |
jpally | 0:553477233cd5 | 168 | |
jpally | 0:553477233cd5 | 169 | else if(valeur_hum > 70) |
jpally | 0:553477233cd5 | 170 | { |
jpally | 0:553477233cd5 | 171 | lcd.SetBackColor(LCD_COLOR_WHITE); |
jpally | 0:553477233cd5 | 172 | lcd.SetTextColor(LCD_COLOR_BLACK); |
jpally | 0:553477233cd5 | 173 | lcd.SetFont(&Font20); |
jpally | 0:553477233cd5 | 174 | lcd.DisplayStringAt(250, LINE(10), (uint8_t *)"Humidite Elevee", LEFT_MODE); |
jpally | 0:553477233cd5 | 175 | } |
jpally | 0:553477233cd5 | 176 | } |
jpally | 0:553477233cd5 | 177 | |
jpally | 0:553477233cd5 | 178 | |
jpally | 0:553477233cd5 | 179 | } |
jpally | 0:553477233cd5 | 180 | } |