Presentation of ElectroDB
ElectroDB is an offline, light and open source tool that makes looking for pinouts and datasheets a child's play! With its 12,000+ components database, most of your needs will be covered!
Designed for hobbyists as well as electronic engineers, this app will avoid you the hassle of browsing the web to find the information you need for your projects.
Within the touch of a button, it will immediately give you access to all the knowledge you need about any component: pinouts, datasheets, features, etc.
From Arduino boards to fairly uncommon chips, this data is there when you need it the most.
Spend less time browsing and more time doing actual electronics!
ElectroDB is available on the Google Play store, for free, with no ads. Its source-code is on GitHub (see below).
Source-code and technical details
In this section, I will be doing a technical overview of the implementation of ElectroDB: how it works, what I used, etc.
This diagram represents the general workflow of the app:
Worflow of the app: a JSON database is constructed from KiCad's lib and dcm files, read at run-time to show the pinouts
The database scrapper
The first issue I tackled was the generation of the database. To fetch data from the biggest number of components I could possibly support, I chose to scrap the KiCad library files because:
- Thanks to the large developer community, it is often updated which means that the database should be fairly complete and error-free;
- Being open-source, there are very few restrictions to the usage of these files (CC-BY-NA license).
- There are third party libraries that I could support at a later date.
To use these resources, I extracted all the information that they contained and assembled it into a universal and easy to read format: JSON. To do so, I developed an AWK script. This quite dense script parses all the files and outputs a single, structured JSON file with all the required information included. This format is then very efficient to parse at run-time with Android's library org.json.
The Android app
ElectroDB was the first Android app I published on the Google Play Store.
Generating pinout pictures
After the database, the most important aspect of the app is showing a picture of the pinout of every chip. Some pictures are manually saved (mostly for popular board, such as the Arduino Uno). However, due to the number of supported components, the pictures cannot all be stored in the app: they have to be generated at run-time.
The pinout pictures are drawn on a canvas with bitmaps and text. Some packages are straightforward: TO-92, for instance, always has 3 pins. For this package, we simply need to write the pins description on the package picture, based on the information from the database.
A TO-92 component automatically generated picture (LM35 temperature sensor)
However, there are other packages that have a variable shape and number of pins. To show them in my app, they are dynamically built with a set of "tiles". For instance, DIP packages are made out of 3 different pictures: top, mid and bottom part. The most extreme example is the QFN/QFP package, that is made of 11 different tiles.
A 20 pin QFP package automatically generated picture (ATtiny406-M microcontroller)
Unsupported package types such as BGA show their pinout in a table.
Look and feel
Design-wise, I followed Google's Material design guidelines. There are numerous advantages to this choice:
- The app's style is consistent with the Android UI/UX,
- It is very intuitive and efficient,
- The layout is simple and fast to develop,
- The design language is well defined with strict rules, making it easier to follow.
Some Material Design assets I drew for ElectroDB (components icons)
Search engine algorithm
To search component names in the database, we need a way to evaluate the similarity between the input string and every component name in the database. We keep and rank the top N results.
I first used a naive implementation of the Levenshtein distance. It measures the edit distance between two character sequences (insertion, deletion, substitution or transposition of characters). This metric is used to pick the most relevant results to a query string from the database.
I then switched to an implementation of the Jaro-Winkler similarity algorithm: the results tends to be better in this context, with the same O(n×m) time complexity.
Lately, I switched to a more advanced "Partial Ratio" algorithm from FuzzyWuzzy. It is still fundamentally based of the Levenshtein distance, but it has the huge advantage of being immune to offsets.
External libraries and resources
I used the following resources:
- KiCad symbols library (CC-BY-SA 4.0): http://github.com/KiCad/kicad-symbols
- Digikey symbols library (CC-BY-SA 4.0): https://github.com/Digi-Key/digikey-kicad-library
- Fritzing parts SVGs (CC-BY-SA 3.0): http://github.com/fritzing/fritzing-parts
- PhotoView by Chris Banes (Apache 2.0): http://github.com/chrisbanes/PhotoView
- JavaWuzzy by xdrop (GPLv2): https://github.com/xdrop/fuzzywuzzy
Source-code
The source-code for both the database scrapper and the app is available on this GitHub repository: https://github.com/CGrassin/electrodb
To go further
Although I want to keep ElectroDB lightweight, fast and focused, there are several features that I am thinking on adding to the app in future updates:
- Add other tools (resistor value calculator, circuit examples, etc.): having all these functions in one app with a common UX design language could be very convenient.
- Enrich my DB: I could gather more information to offer a powerful parametric search. For instance: usual price, power requirements, etc.
Feel free to contact me if you want to share ideas with me!
Author: Charles Grassin
What is on your mind?
#1 dj
on February 9 2024, 17:52
#2 Quyen
on March 21 2024, 22:56