JLCPCB – A new PCB fabrication house

I was recently approached by a new PCB fabrication house JLCPCB (technically they’ve been in business for some time but just started advertising to USA customers) to write some reviews on their service. Given my experience designing PCB and using PCB fabrication services (batchpcb, seeedstudio, iteadstudio, oshpark etc.) over the past decade, writing a review shouldn’t be too hard. If they are any good, I could use their service myself and recommend them to others in the hobby electronics community. So I sent them two of my designs and got them back relatively fast, with DHL. Since I still have some older versions of one of the boards, I could make a comparison with the two fabrication services. JLCPCB has offered their service free of charge for the exchange of a fair review. So I decide to not mention which competition I pitched JLCPCB against. What I primarily looked at was how accurately each layer of board is printed and how well they are aligned with one another from each fab service. JLCPCB‘s results are very good. Its competition, a long-standing name among DIYers, doesn’t look quite as good.

In case you’re still learning how to design PCBs, especially surface-mount components, here are some terms I’m going to use:

Top layer: this logic layer contains all copper traces, pads, and vias on the top side of the two-sided circuit board. A process is used to protect all aforementioned features specified in this layer when the entire board is etched in acid. If the process isn’t accurate, then your features aren’t exactly where they are supposed to be.

Top solder paste: this logic layer contains only pads for surface-mount components. It is a subset of top layer and is used to generate stencils for reflow soldering. Again if the fabrication isn’t very good, these features tend to not align with other features.

Top solder resist: this logic layer contains similar information to the pads and vias contained in top layer but the sizes of the features in this layer are slightly enlarged to a peel-back amount so they don’t accidentally apply solder resist on top of your pads where solder should go. Solder resist is a lacquer that prevents solder from adhering to the copper traces. They also protect the bare copper from rusting away. You will want them to be applied to all your traces and only leave the pads exposed so later process will cover them with a very thin layer of solder (the shiny looking stuff) and you then reflow solder your components to these pads. If the registration of this layer of lacquer is not well registered with the top layer, you will see visually under a magnifier. This is why fabrication houses usually do quite a bit of peel-back so they leave room for themselves to be less-aligned but still the lacquer won’t cover up the pads.

The following images are from an FTDI chip (FT232RL). The pitch was the finest on my board so I selected these pads for comparison of how well the different layers register with one another on these two service providers.

Top: JLCPCB Bottom: competition

They look similar. I’ve unfortunately scratched the pads on the competition’s board. I applied solder paste to that board and later cleaned the paste off so I could photograph its pads. My bad.
On a closer look there is a difference:

SMD pads (SSOP 0.65mm pitch):

Top: JLCPCB Bottom: competition
You can see that JLCPCB‘s boards (top) have SMD pads (shiny metal pads) that are very symmetrically situated inside the solder-resist masks (slightly larger dark rectangle). The solder resist also goes closer to the board than its competition. These are manufactured from the same designs! The engineers at the competition must have increased the peel-off (sizes of feature not covered by solder resists) to offset their less-perfect layer registrations and/or accuracy on each layer. As you can see, not all pads and their solder resist have the same offset. Some look better than others. This is clear with the second to the last pad and the last pad. The pads are not centered at all. This is very consistent across the board made by competition. JLCPCB has better overall registration than competition. Better registration translates into better chance to prevent solder bridges and less chances to reworking on your boards after you reflow them, that means time and money saved.

Thru-hole pads (o.1″ spacing):

Top: JLCPCB Bottom: competition

The top one has less size solder resist layer, the edges of the red lacquer surrounding the shiny pads (almost same size as the thru-hole pads) and very symmetrical. The competition has again increased the solder resist layer and couldn’t keep the layer registered well with the pad.

The via to the right of the bottom right through hole pin hole will be compared next. On JLCPCB‘s board, its solder resist has 2.8mm diameter when displayed on my computer monitor. On the competition board, it is 3.1mm. The images were taken under a high-magnification lens and I checked the images to be exactly the same zoom, measuring the same across the same features on screen. What this means is that if you have a lot of vias in one area, very close to one another, you may get some solder bridges between the vias if there is not enough solder resist to separate them. Not a problem on this board but a problem if you happen to have vias very close and also close to thru-hole components. You solder the thru-hole and inevitably fill the adjacent vias with some solder. This could short vias.

