The Bus Pirate is an open source test device designed by Dangerous Prototypes. It can test a number of common protocols including SPI, I2C, MIDI etc and also works as a 40MHz frequency analyser and 1MHz logic analyser.
I was recently lent a Sparkfun Bus Pirate version to have a play with.
It is configurable using a serial terminal. This blog post is a collection of my notes on getting it working, which migh be useful to others.
The first thing I did was to plug it in to my USB port. It installed sucessfully and appears as a new COM port. It uses the FTDI USB-serial IC, which is also used in my Arduino programming cable, hence I did not need to install new drivers as they were already installed.
I then checked out the Bus Pirate 101 and 102 tutorial.
The next thing was to try and talk to it. I am running Windows 7 on this machine. The Bus Pirate is designed to talk via some kind of serial terminal. Previous versions of Windows came with Hyperterminal installed, but Windows 7 does not. Hyperterminal is available for Windows 7 but is not freeware. Using the advice of Dangerous Prototypes, I downloaded the open source freeware Tera Term Pro. This is an .exe file which needs permission to run.
Due to my use of numerous FTDI cables, the Bus Pirate connected as COM31. Tera Term Pro only works with COM ports up to COM12. To change this I went to Control Panel -> Device Manager. I then looks at the ports and found the correct COM port. Right click to get ‘Properties’ then click on ‘Advanced’. You can then choose any COM port number. I chose 9, which it said was ‘in use’, but I have not noticed anything malfunctioning.
You then need to set up the serial port in Tera Term Pro – the Baud rate is 115200, 8 bits with 1 stop bit, 0 bit parity and 0 flow control.
Typing ‘?’ into the terminal and pressing return and sucess! A list of all the commands and help files is returned.
I have a DHT11 temperature and humidity sensor to test and I thought this would be good to try out. There is a great Adafruit tutorial on using the DHT11 sensor here, which I also used, along with their Arduino code and example fo the DHT11/22.
I then performed a hardware self-test for the Bus Pirate. I needed the Sparkfun cable pin out (which is different to the Dangerous Prototypes one). I needed to connect Vpu to +5V and ADC to +3.3V. I used short jumper cables to connect the relevant cables together and followed the terminal instructions. Everything worked correctly and no errors were found.
Now to try out with the DHT11. I used the 5V supply and ground to power the sensor and used a 1-wire line to connect.
I enetered 1-wire mode by pressing ‘m’ then ‘2’. It took a while to play around with but I think I am getting some data back. Reading the DHT11 data sheet we need to pull down the voltage on the 1-wire for at least 18mS and then read data back.
In order to do this I needed to write a short list of commands. I set the line low using a write command (0x00), then delay for a while using the 1uS delay function (&) and the repeat command (:xxxx, where xxxx is the number of repatitions). I then set the line high again (0x01) and read in any data sent back using the read command (r) and the repeat command (:100), to read in the next 100 pieces of data.
So the command used is:
0x00 &:18000 0x01 &:1000 r:100
Data is sent back as a 40-bit data sequence. This includes the temperature and humidity data along with a checksum. Here is a screen shot of the data received showing the data within a stream of 0xFF.
I need to figure out how to convert this data into actual readings, but it shows the bus pirate is working and has amazing potential to test hardware. I think I will follow Adafruit’s Arduino tutorial for this device to check I am getting the correct data.
Update 29/1/13: Here is a tutorial from some who decided to do a very similar thing to learn how to use their Bus Pirate, but with a different sensor – a barametric pressure sensor.
Update 23/4/13: I needed to test some LCD 16×2 digit displays with the HD44780 control IC. Here are some notes on getting them working.
First I connected to the Bus Pirate as mentioned above.
I needed to change the mode, so entering ‘m’ then seeing the list I changed to ‘8’ (LCD mode).
I followed this basic ‘geeting started guide’ to get the LCD running.
Entering ‘W’ turns on the voltages. The screen blinked into life, and I adjusted the contrast to display a row of blanks. Using ‘v’ then checks the voltages.
There are a number of macros written which send the correct series of data to get the device to work. These can be found by typing ‘(0)’. I ran macro ‘(1)’ to reset the LCD.
I then ran ‘(2)’ to initialise the display. This gave me a blank screen. Typing any text within speech brackets will output that text to th cursor position. For example ‘(4) 8’ moves the cursor to the first line, 8th character. Typing ‘ “hello” ‘ then outputs hello onto the screen. Its all working great!