Ingo Lohs
Published © LGPL

Bluetooth HM-10 Module + PHPoC Blue/Black

A short introduction to use a BLE module with an PHPoC Blue/Black to control an LED via Serial.

BeginnerProtip30 minutes532
Bluetooth HM-10 Module + PHPoC Blue/Black

Things used in this project

Hardware components

PHPoC Blue
PHPoC Blue
×1
LED (generic)
LED (generic)
×1
Bluetooth HM-10
×1

Software apps and online services

PHPoC Debugger
PHPoC Debugger

Story

Read more

Code

Control your PHPoC Blue/Black with BLE HM-10

PHP
read serial to blink LED
<?php

// Mapping BLE HM-10 to P4S-34x
// GND <> GND
// VCC <> 3.3V
// RXD <> U0TX/4
// TXD <> U0RX/5

include_once "/lib/sd_340.php";
$rbuf = ""; // Var for reading data

uart_setup(0, 9600); // Configuring UART0 to 9600bps

echo "PHPoC Example : P4S-34X / UIO / bright LED on Port 13 and 2 internal LED via BLE Modul HM-10\r\n";

uio_setup(0, 13, "out low");
uio_setup(0, 30, "out low"); // internal LED30 on - why?
uio_setup(0, 31, "out low"); // internal LED31 on - why?

while(1)
{
uart_read(0, $rbuf); // Reading data from UART0 into $rbuf

if ($rbuf == "1") {
uio_out(0, 13, HIGH);
uio_out(0, 30, LOW); // yes, low to put internal LED30 bright
uio_out(0, 31, LOW); // yes, low to put internal LED31 bright
echo "LEDs bright\r\n";
} else if ($rbuf == "2") {
uio_out(0, 13, LOW);
uio_out(0, 30, HIGH);
uio_out(0, 31, HIGH);
echo "LEDs off\r\n";
} else {
echo "Command <$rbuf> not known\r\n";
}
}

?>

Credits

Ingo Lohs

Ingo Lohs

182 projects • 194 followers
I am well over 50 years and come from the middle of Germany.

Comments