Overlay (white texts):

The quality of the white overlay texts are about the same between the two fabricators, although at some places you see one board having better quality than the other board while at different places the quality is reversed. This is not a crucial feature to look at though.

JLCPCB: top, Competition: bottom

With the explanation above, you can easily distinguish these two photos. The bottom one has so much space between the edges of the shiny pads and the red lacquer (less qualty). The top one has so much less and so symmetric.

So the results are clear. JLCPCB is a pretty decent PCB fab house and I will order my next batch from them. The shipping cost is also slightly less than competition if you use DHL. I always use DHL. They do a good job delivering to small cities like the one I live in!

Here is a link to JLCPCB’s website:

I am not getting any commissions for your purchases. The link has no “trackers” 🙂

P.S.: I had a research student hand solder this board (yes, every single chip resistor and the FTDI chip) as a good test of his skills and it turned out fine. This is a proof that having the right size solder resist helps, really. This is what the board looks like after assembly:

Augmented reality sandbox control box updated

This slideshow requires JavaScript.

I constructed a couple of these control boxes for my ARsandbox project using Arduino Micro and Adafruit Feather 32u4. The main goal is to make the interaction between a user and the software more intuitive. The two flashing buttons add and remove water from the simulation, which is pretty nice. I wanted to add another feature, to move the elevation up and down. Say you have a lot of sand in the box but you want to display some “water”. You have to remove a lot of sand (time consuming) from the box or edit a config file (near impossible for an average user). On the other hand, if I can change the base plane location in the calculation, I can achieve the above goal without removing sand or editing files. With help of the original developer Dr. Oliver Kreylos, I started messing with the source code. It took me a day to understand what I could do to change the base plane and how to do it. I ended up creating a tool to manipulate the plane. Now that the plane can be moved, I added a rotary encoder to the control box to emulate the keyboard keys assigned to move the plane. Voila!

The photo gallery above shows 5 shots of different elevation values. You can clearly see the “sea” on bottom right is shrinking after each turn of the knob.

Here is a short video. I was slowly raising the elevation so more and more land became above water. Then I quickly returned the land back into water:

Here is a photo of the inside of the box:

I added a breakout board for rotary encoder and buttons. It’s very tightly sandwiched between the two buttons. There is no space between the board and the buttons, not even a fraction of millimeter. I don’t know how these pieces just managed to fit. Here is the breakout board:

I made this a while ago as an interface for my phi-panels LCD backpacks. This breakout board is pretty simple. There are two encoder channels and one shaft button, plus six push buttons, which I am not using. I just connected to the encoder channels, shaft button, and the common. I had to cut off a strip on the right side of the board to fit into the box. I was using my phi_interfaces library to read the encoder and emulate a button push if the encoder is rotated one way, another button if the encoder is rotated the other way. I didn’t assign any function for the shaft button. I am thinking that I should use it to switch between elevation adjustment and water speed adjustment.

I haven’t updated the Adafruit Feature 32u4 version but will probably design a new printed circuit board so assembling will be easier, and not involving cutting off part of a board. Some code in case anyone wants to replicate it.

 * Credit: Dr. John Liu
 * Purpose: This sketch emulates keyboard keys "1" and "2" with two push buttons with LEDs. It also flashes the LEDs
 * If a rotary encoder is present, it will emulate '5' and '6' if you rotate the encoder's shaft. This combined with my modification on ARsandbox source code will shift color mapping up and down.
 * This version uses p-channel mosfets and open drain with 10Kohm pull-up to 5V to control LEDs with the 3.3V Adafruit Feather32u4.
 * Notes: On Adafruit Feather 32u4, pin 9 is connected to battery sensing voltage divider.
 * 2018-01-28
 * Visit for more information
#include "Keyboard.h"
#include <phi_interfaces.h>
const int button_1=2; // 11 for Adafruit feather 32u4, 2 for Arduino Micro;
const int button_2=3; // 10 for Adafruit feather 32u4, 3 for Arduino Micro
const int EncoderChnA=7;
const int ChnCommon=8;
const int EncoderChnB=9;
const int ShaftBtn=10;
const int EncoderDetent=18;

const int button_1=11; // 11 for Adafruit feather 32u4, 2 for Arduino Micro;
const int button_2=10; // 10 for Adafruit feather 32u4, 3 for Arduino Micro

