In February 2012, I read the Hack a Day article about ElectroDroid, and the following remark triggered challenge accepted in my mind.
A ‘killer app’ for electronic reference tools would be a front end for
alldatasheet.com that includes the ability to search, save, and display
the datasheet for any imaginable component.
First, I checked whether any applications like that exists on the smartphone application markets. I found several applications of high quality but tied to certain chip vendors, such as Digi-Key and NXP. There's also one that implies to be an alldatasheet.com application, it even calls itself Datasheet (Alldatasheet.com), but as one commenter writes
All this app does is open a web browser to their website.
Nothing more. A bookmark can suffice.
I looked around the alldatasheet.com website and found the search to be rather
easy. Although there's no API available, the HTML output can be easily parsed
with the MIT-licensed jsoup library. First I tried to build a separate
Java API for the site, and a separate Android UI, with former having no
dependencies on the Android library. The API can be found in the
hu.vsza.adsapi package, and as of version 1.0, it offers two classes.
The Search
class has a method called searchByParName
which can be used to
use the functionality of the left form on the website. Here's an example:
List<Part> parts = Search.searchByPartName("ATMEGA168", Search.Mode.MATCH);
for (Part part : part) {
doSomethingWithPart(part);
}
The Part
class has one useful method called getPdfConnection
, which returns
an URLConnection
instance that can be used to read the PDF datasheet about
the electronics part described by the object. It spoofs the User-Agent
HTTP
header and sends the appropriate Referer
values wherever it's necessary to
go throught the process of downloading the PDF. This can be used like this:
URLConnection pdfConn = selectedPart.getPdfConnection();
pdfConn.connect();
InputStream input = new BufferedInputStream(pdfConn.getInputStream());
OutputStream output = new FileOutputStream(fileName);
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) output.write(data, 0, count);
output.flush();
output.close();
input.close();
The Android application built around this API displays a so-called Spinner (similar to combo lists on PCs) to select search mode and a text input to enter the part name, and a button to initiate search. Results are displayed in a list view displaying the name and the description of each part. Touching a part downloads the PDF to the SD card and opens it with the default PDF reader (or prompts for selection if more than one are installed).
You can download version 1.0 by clicking on the version number link or using the QR code below. It only does one thing (search by part name), and even that functionality is experimental, so I'm glad if anyone tries it and in case of problems, contacts me in e-mail. The source code is available on GitHub, licensed under MIT.