Outils pour utilisateurs

Outils du site


tel0026

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
Prochaine révisionLes deux révisions suivantes
tel0026 [2017/04/28 11:18] simontel0026 [2017/05/07 14:15] simon
Ligne 74: Ligne 74:
 </code> </code>
  
-=== Configuration de deux modules ===+=== Erreurs possibles === 
 +La page 16/23 du [[http://image.dfrobot.com/image/data/TEL0026/TEL0026_Datasheet.pdf|datasheet du TEL0026]] donne la liste des erreurs possibles. 
 +<code> 
 +Error_code (hex)  | Explanation 
 +------------------------------------------------------------------------ 
 +0                 | AT command error 
 +1                 | The result is default value 
 +2                 | PSKEY write error 
 +3                 | Device  name  is  too  long  (more  than  32 bytes)  
 +4                 | Device name is 0 byte 
 +5                 | Bluetooth address: NAP is too long 
 +6                 | Bluetooth address: UAP is too long 
 +7                 | Bluetooth address: LAP is too long 
 +8                 | PIO port mask length is 0 
 +9                 | Invalid PIO port 
 +A                 | Device class is 0 byte 
 +B                 | Device class is too long 
 +C                 | Inquire Access Code length is 0 
 +D                 | Inquire Access Code is too long 
 +E                 | Invalid Inquire Access Code 
 +F                 | Pairing password is 0 
 +10                | Pairing password is too long (more than 16 bytes)  
 +11                | Role of module is invalid 
 +12                | Baud rate is invalid 
 +13                | Stop bit is invalid 
 +14                | Parity bit is invalid 
 +15                | No device in the pairing list 
 +16                | SPP is not initialized 
 +17                | SPP is repeatedly initialized 
 +18                | Invalid inquiry mode 
 +19                | Inquiry timeout 
 +1A                | Address is 0 
 +1B                | Invalid security mode 
 +1C                | Invalid encryption mode 
 +</code> 
 + 
 +===== Configuration de deux modules =====
 Pour faire la configuration de ces deux modules en même temps, j'ai utilisé : Pour faire la configuration de ces deux modules en même temps, j'ai utilisé :
   * deux ordinateurs avec le logiciel arduino (mais n'importe quel programme de terminal série peut convenir)   * deux ordinateurs avec le logiciel arduino (mais n'importe quel programme de terminal série peut convenir)
Ligne 80: Ligne 116:
   * deux modules bluetooth (deux [[https://www.dfrobot.com/product-360.html|TEL0026 de DFRobot]] dans mon cas)   * deux modules bluetooth (deux [[https://www.dfrobot.com/product-360.html|TEL0026 de DFRobot]] dans mon cas)
  
- +==== Cosmo (slave) ====
- +
-== Cosmo (slave) ==+
 <code> <code>
 at at
Ligne 108: Ligne 142:
 at+cmode? at+cmode?
   +CMOD:0   +CMOD:0
 +at+inq
 +  OK
 +at+bind?
 +  +BIND:0:0:                   //pas d'adresse configurée
 +at+bind=98d3,32,20222e           //"bind" avec l'adresse du module master
 +  OK
 +at+state?
 +  +STATE:PAIRABLE
 </code> </code>
  
-== Commande (master) ==+==== Commande (master) ====
 <code> <code>
 at at
Ligne 150: Ligne 192:
 at+state? at+state?
   +STATE:PAIRED                  //yes!   +STATE:PAIRED                  //yes!
-at+mrad? +at+mrad?                         //voir le dernier module connecté 
-  +MRAD:98d3:32:302390 +  +MRAD:98d3:32:302390           //c'est bien le slave 
-at+fsad=98d3,32,302390 +at+fsad=98d3,32,302390           //voir si le module slave est dans la liste des modules authentifiés 
-  OK +  OK                             //OK = oui 
-at+link=98d3,32,302390+at+link=98d3,32,302390           //faire le lien avec le module slave
   OK   OK
   (réception de ce que le module slave envoit!)   (réception de ce que le module slave envoit!)
 </code> </code>
  
-=== Erreurs possibles === +==== Programmes Arduino ==== 
-La page 16/23 du [[http://image.dfrobot.com/image/data/TEL0026/TEL0026_Datasheet.pdf|datasheet du TEL0026]] donne la liste des erreurs possibles+Maintenant que nous avons configurés deux modules pour qu'ils se connectent ensemble, nous pouvons les utiliser chacun sur une Arduino et faire communiquer les deux Arduino ensemble.  
-<code> + 
-Error_code (hex)  Explanation +  * [[allumer une led via bluetooth]] 
------------------------------------------------------------------------- +  * [[Gestion de 3 leds via bluetooth]] 
-0                 | AT command error + 
-1                 The result is default value +=== Mise en place === 
-2                 | PSKEY write error +  * Arduino "master" :  
-3                 | Device  name  is  too  long  (more  than  32 bytes)  +    * Une [[https://www.dfrobot.com/product-786.html|Dreamer Nano V4.1]] avec un ATmega32u4. 
-4                 | Device name is 0 byte +    * Avec un [[https://www.dfrobot.com/product-68.html|shield]]. 
-5                 | Bluetooth address: NAP is too long +    * Sur lequel on met un [[https://www.dfrobot.com/product-360.html|TEL0026]] et un [[https://www.dfrobot.com/product-1098.html|bouton]] 
-6                 | Bluetooth address: UAP is too long + 
-7                 | Bluetooth address: LAP is too long +  * Arduino "slave"
-                | PIO port mask length is 0 +    * Une [[https://www.arduino.cc/en/Main/arduinoBoardMega2560|Arduino MEGA 2560]] 
-9                 | Invalid PIO port +    * Avec un [[https://www.dfrobot.com/product-560.html|shield]] 
-A                 | Device class is 0 byte +    * Sur lequel on met une [[https://www.dfrobot.com/product-490.html|LED]] et on connecte un TEL0026. 
-B                 | Device class is too long + 
-C                 | Inquire Access Code length is 0 +<WRAP center round important 60%> 
-D                 | Inquire Access Code is too long +**TODO:** Ajouter photos! 
-E                 | Invalid Inquire Access Code +</WRAP> 
-F                 | Pairing password is 0 + 
-10                | Pairing password is too long (more than 16 bytes)  +=== Programme "master" === 
-11                | Role of module is invalid +<code c> 
-12                | Baud rate is invalid +/* Minimal code for testing bluetooth module TEL0026 with a button 
-13                | Stop bit is invalid + 
-14                | Parity bit is invalid +This program must be used with "bluetooth-TEL0026-robot-avec-led.ino". 
-15                | No device in the pairing list + 
-16                | SPP is not initialized +The circuit is based on Dreamer Nano V4.1, compatible Arduino Leonardo ( https://www.dfrobot.com/product-786.html ). 
-17                | SPP is repeatedly initialized +TEL0026 and button are plugged on Nano I/O Shield https://www.dfrobot.com/product-68.html 
-18                | Invalid inquiry mode +  
-19                | Inquiry timeout +Created 2017 by Simon Lefort. 
-1A                | Address is 0 +*/ 
-1B                | Invalid security mode + 
-1C                | Invalid encryption mode+int buttonPin = 8; //button is on pin 8 
 + 
 +void setup() { 
 +  Serial.begin(38400);   // Serial to talk with computer via USB 
 +  Serial1.begin(38400);  // Serial to talk to bluetooth module TEL0026 
 +} 
 + 
 +void loop() { 
 +  int val = digitalRead(buttonPin); 
 +  delay(50); 
 +   
 +  if (val == HIGH) { 
 +    Serial1.print("b"); 
 +    //Serial.println("push"); 
 +  } 
 +  else 
 +   
 +    //Serial.println("no push"); 
 +  } 
 +}
 </code> </code>
 +
 +=== Programme "slave" ===
 +<code c>
 +/* Minimal code for testing bluetooth module TEL0026 with a led.
 +If we received "b1" by the bluetooth module, we light on the led.
 +
 +This program must be used with "bluetooth-TEL0026-commande-avec-bouton.ino".
 +
 +The circuit is based on Dreamer Nano V4.1, compatible Arduino Leonardo ( https://www.dfrobot.com/product-786.html ).
 +TEL0026 and button are plugged on Nano I/O Shield ( https://www.dfrobot.com/product-68.html )
 + 
 +Created 2017 by Simon Lefort.
 +*/
 +
 +int ledPin = 14;
 +int incomingByte = 0;
 +
 +void setup() {
 +  Serial.begin(38400);  //communicate via USB
 +  Serial1.begin(38400); //communicate via Bluetooth
 +  
 +  digitalWrite(ledPin, LOW);
 +}
 +
 +void loop() {
 +  if (Serial1.available() > 0){
 +    incomingByte = Serial1.read();
 +  
 +    Serial.print("I received: ");
 +    Serial.println(incomingByte);
 +    
 +    if (incomingByte = 'b'){
 +      digitalWrite(ledPin, HIGH);
 +      delay(500);
 +    }
 +  }
 +  else{
 +    Serial.println("nothing...");
 +    digitalWrite(ledPin, LOW);
 +    delay(500);
 +  }
 +}
 +</code>
 +
 +=== Remarques ===
 +Ça marche mais j'ai des soucis si je laisse le bouton appuyé. Ça envoie une série de caractères et le "slave" met un certain temps à la traiter. Il faut que je regarde comment améliorer ça très prochainement.
 +
  
 ===== Sources ===== ===== Sources =====
tel0026.txt · Dernière modification : 2020/08/09 13:03 de 127.0.0.1