Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente |
materiels:afficheurs:ada1107 [2022/06/23 09:26] – [2.1 Un premier exemple pour tester l'afficheur] phil | materiels:afficheurs:ada1107 [2023/08/20 18:43] (Version actuelle) – [Adafruit 1,3" 128x64 OLED FeatherWing - SH1107 + 3 buttons (I2C)] phil |
---|
| |
===== Adafruit 1,3" 128x64 OLED FeatherWing - SH1107 + 3 buttons (I2C) ===== | ===== Adafruit 1,3" 128x64 OLED FeatherWing - SH1107 + 3 buttons (I2C) ===== |
[Mise à jour le 23/6/2022] | [Mise à jour le 18/8/2023] |
| |
{{ :materiels:afficheurs:langfr-330px-arduino_logo.svg.png?nolink&150|}} | {{ :materiels:afficheurs:langfr-330px-arduino_logo.svg.png?nolink&150|}} |
* **Ressources** | * **Ressources** |
* **Adafruit** <html><a href="https://learn.adafruit.com/adafruit-128x64-oled-featherwing/overview" target="_blank"><strong>1,3" 128x64 OLED FeatherWing - SH1107 + 3 buttons</strong></a></html> \\ | * **Adafruit** <html><a href="https://learn.adafruit.com/adafruit-128x64-oled-featherwing/overview" target="_blank">1,3" 128x64 OLED FeatherWing - SH1107 + 3 buttons</a></html> \\ |
* **Distribué** par <html><a href="https://www.mouser.fr/new/adafruit/adafruit-featherwing-128-64-oled/" target="_blank">Mouser</a></html> | * **Distribué** par <html><a href="https://www.mouser.fr/new/adafruit/adafruit-featherwing-128-64-oled/" target="_blank">Mouser</a></html> |
| |
* **Lectures connexes** | * **Lectures connexes** |
* <html><a href="https://webge.fr/dokuwiki/doku.php?id=materiels:afficheurs:graphique" target="_blank">Les afficheurs graphiques</a></html> | * <html><a href="https://webge.fr/dokuwiki/doku.php?id=materiels:afficheurs:graphique" target="_blank">Les afficheurs graphiques : généralités et primitives</a></html> |
* <html><a href="https://webge.fr/dokuwiki/doku.php?id=arduino:biblio:libgfx" target="_blank">Bibliothèque - Adafruit GFX Graphics Library</a></html> | * <html><a href="https://webge.fr/dokuwiki/doku.php?id=materiels:afficheurs:libgfx" target="_blank">Bibliothèque - Adafruit GFX Graphics Library</a></html> |
* <html><a href="https://webge.fr/dokuwiki/doku.php?id=materiels:afficheurs:ard0_96" target="_blank">0,96" 128x64 OLED 2864 Display module - SSD1306 (I2C)</a></html> | * <html><a href="https://webge.fr/dokuwiki/doku.php?id=materiels:afficheurs:ard0_96" target="_blank">0,96" 128x64 OLED 2864 Display module - SSD1306 (I2C)</a></html> |
* <html><a href="https://webge.fr/dokuwiki/doku.php?id=materiels:afficheurs:ard1_8shv2" target="_blank">Adafruit 1.8" 128x160 Color TFT LCD display with MicroSD Card v2 - ST7735R (SPI)</a></html> | * <html><a href="https://webge.fr/dokuwiki/doku.php?id=materiels:afficheurs:ard1_8shv2" target="_blank">Adafruit 1.8" 128x160 Color TFT LCD display with MicroSD Card v2 - ST7735R (SPI)</a></html> |
| |
==== 2. Exemples ==== | ==== 2. Exemples ==== |
=== 2.1 Un premier exemple pour tester l'afficheur === | === 2.1 Un premier exemple pour tester l'afficheur avec l'IDE Arduino === |
* **Description** : mesure de de la température, de l'humidité et de la pression à l'aide d'un capteur **Sparkfun BME280** et affichage sur un écran Oled **Adafruit SH1107**. L'écran et le capteur son reliés via le système <html><a href="https://www.sparkfun.com/qwiic#products" target=""><strong>Qwiic</strong></a></html> de Sparkfun. | * Fichier -> Exemples -> Adafruit SHT110X -> **OLED_featherwing.ino** |
| |
| === 2.2 Mise en oeuvre de l'afficheur avec un capteur BME280 === |
| * //Description// : mesure de de la température, de l'humidité et de la pression à l'aide d'un capteur **Sparkfun BME280**, test des boutons-poussoirs et affichage sur un écran Oled **Adafruit SH1107**. L'écran et le capteur sont reliés via le système <html><a href="https://www.sparkfun.com/qwiic#products" target=""><strong>Qwiic</strong></a></html> de Sparkfun. |
| |
{{ :materiels:afficheurs:bme280sh1107.jpg?nolink&600 |}} | {{ :materiels:afficheurs:bme280sh1107.jpg?nolink&600 |}} |
* **Matériels** | * //Matériels// |
* Carte à microcontrôleur : [[arduino:uc:esp8266|Adafruit Feather Huzzah ESP8266 + Support Particle]] | * Carte à microcontrôleur : [[arduino:uc:esp8266|Adafruit Feather Huzzah ESP8266 + Support Particle]] |
* Afficheur : Adafruit OLED SH1107 | * Afficheur : [[materiels:afficheurs:ada1107|Adafruit OLED SH1107]] |
* Capteur (température, humidité et pression) : [[materiels:capteurs:environnement:environnement|Sparkfun BME280]] | * Capteur (température, humidité et pression) : [[materiels:capteurs:environnement:environnement|Sparkfun BME280]] |
| |
* **Bibliothèques à installer dans l'IDE Arduino ou dans PlatformIO (VSCode)** | * //Bibliothèques à installer dans l'IDE Arduino ou dans PlatformIO (VSCode)// |
* Adafruit GFX Library by Adafruit | * Adafruit GFX Library by Adafruit <html><a href="https://github.com/adafruit/Adafruit-GFX-Library" target="_blank">[GitHub]</a></html> |
* Adafruit SH110X by Adafruit | * Adafruit SH110X by Adafruit <html><a href="https://github.com/adafruit/Adafruit_SH110X" target="_blank">[GitHub]</a></html> |
* SparkFun BME280 by SparkFun Electronics | * SparkFun BME280 by SparkFun Electronics <html><a href="https://github.com/sparkfun/SparkFun_BME280_Arduino_Library" target="_blank">[GitHub]</a></html> |
| |
{{ :arduino:arduino.png?nolink&50|}} | * //Code Arduino// |
* **Code Arduino** | {{ :materiels:capteurs:distance:arduinoico.png?nolink&50|}} |
<code cpp *.cpp> | <code cpp *.cpp> |
// Matériels : Adafruit Feather Huzzah ESP8266 + Support Particle, Adafruit OLED SH1107, Sparkfun BME280, câble Qwiic | // Matériels : Adafruit Feather Huzzah ESP8266 + Support Particle, Adafruit OLED SH1107, Sparkfun BME280, câble Qwiic |
// Constructeurs | // Constructeurs |
Adafruit_SH1107 display = Adafruit_SH1107(64, 128, &Wire); | Adafruit_SH1107 display = Adafruit_SH1107(64, 128, &Wire); |
BME280 mySensor; | BME280 bme_280; // L'adresse du circuit BME280 est 0x77 par défaut |
| |
void setup() | void setup() |
// Bus I2C | // Bus I2C |
Wire.begin(); // Initialisation | Wire.begin(); // Initialisation |
display.begin(0x3C, true); // Addresse de l'afficheur : 0x3C par défaut | Wire.setClock(400000); // Fast I2C |
| display.begin(0x3C, true); // L'addresse de l'afficheur est 0x3C par défaut |
| |
// Configuration de l'affichage | // Configuration de l'affichage |
display.setTextSize(1); // Horizontal | display.setTextSize(1); // Horizontal |
display.setTextColor(SH110X_WHITE); | display.setTextColor(SH110X_WHITE); |
display.clearDisplay(); // Pour ne pas afficher le logo Adafruit | display.clearDisplay(); // Pour ne pas afficher le logo Adafruit chargé |
| // automatiquement à la mise sous tension |
// Test de la communication avec le(s) capteur(s) | // Test de la communication avec le capteur |
if (mySensor.beginI2C() == false) | if (bme_280.beginI2C() == false) |
{ | { |
display.println("DEFAUT(s)"); | display.println("DEFAUT(s)"); |
display.print("1. Le capteur BME280 ne repond pas ! "); | display.println("1. Le capteur BME280 ne repond pas ! "); |
| display.println(); |
| display.print("BLOCAGE du PROGRAMME"); |
display.display(); // Transfert du buffer sur l'écran | display.display(); // Transfert du buffer sur l'écran |
while (1) | while (1) |
display.setCursor(0, 12); | display.setCursor(0, 12); |
display.print("Humidite : "); | display.print("Humidite : "); |
display.print(mySensor.readFloatHumidity(), 0); | display.print(bme_280.readFloatHumidity(), 0); |
display.println("%"); | display.println("%"); |
| |
display.setCursor(0, 22); | display.setCursor(0, 22); |
display.print("Pression : "); | display.print("Pression : "); |
display.print(mySensor.readFloatPressure() / 100, 0); | display.print(bme_280.readFloatPressure() / 100, 0); |
display.println("hPa"); | display.println("hPa"); |
| |
display.setCursor(0, 32); | display.setCursor(0, 32); |
display.print("Temp : "); | display.print("Temp : "); |
display.print(mySensor.readTempC(), 1); | display.print(bme_280.readTempC(), 1); |
display.print("degC"); | display.print("C"); |
| |
// Infos | // Infos |
display.print("Appuyer sur A, B, C"); | display.print("Appuyer sur A, B, C"); |
| |
| // yield(); |
display.display(); // Transfert du buffer sur l'écran | display.display(); // Transfert du buffer sur l'écran |
delay(10); | delay(10); |
| |
{{ :arduino:uc:platformioico.png?nolink&50|}} | {{ :arduino:uc:platformioico.png?nolink&50|}} |
<note tip><html><a href="https://webge.fr/doc/wikis/code/Arduino/ARD_PIO_8266_BME280_ADASH1107.zip" target="_blank">Télécharger</a></html> le projet PlatformIO pour VSCode.</note> | <callout type="tip" icon="true"><html><a href="https://webge.fr/doc/wikis/code/Arduino/ARD_PIO_ESP8266_OLED128x64_BME280.zip" target="_blank">Télécharger</a></html> le projet PlatformIO pour VSCode. |
| </callout> |