const int led_1=6;
const int led_2=5;
const unsigned long led_on_ms=300;
const unsigned long led_off_ms=1700;
const unsigned int button_1_key='1'; //KEY_LEFT_ARROW;
const unsigned int button_2_key='2'; //KEY_RIGHT_ARROW;
const unsigned int UpKeyOut='5';
const unsigned int DownKeyOut='6';

int prev_1=HIGH;
int prev_2=HIGH;
int led_stat=LOW;

unsigned long prev_1_ms=0;
unsigned long prev_2_ms=0;
unsigned long blink_timer_0_ms=0;
unsigned long blink_timer_1_ms=0;

int debounce_ms=25;

char mapping[]={'U','D'}; // This is a rotary encoder so it returns U for up and D for down on the dial.
phi_rotary_encoders MyEncoder(mapping, EncoderChnA, EncoderChnB, EncoderDetent);
//multiple_button_input* dial1=&my_encoder1;

void setup()
  // make pin 2 an input and turn on the
  // pullup resistor so it goes high unless
  // connected to ground:
  pinMode(button_1, INPUT_PULLUP);
  pinMode(button_2, INPUT_PULLUP);
  digitalWrite(ChnCommon,LOW); // Using this pin as ground since some prototypes don't have enough gnd pins.

void loop()
  unsigned char ch=MyEncoder.getKey(); // Rotary encoder emulates two buttons.
  if (ch==mapping[0])
  else if (ch==mapping[1])

  switch (led_stat)
    case LOW:
    if (millis()-blink_timer_0_ms>led_on_ms)
      pinMode(led_1,INPUT); // Open drain to let pull-up resistor pull drain to 5V.
      pinMode(led_2,INPUT); // Open drain to let pull-up resistor pull drain to 5V.

    case HIGH:
    if (millis()-blink_timer_0_ms>led_off_ms)
      pinMode(led_1,OUTPUT); // Pull drain to GND.
      pinMode(led_2,OUTPUT); // Pull drain to GND

  if ((digitalRead(button_1) == HIGH)&&(prev_1==LOW))
    if (millis()-prev_1_ms>debounce_ms)
      //Serial.println("1 released");

  if ((digitalRead(button_1) == LOW)&&(prev_1==HIGH))
    if (millis()-prev_1_ms>debounce_ms)
      //Serial.println("1 pressed");

  if ((digitalRead(button_2) == HIGH)&&(prev_2==LOW))
    if (millis()-prev_2_ms>debounce_ms)
      //Serial.println("2 released");

  if ((digitalRead(button_2) == LOW)&&(prev_2==HIGH))
    if (millis()-prev_2_ms>debounce_ms)
      //Serial.println("2 pressed");

Augmented reality sandbox control using Arduino Feather

It’s been a while since I completed this project. I promised the Augmented reality sandbox community to write something in details so someone can replicate it. Here is the gist of it:

The Augmented reality sandbox (ARsandbox) is an awesome simulator that blends sand landscaping with augmented reality. A projector casts color-coded elevation, contours, and simulated water flow over regular sand. A 3D sensor measures the sand landscape in real time so the computer knows where sand is high and how it slopes down and renders color and contours according the the 3D data. You can rain over the landscape by pressing a button or hold out your palm over a certain area.

Here is a video of one of my builds:

This is where the control box comes in. The sand box is a 40″ by 30″ box with up to 200lb of sand. The function to rain over the augmented terrain is to press the “1” key on a keyboard. Sand and keyboard shouldn’t mix, not to mention if the system is deployed in a museum, the keyboard probably should be hidden from patrons. So a box with rain and dry buttons will be most convenient. You can make these buttons by following this forum post. You buy and assemble a USB gamepad kit and doing some scripting but it’s not that easy to follow if you are a Linux beginner. I want a plug-n-play solution so that anyone that wants to add a button box can add it without any knowledge of Linux and minimal skills in circuit assembly. In order to achieve my goals, the electronics inside the box has to emulate keyboard keys “1” and “2” for rain and dry. This ensures that the control box requires no software setup on the Linux system. As a bonus, the buttons should flash blue and orange so it would invite patrons to press and is color-coded for rain (blue) or sun (orange). Enter the ARsandbox control box:

