Bonjour à tous,

J'ai un petit soucis pour obtenir une liaison série en bluetooth avec mon Arduino Pro Mini.

J'utilise le module BT : HC-06

Je n'ai pas d'erreur mais une fenêtre vide.

Pour essayer de trouver l'erreur, j'ai testé avec ce script qui me permet bien d'obtenir une liaison série en bluetooth :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
int counter = 0;
     unsigned long time;
 
    void setup() {
        Serial.begin(9600); //Module bluetooth par défaut 9600, N, 8, 1
        pinMode(13, OUTPUT);   //Led 13 de témoin OK
    }
 
    void loop() {
        digitalWrite(13, HIGH);   // LED 13 ON
        delay(100);             
        digitalWrite(13, LOW);    // Off
 
        Serial.print("Test module HC-06 bluetooth ");
        Serial.print(++counter);
        Serial.print(" " );
        time = millis();
        Serial.println(time);
        delay(1000);  //Un envoi de données par seconde
    }
Dans ce cas j'ai bien les données qui s'affichent dans la fenêtre.


Mais, le problème survient lorsque je veux utiliser mon script qui est celui-ci:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
 
// include the library code:
#include <Keypad.h>
#include <Wire.h>
#include "RTClib.h"
 
//4x4 Matrix key pad
 
const byte ROWS = 4; // Four rows
const byte COLS = 3; // Four columns
 
// buzzer
const int buzzer = 10; //buzzer to arduino pin 9
 
//LED
const int greenPin = 11;
const int orangePin = 12;
const int redPin = 13;
 
 
// Define the Keymap
char keys[ROWS][COLS] = 
  {
 
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
 
  };
 
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to
byte rowPins[ROWS] = { 3, 14, 15, 5 };
 
// Connect keypad COL0, COL1, COL2 and COL3 to
byte colPins[COLS] = { 4, 2, 6 }; 
 
// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
 
int incomingByte = 0;   // for incoming serial data
 
 
RTC_DS3231 rtc;
 
void setup() 
{
#ifndef ESP8266
  while (!Serial); // for Leonardo/Micro/Zero
#endif
 
 
 
 
// ------- Broches LED en sorties numériques -------  
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(orangePin, OUTPUT);  
 
digitalWrite(greenPin,LOW);
digitalWrite(redPin,LOW);
digitalWrite(orangePin,LOW);
 
//buzzer
pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
 
Serial.begin(9600);
 
  delay(3000); // wait for console opening
 
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    digitalWrite(orangePin,HIGH);
    while (1);
  }
 
  if (rtc.lostPower()) {
    Serial.println("RTC lost power, lets set the time!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
 
}
 
void loop() 
{
DateTime now = rtc.now();
 
 
 
long int mastercode = a*b*c*e;
long int admincode = 000000;
    Serial.print("Date:");
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.println("\t");
    Serial.print("concat annee:");
 
    Serial.print(a);
    Serial.println("\t");
    Serial.print("concat heure:");
 
    Serial.print(h);
    Serial.println("\t");
 
Serial.print("master: ");
Serial.print(mastercode);
Serial.println("\t");
char enteredcode[10] ="";
char *eptr;
long result;
// read a 6 digit code (you can have any length)
for (int i = 0; i <=5; i++){
    char key = kpd.waitForKey();
    if(key == '#'){ // # is used to cancel
    i = 5; //skip to the end
    Serial.println("Cancelled"); // set the other reason why entry failed. You pressed # to cancel if you pressed a wrong number
 
    }
    if(key != NO_KEY){ // if you aren't reading no keypress
      Serial.print(key); // print a # to the LCD so people don't see the number but you know you pressed a button
      char str[2];   // converti char key en char key[2]  
        str[0]=key;
        str[1]='\0';
    tone(buzzer,2000); // Send 1KHz sound signal...
      delay(150);        // 1000 for 1 sec
      noTone(buzzer);     // Stop sound...
      strcat(enteredcode, str);//ajoute un digit à enteredcode.
    }
}
  result = strtol(enteredcode, &eptr, 10); //converti enteredcode en int
    Serial.println("\t");
    Serial.print("enteredcode: ");
    Serial.print(result);
    Serial.println("\t");
 
 
if (result == mastercode) //si code correct
   {
   delay(300);
   Serial.println("CODE CORRECT");
   Serial.println("\t");
   tone(buzzer,2000); // Send 1KHz sound signal...
   digitalWrite(greenPin,HIGH); // allume la couleur voulue
   delay(6000); // pause
   digitalWrite(greenPin,LOW); // éteint la couleur voulue
   noTone(buzzer);     // Stop sound...
   }
 
else if (result == admincode){   //admin code
    delay(300);
    Serial.println("CODE CORRECT");
    Serial.println("\t");
    tone(buzzer,2000); // Send 1KHz sound signal...
    digitalWrite(greenPin,HIGH); // allume la couleur voulue
    delay(3000); // pause
    noTone(buzzer);     // Stop sound...
    digitalWrite(greenPin,LOW); // éteint la couleur voulue
 
  }
 
  else {  // if the code is wrong or cancelled
    // tell the user what happened
    delay(100);
    Serial.println("CODE INCORRECT");
    digitalWrite(redPin,HIGH); // allume la couleur voulue
    tone(buzzer,400,100); // Send 1KHz sound signal...
    delay(110);
    tone(buzzer,400,100); // Send 1KHz sound signal...
    delay(110);
    tone(buzzer,400,100); // Send 1KHz sound signal...
    delay (300);
    digitalWrite(redPin,LOW); // éteint la couleur voulue
    delay (100); // wait 3 seconds before allowing a retry
    Serial.println("ENTER NEW CODE");
    Serial.print("\t");
 
  }
 
}
Je ne comprend pas pourquoi la liaison série BT ne m'affiche pas au moins ceci:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
Serial.print("Date:");
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
Je précise que ma liaison série filaire fonctionne parfaitement et que je débranche bien celle-ci lorsque j'utilise la liaison BT.



Pouvez-vous m'aider svp