Programming ATTiny85 with VSC and PlatformIO.
HTML-код
- Опубликовано: 25 авг 2024
- - Learn how to upload programs to the ATTiny85 boards, and fix
' Could not find USBtiny device (0x1781/0xc9f)'
'Error 3221225781'.
I take you through the set-up of Visual Studio Code with the PlatformIO extension installed, and show you how to fix the errors I encountered.
The Platformio.ini text is 'upload_protocol = micronucleus'
The link for the USB driver installer is zadig.akeo.ie/
When looking at the LED you'll probably see that it flashes too fast. This is because the compiler assumes the wrong frequency than what has actually be set via the fuses.
Adding the following lines to the platformio ini file you can set the boards frequency to internal 8MHz and also tell the compiler that it is set to 8MHz:
board_build.mcu = ${env.board}
board_build.f_cpu = 8000000L
board_build.clock_source = 6
Thank you. This is something that hasn't affected me yet, but could be useful to others.
Hi Richard, thank you so much. I’ve had the platfomrio upload error:
“ avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)”
have tried all kinds of ways and spend also hours searching.
Finally found your video and information about the platformio.ini file with the additional input
upload_protocol = micronucleus
and so that made the upload finally work.
Thanks again!
It makes it all worthwhile to know I've helped someone.
Thank you! I fought with Arduino IDE and couldn't get this to work. VSC worked perfect.
You are very welcome!
Great Video ! You saved me quite some time figuring it out my self. Thank you so much for that :)
Hi, thanks for this video. I thought this would save my day but unfortunately this does not work for me. The first part, wrt the nucleus, was successful to get out of the first error but I'm still getting the second one, whatever I do to install the drivers (I've also looked at other videos with other suggestions). I've already spent several hours on this, on 3 different computers, so I guess the issue may come from the Attiny85 devices. They are really looking alike yours, except I'm not seeing any HW (HardWare?) info on the board. Any idea on what I should try ? Thanks.
Is the device visible in Windows 'Device manager' ?
@@richardlangner Hi, thanks for your answer, I really appreciate. It comes as Unknown Device #1 and still after running Zadig. 😞. This evening, I have uploaded a bootloader to the device, using an Arduino as an ISP, and am still getting the issue. I can see the device was reset after bootloader upload, and the blink program that came with it is as expected no longer there but I cannot pass the second error. If I uninstall the device and start again this does not help. I need to find the way to remove the drivers and install again, as currently when I try to update the the driver, (using digispark drivers this time) the systems tells me there is no better driver to install.
@richardlangner, you know what, I've managed to make it work!!! (at least once ;-) ...). Not sure what I've done differently from the past trials though, but eventually I ended up having Digispark Bootloader under libusb-win32 devices in the device manager, and then I could upload my code. Believe me, I've spend hours and hours trying to make this work, whereas I thought this would be a matter of minute when I discovered your Video and I passed the first error message. I think key was to reboot in the middle of my experiments of updating/removing/deleting devices/drivers etc. At least this has worked once, I hope this is now going to work again as I'm eager to start working on the real meat of my project !
Now I'm afraid of stopping my computer or removing the device ! Hopefully this will continue to work OK.
As a result, you got my thumb up 🙂 If I could I would have given 2, even if Zadig was unsuccessful so, not sure what has installed the correct drivers. Using Zadig several times (it always ended up with successful but in the details log, many errors), or going through manual installation, pointing at downloaded Digispark drivers. Eventually, the result is there.. Too bad this is already past midnight, too late to continue, but not to get a drink to honor this victory 🙂. Cheers!
I'm really glad to had some success. I must admit I struggled to find how to install the board driver. Zadig is a useful tool, and it's best to reboot after using it to ensure the new driver is seen by Windows.
If you need to see all USB drivers’ details - a great tool is USBDEVIEW (www.nirsoft.net/utils/usb_devices_view.html). It gives masses of information about all USB connected devices, and lets you disable/remove devices easily. Let me know what you think of it.
I had exactly the same problem. Every time I connected the Digispark to my PC, it kept connecting and disconnecting repeatedly. Then I connected the Reset pin to GND and loaded the sketch onto the Digispark. Only when prompted to plug in the hardware, did I disconnect the connection between GND and Reset. Then I was able to successfully upload the sketch.
Doing the micronucleus step works; thank you. However, my ATtiny85 doesn't show up in the device manager, and nothing happens when I install the drivers.
Ensure Zadig has the correct settings so that loads the correct drivers. Remmber to to refresh Device Mangler.
@@richardlangner my device doesn't show up in Zadig. Regardless, I installed the same drivers as per the video, but it has no effect.
@@nabilandadamslaboratory3422 The ATTiny does not have a hardware USB interface, instead it is implemented in software during the first 5 seconds of power-up. Assuming you have installed the Zadig driver, open Device Manager and watch it as you plug in the ATTiny. You will see the device name pop up as a device for the first few seconds, then disappear. The trick is to follow my video - start the upload then after a second or two plug in the ATTiny. Let me kknow how you get on.
It works, thanks!
It's always nice to receive thanks for my effort. It may be worth subcribing as I have more videos to release concerning micro-controllers and VSCode.
Thank you Rich! Very helpful. My driver installation with zadig timed out, but seemed to have worked fine once I restarted my computer. Any trick to getting serial monitoring to work?
I'm glad you got it working. The ATTiny85 does not have serial hardware. If you have pins and program space spare you can do it in software using "SoftwareSerial.h". See docs.arduino.cc/learn/built-in-libraries/software-serial
On the offchance anyone sees this since this video was released a while ago
What should I do if, when I plug the device in, the computer doesn't recognize it, so it just leaves me with the "please plug in the device" message?
Hi Linda. Did you connect the ATtiny only after the request to plug it in?
Is the ATtiny new, or have you tried another? Please let me know.
@@richardlangner Hi, thank you for your quick response. At first I had it plugged in so I unplugged it and re-plugged it as you said in the video.
The ATtiny is new, yes.
@@lindalaufer2949 I assume you followed the video and installed the USB driver. My method worked for all the devices I have tried. If possible I would try another ATtiny on another system. There may be something peculiar about your device, it's difficult to tell without trying. The devices sometimes come with an LED flasher program, and when powered up the ATtiny normally waits 5 seconds or so to see if it's going to be programmed. After that it will not respond to programming as the software serial is turned off. Try various substitutions and let me know how you get on.
Hi Sir, do you also know how to upload in Linux? Zadig doesn’t exist in Ubuntu
I don't normally use Linux, sorry.
Thanks!
Outdated, does not work. Please update video or take down.
The part of updating the drivers is valid though, but the micro nucleus directive doesn’t work. Just use USBTiny.
Thanks for the feedback. I will look into this and update the video as required.
How many mb of code I can use?
ATTiny85 has 8k flash, 512 bytes RAM. Plenty for small projects like neopixel controllers, etc.
Data is here www.microchip.com/en-us/product/ATtiny85#document-table
well i use an arduino-uploader, maybe you add your micronucleus to the video title
Thanks for the feedback. I have not used micronucleus but it looks very useful to burn bootloaders.