The Arduino has been badly cut without a shield in its connectivity to the outside world and so I ventured on the subject of Bluetooth, using the BLE module HM-10 (ZS-040) with Chip CC2541 (3 Euro).
As it turned out later, the BLE module communicates via serial inputs and outputs, so that via smartphone apps ("ElegooBLE" or "Serial") the "code words" to which to respond via BLE module is transmitted to the Arduino and be interpreted.
In my example, I transmit "ein" to turn on the LED (the internal on 13, as well as a white external to A0 (long leg in A0, short leg in GND) and an "aus" for turning off the LEDs.
Wiring: VCC <> 5V or 3.3V, GND <> GND, RXD <> 11, TXD <> 10.
void loop() {
if (SerialBT.available()){ // Daten liegen an
msg = SerialBT.readString(); // Nachricht lesen
if (msg == "ein") {
digitalWrite(LED, HIGH);
digitalWrite(LED_ext, HIGH);
SerialBT.print("LED an Pin ");
SerialBT.print(LED);
SerialBT.println(" ist eingeschaltet!");
}
else
if (msg == "aus") {
digitalWrite(LED, LOW);
digitalWrite(LED_ext, LOW);
SerialBT.print("LED an Pin ");
SerialBT.print(LED);
SerialBT.println(" ist ausgeschaltet!");
}
else {
SerialBT.print("Kommando <");
SerialBT.print(msg);
SerialBT.println("> nicht bekannt");
}
}
}
For the German reader I recommend a further article from the Heise publishing house.
In my simulation, I've also tried different Arduino shields: as the ports of the Arduino are passed to the shields, it works right away with both the PHPoC Arduino shield (P4S-348) and the 1Sheeld + without the additional inclusion of their special ones Libraries.
Have you noticed that the BLE modules are wrapped in an extra protective film? I've never experienced that in any other sensor.
The use of Bluetooth allows control within a radius of a few meters (up to 10) around the location of the device, which opens up further fields of application.
Comments
Please log in or sign up to comment.