issue170:micro-ci_micro-la
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
issue170:micro-ci_micro-la [2021/06/29 14:29] – d52fr | issue170:micro-ci_micro-la [2021/06/30 15:55] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 4: | Ligne 4: | ||
Arduino has finally released their Nano RP2040 Connect which costs about $26 USD. It supports Wi-Fi, Bluetooth, and Bluetooth Low-Energy (v4.2), a built-in microphone for sound or voice activation, an RGB LED, and a six-axis motion sensor. ** | Arduino has finally released their Nano RP2040 Connect which costs about $26 USD. It supports Wi-Fi, Bluetooth, and Bluetooth Low-Energy (v4.2), a built-in microphone for sound or voice activation, an RGB LED, and a six-axis motion sensor. ** | ||
+ | |||
+ | Je tiens à m' | ||
+ | |||
+ | Le mois dernier, je vous ai dit que nous allions examiner le SparkFun Thing Plus ESP-32 WROOM (https:// | ||
+ | |||
+ | Arduino a enfin sorti son Nano RP2040 Connect qui coûte environ 26 dollars US. Il prend en charge les technologies Wi-Fi, Bluetooth et Bluetooth Low-Energy (v4.2) ; il a un microphone intégré pour le son ou l' | ||
+ | |||
**Seeed Studio has released the Wio RP2040 mini development board which includes 2.4 GHz 802.11b/g/n WiFi 4 supporting AP & station modes, but no Bluetooth support. The estimated price will be about $13 USD and is available only for pre-order at this point. It’s still unclear when the board will start shipping. | **Seeed Studio has released the Wio RP2040 mini development board which includes 2.4 GHz 802.11b/g/n WiFi 4 supporting AP & station modes, but no Bluetooth support. The estimated price will be about $13 USD and is available only for pre-order at this point. It’s still unclear when the board will start shipping. | ||
Finally, there is really big news from Adafruit. I’ll quote the headline from Tom’s Hardware site…”CircuitPython Libraries Slither Into MicroPython on the Raspberry Pi Pico”. That’s right. This is a big thing for the RPi Pico, since eventually the entire CircuitPython library should be available to MicroPython users. Currently, there are many drivers that don’t work, but it’s early days yet. Congratulations to Adafruit for making this move! You can find more about it at https:// | Finally, there is really big news from Adafruit. I’ll quote the headline from Tom’s Hardware site…”CircuitPython Libraries Slither Into MicroPython on the Raspberry Pi Pico”. That’s right. This is a big thing for the RPi Pico, since eventually the entire CircuitPython library should be available to MicroPython users. Currently, there are many drivers that don’t work, but it’s early days yet. Congratulations to Adafruit for making this move! You can find more about it at https:// | ||
+ | |||
+ | Seeed Studio a sorti la mini-carte de développement Wio RP2040 qui inclut le WiFi 4 2.4 GHz 802.11b/g/n supportant les modes AP et station, mais sans support du Bluetooth. Le prix est estimé à environ 13 dollars US et elle n'est disponible pour le moment qu'en pré-commande. On ne sait toujours pas quand la carte sera livrée. | ||
+ | |||
+ | Enfin, il y a de très grandes nouvelles en provenance d' | ||
+ | |||
**Sparkfun Thing Plus 32 Wroom | **Sparkfun Thing Plus 32 Wroom | ||
Ligne 22: | Ligne 34: | ||
Now, let’s get into our projects for this month...** | Now, let’s get into our projects for this month...** | ||
+ | |||
+ | Sparkfun Thing Plus 32 Wroom | ||
+ | |||
+ | Venons-en au véritable sujet de mon article de ce mois-ci. Le SparkFun Thing Plus 32 Wroom est un petit microcontrôleur génial qui fait tourner facilement MicroPython. Le prix de la carte est un peu élevé, environ 21 dollars US. Si le prix est trop élevé pour votre budget, vous pouvez trouver une carte générique similaire avec la puce WiFi Wroom sur le Web. J'ai trouvé une carte de développement Aokin ESP32 sur Amazon dans un pack de trois pour un peu moins de 17 dollars US. Le brochage et le format des deux cartes sont différents, | ||
+ | |||
+ | Pour la carte générique, | ||
+ | |||
+ | Les deux cartes prennent en charge le WiFi 2,4 Ghz et le Bluetooth, ainsi que les capteurs tactiles capacitifs, le capteur de Hall (capteur magnétique) et d' | ||
+ | |||
+ | Vous trouverez ci-dessous le brochage de la carte Sparkfun Thing Plus 32 WROOM : | ||
+ | |||
+ | Ci-dessus, la carte de développement générique ESP32. | ||
+ | |||
+ | Maintenant, entrons dans nos projets de ce mois-ci. | ||
+ | |||
**Project Program #1 - TouchPad | **Project Program #1 - TouchPad | ||
Ligne 32: | Ligne 59: | ||
touch7 = machine.TouchPad(machine.Pin(27))** | touch7 = machine.TouchPad(machine.Pin(27))** | ||
+ | |||
+ | Programme du projet n° 1 - Pavé tactile | ||
+ | |||
+ | Le SparkFun Thing Plus et la carte de développement générique ESP32 sont tous deux dotés de plusieurs entrées de capteur de pavé tactile. Pour le Thing Plus, il y en a 8 qui sont réparties sur les broches externes. Pour le Generic que j' | ||
+ | |||
+ | import machine | ||
+ | |||
+ | import utime | ||
+ | |||
+ | touch7 = machine.TouchPad(machine.Pin(27)) | ||
+ | |||
**Now (top right), we’ll create a variable called lowvalue and initialize it to 1000. When running, the touch pad actually floats between 700 and 600. Then we start a “forever loop”. We’ll read the value of the touch pin and compare that with the last recorded lowvalue figure. If the current touchvalue is lower than the last lowvalue, we set lowvalue to the touchvalue. We also print the lowvalue at this point. Finally we sleep for 100 milliseconds and loop again. We can use the {Stop} button in Thonny to quit the program. | **Now (top right), we’ll create a variable called lowvalue and initialize it to 1000. When running, the touch pad actually floats between 700 and 600. Then we start a “forever loop”. We’ll read the value of the touch pin and compare that with the last recorded lowvalue figure. If the current touchvalue is lower than the last lowvalue, we set lowvalue to the touchvalue. We also print the lowvalue at this point. Finally we sleep for 100 milliseconds and loop again. We can use the {Stop} button in Thonny to quit the program. | ||
Ligne 55: | Ligne 93: | ||
Now (below), we can modify the program a little bit to allow the program to self terminate…** | Now (below), we can modify the program a little bit to allow the program to self terminate…** | ||
+ | |||
+ | Maintenant (en haut à droite), nous allons créer une variable appelée lowvalue et l' | ||
+ | |||
+ | Voici à quoi ressemble l' | ||
+ | |||
+ | LowValue = 677 | ||
+ | LowValue = 671 | ||
+ | LowValue = 667 | ||
+ | LowValue = 658 | ||
+ | LowValue = 616 | ||
+ | LowValue = 456 | ||
+ | LowValue = 390 | ||
+ | LowValue = 347 | ||
+ | LowValue = 227 | ||
+ | LowValue = 128 | ||
+ | LowValue = 107 | ||
+ | LowValue = 100 | ||
+ | LowValue = 94 | ||
+ | LowValue = 92 | ||
+ | LowValue = 88 | ||
+ | LowValue = 87 | ||
+ | |||
+ | À présent (ci-dessous), | ||
+ | |||
**Notice that we haven’t changed it that much. We just added an assignment to a variable called loopit, changed the while statement to “while loopit:” instead of “while True:”, and then check to see if the lowvalue is less than 90 as a “trigger”. If it is, then we set the loopit value to False to make the loop fail. | **Notice that we haven’t changed it that much. We just added an assignment to a variable called loopit, changed the while statement to “while loopit:” instead of “while True:”, and then check to see if the lowvalue is less than 90 as a “trigger”. If it is, then we set the loopit value to False to make the loop fail. | ||
Ligne 72: | Ligne 134: | ||
passwd = ' | passwd = ' | ||
+ | |||
+ | Remarquez que nous ne l' | ||
+ | |||
+ | Je dois tenir et presser doucement le cavalier mâle pour que la valeur soit suffisamment basse pour déclencher la sortie. | ||
+ | |||
+ | Programme du projet n° 2 - Programmation du réseau | ||
+ | |||
+ | Ceci est un exemple simple de la façon de se connecter à votre routeur local. Tout ce qu'il fait réellement est de se connecter au routeur avec votre mot de passe, obtenir une adresse IP et l' | ||
+ | |||
+ | Tout d' | ||
+ | |||
+ | import network | ||
+ | |||
+ | essid = 'Votre RouteurRéseau' | ||
+ | |||
+ | |||
+ | passwd = 'Votre mot de passe réseau' | ||
+ | |||
**Now (top right) we’ll create the function to do the actual communications with the router (essid). We set the network object (wlan) to station mode, which is like a “normal” computer on the network. You could also set it up as an access point. Next, we set the network object to active and then try to connect. Once we have connected, we print out the network information (ip address, etc). The final line calls the connection function. | **Now (top right) we’ll create the function to do the actual communications with the router (essid). We set the network object (wlan) to station mode, which is like a “normal” computer on the network. You could also set it up as an access point. Next, we set the network object to active and then try to connect. Once we have connected, we print out the network information (ip address, etc). The final line calls the connection function. | ||
Ligne 80: | Ligne 160: | ||
Our final project for this month involves using the ESP32/ | Our final project for this month involves using the ESP32/ | ||
+ | |||
+ | Maintenant (en haut à droite), nous allons créer la fonction pour effectuer les communications réelles avec le routeur (essid). Nous définissons l' | ||
+ | |||
+ | Comme je l'ai dit, il s'agit d'un exemple très simple qui ne fait rien d' | ||
+ | |||
+ | Programme du projet #3 - Serveur Web et DHT-11/22 | ||
+ | |||
+ | Notre projet final pour ce mois-ci implique l' | ||
+ | |||
**The entire project is described in detail at: https:// | **The entire project is described in detail at: https:// | ||
Ligne 98: | Ligne 187: | ||
You can find out more about upip at: https:// | You can find out more about upip at: https:// | ||
+ | |||
+ | L' | ||
+ | |||
+ | Ce projet utilise la bibliothèque PicoWeb qui se trouve à l' | ||
+ | |||
+ | Bien entendu, vous devez ajouter Picoweb et ses dépendances. Vous pouvez essayer de suivre les instructions dans le lien pour le projet lui-même, ou vous pouvez utiliser upip dans le REPL de Thonny. Vous devrez installer micropython-pkg_resources, | ||
+ | |||
+ | import upip | ||
+ | |||
+ | upip.install(' | ||
+ | |||
+ | upip.install(' | ||
+ | |||
+ | upip.install(' | ||
+ | |||
+ | upip.install(' | ||
+ | |||
+ | Vous pouvez trouver plus d' | ||
+ | |||
**There is the code, diagrams and step-by-step projects leading up to the full webserver project. The code for the webserver project is pretty long and includes both the python file and the index.html file that displays the web information. I won’t duplicate it here, but I will point out a few changes that I had to make to get the project to work the way that I wanted it to. | **There is the code, diagrams and step-by-step projects leading up to the full webserver project. The code for the webserver project is pretty long and includes both the python file and the index.html file that displays the web information. I won’t duplicate it here, but I will point out a few changes that I had to make to get the project to work the way that I wanted it to. | ||
Ligne 110: | Ligne 218: | ||
Line 33 (in my code) needs to be modified to support your network. | Line 33 (in my code) needs to be modified to support your network. | ||
sta_if.connect(' | sta_if.connect(' | ||
+ | |||
+ | Il y a le code, les diagrammes et les projets, étape par étape, menant au projet complet de serveur Web. Le code du projet de serveur Web est assez long et comprend à la fois le fichier python et le fichier index.html qui affiche les informations Web. Je ne vais pas le reproduire ici, mais je vais signaler quelques changements que j'ai dû faire pour que le projet fonctionne comme je le voulais. | ||
+ | |||
+ | J'ai enregistré le code principal dans un fichier nommé ESP32-DHT-Touch-Picoweb.py. | ||
+ | |||
+ | Les lignes 18, 19 et 20 définissent les broches pour les LEDs. J'ai décidé de n' | ||
+ | r_led = machine.Pin(2, | ||
+ | |||
+ | Et j'ai laissé les lignes 19 et 20 telles quelles. | ||
+ | |||
+ | La ligne 33 (dans mon code) doit être modifiée pour supporter votre réseau. | ||
+ | sta_if.connect(' | ||
+ | |||
**Line 58 defines the callback for the touchpad timer interrupt handler. I modified lines 62, 70 and 78. They each are an if statement testing the touchpad.read() value to be less than 100. Since I’m just using just wires, not true copper pads, the earlier tests showed that I can achieve a value of under 100, but it takes a number of seconds for it to get that low. So, I changed the test value to less than 200 for all three values. It still takes around 2 ½ seconds to 3 seconds and a fairly tight squeeze to get it to trigger, but it does. So line 62 was changed to: | **Line 58 defines the callback for the touchpad timer interrupt handler. I modified lines 62, 70 and 78. They each are an if statement testing the touchpad.read() value to be less than 100. Since I’m just using just wires, not true copper pads, the earlier tests showed that I can achieve a value of under 100, but it takes a number of seconds for it to get that low. So, I changed the test value to less than 200 for all three values. It still takes around 2 ½ seconds to 3 seconds and a fairly tight squeeze to get it to trigger, but it does. So line 62 was changed to: | ||
Ligne 127: | Ligne 248: | ||
dht22_timer.init(period=1000, | dht22_timer.init(period=1000, | ||
+ | |||
+ | La ligne 58 définit le callback pour le gestionnaire d' | ||
+ | if t7 < 200 : | ||
+ | |||
+ | La ligne 70 a été changée en : | ||
+ | if t8 < 200 : | ||
+ | |||
+ | Et la ligne 78 a été changée en : | ||
+ | if t9 < 200 : | ||
+ | |||
+ | Les lignes 87, 89 et 90 (mon code) font référence au capteur DHT11. Comme j' | ||
+ | |||
+ | d = dht.DHT22(machine.Pin(23)) | ||
+ | |||
+ | dht22_timer = machine.Timer(0) | ||
+ | |||
+ | dht22_timer.init(period=1000, | ||
+ | |||
**Also, in the index.html file I made a change to make the temperature and humidity display text smaller. Around line 45, you will find the code: | **Also, in the index.html file I made a change to make the temperature and humidity display text smaller. Around line 45, you will find the code: | ||
Ligne 149: | Ligne 288: | ||
Until then, as always; stay safe, healthy, positive and creative!** | Until then, as always; stay safe, healthy, positive and creative!** | ||
+ | |||
+ | De plus, dans le fichier index.html, j'ai fait une modification pour rendre le texte d' | ||
+ | |||
+ | | ||
+ | font-size : 160px ; | ||
+ | color : #999 ; | ||
+ | } | ||
+ | |||
+ | J'ai trouvé que la taille de la police était beaucoup trop grande pour moi. Je l'ai changée en : | ||
+ | |||
+ | .table-value { | ||
+ | font-size : 60px ; | ||
+ | color : #999 ; | ||
+ | } | ||
+ | |||
+ | ce qui fonctionne beaucoup mieux, du moins pour moi. Vous pouvez faire ce changement si vous le souhaitez. | ||
+ | |||
+ | Mon code peut être trouvé sur mon dépôt github à l' | ||
+ | |||
+ | La prochaine fois, nous verrons les dispositifs NeoPixel et comment les programmer en utilisant l' | ||
+ | |||
+ | D'ici là, comme toujours, restez en sécurité, en bonne santé, positifs et créatifs ! | ||
+ | |||
issue170/micro-ci_micro-la.1624969751.txt.gz · Dernière modification : 2021/06/29 14:29 de d52fr