issue209:micro-ci_micro-la
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue209:micro-ci_micro-la [2024/09/28 18:19] – créée auntiee | issue209:micro-ci_micro-la [2024/10/01 15:43] (Version actuelle) – auntiee | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | + | **CYD (Cheap Yellow Display) ESP-32 | |
- | CYD (Cheap Yellow Display) ESP-32 | + | |
Greetings again fellow Sentient Lifeforms. Things here at landing pad 2997 on Terra STILL haven' | Greetings again fellow Sentient Lifeforms. Things here at landing pad 2997 on Terra STILL haven' | ||
Ligne 8: | Ligne 7: | ||
This is a really neat little board driven by an ESP32-WROOM with a ILI9341 320 x 240 screen attached. The screen is also a Resistive Touch screen, which makes it rather nice to hold a GUI or to become a Gaming board. | This is a really neat little board driven by an ESP32-WROOM with a ILI9341 320 x 240 screen attached. The screen is also a Resistive Touch screen, which makes it rather nice to hold a GUI or to become a Gaming board. | ||
- | 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”. | ||
+ | |||
+ | 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' | ||
- | 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”. | + | 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:// |
- | 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:// | ||
- | 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 |
https:// | https:// | ||
Ligne 20: | Ligne 35: | ||
The third way to program the board is to use one of the ESPHome. However, I haven’t taken the time yet to investigate this. | The third way to program the board is to use one of the ESPHome. However, I haven’t taken the time yet to investigate this. | ||
- | 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:// |
- | 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. | + | 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. | ||
To use LVGL on MicroPython, | To use LVGL on MicroPython, | ||
- | 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.** |
- | Connectors | + | 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 | ||
While it looks like there are many available pins for sensors and other connections, | While it looks like there are many available pins for sensors and other connections, | ||
- | 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/ |
i2c = SoftI2C(scl=Pin(27), | i2c = SoftI2C(scl=Pin(27), | ||
Ligne 42: | Ligne 78: | ||
Of course, you have to import the library first. This can be just about any I2C device as long as you get the pins defined correctly. | Of course, you have to import the library first. This can be just about any I2C device as long as you get the pins defined correctly. | ||
- | 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' | ||
+ | |||
+ | **# ========================= | ||
# initialize si7021 Temp & Humidity sensor | # initialize si7021 Temp & Humidity sensor | ||
Ligne 60: | Ligne 106: | ||
If you want to use the P3 connector, here (below) is a pinout of it. | If you want to use the P3 connector, here (below) is a pinout of it. | ||
- | 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.** |
- | 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. | + | # ========================= |
+ | |||
+ | # 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. | ||
You might wonder why GPIO 01 and GPIO 03 are marked with a trailing question mark. That’s the information I have and it’s included that way. I wouldn’t try to use these pins as GPIO pins at this point. More research needs to be done! | You might wonder why GPIO 01 and GPIO 03 are marked with a trailing question mark. That’s the information I have and it’s included that way. I wouldn’t try to use these pins as GPIO pins at this point. More research needs to be done! | ||
Ligne 68: | Ligne 133: | ||
Onboard RGB LED | Onboard RGB LED | ||
- | 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, |
- | Drivers | + | 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 | ||
The best place that I’ve found to get drivers for MicroPython is https:// | The best place that I’ve found to get drivers for MicroPython is https:// | ||
Ligne 83: | Ligne 157: | ||
The speaker connector (P4) requires a 2 pin 1.25mm JST connector which is not usually included. | The speaker connector (P4) requires a 2 pin 1.25mm JST connector which is not usually included. | ||
- | 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, |
For the Speaker connector (2 pin), you can try… | For the Speaker connector (2 pin), you can try… | ||
Ligne 94: | Ligne 183: | ||
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:// | ||
+ | |||
+ | 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:// | https:// | ||
- | MicroPython Coding | + | |
+ | **MicroPython Coding | ||
You need to have cydr.py, ili9341.py, xpt2046.py, and the xglcd_font.py on the CYD device, and NORMALLY they are put into a folder named lib. You CAN have them in the root of the device, but it’s standard practice to have them in the lib folder. | You need to have cydr.py, ili9341.py, xpt2046.py, and the xglcd_font.py on the CYD device, and NORMALLY they are put into a folder named lib. You CAN have them in the root of the device, but it’s standard practice to have them in the lib folder. | ||
Ligne 102: | Ligne 203: | ||
Now I’m going to tell you why you need both the CYD and the ili9341 driver sets. | Now I’m going to tell you why you need both the CYD and the ili9341 driver sets. | ||
- | 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, |
- | 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. | + | 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 CYD driver imports the display driver and touchscreen libraries for you, and provides a single interface to all of them that is (as I said above) MUCH easier to use. If you want to use the special fonts, you will have to import that yourself into your program. | The CYD driver imports the display driver and touchscreen libraries for you, and provides a single interface to all of them that is (as I said above) MUCH easier to use. If you want to use the special fonts, you will have to import that yourself into your program. | ||
- | 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. |
Using the CYD driver is really easy. First, you have to import the library, then initialize an object of the CDY master object. | Using the CYD driver is really easy. First, you have to import the library, then initialize an object of the CDY master object. | ||
Ligne 121: | Ligne 238: | ||
So, now that we have instantiated the CYD object and named it cyd, you can clear the display with a simple call like this… | So, now that we have instantiated the CYD object and named it cyd, you can clear the display with a simple call like this… | ||
+ | |||
+ | 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() | cyd.display.clear() | ||
- | To print text on the display is just as easy. | + | |
+ | **To print text on the display is just as easy. | ||
text = “This is a test!” | text = “This is a test!” | ||
Ligne 134: | Ligne 266: | ||
In this mode, position (0,0) is at the top-left corner of the display (when it is oriented with the USB plug on the right side of the device). | In this mode, position (0,0) is at the top-left corner of the display (when it is oriented with the USB plug on the right side of the device). | ||
- | I’ve created a github repository at https:// | + | I’ve created a github repository at 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/ | + | 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/ | ||
That’s it for this month. I’m certain that we will readdress the CYD in more than one future article. | That’s it for this month. I’m certain that we will readdress the CYD in more than one future article. | ||
- | 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.1727540348.txt.gz · Dernière modification : 2024/09/28 18:19 de auntiee