BLE HM-11: can send but not read

wireless communication and related Bees.

Moderators: lily.li, violet, jessie

Post Reply
fstengel.vpc
Pre-kindergarten
Pre-kindergarten
Posts: 2
Joined: Sat Jan 03, 2015 2:52 am

BLE HM-11: can send but not read

Post by fstengel.vpc » Mon Sep 14, 2015 11:33 pm

Hello,

I am trying too use a BLE Bee (HM-11 module) to talk to my stalker v2.3.

To see if I understood things well I connected the bee to the UartSBee, the UartSBee via usb to my computer. I then fired up a terminal emulator (coolTerm) to talk to the bee via USB and LightBlue to connect to the Bee using BLE. Typing text in the terminal resulted in that text being sent via the proper service/characteristic to LightBlue and sending text via bluetooth resulted in text being printed in the terminal via USB. So, as far as I know using BLE I can talk to the bee and it talks to me.


So then comes the test on the stalker. I program the stalker, disconnect, plug the bee, restart the stalker and try to understand what happens. The following program should alternatively send '0' or '1' repeatedly to the computer which it does and echo any character received by bluetooth... The problem is : the computer recieves the '0's and '1's, but, nothing I send is being seen by the stalker. It is as if Serial.available() is always false...

Code: Select all

/*
Test program
*/
int state = 0;

 void setup()
{
  pinMode(13, OUTPUT); 
  digitalWrite(13, LOW);  
  Serial.begin(9600);
}

void loop()
{
  switch (state) {
    case 0:
      state = 1;
      Serial.print('0');
      break;
    case 1:
      state = 0;
      Serial.print('1');
      break;
    default:
      break;
  }
  if (Serial.available()) {
    digitalWrite(13, HIGH);
    char chr=Serial.read();
    Serial.print(chr);
    state = 2;
  }
  delay(500);
}

Post Reply