{"id":4653,"date":"2020-05-07T19:13:25","date_gmt":"2020-05-07T17:13:25","guid":{"rendered":"http:\/\/www.ardpylab.fr\/?page_id=4653"},"modified":"2020-05-16T11:51:38","modified_gmt":"2020-05-16T09:51:38","slug":"projet-5-activite-1","status":"publish","type":"page","link":"https:\/\/www.ardpylab.fr\/?page_id=4653","title":{"rendered":"Projet 5 &#8211; Activit\u00e9 1"},"content":{"rendered":"\n<h2 style=\"text-align: center;\"><strong><em data-rich-text-format-boundary=\"true\">\u201dMesure de temp\u00e9ratures avec un <br><\/em><\/strong><strong><em data-rich-text-format-boundary=\"true\">capteur TMP 36 ou LM 35 \u201d<\/em><\/strong><\/h2>\n<p>&nbsp;<\/p>\n\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"577\" height=\"433\" class=\"wp-image-4633 aligncenter\" style=\"border: 3px solid #eeeeee; padding: 3px; margin: 3px;\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/05\/projetpython5-2.jpg\" alt=\"\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/05\/projetpython5-2.jpg 577w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/05\/projetpython5-2-300x225.jpg 300w\" sizes=\"auto, (max-width: 577px) 100vw, 577px\" \/><\/figure>\n<\/div>\n<p>&nbsp;<\/p>\n\n\n\n<h4>&nbsp;<\/h4>\n<h4><strong><span style=\"color: #3366ff;\">.&nbsp;<span style=\"text-decoration: underline;\">Objectif<br><br><\/span><\/span><\/strong><\/h4>\n<p>Dans cette activit\u00e9, nous allons mesurer une temp\u00e9rature \u00e0 l\u2019aide d&rsquo;un capteur <strong>TMP 36<\/strong> ou <strong>LM 35<\/strong>.<br>La tension de sortie de ces capteurs est lin\u00e9airement proportionnelle \u00e0 la temp\u00e9rature.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong><span style=\"color: #3366ff;\">.&nbsp;<span style=\"text-decoration: underline;\">Le programme<br><br><\/span><\/span><\/strong><\/h4>\n<p>Le code de l\u2019activit\u00e9, en Python ou en langage Arduino, lit la valeur de la broche A0 (nombre entier entre 0 et 1023), convertit cette valeur en tension en V (nombre d\u00e9cimal entre 0 et 5 V) et affiche la temp\u00e9rature correspondante dans la fen\u00eatre Python Shell ou le moniteur s\u00e9rie.<\/p>\n<p>Par d\u00e9faut, le code est pr\u00e9vu pour un capteur TMP 36, mais le calcul de la temp\u00e9rature avec un LM 35 \u00e9tant en commentaire, il suffit de modifier le code pour mesurer une temp\u00e9rature avec ce capteur.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>. <u>Programme en Python (\u201d<a href=\"https:\/\/www.ardpylab.fr\/downloads\/projetspython\/projet5\/projet5-activity1.zip\">Projet5\\Activity1\\PY\\Activity1.py<\/a>\u201d)<br><br><\/u><\/strong><\/h4>\n\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.ardpylab.fr\/downloads\/projetspython\/projet5\/Activity1\/PY\/Activity1.py\"><img loading=\"lazy\" decoding=\"async\" width=\"905\" height=\"948\" class=\"wp-image-5107 aligncenter\" style=\"border: 3px solid #eeeeee; padding: 3px; margin: 3px;\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/05\/projet5-activity1-1.png\" alt=\"\" srcset=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/05\/projet5-activity1-1.png 905w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/05\/projet5-activity1-1-286x300.png 286w, https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/05\/projet5-activity1-1-768x804.png 768w\" sizes=\"auto, (max-width: 905px) 100vw, 905px\" \/><\/a><\/figure>\n<\/div>\n<p>&nbsp;<\/p>\n\n\n\n<p><strong><u>D\u00e9roulement du programme<\/u><\/strong><strong>&nbsp;:<\/strong><\/p>\n<p>&#8211; <u>Importation des librairies&nbsp;et d\u00e9finition de fonctions<\/u> :<\/p>\n<p style=\"padding-left: 40px;\">. Le module <strong>\u201dConnectToArduino.py\u201d, <\/strong>contenant les fonctions de connexion \u00e0 l\u2019Arduino via le protocole <strong>\u201dFirmata Express\u201d<\/strong>,<\/p>\n<p style=\"padding-left: 40px;\">. Le module <strong>\u201d<\/strong><strong>PymataExpressDef.Py\u201d<\/strong> regroupant toutes les fonctions utiles \u00e0 l\u2019utilisation de <strong>\u201d<\/strong><strong>Pymata<\/strong><strong>-express\u201d<\/strong>&nbsp;(fonction de d\u00e9claration des entr\u00e9es et sorties, de lectures, d\u2019\u00e9critures\u2026),<\/p>\n<p style=\"padding-left: 40px;\">. La biblioth\u00e8que <strong>\u201d<\/strong><strong>time\u201d <\/strong>pour la gestion des temps de pause.<br><br><\/p>\n<p>&#8211; <u>D\u00e9claration des constantes et variables<\/u>&nbsp;:<\/p>\n<p style=\"padding-left: 40px;\">. <strong>PinSensor = 0 <\/strong>(cst correspondant au n\u00b0 de la broche A0 sur laquelle le capteur de temp\u00e9rature est connect\u00e9)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>ValSensor = 0 <\/strong>(variable pour stocker la valeur de la broche du capteur de temp\u00e9rature)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>tension = 0 <\/strong>(variable correspondant \u00e0 la valeur de la tension en V de la broche du capteur de temp\u00e9rature)<\/p>\n<p style=\"padding-left: 40px;\">. <strong>temperature = 0<\/strong> (variable correspondant \u00e0 la temp\u00e9rature en \u00b0C calcul\u00e9e \u00e0 partir de la valeur de la broche du capteur)<\/p>\n<p style=\"padding-left: 40px;\">.<strong>PortComArduino <\/strong>(port COM sur lequel l\u2019Arduino est connect\u00e9)&nbsp;<br><br><\/p>\n<p>&#8211; <u>Connexion \u00e0 l&rsquo;Arduino<\/u>&nbsp;:<\/p>\n<p style=\"padding-left: 40px;\">. D\u00e9tection du port COM, tentative d\u2019ouverture du port COM s\u00e9lectionn\u00e9 et connexion \u00e0 l\u2019Arduino:<\/p>\n<p style=\"padding-left: 80px;\"><strong>PortComArduino = SelectPortCOM()<\/strong><\/p>\n<p style=\"padding-left: 80px;\"><strong>board = OpenPortCom(PortComArduino)<br><br><\/strong><\/p>\n<p style=\"padding-left: 40px;\">. Si la connexion \u00e0 l\u2019Arduino est r\u00e9ussie :<\/p>\n<p style=\"padding-left: 80px;\">&#8211; D\u00e9claration de la broche du capteur de temp\u00e9rature en entr\u00e9e analogique&nbsp;:<\/p>\n<p style=\"padding-left: 120px;\"><strong>Set_AnalogInput_Pin(board, PinSensor)<br><br><\/strong><\/p>\n<p>&#8211; <u>Boucle principale du programme (boucle \u201d<\/u><u>while True\u201d<\/u><u>)<\/u> :<\/p>\n<p style=\"padding-left: 40px;\">. Lecture de la valeur de la broche du capteur de temp\u00e9rature :<\/p>\n<p style=\"padding-left: 40px;\"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sensorVal = Analog_Read(board, PinSensor)<\/strong><\/p>\n<p style=\"padding-left: 40px;\">. Calcul de la tension en V de la broche du capteur de temp\u00e9rature :<\/p>\n<p style=\"padding-left: 40px;\"><strong>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;tension = (sensorVal\/1023)*5<\/strong><\/p>\n<p style=\"padding-left: 40px;\">. Calcul de la temp\u00e9rature en \u00b0C correspondante (exemple pour un capteur TMP 36) :<\/p>\n<p style=\"padding-left: 40px;\"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; temperature = (tension &#8211; 0.5) * 100<\/strong><\/p>\n<p style=\"padding-left: 40px;\">. Affichage de ces 3 valeurs dans la fen\u00eatre Python Shell.<\/p>\n<p style=\"padding-left: 40px;\">. Attente de 100 ms avant une nouvelle mesure :<\/p>\n<p style=\"padding-left: 40px;\"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; time.sleep(0.1)<br><br><\/strong><\/p>\n<p>&#8211; <u>Fin du programme en appuyant sur <\/u><u>Ctrl-C<\/u>&nbsp;:<\/p>\n<p style=\"padding-left: 40px;\">&#8211;&gt; Le port COM est ferm\u00e9.<\/p>\n<p>&nbsp;<\/p>\n<p><strong><u>R\u00e9sultats dans la fen\u00eatre Python Shell<\/u><\/strong><strong>&nbsp;:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-5110 aligncenter\" style=\"border: 3px solid #eeeeee; padding: 3px; margin: 3px;\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/05\/projet5-activity1-2.png\" alt=\"\" width=\"578\" height=\"344\"><\/figure>\n<\/div>\n<p>&nbsp;<\/p>\n\n\n\n<h4><strong><br \/>. <u>Programme en langage Arduino (\u201d<a href=\"https:\/\/www.ardpylab.fr\/downloads\/projetspython\/projet5\/projet5-activity1.zip\">Projet5\\Activity1\\INO\\Activity1.ino<\/a>\u201d)<br \/><br \/><\/u><\/strong><\/h4>\n<p>Le code de l&rsquo;activit\u00e9 en langage Arduino a d\u00e9j\u00e0 \u00e9t\u00e9 \u00e9tudi\u00e9 dans la partie:<br \/>\u201d<a href=\"https:\/\/www.ardpylab.fr\/?page_id=856\/#prog\"><strong>Activit\u00e9s pour les lyc\u00e9es \/ Temp\u00e9ratures \/ Activit\u00e9 1<\/strong><\/a>\u201d<\/p>\n<p><br \/><br \/><\/p>\n\n\n<div  class=\"grids-section grids-is-stretch\" style=\"--_gs-gap-desktop:0px 0px;--_gs-m-desktop:0 0 0 0;--_gs-p-desktop:0 0 0 0;--_gs-bg-desktop:transparent none;--_gs-bg-xp-desktop:0px;--_gs-zi-desktop:auto;--_gs-d-desktop:block;--_gs-mw-desktop:calc(100% - 0 - 0);--_gs-gap-tablet:0px 0px;--_gs-m-tablet:0 0 0 0;--_gs-p-tablet:0 0 0 0;--_gs-bg-tablet:transparent none;--_gs-bg-xp-tablet:0px;--_gs-zi-tablet:auto;--_gs-d-tablet:block;--_gs-mw-tablet:calc(100% - 0 - 0);--_gs-gap-mobile:0px 0px;--_gs-m-mobile:0 0 0 0;--_gs-p-mobile:0 0 0 0;--_gs-bg-mobile:transparent none;--_gs-bg-xp-mobile:0px;--_gs-zi-mobile:auto;--_gs-d-mobile:block;--_gs-mw-mobile:calc(100% - 0 - 0);--_gs-columns:2;--_gs-rows:1\"><div class=\"grids-s-w_i\">\n<div class=\"grids-area\" style=\"--_ga-column:1\/2;--_ga-row:1\/2;--_ga-m-desktop:0 0 0 0;--_ga-p-desktop:0 0 0 0;--_ga-bg-desktop:transparent none;--_ga-zi-desktop:auto;--_ga-d-desktop:flex;--_ga-mw-desktop:calc(100% - 0 - 0);--_ga-m-tablet:0 0 0 0;--_ga-p-tablet:0 0 0 0;--_ga-bg-tablet:transparent none;--_ga-zi-tablet:auto;--_ga-d-tablet:flex;--_ga-mw-tablet:calc(100% - 0 - 0);--_ga-m-mobile:0 0 0 0;--_ga-p-mobile:0 0 0 0;--_ga-bg-mobile:transparent none;--_ga-zi-mobile:auto;--_ga-d-mobile:flex;--_ga-mw-mobile:calc(100% - 0 - 0)\">\n\n<div class=\"wp-block-image\"><figure class=\"alignleft size-large\"><a href=\"https:\/\/www.ardpylab.fr\/?page_id=4631\"><img loading=\"lazy\" decoding=\"async\" width=\"50\" height=\"28\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/03\/moins.jpg\" alt=\"\" class=\"wp-image-107\"\/><\/a><\/figure><\/div>\n\n<\/div>\n\n<div class=\"grids-area\" style=\"--_ga-column:2\/3;--_ga-row:1\/2;--_ga-m-desktop:0 0 0 0;--_ga-p-desktop:0 0 0 0;--_ga-bg-desktop:transparent none;--_ga-zi-desktop:auto;--_ga-d-desktop:flex;--_ga-mw-desktop:calc(100% - 0 - 0);--_ga-m-tablet:0 0 0 0;--_ga-p-tablet:0 0 0 0;--_ga-bg-tablet:transparent none;--_ga-zi-tablet:auto;--_ga-d-tablet:flex;--_ga-mw-tablet:calc(100% - 0 - 0);--_ga-m-mobile:0 0 0 0;--_ga-p-mobile:0 0 0 0;--_ga-bg-mobile:transparent none;--_ga-zi-mobile:auto;--_ga-d-mobile:flex;--_ga-mw-mobile:calc(100% - 0 - 0)\">\n\n<div class=\"wp-block-image\"><figure class=\"alignright size-large\"><a href=\"https:\/\/www.ardpylab.fr\/?page_id=4660\"><img loading=\"lazy\" decoding=\"async\" width=\"50\" height=\"28\" src=\"https:\/\/www.ardpylab.fr\/wp-content\/uploads\/2020\/03\/plus.jpg\" alt=\"\" class=\"wp-image-106\"\/><\/a><\/figure><\/div>\n\n<\/div>\n<\/div><\/div>\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>\u201dMesure de temp\u00e9ratures avec un capteur TMP 36 ou LM 35 \u201d &nbsp; &nbsp; &nbsp; .&nbsp;Objectif Dans cette activit\u00e9, nous allons mesurer une temp\u00e9rature \u00e0 l\u2019aide d&rsquo;un capteur TMP 36 ou LM 35.La tension de sortie de ces capteurs est lin\u00e9airement proportionnelle \u00e0 la temp\u00e9rature. &nbsp; .&nbsp;Le programme Le code de l\u2019activit\u00e9, en Python ou [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-4653","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/pages\/4653","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4653"}],"version-history":[{"count":1,"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/pages\/4653\/revisions"}],"predecessor-version":[{"id":5199,"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=\/wp\/v2\/pages\/4653\/revisions\/5199"}],"wp:attachment":[{"href":"https:\/\/www.ardpylab.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}