How to make a standalone ATMEGA328 but connect to PC via USB?

Hey! I am currently making a midi controller with my Arduino and wanted to make it standalone. I have made Arduino ATMEGA238 stand-alone projects by themselves and have a USB burner for it (Paolo) although I have never connected a usb to a stand-alone because they’ve never required it. are there certain pins I can connect it to? Is there a certain usb cable I need to buy and strip one side of? Will a scrap usb cable work? Any information helps.

Thank you!

You need some of these modules:
image
CH340G USB to UART modules.

Edit: I was going to write more but due to some work I submitted and went thinking that the rest you might research and know....Sorry :slight_smile:

1 Like

…or similar.

Your PC talks serial over USB, and the ‘328 only talks TTL serial..

It’s necessary using the module to convert the TTL serial into packetised USB for your PC.to see as a virtual COM port.

Beyond that, you’ll need to burn a bootloader, or provide ICSP pins so you can load your program into the chip… remember to expose the RESET pin, so the programming cycle can restart the processor.

...and then just include a header on your standalone board for it to plug into... like this example

1 Like

Thank you so much! (To everyone else aswell)
I found that here- CH340G USB to UART Converter
Although, is there any cheaper route to this? The reason I went about using plane ATmegas is because I didn't want each project to cost $13 for an Arduino Nano. This Module costs about $7 and I'll need to order a few at a time because of shipping (I just wasn't considering spending that much on this project or now for that matter). Do you have any alternatives you know of? If not, I'll just buy some. There are 2 packs for $8 on Amazon aswell, so I could so with that. ( Here is that product - https://www.amazon.com/IZOKEE-CP2102-Converter-Adapter-Downloader/dp/B07D6LLX19/ref=sr_1_3?crid=3O8TRW94U8IVV&keywords=ch340g+usb+to+uart+module&qid=1642678269&sprefix=ch340g+usb+to+uart+modules%2Caps%2C205&sr=8-3 )

Edit: There are also these: https://www.amazon.com/HiLetgo-FT232RL-Converter-Adapter-Breakout/dp/B00IJXZQ7C/ref=pd_sbs_1/130-9966877-8049459?pd_rd_w=65fju&pf_rd_p=0a3ad226-8a77-4898-9a99-63ffeb1aef90&pf_rd_r=WZTWSA13T100VRSPDV6T&pd_rd_r=f6355cc4-d971-48a3-ae2e-360cc8dd4037&pd_rd_wg=tOqPY&pd_rd_i=B00IJXZQ7C&psc=1

Thanks!

Appreciate that

You could use a chip that has built-in USB support, such as an atmega32u4 (used in the Arduino Leonardo and the pro micro) instead of the atmega328.

1 Like

Ah okay. Thank you. I found that on Digikey for $5 a piece.

Would you say there would be something wrong with making the FT232RL board yourself?

Either this or the CH340G Chip.

Remember you on,y need one single USB-TTL module.
You simply move it between target devices as you’re uploading code or using the serial for configuration.

Or, forget the USB requirement completely and as mentioned, simply burn the hex into the targets using the ICSP programming capability. (You would have developed and debugged on a similar hardware module with aUSB capability… then take that’working code’ (hex file) to your production boards.

I thought the purpose of these were that you were hooking them up to a project? I think you all misunderstood, I should have been more detailed about what I was making.

I am making a midi controller with an Atmega328 Chip. My problem is that for the midi controller to work, it must be hooked up to the computer at all times. But I don't want to use my Arduino Nano and just have it sitting with this project for ever. What would other alternatives be? I assume the only other option would be the USB CH340G.

Wait I'm sorry, what do you mean by "burn the hex into the targets"?

7$ for 1 CH340G module....That's a bit overpriced for a chinese chip. In India, I'm getting it for around $1-$2 each... You can also get cheap Arduino Nano clones for around $3-$5 each. I think you need to check on Aliexpress-many people order it from there... You can also try the Raspberry Pi pico (4$ Microcontroller board).

Yes Many alternatives are there like CP2102, FT232RL,PL2303 etc.

Just search a bit more and you may get "USB to TTL modules" for cheap enough. I hope you know on how to burn a bootloader into a bare ATMEGA328 chip.

Also you need to download drivers for the CH340G and CP2102, you can do it from here (for the CH340G) and here (For CP2102).

Yes @Snizce you can try this out too. But @david_2018 do we need to burn a Leonardo bootloader into this?

What I know: This is the way of programming microcontrollers without a bootloader through the ICSP interface. You need some sort of cables like this to program. Then you can use one Arduino or a USB AVR programmer like this.

What I don't Know: I have never used that method, don't know how to generate a .hex file from a .ino file (maybe that requires Atmel Studio?). I still use the USB method because it's easy for me.

If you can and that is cheaper for you then nothing's wrong. I never tried making one because buying modules is always cheaper in my country.

Regards.

Yes. Aliexpress.

Yes. Using a FT232!

The ridiculously obvious solution to your whole absurd question.

Buy a second Nano (clone)!

Would have posted before you but doing research, the Nano prices on Aliexpress seem to have become quite absurd - and the Aliexpress search engine is even more useless than it used to be! :astonished:

In India , Aliexpress is banned. I just forgot about ebay bcz that also doesn't seem to deliver cheap products from china yet. I just wrote without any research, I agree :grin:.

Things have been changing a lot since Wuhan affected us. :roll_eyes: Back and forth.

I used to get stuff on eBay. Now I only use it for things from here in Australia. Most of the stuff on the slow boat from China has been much cheaper on Aliexpress but the search engine is unbelievably broken.

Specifically, the price of Nanos seems to now be outrageous, but I did then find that one I linked on eBay at a plausible price - and certainly vastly more sensible than mucking around with a "bare bones ATmega328" and adding a USB-serial (not "TTL") module.

By no means whatever was I criticising you for lack of research. :grin:

Thank you everyone! I will end up trying one of these FT chips but for the time being I ended up purchasing a pack of AtMega32u4(s) because they’ll be sensed as MIDI Controllers without external software.

Thanks for all the help and information!

For whatever reason, you really are trying to do it the hard way! :grimacing:

Lotsa luck! :grin:

I’m sorry, I meant sometime in the future I will try that. I just enjoy doing things from scratch. But for now I purchased some Atmega32u4(s) haha

Did you buy the bare chips? Maybe you need to burn the bootloader....I have not used any Atmega32u4 yet so I don't know....Can somebody help?

Well again, if you insist on buying "raw" chips, you either need to burn a bootloader to match the chip, or provide an ICSP interface for all code uploading.