Making a cheap USB to Serial CH340 adapter work with a breadboard ATMega328

How To Make A CH340 USB-To-Serial Adapter Work With An ATMega328 Breadboard

 

A few months ago I took an interest in the ATMega328 and Arduino so I built a small project that used a breadboard style configuration, but on a perf-board. The project worked well so I decided to build something else, but thought I would like to have a USB-to-Serial adapter too. In my previous project I used a TinyUSB programmer which I modified with a cable from my junk box to allow it to plug onto the ISP header that I copied from my Arduino Uno.

 

https://www.sparkfun.com/products/11801

 

  

                I found a cheap Chinese adapter for the USB-to-Serial portion and incorporated it into my project.

 

https://www.ebay.com/itm/CH340-Replace-FT232-USB-TO-232-TTL232-RS232-Serial-Port-Arduino-Pro-Mini-DTR-CTS/232332623388?rt=nc&_trkparms=aid%3D222007%26algo%3DSIM.MBE%26ao%3D2%26asc%3D44040%26meid%3D8f2518c113dc467ca4138ad761bc059d%26pid%3D100005%26rk%3D1%26rkt%3D2%26sd%3D272917463767%26itm%3D232332623388&_trksid=p2047675.c100005.m1851

 

The finished board appears here:

 

 

Note the LED jumper that can be used to disconnect the “built-in LED”. The connecter for the adapter is just part of a DIP IC socket that I cut down. The adapter connects (per the illustration in the seller’s page) from DTR through a 0.1 mfd capacitor with a 10k pullup resistor to the 328’s reset (pin 1) pin. Also connected to this pin are the ISP reset line and a manual pushbutton. The red jumper breaks the adapter’s reset line but was not really needed. The red “Power” led is also superfluous since the Serial Adapter has one.

 

                The 328PU CPUs that I bought were without a bootloader so I put them in my UNO and flashed the bootloader and the Blink program. When I fired up my creation the Blink program ran but I could not get the serial adapter to work despite several attempts. My biggest problem was not really knowing how to configure the adapter or the CPU. (I had already installed the USB driver in my PC and confirmed that the adapter was working via a loop-back test.)

 

                Since there were so few choices in the Tools dropdown menu in the IDE, I concluded this was due to the choices dictated by the bootloader. I flashed Optiboot to the chip and was able to set choices as below. The serial adapter worked! Now my creation acts just like a Uno.  To upload a sketch, just use “Upload” instead of “Upload Using Programmer”. I tried a sketch that sends data to the IDE’s serial monitor and it works, but I did have to choose a different baud rate (don’t know why).

 

https://github.com/Optiboot/optiboot

 

 

 

I also bought an SD card adapter that I thought I might like to use in the future so I cobbled up a small adapter board  that allows me to plug it onto the ISP header. The SD adapter doesn’t use the ISP’s Reset pin but rather employs a separate lead to connect to the Chip Enable pin of your choice. The connectors are just cut-down pieces from my computer junk box.

 

https://www.amazon.ca/dp/B0146RS8KQ/ref=pe_3034960_236394800_TE_3p_dp_1