start:arduino:esp32:spi:start
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 | ||
| start:arduino:esp32:spi:start [2022/11/15 04:50] – [Trouver les broches SPI par défaut de votre carte ESP32] gerardadmin | start:arduino:esp32:spi:start [2023/01/27 16:08] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 90: | Ligne 90: | ||
| </ | </ | ||
| - | Important : assurez-vous de sélectionner | + | Important : assurez-vous de sélectionner |
| Après avoir téléchargé le code, ouvrez le moniteur série, RST votre carte et vous verrez les broches SPI. | Après avoir téléchargé le code, ouvrez le moniteur série, RST votre carte et vous verrez les broches SPI. | ||
| {{ : | {{ : | ||
| + | |||
| + | |||
| + | ====Utilisation de broches ESP32 SPI personnalisées==== | ||
| + | |||
| + | Lorsque vous utilisez des bibliothèques pour vous interfacer avec vos périphériques SPI, il est généralement simple d' | ||
| + | |||
| + | Par exemple, jetez un coup d'œil à l' | ||
| + | |||
| + | |||
| + | <code c bibliothequeadafruitexempleOO1.ino> | ||
| + | |||
| + | |||
| + | /* | ||
| + | Rui Santos | ||
| + | Détails complets du projet sur https:// | ||
| + | Basé sur l' | ||
| + | |||
| + | Permission est accordée, sans frais, à toute personne obtenant une copie | ||
| + | de ce logiciel et des fichiers de documentation associés. | ||
| + | | ||
| + | L'avis de droit d' | ||
| + | des copies ou des parties substantielles du Logiciel. | ||
| + | */ | ||
| + | |||
| + | #comprendre | ||
| + | | ||
| + | #comprendre | ||
| + | | ||
| + | |||
| + | #comprendre | ||
| + | |||
| + | | ||
| + | |||
| + | #comprendre | ||
| + | | ||
| + | |||
| + | #define BME_SCK 25 | ||
| + | #define BME_MISO 32 | ||
| + | #define BME_MOSI 26 | ||
| + | #define BME_CS 33 | ||
| + | #define SEALEVELPRESSURE_HPA (1013.25) | ||
| + | |||
| + | // | ||
| + | // | ||
| + | Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // logiciel SPI | ||
| + | |||
| + | délai long non signé ; | ||
| + | |||
| + | void setup() { | ||
| + | Série.begin(9600); | ||
| + | Serial.println(F(" | ||
| + | |||
| + | état booléen ; | ||
| + | |||
| + | // paramètres par défaut | ||
| + | // (vous pouvez également passer un objet de bibliothèque Wire comme &Wire2) | ||
| + | status = bme.begin(); | ||
| + | si (!statut) { | ||
| + | Serial.println(" | ||
| + | tandis que (1); | ||
| + | } | ||
| + | |||
| + | Serial.println(" | ||
| + | delayTime = 1000 ; | ||
| + | |||
| + | Serial.println(); | ||
| + | } | ||
| + | |||
| + | |||
| + | boucle vide() { | ||
| + | printValeurs(); | ||
| + | retard(delayTime); | ||
| + | } | ||
| + | |||
| + | void printValues() { | ||
| + | Serial.print(" | ||
| + | Serial.print(bme.readTemperature()); | ||
| + | Serial.println(" | ||
| + | | ||
| + | // Convertir la température en Fahrenheit | ||
| + | / | ||
| + | Serial.print(1.8 * bme.readTemperature() + 32); | ||
| + | Serial.println(" | ||
| + | | ||
| + | Serial.print(" | ||
| + | Serial.print(bme.readPressure() / 100.0F); | ||
| + | Serial.println(" | ||
| + | |||
| + | Serial.print(" | ||
| + | Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); | ||
| + | Serial.println(" | ||
| + | |||
| + | Serial.print(" | ||
| + | Serial.print(bme.readHumidity()); | ||
| + | Serial.println(" | ||
| + | |||
| + | Serial.println(); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Vous pouvez facilement transmettre vos broches SPI personnalisées au constructeur de la bibliothèque. | ||
| + | | ||
| + | <code c biblio002.ino> | ||
| + | Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); | ||
| + | </ | ||
| + | |||
| + | Dans ce cas, j' | ||
| + | |||
| + | <code c biblio003.ino> | ||
| + | #define BME_SCK 25 | ||
| + | #define BME_MISO 32 | ||
| + | #define BME_MOSI 26 | ||
| + | #define BME_CS 33 | ||
| + | </ | ||
| + | |||
| + | Si vous n' | ||
| + | |||
| + | <code c bliblio004.ino> | ||
| + | SPI.begin(SCK, | ||
| + | </ | ||
| + | |||
| + | Vous pouvez voir un exemple de ce scénario dans ce tutoriel , dans lequel nous initialisons un émetteur-récepteur SPI LoRa qui est connecté à des broches SPI personnalisées. Ou cet exemple montrant comment utiliser des broches SPI personnalisées avec un module de carte microSD . | ||
| + | | ||
| + | ====== Liens web ====== | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | |||
| + | |||
/home/chanteri/www/fablab37110/data/attic/start/arduino/esp32/spi/start.1668484203.txt.gz · Dernière modification : (modification externe)
