issue209: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 | ||
issue209:micro-ci_micro-la [2024/09/28 22:57] – d52fr | issue209:micro-ci_micro-la [2024/10/01 15:43] (Version actuelle) – auntiee | ||
---|---|---|---|
Ligne 8: | Ligne 8: | ||
There seem to be many variants of the CYD out there from many different vendors. The one I got (from Amazon) is made by AITRIP. Just make sure that you get a board that is described as ESP32-2432S028R. There seems to be at least three versions of this board (again from various manufacturers). Mine seems to be revision 3, and has not only the USB-C connector but also the old style USB micro. Both work to power and program the board, so if you don’t have a USB-C connector cable yet, you might want to look for the revision 3 board if you can find it.** | There seem to be many variants of the CYD out there from many different vendors. The one I got (from Amazon) is made by AITRIP. Just make sure that you get a board that is described as ESP32-2432S028R. There seems to be at least three versions of this board (again from various manufacturers). Mine seems to be revision 3, and has not only the USB-C connector but also the old style USB micro. Both work to power and program the board, so if you don’t have a USB-C connector cable yet, you might want to look for the revision 3 board if you can find it.** | ||
+ | |||
+ | CYD (Cheap Yellow Display) ESP-32 | ||
+ | |||
+ | Je vous salue à nouveau, chers frères et sœurs de la forme de vie sensible. Les choses ici, sur la plateforme d' | ||
+ | |||
+ | Ce mois-ci, nous allons nous pencher sur l' | ||
+ | |||
+ | Il s'agit d'une petite carte très soignée, pilotée par un ESP32-WROOM auquel est attaché un écran ILI9341 320 x 240. L' | ||
+ | |||
+ | Il semble qu'il y ait de nombreuses variantes du CYD chez différents vendeurs. Celui que j'ai acheté (sur Amazon) est fabriqué par AITRIP. Assurez-vous que vous obtenez une carte décrite comme ESP32-2432S028R. Il semble qu'il y ait au moins trois versions de cette carte (encore une fois de différents fabricants). La mienne semble être la révision 3 et possède non seulement le connecteur USB-C mais aussi le micro USB à l' | ||
+ | |||
**A quick note here on obtaining the board. There are MANY places that you can get this board from. I used Amazon and got a two-pack of the boards for about $35 USD. There are some places that show getting the board plus a front and back protective plate set for less than $5.00 USD. PLEASE don't fall for that. Even though the entire web page continually says that the board is included, it isn’t. Look for the board to cost somewhere between $12 USD and $20 USD in single quantities. PLEASE remember the old saying “If it seems too good to be true, it probably is”. | **A quick note here on obtaining the board. There are MANY places that you can get this board from. I used Amazon and got a two-pack of the boards for about $35 USD. There are some places that show getting the board plus a front and back protective plate set for less than $5.00 USD. PLEASE don't fall for that. Even though the entire web page continually says that the board is included, it isn’t. Look for the board to cost somewhere between $12 USD and $20 USD in single quantities. PLEASE remember the old saying “If it seems too good to be true, it probably is”. | ||
As far as I can tell, there are at least four ways to program these boards. The first (and most prevalent on the Internet) is using the Arduino programming language and the Arduino IDE. There are lots of examples of this out there, so I won’t deal with this too much this month. The best place I’ve found is to look at the Random Nerds website (https:// | As far as I can tell, there are at least four ways to program these boards. The first (and most prevalent on the Internet) is using the Arduino programming language and the Arduino IDE. There are lots of examples of this out there, so I won’t deal with this too much this month. The best place I’ve found is to look at the Random Nerds website (https:// | ||
+ | |||
+ | Une petite remarque sur l' | ||
+ | |||
+ | Pour autant que je sache, il existe au moins quatre façons de programmer ces cartes. La première (et la plus répandue sur Internet) consiste à utiliser le langage de programmation Arduino et l'IDE Arduino. Il existe de nombreux exemples de cette méthode et je ne m'y attarderai donc pas trop ce mois-ci. Le meilleur endroit que j'ai trouvé est le site Web Random Nerds (https:// | ||
+ | |||
**The second way to program the board is to use MicroPython. There are many (but not as many as for the Arduino code) websites for this. The two very best drivers (currently) are at | **The second way to program the board is to use MicroPython. There are many (but not as many as for the Arduino code) websites for this. The two very best drivers (currently) are at | ||
Ligne 20: | Ligne 36: | ||
Finally, there is a special GUI library called LVGL which works with this (and many other boards) that, for the moment, is best done using Arduino code. You can find a very good tutorial again at the Random Nerds site at https:// | Finally, there is a special GUI library called LVGL which works with this (and many other boards) that, for the moment, is best done using Arduino code. You can find a very good tutorial again at the Random Nerds site at https:// | ||
+ | |||
+ | La deuxième façon de programmer la carte est d' | ||
+ | |||
+ | La troisième façon de programmer la carte est d' | ||
+ | |||
+ | Enfin, il existe une bibliothèque GUI spéciale appelée LVGL qui fonctionne avec cette carte (et beaucoup d' | ||
+ | |||
**There is a newish product called platformIO that is a plugin for Visual Studio code, and there are some good tutorials for the LVGL programming using this. I’ll address this in a future article. | **There is a newish product called platformIO that is a plugin for Visual Studio code, and there are some good tutorials for the LVGL programming using this. I’ll address this in a future article. | ||
Ligne 26: | Ligne 49: | ||
Here is what the back of my board looks like. On the left, you can see the USB-C connector in the middle and the old style USB connector towards the bottom.** | Here is what the back of my board looks like. On the left, you can see the USB-C connector in the middle and the old style USB connector towards the bottom.** | ||
+ | |||
+ | Il existe un relativement nouveau produit appelé platformIO qui est un plugin pour le code Visual Studio, et il y a quelques bons tutoriels pour la programmation LVGL en l' | ||
+ | |||
+ | Pour utiliser LVGL sur MicroPython, | ||
+ | |||
+ | Voici à quoi ressemble l' | ||
+ | |||
**Connectors | **Connectors | ||
Ligne 32: | Ligne 62: | ||
Using the (hopefully) included JST cable, the pins (looking from the display side of the board and the connector at the bottom) from left to right, are [in the table below].** | Using the (hopefully) included JST cable, the pins (looking from the display side of the board and the connector at the bottom) from left to right, are [in the table below].** | ||
+ | |||
+ | Connecteurs | ||
+ | |||
+ | Bien qu'il semble y avoir beaucoup de broches disponibles pour les capteurs et autres connexions, il n'y en a pas autant qu'on pourrait le penser. Le long du bas de la carte, au milieu, se trouve le slot MicroSD, et juste à droite de celui-ci se trouvent deux connecteurs JST qui semblent être conformes à la norme STEMMA Qwiic, mais ce n'est pas le cas. Ils mesurent 1,25 mm et les connecteurs Qwiic normaux sont juste un peu plus petits. Les deux cartes que j'ai achetées étaient équipées d'un connecteur à cet effet et la plupart des cartes que j'ai examinées semblent en être équipées également. Le connecteur CN1 (le plus proche de l' | ||
+ | |||
+ | En utilisant le câble JST (que j' | ||
+ | |||
**As I said, you can’t use the “normal” I2C pin assignment. You have to “roll your own”. Here is the MicroPython code, using an SI7021 Temp/ | **As I said, you can’t use the “normal” I2C pin assignment. You have to “roll your own”. Here is the MicroPython code, using an SI7021 Temp/ | ||
Ligne 42: | Ligne 79: | ||
If you want to use a DHT11 or DHT22, you can use this pinout as well. Here’s (above) a pinout for the DHT22. You only need to use three of the four pins.And the MicroPython code to support it…** | If you want to use a DHT11 or DHT22, you can use this pinout as well. Here’s (above) a pinout for the DHT22. You only need to use three of the four pins.And the MicroPython code to support it…** | ||
+ | |||
+ | Comme je l'ai dit, vous ne pouvez pas utiliser l' | ||
+ | |||
+ | i2c = SoftI2C(scl=Pin(27), | ||
+ | |||
+ | si7021 = SI7021(i2c) | ||
+ | |||
+ | Bien sûr, vous devez d' | ||
+ | |||
+ | Si vous voulez utiliser un DHT11 ou un DHT22, vous pouvez aussi utiliser ce brochage. Voici (ci-dessus) un brochage pour le DHT22. Vous n'avez besoin d' | ||
**# ========================= | **# ========================= | ||
Ligne 60: | Ligne 107: | ||
There are a couple of things here you need to be aware of. First, the red wire is NOT 3.3v, but a GPIO pin. Don’t try to use this to power your device. In addition, the yellow wire is the same GPIO pin as the blue wire on connector CN1. Why in the world they did this, I can not speculate. Just be aware that your best bet for using I2C devices… use CN1.** | There are a couple of things here you need to be aware of. First, the red wire is NOT 3.3v, but a GPIO pin. Don’t try to use this to power your device. In addition, the yellow wire is the same GPIO pin as the blue wire on connector CN1. Why in the world they did this, I can not speculate. Just be aware that your best bet for using I2C devices… use CN1.** | ||
+ | |||
+ | # ========================= | ||
+ | |||
+ | # initialize si7021 Temp & Humidity sensor | ||
+ | |||
+ | # ========================= | ||
+ | |||
+ | import dht | ||
+ | |||
+ | d = dht.DHT22(Pin(27)) | ||
+ | |||
+ | d.measure() | ||
+ | |||
+ | Bien sûr, vous ne pouvez pas utiliser le dispositif DHT en même temps qu'un capteur I2C sur CN1. | ||
+ | |||
+ | Si vous souhaitez utiliser le connecteur P3, voici son brochage (ci-dessous). | ||
+ | |||
+ | Il y a deux choses dont vous devez être conscient. Tout d' | ||
+ | |||
**One other connector you should be aware of is the P1 connector, which is next to the USB-C Data/power port. This is mostly to be used as a SERIAL port. From top to button the pins are shown above. | **One other connector you should be aware of is the P1 connector, which is next to the USB-C Data/power port. This is mostly to be used as a SERIAL port. From top to button the pins are shown above. | ||
Ligne 68: | Ligne 134: | ||
One of the other things I should tell you about is that the screen isn’t your “normal” RGB display. It uses color565. You can find more information, | One of the other things I should tell you about is that the screen isn’t your “normal” RGB display. It uses color565. You can find more information, | ||
+ | |||
+ | Un autre connecteur que vous devez connaître est le connecteur P1, qui se trouve à côté du port de données/ | ||
+ | |||
+ | Vous vous demandez peut-être pourquoi GPIO 01 et GPIO 03 sont marqués d'un point d' | ||
+ | |||
+ | LED RVB intégrée | ||
+ | |||
+ | Une des autres choses dont je dois vous parler est que l' | ||
+ | |||
**Drivers | **Drivers | ||
Ligne 83: | Ligne 158: | ||
The IO connectors P1, P3 and CN1 are 4 pin 1.25mm JST connectors. At least one is included with most CYD boards.** | The IO connectors P1, P3 and CN1 are 4 pin 1.25mm JST connectors. At least one is included with most CYD boards.** | ||
+ | |||
+ | Pilotes | ||
+ | |||
+ | Le meilleur endroit que j'ai trouvé pour obtenir des pilotes pour MicroPython est https:// | ||
+ | |||
+ | Comme je l'ai dit plus haut, les deux meilleurs pilotes (actuellement) se trouvent sur https:// | ||
+ | |||
+ | Notez que vous devez avoir les pilotes micropython-ili9341 pour pouvoir utiliser le pilote Micropython_CYD. Plus d' | ||
+ | |||
+ | Connecteurs JST | ||
+ | |||
+ | Le connecteur du haut-parleur (P4) nécessite un connecteur JST à 2 broches de 1,25 mm qui n'est généralement pas inclus. | ||
+ | |||
+ | Les connecteurs d'E/S P1, P3 et CN1 sont des connecteurs JST à 4 broches de 1,25 mm. Au moins un de ces connecteurs est inclus dans la plupart des cartes CYD. | ||
+ | |||
**Since these JST connectors are NOT the same as “normal” STEMMA QT/Qwiic JST connectors that you can easily find, I dug around on Amazon.com and found a couple of candidates.However, | **Since these JST connectors are NOT the same as “normal” STEMMA QT/Qwiic JST connectors that you can easily find, I dug around on Amazon.com and found a couple of candidates.However, | ||
Ligne 94: | Ligne 184: | ||
In case you want to “roll your own” connectors, there seems to be a DIY kit that contains 2, | In case you want to “roll your own” connectors, there seems to be a DIY kit that contains 2, | ||
https:// | https:// | ||
+ | |||
+ | Comme ces connecteurs JST ne sont pas les mêmes que les connecteurs JST STEMMA QT/Qwiic « normaux » que vous pouvez facilement trouver, j'ai cherché sur Amazon.com et j'ai trouvé quelques candidats. Je n'ai PAS vérifié qu'ils fonctionneront. | ||
+ | |||
+ | Pour le connecteur du HP (2 broches), vous pouvez essayer : | ||
+ | https:// | ||
+ | |||
+ | Pour les connecteurs IO (4 broches), vous pouvez essayer : | ||
+ | https:// | ||
+ | |||
+ | Au cas où vous voudriez « rouler vos propres » connecteurs, | ||
+ | https:// | ||
+ | |||
**MicroPython Coding | **MicroPython Coding | ||
Ligne 102: | Ligne 204: | ||
While you can use just the ili9341 drivers, there is a bit of a problem. This was designed to be a very generic low-level driver set, and can be used with any ili9341 display board, not just the one on the CYD board. The CYD driver set uses the ili9341 drivers and wraps all of the functions of the display driver, the touchscreen, | While you can use just the ili9341 drivers, there is a bit of a problem. This was designed to be a very generic low-level driver set, and can be used with any ili9341 display board, not just the one on the CYD board. The CYD driver set uses the ili9341 drivers and wraps all of the functions of the display driver, the touchscreen, | ||
+ | |||
+ | Codage en MicroPython | ||
+ | |||
+ | Vous devez avoir cydr.py, ili9341.py, xpt2046.py, et xglcd_font.py sur le périphérique CYD, et NORMALEMENT ils sont placés dans un dossier nommé lib. Vous pouvez les placer à la racine du périphérique, | ||
+ | |||
+ | Je vais maintenant vous expliquer pourquoi vous avez besoin des deux jeux de pilotes CYD et ili9341. | ||
+ | |||
+ | Bien que vous puissiez utiliser uniquement les pilotes ili9341, il y a un petit problème. Ce jeu de pilotes a été conçu pour être un jeu de pilotes de bas niveau très générique et peut être utilisé avec n' | ||
+ | |||
**The ili9341.py driver concentrates on the Display board and some generic RGB LED functions. There are two other drivers included, which are xpt2046.py which deals with the touchscreen functions and the xglcd_font.py which allows you to use some different fonts instead of a very simple 8x8 font. The ili9341.py driver includes things like drawing lines, rectangles, circles and drawing text. | **The ili9341.py driver concentrates on the Display board and some generic RGB LED functions. There are two other drivers included, which are xpt2046.py which deals with the touchscreen functions and the xglcd_font.py which allows you to use some different fonts instead of a very simple 8x8 font. The ili9341.py driver includes things like drawing lines, rectangles, circles and drawing text. | ||
Ligne 108: | Ligne 219: | ||
Another reason to use the CYD driver is that the ili9341 driver is so generic that the demo programs won’t run on the CYD because the SPI interface uses different pins that the generic interface provides by default. For example, the demos initialize the SPI interface like this (shown above).** | Another reason to use the CYD driver is that the ili9341 driver is so generic that the demo programs won’t run on the CYD because the SPI interface uses different pins that the generic interface provides by default. For example, the demos initialize the SPI interface like this (shown above).** | ||
+ | |||
+ | Le pilote ili9341.py se concentre sur la carte d' | ||
+ | |||
+ | Le pilote CYD importe le pilote d' | ||
+ | |||
+ | Une autre raison d' | ||
+ | |||
**You can see that, while the sck and mosi pins are the same between both drivers, the dc, cs and rst pins are all different. The CYD driver is already set up for this. | **You can see that, while the sck and mosi pins are the same between both drivers, the dc, cs and rst pins are all different. The CYD driver is already set up for this. | ||
Ligne 122: | Ligne 240: | ||
cyd.display.clear()** | cyd.display.clear()** | ||
+ | |||
+ | Vous pouvez voir que, alors que les broches sck et mosi sont les mêmes entre les deux pilotes, les broches dc, cs et rst sont toutes différentes. Le pilote CYD est déjà configuré pour cela. | ||
+ | |||
+ | L' | ||
+ | |||
+ | from cydr import CYD | ||
+ | |||
+ | cyd = CYD(rgb_pwm=False, | ||
+ | |||
+ | La plupart des paramètres de l' | ||
+ | |||
+ | Maintenant que nous avons instancié l' | ||
+ | |||
+ | cyd.display.clear() | ||
+ | |||
**To print text on the display is just as easy. | **To print text on the display is just as easy. | ||
Ligne 134: | Ligne 267: | ||
I’ve created a github repository at https:// | I’ve created a github repository at https:// | ||
+ | |||
+ | Il est tout aussi facile d' | ||
+ | |||
+ | text = « Ceci est un test ! » | ||
+ | |||
+ | cyd.display.draw_text8x8(xposition, | ||
+ | |||
+ | Dans la ligne d' | ||
+ | |||
+ | Dans ce mode, la position (0,0) se trouve dans le coin supérieur gauche de l' | ||
+ | |||
+ | J'ai créé un dépôt github à https:// | ||
+ | |||
**One of the demos that I’ve included is an app that uses the OpenWeatherMap API over a WIFI connection to get the current outside conditions of my location and a DHT22 Temp/ | **One of the demos that I’ve included is an app that uses the OpenWeatherMap API over a WIFI connection to get the current outside conditions of my location and a DHT22 Temp/ | ||
Ligne 140: | Ligne 286: | ||
Until next time, as always; stay safe, healthy, positive and creative!** | Until next time, as always; stay safe, healthy, positive and creative!** | ||
+ | |||
+ | L'une des démonstrations que j'ai incluses est une application qui utilise l'API OpenWeatherMap via une connexion WIFI pour obtenir les conditions extérieures actuelles de mon emplacement et un capteur DHT22 Temp/ | ||
+ | |||
+ | C'est tout pour ce mois-ci. Je suis certain que nous aborderons à nouveau la question de la CYD dans un prochain article. | ||
+ | |||
+ | Jusqu' | ||
+ | |||
+ | // Texte en noir, page 40, encadré du haut // | ||
+ | **BUT the CYD board has different pins for the SPI configuration.** | ||
+ | MAIS la carte CYD a des broches différentes pour la configuration SPI. |
issue209/micro-ci_micro-la.1727557057.txt.gz · Dernière modification : 2024/09/28 22:57 de d52fr