Hello,
I have got a problem with my project and I have been breaking my head for the past 2 days and I cannot figure out a way of achieving what I am after.
I am using a Beetle BLE(Atmega 328). It has integrated BLE which communicates via Serial.
What I want to do, is be able to turn a Buzzer on an off from my phone via BLE. Since I want to have it battery powered the following would not be ideal:
void loop{
if (Serial.available() > 0){
// turn on or off depending on Serial.read()
}
}
So I thought instead of polling I might use Interrupts to have the arduino sleeping, and woken up by incoming Serial Data.
However, I cannot use:
ISR(USART_RX_vect)
{
...
}
(Because HardwareSerial.cpp already has that vector in use?)
So firstly is there any way i can use this Interrupt?
And if not, secondly I have read about a library called NeoHWSerial in this forum. It basically lets you execute custom functions during the Serial ISR which is used internally by the Serial algorithm.
So I have tried the following:
volatile const uint8_t ping = 255;
volatile const uint8_t mute = 0;
static void checkMatch(uint8_t c){
if (c == ping) digitalWrite(BUZZER,HIGH);
else if (c == mute) digitalWrite(BUZZER,LOW);
}
void loop() {}
void setup(){
NeoSerial.attachInterrupt( checkMatch );
NeoSerial.begin( 9600 ); // Instead of 'Serial1'
...
}
However it does not seem to recognise the desired inputs. Actually it does not seem to recognise any Input, I have tried the following function attached as an Interrupt aswell, which is supossed to let an LED blink whenever it receives just any character, but the LED never lit up.
static void blink(uint8_t c){
digitalWrite(BUZZER,HIGH);
delay(3000);
digitalWrite(BUZZER,LOW);
}
void setup() {
cli(); // disable interrupts during setup
NeoSerial.attachInterrupt( blink );
NeoSerial.begin( 9600 ); // Instead of 'Serial1'
...
}
I am using the App LightBlue on my App in which I can write all kinds of different values with, however none of them triggered the function and made the LED blink.
I am looking forward to your replies. If you have got any other idea on how I can achieve my goal of my Beetle BLE sleeping all the time (the BLE is always on) and only ever getting waked up when receiving a Signal from my phone, processing that Signal and going back to sleep again.