Here is a short video of the box in action:

Features of the box:

1. Two buttons. Blue button on the left emulates the “1” key. It starts the rain in the main simulation, and is used in the projector calibration program to enter tie points, and can be assigned other functions in other programs such as extracting plane. Orange button on the right emulates the “2” key. It drys the rain in the main simulator, and can be assigned functions in other programs.

2. Both buttons have LEDs that flash to invite patrons to press. My 5-yr old son figured out what they do simply by the colors they flash because he knew the rain and dry features already but wasn’t told what these buttons would do.

3. No software setup is needed. This box works like another keyboard, with only 2 keys though.


Here are the parts I used, in case you want to build your own:

  1. Adafruit Arduino feather 32u4 basic board (1)
  2. LED push buttons 16mm from adafruit (2)
  3. USB-micro cable (1)
  4. USB extension cable (1)
  5. P-channel MOSEFT BS250 from mouser (2)
  6. 330 ohm resistors (2)
  7. 1K ohm resistors (2)
  8. DuPont 30cm female-female jumper wires (4)
  9. Prototype board or my printed circuit board. Click here to download (1)
  10. Enclosure SK-15 and flange kit SK-99 from polycase (1)
  11. Cable gland M3198GBH from Heiland for pre-assembled cables with USB connectors (1)
  12. Arduino sketch. Click here to download

Here is the schematic of the circuit:

Since the ATMEGA32u4 microcontroller on Adafruit Feather 32u4 is operating at 3.3V, I had to use two transistors to ensure that the LEDs inside the buttons light up with sufficient brightness. Currently the code only blinks both button LEDs at the same rate. In the future, I may update the code to blink more rapidly on the button that is depressed.

The following is a prototype that I built with the parts on a perfboard. It’s a bit messy and also took almost 2 hours to complete. I had to solder 16 wire leads and a bunch of jumper wires on the back side of the perfboard. I wouldn’t recommend this to a beginner.

Here is the printed circuit board that I designed (3 boards, two on the right showing the top, 1 on the left showing bottom):

The board is fairly simple and straightforward to solder. Only 8 wire leads and soldering the rest on the printed board, which is very easy. I also cut in half 4 30cm female-female Dupont jumper wires so I can just use the female side with male pins on the board to cut wire leads in half.

Here is a photo of the assembled guts including the microcontroller soldered to the button box board. Notice the black female Dupont connectors :

Here is the assembled board placed inside the enclosure. This enclosure is not cheap but nice and easy to use. It has various knock-outs so I didn’t have to drill a single hole.

Here is the completed box:

Although I am not aiming to sell a lot of these boxes, I think that designing the printed circuit board was the right way to go. I probably spent a few hours designing and proofing my design but I saved about one hour for each subsequent box I made. Plus, if YOU are interested in making this box, it will save YOU at least that much time.

SDI-12 USB adapter manual and logging script updated

Due to the discontinuation of, I moved data logging to

I have other updates that I rolled up in the manual, such as more details on telemetry. New manual is posted on SDI-12 USB adapter page as well as the updated data logging code. Here is a snapshot of data I logged to

The full data stream is here:

Upload data to ThingSpeak

I have been using sparkfun’s Phant server for data upload and retrieval for a few years since they started the service. The service was easy to use and was free. Several months back they discontinued the service, unfortunately. I started looking for suitable alternatives.

Sparkfun recommended three, ThingSpeak, Cayenne, and Blynk. I went ahead and did some research on these services. My goal is to be able to log data online and later retrieve them and possibly visualize them using google charts, like before. I am not at the moment interested in automating my home with actuators or smart phone apps to turn on and off my hall lights. Here are my findings and why I decided that ThingSpeak was the best fit. If you are logging data for later processing or visualization, read on.

This service is provided by the company behind Matlab. I am not a fan of expensive commercial data manipulation tools such as Matlab but they do have a fair amount of business between universities and industry so their service might be a safer way to go against sudden discontinuation of service such as sparkfun. Basically you create a data stream and send data to the stream. It’s very similar to sparkfun. You can also retrieve your data, possibly good for running your data through google chart. They also provide some basic graphs and matlab analysis tools that I have yet tried.

There are two types of application programming interfaces (APIs) you can use: a REST API, and an MQTT API.

