Hi,
I am pretty new to this but am experiencing the following problem:
• I have the bluno beetle wirelessly connected to a HM-10 Bluetooth module ,which is connected to an Arduino nano.
• I am sending a ‘1’ and a '0' through serial.write function from the beetle to the to the HM-10 in the main loop.
• The HM-10 acknowledges the receiving ‘1’ when the serial monitor of the bluno beetle is open or open then closed which turns on and off an LED.
But the main problem I am having is if I do not open the serial monitor to the Beetle when first connected it will not receive the ‘1’.
I hope this is clear as I am quite new to this and it is very hard to describe through text.
I can upload both sketches if needed.
Is the HM-10 receive code inside and if(Serial.available()) structure?
That is my best guess. I hate guessing. But if you post your code I won't have to guess. Read the forum guidelines to see how to properly post code and some information on how to get the most from this forum. Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
I will post both codes here. The nano rx LED lights up when the bluno tx's the '1' but only receives the '1' when I open the Serial monitor. The Diagram for the HM-10 is posted below (HM-10 not HC-05 , resistors are 1k and 2k for tx output).
No diagram needed for Bluno as BLE chip is surface mounted.
Couldn't find the tab for uploading code correctly
if (Serial.available() > 0) {
state = Serial.read();
}
// Controlling the LED
if (state == '1') {
digitalWrite(ledPin, HIGH); // LED ON
state = 0;
}
else if (state == '0') {
digitalWrite(ledPin, LOW); // LED ON
state = 0;
}
}
SoftwareSerial on the hardware serial pins is not correct. You don't appear to be using the monitor on the bluno side, so just use hardware serial for the HM10. Cross connect the rx and tx. Disconnect the leads when loading code on the Bluno.
Hi,
It does not make a difference when I use the Software.serial library or not, I have tried both. (Still only works when serial monitor is opened)
There is no tx and rx leads (they are not used) on the BLUNO as it is SMD chip.
I think that the usb/ttl converter on the Bluno Beetle is part of the CC2540 chip and its not clear to me how the serial port gets opened. Why Serial1.begin() does not allow communication from an external device through pins 0 and 1 is a mystery to me. Perhaps a question to DFRobot support is in order.