The Bus Pirate is one of our favorite tool for quick-and-dirty debugging in the microcontroller world. Essentially it makes it easy to communicate with a wide variety of different chips via a serial terminal regardless of the type of bus that the microcontroller uses. Although it was intended as a time-saving prototyping device, there are a lot of real-world applications where a Bus Pirate can be employed full-time, as [Scott] shows us with his Bus Pirate data logger.
[Scott] needed to constantly measure temperature, and the parts he had on hand included an LM75A breakout board that has a temperature sensor on board. These boards communicate with I2C, so it was relatively straightforward to gather data from the serial terminal. From there, [Scott] uses a Python script to automate the process of gathering the data. The process he uses to set everything up using a Raspberry Pi is available on the project site, including the code that he used in the project.
[Scott] has already used this device for a variety of different projects around his house and it has already proven incredibly useful. If you don’t already have a Bus Pirate lying around there are a few other ways to gather temperature data, but if you have an extra one around or you were thinking about purchasing one, then [Scott]’s project is a great illustration of the versatility of this device.
It would be trivial to gather the data without the BP on a Pi so I suspect it is the actual graphical plotter interface that was the aim of what this makes easier?
I think he’s used the Bus Pirate to get it working on Windows as well as Raspberry Pi (note code comment about device manager).
Either that or HaD gets royalties from the sale of bus pirates ;)
Or HaD sells them on their own store?
http://store.hackaday.com/collections/products-tools/products/buspirate-v3-6-thm180c4m
They are not free of bias, but the worst is that they will never acknowledge it…
When I saw “bus pirate commandeers I2C” I had imagined someone had written an I2C library for it (or something) and intentionally implemented a broken version of I2C’s multi-master bus arbitration. One could do this in order to force complete control over any device with an I2C bus one could tap into (say, through a front panel display) since your master device would always win a buss arbitration against a master running a stock library (chosen by the developer for ease of use) that implemented a version that played by the rules.
Came to say this. That exploit would be pretty impressive.
With an OTG cable, you can also use the BusPirate with your cell phone, and by scripting with DroidScript, you can automate that connection. I wrote a script that makes using the BusPirate as a portable meter and debugging device very easy:
http://techref.massmind.org/techref/language/DroidScript/BusPirate/index.htm
I don’t quite get the advantages of the Bus Pirate yet. So far, it’s a lot easier to use i2c through a Raspberry Pi for essentially the same functionality. Even using an Arduino Nano through the IDE seems to be easier than using the Bus pirate command line. The raspberry Pi isn’t that much more expensive, even if you don’t have one already. And, in contrast to the BusPirate, higher level libraries for many parts already exist.
I’d be delighted if someone could prove me wrong about this. I own a BusPirate, and so far it is quite useless to me.
You have to remember that the BusPirate was around before the Pi was launched.
You may be correct in saying that at this point in time, it is easier (for yourself) to use a Pi, but there was a point when this wasn’t an option!
Personally, I find the BP quite useful when starting out with a new IC or debugging dodgy microcontroller comms. It is also one of the better options for me, as I don’t own a Pi (gasp!).
That makes a ton of sense. The raspberry pi is very “challenged” when it comes to precise timings, but otherwise it is probably one of the easiest ways to access gpio pins, i2c or spi remotely.
Can the Pi Zero do this?
I haven’t tried with the RasPi… but I find the cycle times with the Arduino are annoying. The buspriate allows VERY fast changes to the codes being sent. Especially when used with a small user interface like the one I made for the cell phone above. That also allows me to make use of it on the road, when I don’t have my PC for the Arduino updates. I can just pull out my cell phone, hook up the Pirate, and away we go.
I’m already graphing things in real time using visual IDE on a Windows system, and at the last minute I wanted to add temperature data to this setup. If my goal were only to pull two bytes from an I2C sensor, Raspberry Pi would certainly be easier. Since my goal is integration into an already-running Windows system, Bus Pirate was really handy to have. Notice that I used Python to control its menus, automating the process:
https://github.com/swharden/AVR-projects/blob/master/BusPirate%202017-02-04%20i2c%20temperature/busPirate_LM75A.py#L49
Bus Pirate does a binary mode, but in my experience it can be buggy, and this was incredibly rapid to implement. Since speed is 0% my concern, this was a good solution. I was so pleased by the absolute simplicity of this solution that I wrote it up on my website.
Bus Pirate looked like a good idea, until I got my hands on the first MicroPython board. Now I get the Python REPL over the serial, with control over all the peripherals. And somehow I find it easier to write short Python commands to poke at the buses, than to use the menus. And as a bonus, at the end of the session I can copy the commands that worked into my program.
Interesting… which board do you use and how do you do the serial connection? USB?
I just use the cheapest ESP8266-based dev boards out there, with a built-in cp2021 usb2ttl. Granted, that doesn’t let me use the UART for other stuff — for this I have a pyboard tucked away.
lol
Hi!
I have made a tool to scan, read and manipulate devices using i2c
http://lueftenegger.blogspot.co.at/2016/01/how-to-reset-toner-chip-of-clp-510-or.html
all sources are on github.
regards,
michael
I was on a Windows computer and wanted to analyze temperature data in Python in real time, and the Bus Pirate was an excellent and rapid way to pull temperature from the I2C sensor given my situation.
I have previously interacted I2C devices using the Raspberry Pi, which is great to know how to do (and really convenient considering you can do it directly from bash):
http://www.swharden.com/wp/2016-10-10-raspberry-pi-rf-frequency-counter/
On the other end of the spectrum, there’s code on my GitHub to pull I2C data from a LM75A temperature sensor directly into a microcontroller (ATMega328 in my case, notably not Arduino):
https://github.com/swharden/AVR-projects/tree/master/ATMega328%202017-02-08%20i2c%20LM75A%20thermometer
Hope it helps someone out there who might wish to do something similar one day!