The REST API is based on HTTP so it’s very similar to existing services elsewhere. You use HTTP GET or POST command to send data using an API key, like a private key with sparkfun. Your data are limited to up eight values per data point. If you need more, then you need to create more streams. They also have a bulk update feature that you can use to send multiple sets of data instead of one set of data. This method allows a device to collect data and sleep in between data points. Then when it collects a fair amount of data, it connects to the Internet and sends all data in one shot. It saves power and network bandwidth. You can also create and modify the properties of streams with this API.

With the MQTT API, the underlying protocol is TCP/IP. There is no acknowledgement of data received and it is intended for low-powered devices to just wake up, take data, send it out, and go back to sleep. From my tests, data sent via this method were lost over 50% of the time. Unless future holds differently, I am not recommending this API.

Getting start is easy with ThingSpeak. Just set up an account and follow their tutorial to create a new data stream. Then the following bash code should get you started posting code:

curl ""

You can post any number of field values between 1 and 8. You will receive a zero as a positive response. Then you will see your results like the plot on the top of this page.

I have updated my Python data logging code to use instead of the now discontinued The plot in this post is from Here is a link to the data stream:

Can’t upgrade pyserial in latest raspbian distribution?

This is just for your information if you are a Raspberry Pi user and playing with Python code from my blog. If you are trying to use the latest distro of raspbian with pyserial for some serial port project, you may have come across this issue that regardless how you upgrade pyserial using pip3, your python3 will always call up the old pyserial 2.6 that came with the distribution. I am a bit disappointed that the foundation has included such an old version of pyserial, couldn’t they just try a pyserial 3.0 instead? My solution was to remove the python3-serial module using apt-get and then install pyserial 3.3 using pip3.

sudo apt-get remove python3-serial
sudo pip3 install pyserial

Hope this helps.

Augmented reality sand box

I have been involved in constructing augmented reality sand box (ARSandbox) lately. It is a beautiful project created by Dr. Oliver Kreylos at UC Davis. The system uses a Microsoft XBox 360 Kinect sensor to digitize the sand in a box and then uses a projector to project color-coded elevation and contours on the sand, thus augmenting the sand with colors and contours. Here is a photo I took on a prototype that we replicated from the ARSandbox created by Dr. Kreylos:

When someone manipulates the sand, thus changing the topography, the projected colors and contours change accordingly. You can also rain over the terrain by a hand gesture over the terrain.

For those that didn’t know, the Microsoft XBox 360 Kinect sensor is a sophiscated set of sensors that include IR projector and camera for depth sensing, body movement and gesture capture, and regular RGB camera and microphone array. The software Dr. Kreylos developed takes the depth image and calculates a topography map and projects it onto the very same sand using a calibrated projector. To show you how good the simulation is, here is a photo:

Did you notice the white cone and the colors/contours on it? The contours are depicting 1cm heights and the cone is about 4cm tall. Here is a close-up of the cone placed at a different location:

It shows roughly 4cm tall and the contours are very well centered around the tip of the cone.

Here is a video:

Like it? The whole setup is not cheap. It needs an expensive video card for the simulation, especially the water. It also needs a decent desktop computer and projector, sand box, frames etc. Here is what my setup looks like:

I didn’t buy a more expensive (thus shorter throw ratio) projector so my setup is very tall even without any legs. I am hoping to develop it into a portable system so I can take a few of them to teachers’ training workshops, museums, schools, fairs etc. for basic education and outreach for water resources.

What I’m thinking about doing using my Arduino/Raspberry pi skills is to add sensors to help preserve the projector’s bulb and have kids and operators interact with the sand box without having to use the keyboard and mouse or understanding linux. Big buttons will do certain predefined things such as rain, drought, etc.

SDI-12 + GPS USB adapter

After a final revision, I am happy to release the SDI-12 GPS USB adapter! This adapter is the latest one to add to the line of SDI-12 USB adapters. In August 2015, I released my first SDI-12 USB adapter with this post. It was an idea that I thought about while traveling. I was working on data logger designs that use SDI-12 sensors and felt that interacting with SDI-12 sensors is not easy for agricultural or water resource researchers. Having an adapter that connects a computer to an SDI-12 sensor and reads measurements directly from the sensor would be very useful. So I made the adapter to simplify lab tests and data logger deployments. Since then, I’ve written free Python scripts for basic data logging (read the SDI-12 USB adapter main page). The demand for the adapter since then has been high enough to support my continued update on the data logging script, expanding from PC/Mac/Linux to single-board computers such as Raspberry Pi and Beagle Bone Bone. I have also expanded the adapter with an SDI-12 + Analog USB adapter that includes four high-precision analog inputs.

