Starting with Raspberry Pi Bluetooth & Python

March 25, 2020

I recently started doing a small fun project with a RPi and a BT enable remote controlled car. (Dagu Racer 1) when I hit some problems with writing Python code to connect to the RPi’s BT.

After some web browsing and a bit of trial and error I found the following application updates and library installs got things working.


sudo apt-get update
sudo apt-get install bluetooth bluez libbluetooth-dev
sudo python3 -m pip install pybluez

For the Python code


import bluetooth

# Bluetooth stuff
bd_addr = “20:13:05:30:01:14”
port = 1
sock = bluetooth.BluetoothSocket( bluetooth.RFCOMM )
sock.connect((bd_addr, port))

# 0x1X for straight forward and 0x11 for very slow to 0x1F for fastest
sock.send(‘\x1A’)


New Raspberry Pi 4

June 24, 2019

A bit out of the blue, comes a new Raspberry Pi. The 4th major revision of the popular SBC.

It’s spec looks very good. Faster processor, more RAM (choice of 1GB, 2GB or 4GB but at a price of more $$$), dual HDMI video, USB-C, Gigabit Ethernet, WIFI, Bluetooth 5.

Some things have changed on the new Pi. The connector positions have changed, so you’ll need a new enclosure and power is now provided by USB-C connector so you’ll need a suitable USB adapter or a new USB-C PSU. The dual HDMI are micro HDMI connectors instead of standard HDMI.

From earlier interviews with the Raspberry Pi foundation it wasn’t expected to be available until 2020 but it looks like Broadcom was able to get their latest SoC ready a good 6 to 9-months early.


eDay7

October 31, 2018

We were at eDay again earlier in the month (Saturday 6th October 2018) as part of Newcastle Maker Space. This is the seventh year its been going and as usually we had a great time showing off various projects.

We had the following R-Kade and PiZythn and Rc2014 projects on show.

For those who don’t know what eDay is: eDay is a local digital skills day where various digital technologies are demonstrated to an enquiring general public. A sort-of geeky show and tell where local groups and individuals meet at Gateshead Central Library and show off their projects or what interests them.


Raspberry Pi Hardware GPIO Shutdown

September 12, 2018

I found this snippet of knowledge from the Raspberry Pi forum the other day when searching for a easy way to shutdown a RPi from a simple push button.

Open /boot/config.txt in your favorite Raspbian editor and add the following line:

dtoverlay=gpio-shutdown,gpio_pin=7

You may need to add a pull-up resistor to the GPIO pin or add the instruction gpio_pull=up to the instruction. You can also leave out the gpio_pin and the system will default to GPIO3.

You can also monitor the RPi’s status by adding this line to config.txt:

dtoverlay=gpio-poweroff,gpiopin=27,active_low=1

GPIO27 will be high to indicate when the RPI is running or low when it is shut down.

There is more detailed information here:
https://www.raspberrypi.org/forums/viewtopic.php?t=221997
https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README


Setting up RPi MIDI #2

July 27, 2017

In a previous post on setting MIDI baud-rates on the RPi I used a slight of hand (i.e. init_uart_clock etc.) to trick the RPi in setting the UART to a 31250 baud needed for MIDI. While browsing the Raspberry Pi forum I spotted this nugget of information from PhilE:

in config.txt add:

enable_uart=1
dtoverlay=pi3-miniuart-bt
dtoverlay=midi-uart0

 

This combination does three things:

1) Enables the UART. It isn’t strictly necessary when combined with pi3-miniuart-bt
2) Reassigns the weaker UART (ttyS0) for Bluetooth and frees ttyAMA0 for our MIDI interface
3) Using an DT overlay to achieve the same UART clock settings as our init_uart_clock etc. trick

It makes things a lot simpler 🙂


Zero MIDI

December 26, 2016

A quick teaser for my next Raspberry Pi MIDI project:

 


Raspberry PI – FieldBus CAN/RS485/RS232 add-on board

November 22, 2016

Despite USB being everywhere, I still use a lot of industrial and embedded interfaces, such as RS232 and RS485 interfaces, in my projects. Legacy equipment especially and even new industrial equipment still use RS232 for programming and monitoring. While RS485 interfaces can still be found a lot in industrial communications such as factory automation.

So with this in mind I felt I needed an Raspberry Pi add-on board to simplify a lot of these connections. So here is the Raspberry PIIO FieldBus add-on board. It is a multi-communications board RS232 or RS485 and CAN Bus interfaces.

rpi_piio_fieldbus1_small
The board uses 3.3V components and is completely voltage compatible with the Raspberry Pi.

The board connects directly to the Raspberry Pi’s SPI to provide CAN Bus communications and also to the UART Rx and Tx to provide RS232 or RS485 communications.

CAN Bus interface uses MCP2515 CAN controller and MCP2551 CAN transceiver IC provides CAN Bus v2.0 A/B at 1 Mb/s. It is connected the Pi’s SPI Interface. Connection is provided via a 3-Way screw terminals.

RS232 interface uses a 3.3V MAX3232 (or Equivalent IC) chip and CTS (GPIO16) & RTS (GPIO17) signals are provided. Connection is provided via an industry standard 9-Way D Connector (Male).

RS485 interface uses 3.3V MAX3485 (or Equivalent IC) chip with DE (GPIO27) & !RE (GPIO22) used to control the RS485 transceiver control signals. Connection is provided via a 3-Way screw terminals to the outside world.

The Raspberry Pi expansion port has only on UART interface available for serial communications. So where both circuits are fitted, only one RS232 or one RS485 interface may be connected to the UART, therefore only one interface can be used at any time.

You can find them on our Tindie store