Uploading via serial adapter: what settings?

Novice here.

My 328 runs OK on my UNO board. I've moved it a breadboard wired correctly for use independently. That runs OK when a 5V power supply is connected.

I now want to upload a new sketch to it via my 'CH340G Serial USB to UART TTL Adapter'. But I can find no combination of settings that works' All give an error, usually one of those 'Attempt to sync...' types.
What Board and Programmer should I use please?

I don't really understand how any is relevant, as there is no longer an Arduino board in use!

(deleted)

The "board" sets parameters like the chip, the clock speed, what bootloader the IDE will assume is present and try to communicate with. So if you took your working chip from an Arduino Uno, you should select Arduino Uno as the board.

If you are using a board definition with a bootloader, Tools -> Programmer is only used when doing "burn bootloader" or "upload using programmer". If using a board definition that doesn't specify a bootloader, it is used for uploads as well. In any event, you should select the programmer you are using - this is a physical device that you have connected to the chip or board that you are programming. To determine the correct programmer to select in cases where you are using a programmer, look down at it and look for a name that matches something in the menu.

Based on your description of the problem, I conclude that your breadboard is in fact not wired correctly. Possible issues:

  • You do not have a crystal and it's loading capacitors connected, or they are connected incorrectly. Sometimes on breadboard, stray capacitance is such that you must remove the loading caps, in other cases, they are required. When not using breadboard, they are always required. While it is possible to configure the atmega328p to run off internal 8mhz oscillator, the Uno uses an external 16mhz crystal. The chip is set to use this external crystal, and if it is not present, it will have no clock and be completely inert; if it is the wrong speed, uploading via the bootloader won't work because the baud rates won't match.
  • You do not have TX and RX of adapter connected to TX and RX of chip correctly (TX goes to RX).
  • You do not have the DTR autoreset connected - the DTR (or RTS) pin of the serial adapter goes to one side of a 0.1uF ceramic cap, the other side of which goes to reset. Reset must have 10k pullup to vcc.
  • You do not have power, ground, or some other essential connection correct.

Thanks both.

I finally got it working last night. By that stage I was configured with no changes to either the Board or Programmer settings that I use with the UNO itself. But I had wrongly assumed Tx went to Tx and Rx to Rx. (The second of @DrAzzy’s suggested errors.) After reversing those I successfully uploaded my sketch.

Is this approach of using a serial adaptor generally regarded as the simplest when transferring a project to an independent 328 on a b/b or circuit board? (Veroboard in my case, as a hobbyist.) Or is there an inexpensive but reliable 328 module I’ve not yet discovered that can be connected directly to a PC USB port for editing, and allows direct connection from its pins to a component board? IOW a sort of cheap, stripped down UNO I suppose?

Hi,

Terrypin:
a sort of cheap, stripped down UNO I suppose?

Wouldn't a Nano do it?

Peter

Peterd51:
Hi,

Wouldn't a Nano do it?

Peter

Hi Peter,

Yes, and plugged into a breadboard it would have the added convenience of allowing direct connection to PC via its micro USB. But on the downside it seems to me that it wouldn’t be so easy to use with a circuit board? And those I’ve looked at are still quite pricey.

I guess that now I’ve spent on an adapter it will be hard to find a cheaper solution.

Terry

Look on ebay. Nano clones are $2.50 shipped. Pro Mini clones (which would be connected via a serial adapter, and have a smaller form factor as a result of not needing the usb serial chip) are like $2 shipped.

Using the bare chip on prototyping board is fine, just don't forget the 0.1uF decoupling caps - without them the chip may hang or reset (or may not, depending on non-obvious factors). For anything semi-complicated, though I end up designing a custom PCB with SMD parts on it, as assembling boards with SMD parts can be done a lot faster once you have a reflow oven (I use a converted toaster oven)

By the way, if you like veroboard, check out my Tindie store - https://tindie.com/stores/drazzy I sell a bunch of prototyping board in a similar style, but made of real PCB material, doublesided with plated through holes instead of that single-sided phenolic stuff normally used for veroboard.

Thanks @DrAzzy but maybe I'll resume adding my sig. I'm in UK so ]"Shipping to United Kingdom starts at $6.50 (£5.07 GBP) usually confines my shopping to ebay UK and Amazon UK.

Terry, East Grinstead, UK

Hi Terry,

agreed but that’s a reasonable postage price to the UK.

I bought a Jukebox Service Manual earlier this year from a US supplier, around US$16 (A4 paperback) and the postage was close to $20…made it very expensive.

Actually as I get the Jukebox in a local auction room for just over 30 quid, it cost me more to buy the manual!

Peter