Search This Blog

Saturday, 12 October 2013

Buying Electronic Parts from China

Opportunity for a Bargain?

With the wonders of the internet it is possible to search for and buy electronic components directly from China and with a "normal mail" shipping service the cost is reasonable with delivery take something between a week and a month. Normally an expensive courier shipping is also available which will deliver your order sooner, but will likely take away any costs savings on the item.

Stores like Suntek Store sell a whole range of items (not just electronics) with prices in GBP, and free worldwide shipping so you know exactly what you are paying.Often there are deals to be had on bulk purchases too. A quick search for "arduino" on the Suntek Store will bring up a lot of interesting bits and peices.

When you are squeezing the most out of a tight budget you need to shop around. The products in China might not be the cheapest and generic electronics are often bought in bulk and resold through eBay and Amazon at similar or sometimes lower prices. For example Suntek sell the GY-61 accellerometer cheaper on Amazon than on the Suntek Store website.



A lot of the international shops will show prices in US Dollars. You can get an idea of the equivalent cost in GB pounds using a currency converter, such as the one at, but the exchange rate there is an idealised one, and the rate that you get for your transaction may be quite a few pence/cents different. I like to use XE to get an idea of the cost, and if I want to know exactly what I will be paying then I use Paypal, which will show me the conversion before I pay. If you pay be card you may not know the exhange rate until you see the payment on your statement.

Anything to Declare?

 When goods are imported there are usually two types of tax that apply, duty and VAT. Duty is only charged against more expensive items (£135 or more) and so I am going to ignore it. VAT could result in unexpected fees if you are not careful.

Import Paperwork

Although the shipper prepares the paperwork and the CN22 form (the sticker on the packet that declares what's inside) it is actually the receiver that is responsible for making sure it is correct. Although this seems rather illogical it allows the import duty collecting country to get their taxes even if the items are declared falsely or incorrectly.

From my experience of ordering small items from China often the declaration on the CN22 often bears no relation to the goods ordered or the cost, and no invoice is provided.

VAT Threshold

 To stay clear of paying VAT keep your order total under £15. Note that any Shipping Charge is included in the total (this prevents the value of the goods being transferred into a shipping fee - USB Camera only 1p, £10 shipping). I have seen people who carefully kept the cost of their goods under the threshold caught out on the shipping charges. Presumably you would also need to be careful of exchange rates when near the threshold.

If you get charged VAT it is very likely to wipe out any savings. The main reason for this is that Royal Mail will charge an £8 handling fee which is to cover the work involved in inspecting the mail, taking the payment, forwarding the payment on to HMRC.

To demonstrate here is an example - I am going to get an Enthernet Shield for £12 with a £2 shipping fee:

Ethernet Shield£12.00

But before I go through checkout I notice an LCD module for just £2, so I add that in and place the order:

Ethernet Shield£12.00
LCD Module£2.00

In a couple of weeks I get a Red Card through my door from the postman telling me I have a fee to pay. This can either be done online, following the instructions on the card, or at your local delivery office where the parcel is being held. The final bill would look like this:

Ethernet Shield£12.00

LCD Module£2.00



Royal Mail Handling Fee£8.00


VAT at 20%£4.80

Amount Due£12.80

Total Cost£28.80

Remember that any shipping charge counts towards the total. Also the Royal Mail handling fee is itself subject to VAT, so it is effectively a cost of £9.60.

In order to get my parcel I would have to pay £12.80. The cheap LCD has ended up "costing" more that the ethernet shield. It's easy to imagine turning up at the delivery office with a gobsmacked cry of "How much!?"

HMRC Guide to Importing
Royal Mail (Information about Receiving Mail is at the end of the page).

The Handling Fee is charged by the company delivering the parcel. If you choose a more expensive delivery option you may find the charge is cheaper, for example DHL only charge a £5 handling fee. Check the delivery options if you are going to place a big order.



Shop around - check UK prices too.

Remember that Shipping charges count towards the total.

Keep your order below £15. If you go over £15 you are going to be liable for at least an extra £12.60.

Split your orders. You might have to pay more for shipping a second order, but it is bound to be cheaper than £12.60, but might start to become less competitive with an order from a UK company.

If you choose to "gamble" you may get lucky and avoid paying the VAT, but be prepared to have to pay up graciously.

GY-61 Accelerometer setup and test

The GY-61 is a small board based on the ADXL-335 Chip. There are several similar boards available (see below) and they should operate in much the same way.

The Pins on the GY-61 are:
  • Vcc - 3.3V - Red
  • Xout - A0 - White
  • Yout - A1 - Yellow
  • Zout - A2 - Blue
  • GND - GND - Black

About the Sensors

Three sensors are at right angles to one another and measure the acceleration in each of three axes. According to the datasheet for the ADXL-335 they can measure accelleration up to a minimum of +/- 3 g (where 1 g is approximately the equivalent of the acceleration due to gravity on the earth's surface). The sensor outputs an analogue signal for each of the three axes, the voltage is linearly proportional to the acceleration, with 0V being the maximum negative value. The sensor accepts a wide range of supply voltage from 1.8 to 5V, but is designed for 3.3V, so that's what I used.

As each sensor is different they will need some calibration before use. I couldn't figure out a way to reliably calibrate it automatically, but I have a method that you can use to calculate the range and offsets using a calibration sketch and these values can then be use for more practical applications, or you could have a calibration on start up.

The sensor has a Self Test facility and some breakout boards have a pin marked ST (on the GY-61 there isn't a pin, but there is a hole on the board to the left of the sensor in the picture above). The ST will exercise the accelerometers to their maximum values. I am not really sure how useful this would be for calibration if you do not know what that maximum actually represents.

Wiring it up

Wiring up the sensor is simple. The Frizting diagram below shows how. Fritzing has an ADXL-335 version which has slightly different pin arrangement than the GY-61. The analogue accellerometer outputs are connected to the Arduino analogue inputs, X to A0, Y to A1 and Z to A2. The Arduino 3.3V output is used to provide power to Vcc and the GND is connected to ground.

For the analogue inputs the Arduino uses a reference voltage to convert the input voltage to a value. Normally this is the internal 5V supply. Because we are powering the sensor from the 3.3V we need to provide a reference voltage by feeding the 3.3V into the Arduino AREF input.



Calibration is based around the assumption that the sensor response is linearly proportional to the accelleration, and that we know three values of accelleration for which we can measure the sensor response on each of the axes.

When the sensor is at rest, positioned flat on a horizontal surface then the Z axis will be measuring the force of gravity - 1g - and the X and Y sensors will each be measuring zero. If we then flip the sensor upside-down we can measure negative 1g on the Z axis. The sensor can be rotated so that each of the axes is in turn parallel to the force of gravity and a reading for zero acceleration, 1g and -1g obtained for each axis.

So for example, when at rest and powered with 3.3V the sensors give analogue readings of:
  • X (0g) - 516
  • Y (0g) - 506
  • Z (1g) - 619
With the sensor upside down:
  • Z (-1g) - 416
With three points we can then use a linear equation to extrapolate the maximum and minimum values using the formula:

y = mx + c

Where m is the slope of the line and c is the intercept - the value on the y axis when x is zero, which you can see from the readings above, is about 510. y is the sensor reading and x is the acceleration.

With readings taken from the 6 different orientations and plotted onto a graph it is reassuring to see that the relationship does appear to be linear as shown below:


The part I used was the GY-61, which you can buy from Amazon (link below left). There are plenty of other breakout boards for the ADXL-335 on Amazon and your favourite online hobby electronics website.