Later I found some need to add GPS modules to the existing SDI-12 USB adapter so that mobile data loggers such as those mounted on tractors will be able to produce with Geo-tagged data that can be made into maps. After some initial struggle using the new ATMEGA328PB processor that sports two hardware serial ports (one to talk to PC and the other with GPS), I realized that the GPS module actually interfered with the processor and caused program freeze-up. Then I made some hardware revisions and was able to prevent interference. It turned out that the new ATMEGA328PB processor that I used in my initial prototype was especially susceptible to interference when I used its second hardware serial port that have the same pins as the SPI pins that program the processor. So I switched to the ATMEGA1284P processor that I have been using on my open source physics laboratory design.

After extensive tests, I am happy to add this adapter to the product line. You can purchase (small quantity at the moment) at or on my blog (in the middle of the page). The adapter requires a separate purchase of the GPS module that Adafruit makes and sells, the Ultimate GPS module part number 746. You only need to solder four pins on the GPS module, the TX, RX, GND, and VIN, and the same pins on the adapter. Since the GPS module is relatively expensive, I can’t stock them up. But if you really need it assembled, you may have a GPS unit sent to me and a few extra dollars for assembly and testing. Just contact me once you make a purchase if you want assembly.

SDI-12 data logging on Beagle Bone Black

In my previous post, I wrote about my initial success reading SDI-12 sensors using my SDI-12 USB adapter and a Beagle Bone Black (BBB), via a simple linux command “screen”. Upon further testing, I had trouble running my open-source python data logging script on BBB, because a number of python modules including pyserial and urllib3 are missing and I couldn’t install them the way I used to do on a Raspberry Pi. So after searching online for the past few days, I finally found how to solve the problem and here is a screen shot of the data logging script happily logging data on BBB:


The SDI-12 sensor I was using was the GPS sensor from my newest SDI-12 + GPS USB adapter. It has an on-board GPS module (separate purchase from Adafruit and its vendors). I was logging coordinates.

Here are the steps to prepare your BBB to run the data logging script:

  1. Install pip for python3: sudo apt-get install python3-pip
  2. Upgrade pip: sudo pip3 install –upgrade pip
  3. Install pyserial module: sudo pip3 install pyserial
  4. Install dropbox module: sudo pip3 install dropbox

The reason that I installed dropbox is because that I can use it to send data files from remote logger to my desktop, and installing it upgrades urllib3, which I use to generate URI-safe address for sending data to sparkfun’s phant server. If you are not doing telemetry or you prefer logging into your BBB to get your data files, you don’t have to install dropbox or upgrade urllib3. Now all I have to do is to update my documentation and welcome BBB to the club!

Adding Beagle bone to the mix

I was recently contacted by someone who was interested in using the SDI-12 USB adapter on a Beagle Bone Black single board computer. I’ve never used a Beagle Boards but I know that they are ARM-based computers running linux thus should operate similarly to the Raspberry pi boards that I’ve been playing since 2012. So I took the dive and got a Beagle Bone Black from MCM electronics and gave it a try. Right out of the box the board boots into a version of Linux. I was able to test its connectivity with the SDI-12 USB adapter successfully using the “screen” command. Later I ran a simple Python script under Python 2.7 and got very nice results:

There are a few differences that I noticed while exploring BBB:

  1. There is a “serial” module included in Python that is not available on other platforms, such as windows, linux, Mac OS, or Raspberry pi. It functions like the pyserial module used on all these systems.
  2. The board boots much faster than raspberry pi 3B, maybe in 15 seconds. RPI 3B takes about 30 seconds. This is a good thing.
  3. There are a lot fewer instructions on basic operations for Beagle boards than Raspberry pi, which was the primary reason I got my raspberry pi B instead of Beagle board back in 2012.

When I have more time, I will test my open-source python data logger on BBB to make sure it works just as it does on all other systems. For now, one more box is checked: “compatible with Beagle Bone Black”.


%d bloggers like this: