Menu

Demos

Bruno Quoitin

The library is provided with demos. Two different programs are available in the src/dev directory. The first one, named buspirate-demo, can be used with different devices. It can also be used to read a voltage using the ADC. The second one, named buspirate-demo24, focuses on the MRF24J40 radio transceiver from Microchip. Those programs should build automatically when you build the library.

Introduction

Here is an example of how you would use the first demo, buspirate-demo. If you run this program without options, it should display a short help screen as follows:

host:libbuspirate user$ cd src/dev
host:dev user$ cd src/dev
host:dev user$ ./buspirate-demo
Bus Pirate library demonstration
(C) 2010-2014, Bruno Quoitin
Error: not enough arguments

usage: buspirate-demo DEVICE DEMO_ID

with DEMO_ID in
  01  version
  02  bitbang
  03  adc
  04  spi
  05  spi-cc2500
  06  spi-enc28j60
  07  i2c-ds1624
  08  i2c-24c02
  09  i2c-24fc1025
  10  spi-pcd8544
  11  raw-ht1632

See src/dev/README file for instructions on how to wire the Bus Pirate
for a specific demo.
host:dev user$

ADC example

As an example, let's use the ADC demo as it does not require to wire any complex device. With this demo, the Bus Pirate ADC can be used to measure a voltage between the GND and ADC pins. The demo program will connect to the Bus Pirate using the libbuspirate library and report the voltage read.

To invoke the demo, 2 arguments need to be provided. The first argument is the name of the USB/serial device that corresponds to the Bus Pirate. The second argument is the demo identifier. For the ADC demo, the identifier is 3.

Operating systems use different mechanisms to name their serial devices. In the illustration below which was run under Mac OS X, the Bus Pirate appears as /dev/tty.usbserial-BP3. Under Linux, a USB/serial device is usually given a name such as /dev/ttyUSB0 where the number at the end can vary. Under Windows, serial devices are named COM1 where the number varies. You will need to check in the Windows Device manager what is the appropriate name.

host:dev user$ ./buspirate-demo /dev/tty.usbserial-BP3 3
Bus Pirate library demonstration
(C) 2010-2014, Bruno Quoitin
-->Firmware=[5.10]
Binary I/O mode version: 1
*** ADC demo ***
This demo reads the ADC input voltage.
0 mV  (249 reads)
Ctrl-C received
Reset device to user terminal
-->Firmware=[5.10]
Closing.
host:dev user$

When the demo program is connected to the Bus Pirate, it will sample the ADC and display the mean value. The number of values read is shown between parentheses. To interrupt the program, just press Ctrl-C.

Other demos

A description of the other demos is available in the source code archive in file src/dev/README.


Related

Wiki: Home
Wiki: Install

MongoDB Logo MongoDB