{"id":339,"date":"2020-03-22T16:31:05","date_gmt":"2020-03-22T16:31:05","guid":{"rendered":"https:\/\/marcjuneau.ca\/?p=339"},"modified":"2020-03-23T12:51:10","modified_gmt":"2020-03-23T12:51:10","slug":"premier-projet-esp32-dans-platformio","status":"publish","type":"post","link":"https:\/\/marcjuneau.ca\/?p=339","title":{"rendered":"Premier projet ESP32 dans PlatformIO"},"content":{"rendered":"\n<p>Comme premier projet, le classique clignotement d&rsquo;un LED. Nous allons donc faire clignoter le LED bleu aux 500ms.<\/p>\n<h4>1 &#8211; Cr\u00e9er le projet<\/h4>\n<p>Apr\u00e8s le lancement de VSCode :<\/p>\n<ol>\n<li>Cliquez sur <strong>PlatformIO<\/strong><\/li>\n<li>Cliquez sur <strong>Home<\/strong><\/li>\n<li>Cliquez sur <strong>New Project<\/strong><\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-344\" src=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image8.png\" alt=\"\" width=\"1246\" height=\"529\" srcset=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image8.png 1246w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image8-300x127.png 300w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image8-1024x435.png 1024w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image8-768x326.png 768w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image8-465x197.png 465w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image8-695x295.png 695w\" sizes=\"auto, (max-width: 1246px) 100vw, 1246px\" \/><\/p>\n<p>Dans la nouvelle fen\u00eatre :<\/p>\n<ol>\n<li>Nommez votre projet<\/li>\n<li>S\u00e9lectionnez la carte que vous utilisez (moi c&rsquo;est le <a href=\"https:\/\/axesstek.com\/store\/index.php?rt=product\/product&amp;product_id=140\">DOIT ESP32<\/a> )<\/li>\n<li>Cliquez sur <strong>Finish<\/strong><\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-345\" src=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image9.png\" alt=\"\" width=\"1078\" height=\"846\" srcset=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image9.png 1078w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image9-300x235.png 300w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image9-1024x804.png 1024w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image9-768x603.png 768w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image9-465x365.png 465w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image9-637x500.png 637w\" sizes=\"auto, (max-width: 1078px) 100vw, 1078px\" \/><\/p>\n<p>PlatformIO va charger les librairies requises, ce que pourrait-\u00eatre long la premi\u00e8re fois.<\/p>\n<h4>2 &#8211; Ouverture du fichier main.cpp<\/h4>\n<p>Apr\u00e8s le lancement de VSCode :<\/p>\n<ol>\n<li>Ouvrez la zone src, o\u00f9 se trouve les sources de votre projet<\/li>\n<li>Cliquez sur main.cpp, ce qui ouvrira le fichier dans la zone d&rsquo;\u00e9dition \u00e0 droite.<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-347\" src=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image10.png\" alt=\"\" width=\"1543\" height=\"903\" srcset=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image10.png 1543w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image10-300x176.png 300w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image10-1024x599.png 1024w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image10-768x449.png 768w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image10-1536x899.png 1536w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image10-460x270.png 460w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image10-465x272.png 465w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image10-695x407.png 695w\" sizes=\"auto, (max-width: 1543px) 100vw, 1543px\" \/><\/p>\n<h4>3 &#8211; \u00c9dition du fichier main.cpp<\/h4>\n<p>Comme dans Arduino IDE, il y a 2 fonctions :<\/p>\n<ol>\n<li>setup() qui est appel\u00e9e au lancement<\/li>\n<li>loop() qui est appel\u00e9e perp\u00e9tuellement<\/li>\n<\/ol>\n<p>Le code suivant configure la broche GPIO2 en sortie dans la fonction setup(), puis il \u00e9crit en alternance un niveau haut (3.3V) puis bas (0V) sur la broche GPIO2.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#define&nbsp;LED&nbsp;2\nvoid&nbsp;setup()\n{\n&nbsp;&nbsp;pinMode(LED,&nbsp;OUTPUT);\n}\n\nvoid&nbsp;loop()\n{\n&nbsp;&nbsp;digitalWrite(LED,&nbsp;1);&nbsp;\n&nbsp;&nbsp;delay(500);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;digitalWrite(LED,&nbsp;0);&nbsp;\n&nbsp;&nbsp;delay(500);\n} <\/pre>\n\n\n\n<h4>4 &#8211; Compilation du projet<\/h4>\n<p>La fa\u00e7on la plus simple est d&rsquo;appuyer sur le bouton <strong>Build<\/strong> (crochet) dans la barre d&rsquo;outils bleu en bas de l&rsquo;\u00e9cran.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-355\" src=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image12-1.png\" alt=\"\" width=\"1392\" height=\"157\" srcset=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image12-1.png 1392w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image12-1-300x34.png 300w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image12-1-1024x115.png 1024w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image12-1-768x87.png 768w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image12-1-465x52.png 465w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image12-1-695x78.png 695w\" sizes=\"auto, (max-width: 1392px) 100vw, 1392px\" \/><\/p>\n<p>Il est aussi possible d&rsquo;utiliser les combinaisons de touches suivantes :<\/p>\n<p><code class=\"docutils literal notranslate\"><span class=\"pre\">ctrl+alt+b<\/span><\/code>\u00a0\/\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">cmd-shift-b<\/span><\/code>\u00a0\/\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">ctrl-shift-b<\/span><\/code><\/p>\n<p>Les combinaisons de touches peuvent-\u00eatre modifi\u00e9es.\u00a0 Lisez ceci :<a href=\"https:\/\/code.visualstudio.com\/docs\/getstarted\/keybindings\">https:\/\/code.visualstudio.com\/docs\/getstarted\/keybindings<\/a><\/p>\n<h4>4 &#8211; T\u00e9l\u00e9chargement dans le ESP32<\/h4>\n<p>Assurez-vous que votre ESP32 est bien connect\u00e9 et d\u00e9tect\u00e9. Le ESP32 n&rsquo;est pas natif USB donc vous devriez voir un autre circuit int\u00e9gr\u00e9 dans la liste. Le DOIT Devkit V1 utilise le CP2102.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-357\" src=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image13-1.png\" alt=\"\" width=\"1185\" height=\"527\" srcset=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image13-1.png 1185w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image13-1-300x133.png 300w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image13-1-1024x455.png 1024w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image13-1-768x342.png 768w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image13-1-465x207.png 465w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image13-1-695x309.png 695w\" sizes=\"auto, (max-width: 1185px) 100vw, 1185px\" \/><\/p>\n<p>Pour t\u00e9l\u00e9charger, cliquer sur la fl\u00e8che \u00e0 cot\u00e9 du crochet dans la barre d&rsquo;outils bleu en bas de l&rsquo;\u00e9cran.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-361\" src=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image14.png\" alt=\"\" width=\"1392\" height=\"157\" srcset=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image14.png 1392w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image14-300x34.png 300w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image14-1024x115.png 1024w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image14-768x87.png 768w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image14-465x52.png 465w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image14-695x78.png 695w\" sizes=\"auto, (max-width: 1392px) 100vw, 1392px\" \/><\/p>\n<p>Il est possible que vous deviez appuyer sur le bouton BOOT lorsque vous verrez <strong>connecting&#8230;..<\/strong> dans le terminal<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-363\" src=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image16.png\" alt=\"\" width=\"970\" height=\"457\" srcset=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image16.png 970w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image16-300x141.png 300w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image16-768x362.png 768w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image16-465x219.png 465w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image16-695x327.png 695w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><\/p>\n<p>Le bouton <b>BOOT <\/b>est situ\u00e9 \u00e0 cot\u00e9 du connecteur USB. Il se nomme <strong>FLASH <\/strong>sur d&rsquo;autres cartes ESP32.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-362 aligncenter\" src=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image15.png\" alt=\"\" width=\"338\" height=\"173\" srcset=\"https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image15.png 338w, https:\/\/marcjuneau.ca\/wp-content\/uploads\/2020\/03\/Image15-300x154.png 300w\" sizes=\"auto, (max-width: 338px) 100vw, 338px\" \/><\/p>\n<p>Normalement, vous devriez voir le LED bleu clignot\u00e9 apr\u00e8s cette \u00e9tape.\u00a0<\/p>\n<p>Voici un vid\u00e9o des \u00e9tapes.<\/p>\n<p><iframe loading=\"lazy\" title=\"Installation de PlatformIO sous Visual Studio Code\" width=\"1333\" height=\"1000\" src=\"https:\/\/www.youtube.com\/embed\/1bIQAHWXdfo?start=329&#038;feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Comme premier projet, le classique clignotement d&rsquo;un LED. Nous allons donc faire clignoter le LED bleu aux 500ms. 1 &#8211; Cr\u00e9er le projet Apr\u00e8s le lancement de VSCode : Cliquez sur PlatformIO Cliquez sur Home Cliquez sur New Project Dans la nouvelle fen\u00eatre : Nommez votre projet S\u00e9lectionnez la carte<span class=\"more-link\"><a href=\"https:\/\/marcjuneau.ca\/?p=339\">Continue Reading<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":340,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["entry","author-mjuneau","post-339","post","type-post","status-publish","format-standard","has-post-thumbnail","category-esp32-projets"],"_links":{"self":[{"href":"https:\/\/marcjuneau.ca\/index.php?rest_route=\/wp\/v2\/posts\/339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/marcjuneau.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/marcjuneau.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/marcjuneau.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/marcjuneau.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=339"}],"version-history":[{"count":18,"href":"https:\/\/marcjuneau.ca\/index.php?rest_route=\/wp\/v2\/posts\/339\/revisions"}],"predecessor-version":[{"id":376,"href":"https:\/\/marcjuneau.ca\/index.php?rest_route=\/wp\/v2\/posts\/339\/revisions\/376"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/marcjuneau.ca\/index.php?rest_route=\/wp\/v2\/media\/340"}],"wp:attachment":[{"href":"https:\/\/marcjuneau.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/marcjuneau.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/marcjuneau.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}