issue178: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 | ||
issue178:micro-ci_micro-la [2022/02/26 10:09] – créée auntiee | issue178:micro-ci_micro-la [2022/03/02 11:23] (Version actuelle) – auntiee | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | It’s hard to believe that it’s been a year since I started this series of articles. It only seems right to go back to the beginning with the Raspberry Pi Pico and do something new with it, since we’ve spent so many months on the ESP series microcontrollers. | + | **It’s hard to believe that it’s been a year since I started this series of articles. It only seems right to go back to the beginning with the Raspberry Pi Pico and do something new with it, since we’ve spent so many months on the ESP series microcontrollers. |
This time, we will work with the RPi Pico and use a si7021 Temperature and Humidity sensor along with a ssd1306 OLED display. The wiring is basically the same as any RPi Pico with the ssd1306, but we’ll extend I2C to work with the si7021. I got my si7021 from Adafruit for less than $10 USD. https:// | This time, we will work with the RPi Pico and use a si7021 Temperature and Humidity sensor along with a ssd1306 OLED display. The wiring is basically the same as any RPi Pico with the ssd1306, but we’ll extend I2C to work with the si7021. I got my si7021 from Adafruit for less than $10 USD. https:// | ||
- | You can find a driver for the si7021 that I modified to work successfully on the RPi Pico at https:// | + | You can find a driver for the si7021 that I modified to work successfully on the RPi Pico at https:// |
- | Here is the wiring diagram: | + | Il est difficile de croire que cela fait un an depuis que j'ai commencé cette série d' |
+ | |||
+ | Cette fois-ci, nous allons travailler avec le RPi Pico et utiliser un capteur de température et d' | ||
+ | |||
+ | Vous pouvez trouver un pilote pour le si7021, que j'ai modifié pour qu'il fonctionne avec succès sur la RPi Pico, à https:// | ||
+ | |||
+ | |||
+ | **Here is the wiring diagram: | ||
I always run the i2cscan.py utility to verify my wiring and that all my I2C devices are working properly. When you run it, you should see a response of: | I always run the i2cscan.py utility to verify my wiring and that all my I2C devices are working properly. When you run it, you should see a response of: | ||
Ligne 23: | Ligne 30: | ||
oled.text(" | oled.text(" | ||
# Finally update the oled display so the text is displayed | # Finally update the oled display so the text is displayed | ||
+ | oled.show() | ||
+ | time.sleep(5)** | ||
+ | |||
+ | Voici le schéma de câblage : | ||
+ | |||
+ | Je lance toujours l' | ||
+ | |||
+ | 0x3c | ||
+ | 0x40 | ||
+ | |||
+ | Bien sûr, le 0x3c est l' | ||
+ | |||
+ | Maintenant, passons au code. J'ai pris le fichier de test si7021 que j'ai créé pour le pilote et je l'ai modifié pour supporter l' | ||
+ | |||
+ | Une fois que nous avons configuré tout le matériel, nous pouvons faire un petit test pour vérifier que l'OLED fonctionne. Nous allons dormir pendant 5 secondes pour pour que l' | ||
+ | |||
+ | oled.fill(0) | ||
+ | oled.show() | ||
+ | oled.text(" | ||
+ | oled.text(" | ||
+ | # Enfin, mettez à jour l' | ||
oled.show() | oled.show() | ||
time.sleep(5) | time.sleep(5) | ||
- | Now we need to start querying the si7021. The si7021 seems to be a bit odd: to get the proper temperature readings, you have to query the humidity first. It’s part of the chip firmware. We also use this time to get the dew point (not really needed, but why not?), the serial number, and revision. I’ve never gotten the revision to show correctly, but that’s ok, because the chip runs just fine. | + | |
+ | **Now we need to start querying the si7021. The si7021 seems to be a bit odd: to get the proper temperature readings, you have to query the humidity first. It’s part of the chip firmware. We also use this time to get the dew point (not really needed, but why not?), the serial number, and revision. I’ve never gotten the revision to show correctly, but that’s ok, because the chip runs just fine. | ||
+ | |||
+ | humidity = si7021.humidity() | ||
+ | temperature = si7021.temperature() | ||
+ | print(' | ||
+ | print(' | ||
+ | humidity = si7021.humidity() | ||
+ | print(' | ||
+ | dew_point = si7021.dew_point() | ||
+ | print(' | ||
+ | serial = si7021.serialnumber | ||
+ | print(serial) | ||
+ | revision = si7021.revision | ||
+ | print(revision)** | ||
+ | |||
+ | Maintenant, nous devons commencer à interroger le si7021. Le si7021 semble être un peu bizarre : pour obtenir des lectures de température correctes, vous devez d' | ||
humidity = si7021.humidity() | humidity = si7021.humidity() | ||
Ligne 41: | Ligne 85: | ||
print(revision) | print(revision) | ||
- | This is what should be displayed in the IDE REPL: | + | |
+ | **This is what should be displayed in the IDE REPL: | ||
Temperature: | Temperature: | ||
Ligne 52: | Ligne 97: | ||
Now we can finally get down to the business of reading and displaying the Temp/ | Now we can finally get down to the business of reading and displaying the Temp/ | ||
- | As you can see, we go into a “forever loop” and clear the display (oled.fill(0), | + | As you can see, we go into a “forever loop” and clear the display (oled.fill(0), |
- | I print to the REPL, then create two strings to send to the OLED, one for temperature that starts a column 5, row 5, and one for the humidity that shows at column 5, row 15. Again, we call the oled.show() method to push the data to the display, and sleep for 5 seconds. Feel free to change the sleep time up or down. | + | Voici ce qui devrait être affiché dans l'IDE REPL : |
+ | |||
+ | Temperature : 25.17976C | ||
+ | Temperature : 77.32357F | ||
+ | Humidity : 41.80579 | ||
+ | Dew Point : 11.29874 | ||
+ | bytearray(b' | ||
+ | b' ' | ||
+ | |||
+ | Nous pouvons enfin passer à la lecture et à l' | ||
+ | |||
+ | Comme vous pouvez le voir, nous entrons dans une « boucle infinie » et effaçons l' | ||
+ | |||
+ | |||
+ | **I print to the REPL, then create two strings to send to the OLED, one for temperature that starts a column 5, row 5, and one for the humidity that shows at column 5, row 15. Again, we call the oled.show() method to push the data to the display, and sleep for 5 seconds. Feel free to change the sleep time up or down. | ||
That’s it. An easy project for a good and solid Temp/ | That’s it. An easy project for a good and solid Temp/ | ||
Ligne 62: | Ligne 121: | ||
I’ve put the code, drivers and the wiring diagram on my repository at https:// | I’ve put the code, drivers and the wiring diagram on my repository at https:// | ||
- | Until next time, as always; stay safe, healthy, positive and creative! | + | Until next time, as always; stay safe, healthy, positive and creative!** |
+ | |||
+ | J' | ||
+ | |||
+ | C'est tout. Un projet facile pour un bon et solide capteur de température/ | ||
+ | |||
+ | Mon si7021 d' | ||
+ | |||
+ | J'ai mis le code, les pilotes et le schéma de câblage sur mon dépôt à https:// | ||
+ | |||
+ | Jusqu' |
issue178/micro-ci_micro-la.1645866564.txt.gz · Dernière modification : 2022/02/26 10:09 de auntiee