Here's how to use the raspberry to configure the Ibeacon:
1. The Connection. Connect the ibeacon module(HM10) to the UART/Serial port of the raspberry pi, see illustration below:
2. Raspberry Pi Set-up. The raspberry pi will still need to be set up because by default, the uart port serves as another gateway for controlling the computer remotely, so all bootup sequences and messages are being transmitted on the port, but all we need is to configure the uart port to configure the ibeacon so we will need to eliminate this unwanted data. Here is how to do it:
- Modify the file
/boot/cmdline.txt by removing console keyword related to the serial port. Typically the file looks like this: "
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 ....". Just remove the part in bold letters.
The next step is to modify the file
/etc/inittab by commenting the line "
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100". You could just add "#" at the beginning of the line.
Restart the raspberry pi
3. The Python Code. And finally we are ready to configure the ibeacon. I used the following python code to achieve this:
Just follow the rest of the configuration process as described below:import serial port = serial.Serial("/dev/ttyAMA0", baudrate=9600, timeout=3.0) while True: port.write("AT+RENEW") rcv = port.readline() print rcv rcv = "" port.write("AT+RESET") rcv = port.readline() print rcv rcv = "" ....
The ibeacon should respond to every command sent by the python program.
Presskr
ReplyDelete