tel0026
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édenteProchaine révisionLes deux révisions suivantes | ||
tel0026 [2017/04/20 09:36] – [Commandes AT] simon | tel0026 [2017/05/07 14:15] – simon | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== Bluetooth 2.0 Module V3 For Arduino ====== | ====== Bluetooth 2.0 Module V3 For Arduino ====== | ||
- | Le [[https:// | + | Le [[https:// |
===== Initialisation ===== | ===== Initialisation ===== | ||
- | Le [[https:// | + | Le [[https:// |
- | ==== Prérequis ==== | + | ==== Prérequis |
* Un [[https:// | * Un [[https:// | ||
* Un terminal série ( le logiciel arduino, minicom, ... ) | * Un terminal série ( le logiciel arduino, minicom, ... ) | ||
Ligne 17: | Ligne 17: | ||
==== Commandes AT ==== | ==== Commandes AT ==== | ||
+ | === Listes des commandes AT === | ||
+ | Toutes les commandes se trouvent dans la [[http:// | ||
< | < | ||
- | * Input: | + | at |
- | * Return: | + | OK |
+ | |||
+ | at+init | ||
+ | | ||
- | * Input: | + | at+name? |
- | * Return: | + | +NAME: |
+ | OK | ||
- | * Input: | + | at+name=cequonveut |
- | * Return: | + | OK |
- | * Input: | + | at+role? //demander le rôle du module |
- | * Return:+name: cequonveut | + | +role:0 // 0 = slave , 1 = master |
+ | | ||
- | * Input: | + | at+role=0 //donner le rôle " |
- | * Return: +role: | + | OK |
- | * Input: at+role=0 | + | AT+PSWD? //Demander le mot de passe de " |
- | * Return: OK | + | +PSWD:1234 |
+ | | ||
- | * Input: | + | AT+ORGL // |
- | * Return: +PSWD: | + | OK |
- | * Input: | + | AT+UART? //Demander les paramètres de l'UART |
- | * Return: OK | + | +UART:38400,0,0 |
- | * Input: | + | AT+UART=38400, |
- | * +UART: | + | OK //Param1: baud rate (bits/s) 4800/ 9600/ 19200/ |
+ | //Param2: stop bit , 0- 1 bit/ 1- 2 bits | ||
+ | //Param3: parity bit, 0- None/ 1- Odd/ 2- Even | ||
- | * Input: | + | AT+RESET //reset du module |
- | * Return: OK | + | |
- | Param1: baud rate (bits/s) 4800/ 9600/ 19200/ 38400/ 57600/ 115200/ 230400/ 460800/ 912600/ 1382400 | + | |
- | | + | |
- | Param3: parity bit, 0- None/ 1- Odd/ 2- Even | + | |
- | * Input: | + | AT+ADDR? //demander l' |
- | * Return: OK | + | +ADDR:12d5: |
+ | | ||
- | * Input: | + | AT+INQM=1, |
- | * Return: +ADDR: | + | * OK |
- | * Input: | + | AT+IAC? |
- | * Return: | + | +IAC: |
+ | | ||
- | * Input: AT+SENM? | + | Input: AT+SENM? |
- | * Return: | + | +SENM: |
+ | | ||
+ | </ | ||
+ | === Erreurs possibles === | ||
+ | La page 16/23 du [[http:// | ||
+ | < | ||
+ | Error_code (hex) | Explanation | ||
+ | ------------------------------------------------------------------------ | ||
+ | 0 | AT command error | ||
+ | 1 | The result is default value | ||
+ | 2 | PSKEY write error | ||
+ | 3 | Device | ||
+ | 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 | ||
+ | </ | ||
+ | ===== Configuration de deux modules ===== | ||
+ | Pour faire la configuration de ces deux modules en même temps, j'ai utilisé : | ||
+ | * deux ordinateurs avec le logiciel arduino (mais n' | ||
+ | * deux adaptateurs USB to TTL (exemples : [[https:// | ||
+ | * deux modules bluetooth (deux [[https:// | ||
+ | |||
+ | ==== Cosmo (slave) ==== | ||
+ | < | ||
+ | at | ||
+ | OK | ||
+ | at+init | ||
+ | OK | ||
+ | at+state? | ||
+ | +STATE: | ||
+ | at+name=cosmo | ||
+ | OK | ||
+ | at+name? | ||
+ | +NAME:cosmo | ||
+ | at+role=0 | ||
+ | OK | ||
+ | at+role? | ||
+ | +ROLE:0 | ||
+ | at+addr? | ||
+ | +ADDR: | ||
+ | at+uart=38400, | ||
+ | OK | ||
+ | at+uart? | ||
+ | +UART: | ||
+ | at+iac? | ||
+ | +IAC:9e8b33 | ||
+ | at+cmode? | ||
+ | +CMOD:0 | ||
+ | at+inq | ||
+ | OK | ||
+ | at+bind? | ||
+ | +BIND: | ||
+ | at+bind=98d3, | ||
+ | OK | ||
+ | at+state? | ||
+ | +STATE: | ||
</ | </ | ||
+ | |||
+ | ==== Commande (master) ==== | ||
+ | < | ||
+ | at | ||
+ | OK | ||
+ | at+init | ||
+ | OK | ||
+ | at+state? | ||
+ | +STATE: | ||
+ | at+name=commande | ||
+ | OK | ||
+ | at+name? | ||
+ | +NAME: | ||
+ | at+role=1 | ||
+ | OK | ||
+ | at+role? | ||
+ | +ROLE:1 | ||
+ | at+addr? | ||
+ | +ADDR: | ||
+ | at+uart=38400, | ||
+ | OK | ||
+ | at+uart? | ||
+ | +UART: | ||
+ | at+iac? | ||
+ | +IAC:9e8b33 | ||
+ | at+cmode? | ||
+ | +CMOD:0 | ||
+ | at+inq | ||
+ | +INQ: | ||
+ | at+rname? | ||
+ | +RNAME: | ||
+ | at+bind? | ||
+ | +BIND: | ||
+ | at+bind=98d3, | ||
+ | OK | ||
+ | at+bind? | ||
+ | +BIND: | ||
+ | at+pair=98d3, | ||
+ | OK | ||
+ | at+state? | ||
+ | +STATE: | ||
+ | at+mrad? | ||
+ | +MRAD: | ||
+ | at+fsad=98d3, | ||
+ | OK //OK = oui | ||
+ | at+link=98d3, | ||
+ | OK | ||
+ | (réception de ce que le module slave envoit!) | ||
+ | </ | ||
+ | |||
+ | ==== Programmes Arduino ==== | ||
+ | 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. | ||
+ | |||
+ | * [[allumer une led via bluetooth]] | ||
+ | * [[Gestion de 3 leds via bluetooth]] | ||
+ | |||
+ | === Mise en place === | ||
+ | * Arduino " | ||
+ | * Une [[https:// | ||
+ | * Avec un [[https:// | ||
+ | * Sur lequel on met un [[https:// | ||
+ | |||
+ | * Arduino " | ||
+ | * Une [[https:// | ||
+ | * Avec un [[https:// | ||
+ | * Sur lequel on met une [[https:// | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **TODO:** Ajouter photos! | ||
+ | </ | ||
+ | |||
+ | === Programme " | ||
+ | <code c> | ||
+ | /* Minimal code for testing bluetooth module TEL0026 with a button | ||
+ | |||
+ | This program must be used with " | ||
+ | |||
+ | The circuit is based on Dreamer Nano V4.1, compatible Arduino Leonardo ( https:// | ||
+ | TEL0026 and button are plugged on Nano I/O Shield ( https:// | ||
+ | |||
+ | Created 2017 by Simon Lefort. | ||
+ | */ | ||
+ | |||
+ | int buttonPin = 8; //button is on pin 8 | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(38400); | ||
+ | Serial1.begin(38400); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | int val = digitalRead(buttonPin); | ||
+ | delay(50); | ||
+ | | ||
+ | if (val == HIGH) { | ||
+ | Serial1.print(" | ||
+ | // | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | // | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Programme " | ||
+ | <code c> | ||
+ | /* Minimal code for testing bluetooth module TEL0026 with a led. | ||
+ | If we received " | ||
+ | |||
+ | This program must be used with " | ||
+ | |||
+ | The circuit is based on Dreamer Nano V4.1, compatible Arduino Leonardo ( https:// | ||
+ | TEL0026 and button are plugged on Nano I/O Shield ( https:// | ||
+ | |||
+ | Created 2017 by Simon Lefort. | ||
+ | */ | ||
+ | |||
+ | int ledPin = 14; | ||
+ | int incomingByte = 0; | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(38400); | ||
+ | Serial1.begin(38400); | ||
+ | | ||
+ | digitalWrite(ledPin, | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | if (Serial1.available() > 0){ | ||
+ | incomingByte = Serial1.read(); | ||
+ | | ||
+ | Serial.print(" | ||
+ | Serial.println(incomingByte); | ||
+ | | ||
+ | if (incomingByte = ' | ||
+ | digitalWrite(ledPin, | ||
+ | delay(500); | ||
+ | } | ||
+ | } | ||
+ | else{ | ||
+ | Serial.println(" | ||
+ | digitalWrite(ledPin, | ||
+ | delay(500); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Remarques === | ||
+ | Ça marche mais j'ai des soucis si je laisse le bouton appuyé. Ça envoie une série de caractères et le " | ||
+ | |||
===== Sources ===== | ===== Sources ===== | ||
+ | * [[https:// | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// |
tel0026.txt · Dernière modification : 2020/08/09 13:03 de 127.0.0.1