Help receiving data from arduino

Guys, i need ur help , im working on rotary smart parking application and i want to receive some data (parking statust (6slots) and reservation code from arduino. I did the arduino code,

this is a part of it (communication with bluetooth):

void sendParkingStatus() {
  for(int i=0; i<6; i++) {
    // Replace BTSerial.write(places[i][1]); with
    BTSerial.print(places[i][1]);
    if (i < 5) {
      BTSerial.print(","); // separate with a comma
    }
  }

  BTSerial.println(); // send a newline character at the end

}
void loop()
....................................
.....................................
{
    if (BTSerial.available())
  {
  Serial.write(BTSerial.read());
}
// Keep reading from Arduino Serial Monitor and send to HC-06
    if (Serial.available())
 {
      BTSerial.write(Serial.read());
 }
    if (BTSerial.available())
{
  char c = BTSerial.read(); // Lire le caractère depuis le Bluetooth
 // Si l'application Android demande le statut des parkings
     if (c == 'S')
 {
    sendParkingStatus();
 }
 // Si l'application Android veut faire une réservation
   else if (c == 'R')
 {
 // Ici, nous supposons que l'application Android envoie 'R' suivi d'une séquence de 6 caractères
// qui représente l'identifiant pour la réservation. Ce code doit correspondre à celui généré
 // par la fonction get_new_id().
      String id = "";
      for (int i = 0; i < 6; i++) {
        while (!BTSerial.available()) {}
        id += (char)BTSerial.read()
      }
      store_id(id);
    }
  }
  }
  delay(100);
}
1 Like

Hello @AYMAN01,
beinvenu sur le forum.
Je vois par les commentaires dans ton Arduino code que tu parles français, néanmoins je vais te répondre en Englais de façon que tous les gens du forum puissent lire ton problème et te répondre (moi je suis Italien :slight_smile: ).

As far as I can see you don't have posted nothing about your AI2 blocks, so the question is : have you already coded some blocks or not ? In other words, if you have written an app and it does not work, please post your .aia file so we can give it a sight.
Otherwise, if you don't have written any code (AI2 blocks) my strong suggestion is to start by having a look to the huge amount of tutorials, guides, code snippets "ready to use" that you can find on :
@Juan_Antonio 's web site (KIO4.com), or @ChrisWard 's one (professorcad.co.uk).
You can also find ton's of BT mattter on @Taifun (puravidapps.com) together with many (free) extensions that you can consider a "must have" to make your app more efficient.
Therefore my suggestion is to start from having a look to those web sites and on this forum itself (i.e. FAQ by @ABG ) and, if you cannot get rid of your needs, never mind and post a more detailed question.
Best regards/meilleures salutations.

2 Likes