Thursday, February 28, 2019

Arduino - avrdude: stk500_getsync() not in sync - How to fix

This is  reminder for me and hopefully useful for others either new to Arduino or using different boards.

Sometimes on uploading you can get an error message

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00

Of course the attempt number changes as it tries 10 times.

There are a few relatively obvious things that can help stop this error message.

Select the right board.  If you're using an Uno, select Uno. If you're using a Leonardo, select Leonardo.

Select the correct processor: ATMega328 is the Uno one and the default

Make sure your USB port is selected.

Even after doing both of these and it all looking right you might still be getting the error message.

This is where we get into a discussion about Arduino compatible boards.  The Arduino is an Open Source design and so it is perfectly legal and acceptable for anyone to copy the design and make their own boards and sell them (but they cannot call it an Arduino, topic for another day)

Some of these compatible boards use a different USB chip (CH340) and the ATMega328 could have a different bootloader to the actual Arduino.

if you are using a compatible board that has a CH340 make sure to install the driver for the chip otherwise you may not even be able to see the board in the IDE.

Then for the bootloader there is an alternative option under the Processor called "ATMega328P (Old Bootloader)"  Not where I expect to see an alternative bootloader option but there it is.

ATMega328p (Old Bootloader)

This is the one I have to use for compatible boards.

So, once the correct board, processor, and port are selected you should be able to program your Arduino with ease.

Finally, finally. If you're running Linux and not Windows there is one more thing to take into account and that's permissions.  By default a regular user account does not have permission to read/write to USB serial ports so you have to add your user to the group with access. 

The command you need is as follows where [USERNAME] is replaced with your username.

sudo usermod -a -G dialout [USERNAME]

WARNING: This command is run using sudo and so has root access.  It's always the right thing when finding commands online that use sudo to do your own research before blindly using the command.
So, here's where I got the command from

Hope you find this useful as I expect I'll be back here again when I set up my next computer or buy some new compatible boards.

Arduino and NRF24L01 - test code

A while back I made a game using some Arduino Nano and NRF24l01 called ButtonFlash (

Mnadatory video showing it being played.

It was good fun to make and people seemed to enjoy it but it wasn't in a state for someone else to make easily and wasn't robust so running repairs were needed.

But I really liked it and wanted to do a version that others could make easily.
At the same time EasyEDA was starting to be advertised as a simple web based PCB design tool with integration to a PCB fabrication facility so getting the boards manufactured would be super easy.  So, I took the plunge and designed a PCB and had 10 of them manufactured.

Soldered up

I soldered a pair and started running  code to test them and it kept failing.  I tried different libraries and different setups and every time I couldn't get it to work reliably.  This is part of the pleasure of using code and electronic components created by others. 

Today I figured out one of the NRF24l01 that I used can transmit but not receive.  Maybe I damaged it as had power caps in the wrong way around when testing early on.

I soldered up a 3rd but without the switch and LED and ignoring the bad one the pair I used were reliable today.

Now as I tried lots of sample code and had different results with them I have prepared my own tester code.
This code uses the Arduino, NRF24l01, LED attached to Pin2 (through current limiting resistor) and switch on Pin3 using internal pull up.

When uploaded the Arduinos start in transmit mode.
Press the switch on one and it transmits and switches to receive mode.
Now you have one in transmit and one in receive mode.

Pressing the switch on the transmit one and it's LED will flash 5 times and change to receive mode and the receive one will turn it's LED on full and change to transmit mode.

It's amazing how much fun it is to press the switch. See then change. Then press the switch on the other one and see them swap roles.

So, if you are messing with Arduino and NRF24l01 then maybe this code will be useful to help you.

Code is available on GitHub 

Now to actually make ButtonFlash 2.0.

Thursday, November 8, 2018

Electronics Maker Christmas stocking fillers list

It's that time of year when my family ask me for ideas of presents for Christmas and my Birthday.  (both December)

With electronics bits being a bit specific/esoteric I stopped trusting that if I said what I wanted they would get me the right thing after I gave my wife a link without a description for a new CPU.
By the time she clicked it the link redirected to a few screws.  Luckily she checked before buying and I was able to get her the alternative link.

So, these day I provide a wish list email with more items than I expect to get so I still have the surprise when I open the packaging as to what they give me.

This year I've decided to share the list.  This list may be added to as I think of more things.
Before you ask things like Arduinos, Raspberry Pis, Circuit Playground boards are not on this list as these are things I have usually already got a stash of.  This list is for the other bits that make those things useful.  The kind of things it would be useful to have before starting a project but may not have already or may have run out of.

I try to keep the items to less than £20 so for many these are good stocking fillers.

USB Current Tester - £4.50
I buy random items off the Internet and for batteries and USB PSUs I want a way to see if they meet their stated ratings.

Heat Resist Soldering Mat£9.90 - £15.00 - There are bigger and smaller ones out there as well.
I have a regular A3 cutting mat but like this because of the different compartments to keep bits as I regularly drop screws and tools and hope this will help me be more organised when working on something.

I sometimes use buttons with spade connectors and at the moment I solder the wires on which is not ideal.  Want to start using the correct connectors for the correct job and not just bodge something that later causes a headache that I have to fix.

Anker 4-Port USB 3.0 Hub  - £10.99  
Sometimes for the Raspberry Pi I need to burn multiple SD cards.  The great Etcher will burn multiple images at the same time so with this I can add 3 more to be burned in parallel (it's not 4 as I lose a port to connect it)

Starting to try and be more organised so like the idea of this set of wires.  I have loose spools of wire around the place so the plan is to replenish the spools when they run out.

Saying that I still do breadboard stuff so it's always good to replenish the stock of Dupont jumper wires.

Having recently committed a project to an actual prototyping board rather than using a breadboard I want to do more of that for my Raspberry Pi projects so need a bunch of 2x20 female connectors to hand.  Last one I used I 'borrowed' form a Kickstarter I backed, so that's now an incomplete kit.

I'm always looking for microSD cards, so every year I add them to the stocking filler list.
They're small and I'm clumsy so replenishing stock is an ongoing activity.