Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révisionLes deux révisions suivantes |
materiels:capteurs:distance:distus [2024/05/03 11:52] – [2.3 HC-SR04P (GPIO - I2C - UART)] phil | materiels:capteurs:distance:distus [2024/05/18 12:09] – [2.3 HC-SR04P (GPIO - I2C - UART)] phil |
---|
| |
== 2.1.1 Présentation == | == 2.1.1 Présentation == |
* //**Source**// : <html><a href="https://www.gotronic.fr/pj2-hc-sr04-utilisation-avec-picaxe-1343.pdf" target="_blank">ici</a></html> | * //**Source**// : <html><a href="https://www.gotronic.fr/pj2-hc-sr04-utilisation-avec-picaxe-1343.pdf" target="_blank">pdf</a></html> |
| |
<callout type="info" icon="true">Ce module permet d’évaluer les distances entre un objet mobile et les obstacles rencontrés. Il suffit d'envoyer une impulsion de 10 µs en entrée et le capteur renvoie une largeur d'impulsion proportionnelle à la distance.</callout> | <callout type="info" icon="true">Ce module permet d’évaluer les distances entre un objet mobile et les obstacles rencontrés. Il suffit d'envoyer une impulsion de 10 µs en entrée et le capteur renvoie une largeur d'impulsion proportionnelle à la distance.</callout> |
} | } |
</code> | </code> |
| |
| |
{{ :arduino:uc:platformioico.png?nolink&50|}} | {{ :arduino:uc:platformioico.png?nolink&50|}} |
| |
| |
=== 2.2 Module VMA306 à capteur HC-SR05 === | === 2.2 HC-SR05 (GPIO) === |
{{ :materiels:capteurs:hc-scr05.png?nolink&150|VMA306}} | {{ :materiels:capteurs:hc-scr05.png?nolink&150|VMA306}} |
| |
| == 2.2.1 Présentation == |
* //**Source**// : <html><a href="https://www.velleman.eu/downloads/29/vma306_a4v01.pdf" target="_blank">pdf</a></html> | * //**Source**// : <html><a href="https://www.velleman.eu/downloads/29/vma306_a4v01.pdf" target="_blank">pdf</a></html> |
| |
* //Connexion à un shield// <html><a href="https://webge.fr/doc/wikis/pdf/TinkerkitV2.pdf" target="_blank">Tinkerkit v2</a></html>. {{ :materiels:capteurs:hcsr05.jpg?nolink&600 |}} | * //Connexion à un shield// <html><a href="https://webge.fr/doc/wikis/pdf/TinkerkitV2.pdf" target="_blank">Tinkerkit v2</a></html>. {{ :materiels:capteurs:hcsr05.jpg?nolink&600 |}} |
* // Un premier exemple // {{ :materiels:capteurs:distance:arduinoico.png?nolink&30|}} | * // Un premier exemple // {{ :materiels:capteurs:distance:arduinoico.png?nolink&30|}} |
<file cpp HCSR05.cpp> | <code cpp HCSR05.cpp> |
/////////////////////////////////////////////// | /////////////////////////////////////////////// |
// Programme test pour capteur HC-SR05 // | // Programme test pour capteur HC-SR05 // |
// Go Tronic 2017 // | // Go Tronic 2017 // |
/////////////////////////////////////////////// | /////////////////////////////////////////////// |
#define trigPin 10 // Tinkerkit O1 | #define trigPin 10 // Tinkerkit O1 |
delay(500); // délai entre deux mesures | delay(500); // délai entre deux mesures |
} | } |
</file> | </code> |
| |
| |
| |
=== 2.3 HC-SR04P (GPIO - I2C - UART) === | === 2.3 HC-SR04P (GPIO - I2C - UART) === |
{{ :materiels:capteurs:hc-scr05.png?nolink&150|VMA306}} | {{ :materiels:capteurs:distance:hc-sr04p.png?nolink&150|JOY-IT HC-SR04P}} |
| |
== 2.3.1 Présentation == | == 2.3.1 Présentation == |
| |
* //**Caractéristiques**// | * //**Caractéristiques**// |
* Capteurs: HC-SR04 | * Capteurs: <html><a href="https://www.gotronic.fr/pj2-hc-sr04-utilisation-avec-picaxe-1343.pdf" target="_blank" title="pdf">HC-SR04</a></html> |
* Tension d'alimentation: 3 Vcc à 5,5 Vcc | * Tension d'alimentation: 3 Vcc à 5,5 Vcc |
* Interface: GPIO / UART / I2C (**SLA** = **0x57**) | * Interface: GPIO / UART / I2C (**SLA** = **0x57**) |
* Connecteur mâle 4 broches coudé pré-soudé (pas 2,54 mm): Vcc/Trig/Echo/GND | * Connecteur mâle 4 broches coudé pré-soudé (pas 2,54 mm): Vcc/Trig/Echo/GND |
* Dimensions: 45,5 x 20,3 x 15,5 mm | * Dimensions: 45,5 x 20,3 x 15,5 mm |
| |
| * //**Configuration**// de M1 et M2 sur le CI (1 : R10k à ajouter) \\ **M1 M2** \\ 0 0 : GPIO \\ 1 0 : I2C \\ 1 1 : 1-wire \\ 0 1 : UART \\ |
| |
{{ :materiels:capteurs:acrobate.gif?nolink&30|}} | {{ :materiels:capteurs:acrobate.gif?nolink&30|}} |
* //**Documentation**// | * //**Documentation**// |
* Fichier Acrobat Reader à télécharger <html><a href="https://www.gotronic.fr/pj2-hc-sr04-utilisation-avec-picaxe-1343.pdf" target="_blank">ici</a></html> | * Fichier Acrobat Reader à télécharger <html><a href="https://webge.fr/doc/projets/datasheets/SEN-US01.pdf" target="_blank">ici</a></html> |
| |
| \\ |
| |
| {{ :materiels:capteurs:environnement:code.png?nolink|}} |
== 2.3.2 Exemples de code == | == 2.3.2 Exemples de code == |
<tabs> | <tabs> |
duration = pulseIn(echo, HIGH); | duration = pulseIn(echo, HIGH); |
distance = duration * 340 / 2 / 10000; | distance = duration * 340 / 2 / 10000; |
if (distance < 2 || distance > 450) { // On vérifie si la valeur mesurée se situe dans l'intervalle prévu | Serial.println("distance: " + String(distance) + " cm"); // Affichage dans la console |
Serial.println("Distance en dehors de l'intervalle de mesure"); | |
} else { | |
Serial.println("distance: " + String(distance) + " cm"); // Affichage dans la console | |
} | |
delay(3000); // Attente entre 2 mesures | delay(3000); // Attente entre 2 mesures |
} | } |
| |
<pane id="tab-hcsr04pduinoi2c_1"> | <pane id="tab-hcsr04pduinoi2c_1"> |
* //**Ressource**// <html><a href="" target="_blank">????</a></html> | * //**Ressource**// : <html><a href="https://www.arduino.cc/reference/en/language/functions/communication/wire/" target="_blank">Wire</a></html> |
| |
* //**Exemple** utilisant l'**I2C** pour tester le capteur// | * //**Exemple** utilisant l'**I2C** pour tester le capteur// |
| |
<pane id="tab-hcsr04pduinouart_1"> | <pane id="tab-hcsr04pduinouart_1"> |
* //**Ressource**// <html><a href="" target="_blank">????</a></html> | * //**Ressource**// : <html><a href="https://docs.arduino.cc/learn/built-in-libraries/software-serial/" target="_blank">SoftwareSerial Library</a></html> |
| |
* //**Exemple** utilisant l'**UART** pour tester le capteur// | * //**Exemple** utilisant l'**UART** pour tester le capteur// |
</pane> | </pane> |
| |
<pane id="tab-hcsr04ppico_1"> | <pane id="tab-hcsr04pico_1"> |
A venir | A venir |
</pane> | </pane> |
</tabs> | </tabs> |
| |