The Cheapest Microcontroller? Getting started with the 10 cent Puya PY32.

  Переглядів 37,419

Zach of All Trades

Zach of All Trades

День тому

The Puya PY32 is an amazingly cheap 32-bit microcontroller with an ARM Cortex M0+ core. These parts can be had for under 10 cents each in modest quantities, making projects requiring large numbers of microcontrollers affordable for us DIYers.
This video gives a brief introduction to the Puya PY32F0 series of microcontrollers, starting first with the benefits and drawbacks. I’ll then discuss the four options available and their respective features and cost. Next, I’ll go over the software and hardware tools needed to develop code and program these, including details on how to set up the software. Finally, I will show two demonstration codes to prove that these microcontrollers work as advertised and are relatively straightforward to use. First, I’ll do a classic blinking LED test using the onboard LED and one of the timer peripherals. The second example will use the internal analog to digital converter (ADC) to read an analog voltage and send the result out over the serial UART peripheral.
Check out these previous videos where I’m putting the PY32 to use:
Programming the PY32 for the tile backsplash project: • Programming the Smart ...
Introduction to the smart LED tile backsplash project: • LEDs, Microcontrollers...
Chapters:
00:00 Introduction
01:40 Why you might want a 10 cent microcontroller
06:12 The PY32 options
08:43 Getting started with uVision
13:53 Blinking an LED with a timer example
16:55 Reading an analog voltage and sending the result over UART example
19:42 Conclusion
The code used in this video can be found in this repository:
github.com/AllTradesZach/PY32...
The microcontrollers can be procured from LCSC here:
www.lcsc.com/products/Microco...
The development board:
www.lcsc.com/products/Develop...
Some of the tools I’m using in this video can be found here:
ST Link V2 Clone: amzn.to/4arg6u1
Official ST Link V3: amzn.to/4auZe5G
Quality Breadboards: amzn.to/43wJw82
As an Amazon Associate I earn from qualifying purchases.

КОМЕНТАРІ: 87
@lohikarhu734
@lohikarhu734 8 днів тому
I've built stuff, and designed IC's to use in 500 million volumes... Part of the cost calculation goes to a bunch of factors, not least of which are assembly cost, passive components needed, PCB area and technology, connectors, and, believe it or not, production test. So, for high volumes, if you need anything outside the MCU, like capacitors, crystal, resistors, transistors (driving actuators, indicators). In one device case, we were able to build in quite complete self test capability, which saved almost 1/2 the price of the device, in reduced production test ( tested not just the device, but most of its connected components), and we "designed-out" current setting resistors, I2C pull-up resistors, and provided enough drive on the device to handle 95% of use cases... Sorry to blather on, just wanted to bring out some of the "stuff" that needs to get put into the "system cost" consideration. But, still, the amount of logic, or mechanism, that can be programmed into 10¢ !
@lohikarhu734
@lohikarhu734 8 днів тому
As much of a whiner as I can be, your video is very nicely done ... Good style, and good pacing... the one thing that I find, in many of this kind of video, that it would be nice to "zoom in" a bit on the screen images of the development setup. Sonst, prima.
@AllTradesZach
@AllTradesZach 8 днів тому
Thanks for the suggestion! I'm definitely learning here, so any constructive feedback is welcome
@AllTradesZach
@AllTradesZach 8 днів тому
I definitely see where you're coming from. I'm one of my earlier videos I discussed the engineering tradeoffs for the project, and had a lot of the same thoughts you're alluding to. My day job is in a high reliability, high quality field, so BOM cost isn't something we even worry about. In my earlier video though, i mention spending more on passive components than active components, which was absolutely true! Good quality caps and resistors add up!
@murraymadness4674
@murraymadness4674 7 днів тому
Indeed, as a DIY'r the first thing I look at is how many external components do these chips need. I really like the attiny202 because it needs NONE, and I'm using it now with its sdi to interface to a 2.4ghz radio to do very simple stuff. I previously used the msp430 back when they were new, which still needed a couple caps, but really needed a crystal for consistent timing. Although today when you can have small quantity of boards assembled in china, they can put on those external parts, which cost pennies instead of assembling yourself which is very painful for tiny smd parts, which everything is now. I got the ch32v parts recently to test them, real cheap and has so much more than an attiny. I have a new project to switch on/off hundreds of leds, and the ws leds are not bright enough, so the easy way isn't possible.
@lohikarhu734
@lohikarhu734 6 днів тому
Cool...as I said, overall very good video!
@RGormanJr
@RGormanJr 15 днів тому
As an older GenXer, I laughed when you said that 10¢ could buy half a GIGAbyte of storage. I can honestly remember the days when computer scrappers would pay a few bucks per MEGAbyte for non-working hard drives. (Of course an actual working drive cost hundreds of dollars per MB)
@AllTradesZach
@AllTradesZach 15 днів тому
You know, I almost left that one out, 'cause when I calculated that I realized just how cheap flash storage is. But then I remembered that each of these videos takes at least a quarter terabyte of storage, so I suppose it's all relative.
@musiqtee
@musiqtee 8 днів тому
My studio boss got mad at me for the invoice of four MB of RAM for our Atari ST. The set of four chips cost a little over $450 in 1989 - More than the actual computer… 😅
@lohikarhu734
@lohikarhu734 8 днів тому
In about 1980, one could buy a MASSIVE "Winchester" hard disk, even including the control board, for only about USD $2200... for.. 10 Megabytes! $220 per Megabyte !
@edwardfletcher7790
@edwardfletcher7790 7 днів тому
​​@@musiqteeyeah, that's 8x the standard RAM !! LOL I remember getting a 16mb Ram stick for my Amiga in the late 90's for US$150. I paid the same for a secondhand 200mb HD in the early 90's👍😁
@eightsprites
@eightsprites 6 днів тому
Had a 50mb harddrive in my Amiga 2000. No idea what that costed. Much I bet. Thanks dad ❤.
@edwardfletcher7790
@edwardfletcher7790 7 днів тому
Cortex M0 is a powerful little chip!
@cpk001
@cpk001 14 днів тому
Looking forward to future videos
@user-lx9eg4yv5p
@user-lx9eg4yv5p Місяць тому
YES!!! Thanks for the upload Zach! Still tuned & sub'd for the whole project! (and any others you may think of in the future!)
@larsu1212123
@larsu1212123 Місяць тому
Hey, I've been waiting for the follow-up, ever since your video on the "Backdrop" panels. Keep up the great work!
@larsu1212123
@larsu1212123 Місяць тому
RP2040 is a bitt more comlex than the ~1$ controller. You still need NOR Flash, which sets you back around another dollar in small quantities. And at that pricepoint, competition of the esp32 series is getting relevant. Thus, even the more "expensive" PY32s may be worthwile, in my opinion.
@AllTradesZach
@AllTradesZach Місяць тому
Thanks! You bring up a fair point with the RP2040 also needing a flash chip. The size of the RP2040 plus a flash chip is also substantially bigger than the QFN-16 PY32. I don't know about you, but when I get charged by the square inch for boards I make them as small as I can! For the backsplash project in particular size is very important. I think the -F030 has a compeling feature set for general purpose use and is a steal at 30-40 cents each. If it's true that the -F002A is the same die and can be convinced it is actaully a -F030 then that would be the real bargain.
@mytechnotalent
@mytechnotalent 7 днів тому
Incredible Zach!
@WessieNC
@WessieNC 6 днів тому
I find this chip very useful and interesting. Thank You.
@MrVipulLal
@MrVipulLal 5 днів тому
Eye opener video. Many thanks
@omar_l_p
@omar_l_p 8 днів тому
Muy buen video!! Simple e informativo.
@stefanguiton
@stefanguiton 7 днів тому
Great video
@mehmetkendi6067
@mehmetkendi6067 7 днів тому
Thank you!
@andymouse
@andymouse 8 днів тому
Interesting stuff, all the setup work is above my paygrade at the moment, fascinating nonetheless....cheers. Edit: oh yeah 'PB5' same port and pin on the Arduino Uno for the built in LED.
@manfredbogner9799
@manfredbogner9799 9 днів тому
Very good
@Bianchi77
@Bianchi77 9 днів тому
Creative video, thanks :)
@WallaceRoseVincent
@WallaceRoseVincent 4 дні тому
Hey Zach, I have a useful idea for the microcontroller that fits your channel. Since you are a jack of all trades then would a controller that monitors your ac system on your house be useful? A monitor system that helps you see ac problems before the turn catastrophic. It would be mostly temp sensing.
@choppergirl
@choppergirl 7 днів тому
I wonder if you could add input and output to convert this to the equivalent of an old mainframe.
@klassikkustard4828
@klassikkustard4828 4 дні тому
Commented cause i loved this
@RWBHere
@RWBHere 4 дні тому
Ten cents for all of that capability? I remember paying £100 for a megabyte of RAM and thinking that it was a bargain price. How times have changed.
@qnaman
@qnaman 8 днів тому
I've bought about 58 LGT8F328P - LQFP32 Boards of different kinds and they work as regular pro mini and are faster. But initally there was serious problem with libraries for them. Once I almost burned mine programmator, because one of pins started sending singnals through pin which works as input - which lead to shortcircuit.
@GnuReligion
@GnuReligion 8 днів тому
Oh, the Logic Greens? I have some of those atmega328 sorta-clones ... both the 20-pin and 32 pin. The ADC is superior on these, but still mystified that they did not make true clones, instead of these semi-compatible things, or something completely new.
@nguyenthinh6188
@nguyenthinh6188 8 днів тому
I agree, py32f002 is cheapest arm mcu can buy at here. Yes 4600vnd for 1 unit, easy to program via dap,stlink clone,etc...
@nguyenthinh6188
@nguyenthinh6188 8 днів тому
Fmd60 cheaper but programmer of that 8bit mci not cheap
@parthsahni8952
@parthsahni8952 4 дні тому
Very good and informative vid! im ur 700th sub lol
@LifeGeneralist
@LifeGeneralist 9 днів тому
Helpful!
@saddle1940
@saddle1940 8 днів тому
I had to smile when you described over several minutes, thee code needed to flash a led. It reminded me of the joke about the king and the toaster design. Even with interrupts, I'd be thinking under a minute with an arduino before youd be flashing the chip. So much prewritten code and definition files, i worry about code errors made by others, but thats the cost of wanting things like USB to work from libraries.
@etmax1
@etmax1 5 днів тому
RP2040 has no internal Flash and only uses SPI Flash so it has to load the program or bits of program into RAM, reducing how much RAM you actually have for data so your comparison is a non starter in my opinion. What I do really like about this device though is that it's ARM M0+ rather than the somewhat inferior RISC-V. In my opinion the only thing RISC-V really gives you is the cheap FPGA synthesis. What I find interesting here is check the price out of an RTC chip compared to these micros. Obviously you need to be able have low power and a low power 32 kHz crystal connection, but basically you get about 5-10 of these for 1 RTC. I used to use MSP430 family devices as RTC's because they were 1/3 the price of an RTC. We use cheap micros for all sorts of glue logic because you can replace 100 or more logic gates with one of these for a fraction of the cost and PCB area if you don't need fast logic. Oh one last thing, when listing all of the serial options it has, I thought I'd mention that a lot of MCUs have shared HW for the various serial engines eg. the SPI Tx register and UART Tx Register could be the same HW meaning if you use SPI you're down a UART channel. It's not exclusively so, but just something to watch out for.
@AllTradesZach
@AllTradesZach 4 дні тому
I agree on the RP2040 not having flash, I probably should have mentioned that. I do still maintain that it is a powerful chip for 80c (+50c or so for a SPI flash), but needing that flash certainly makes it bigger and more expensive. I'm excited for RISC-V in the future, but so far I haven't seen anything that has made me make the jump. I definitely appreciate open source, but I haven't really seen RISC-V parts being drastically cheaper than ARM parts. This part is probably the cheapest way to get any of the peripherals! I can see using it just for the ADC, or as a GPIO expander, or as a serial translator. Hmm, I'd have to double check to see if there's any conflicting peripheral hardware. So far everything I've run has been fine, but I've not used all the serial peripherals simultaneously.
@etmax1
@etmax1 4 дні тому
@@AllTradesZach I agree, the pico chip is a great bundle, and the PIO engine is really something. The biggest issue is knowing what the real-time performance is going to be for any given implementation once programs exceed the available RAM. PCB footprint with external Flash is also a factor. On the peripherals sharing pins front, that is half of it, and I had a quick look at the Puya and the block diagram "Suggests" the peripherals themselves are separate (I didn't check for pin clashes). The thing I meant was eg. Infineon has not got I2C, SPI, UART, it instead has USIC0 and USIC1 which means that the registers are shared and they have a switchable state machine to make each USIC (only 2 of them) either I2C, SPI or UART. I got stuck with this where I needed 2 UARTs and 1 I2C. Another gotcha was that I couldn't get the SPI to work fast enough to do WS2812 because I couldn't reload the SPI register quick enough to do a 840bit stream without gaps. I could with a PIC.
@marsrocket
@marsrocket 5 днів тому
How long until there is compute power in EVERYTHING and it all meshes together?
@AllTradesZach
@AllTradesZach 4 дні тому
Well, we've got smart toasters, so I'd say that time is now.
@yigitozen
@yigitozen 11 годин тому
well done YT recommendations.
@ChandrashekarCN
@ChandrashekarCN 8 днів тому
💖💖💖💖
@TheRainHarvester
@TheRainHarvester 6 днів тому
😮"wait 11:26 for it to update" oh yank-ware which may stop at any time? Is there a way to download everything to not depend on a company?
@AllTradesZach
@AllTradesZach 4 дні тому
I know, this can be frustrating. Puya revised their website when I was making this video and now some of the documentation is gone. Luckily I did download all of it locally. The packs, datasheets, and some of the tools are available right from GitHub for download though. As far as the IDE's, fingers crossed I guess...
@voidpointmedia853
@voidpointmedia853 17 днів тому
Weird fact: these can be found for free inside geek bar vapes. I recently decided to start disassembling these and found this micro controller in them which is wild being that these are DISPOSABLE VAPES. Such e-waste for no reason
@charlieRcarter
@charlieRcarter 15 днів тому
So hyped for fossilized computer chips in 1 million years
@AllTradesZach
@AllTradesZach 15 днів тому
That's quite interesting, I'd be curious to know what other products use them. They're in a bit of a weird place I think, because they're flash based and not the absolute cheapest, but also don't have the heritage/support/options of more expensive chips from STM, TI, Renesas, etc. But yes, quite a shame that the proliferation of cheap electronics has allowed society to make disposable electronics.
@andymouse
@andymouse 8 днів тому
Awesome, I have been collecting a stock of 3.7v cells from these 'disposable' vapes that litter my town ! I shall take a closer look at the controller now...cheers.
@PainterVierax
@PainterVierax 8 днів тому
most of the time, those cheap devices embed label-sanded chips that can come from any PRC manufacturer so it's not worth salvaging. most of the time they look like PIC pinouts but the programming is very different. And of course, those could be useless one-time-programming chips.
@murraymadness4674
@murraymadness4674 7 днів тому
I get the sense you reading from a teleprompter?
@Ed19601
@Ed19601 7 днів тому
The development board is about 5 USD, which is lunacy compared to and ESP32 board
@AllTradesZach
@AllTradesZach 7 днів тому
Completely agree, they were $18 at one point which is absolutely absurd. These only make sense if you're spinning your own boards, and lots of them. Otherwise I'll personally grab a nucleo.
@Ed19601
@Ed19601 7 днів тому
@@AllTradesZach I have no experience with the Nucleo but they seem like pretty decent boards
@usrrsr
@usrrsr 5 днів тому
Gr8 video and +1 subriber
@jayneatkinson2747
@jayneatkinson2747 7 днів тому
I found datasheets in Chinese a few days ago, but even they've disappeared. I'll stick with STM32
@AllTradesZach
@AllTradesZach 7 днів тому
In Chinese here: www.py32.org/mcu/PY32F002Axx.html They redid their website while I was making this video, there used to be English versions there that were quite good.
@bikkelchiefwizard1681
@bikkelchiefwizard1681 4 дні тому
at EEBLOG they mention an repository with all data sheets (also English)
@TheOpticalFreak
@TheOpticalFreak 8 днів тому
Wait whut 😳😲 is that like an AT Mega?!😮
@isoslow
@isoslow 7 днів тому
AVR stuff is 30 years old overpriced joke compared to modern micros at 1/20 of the price.
@AI-Doom-
@AI-Doom- 7 днів тому
Not available in my country (India) and import costs makes them expensive.
@amandioreal2293
@amandioreal2293 7 днів тому
This a clone of stm32f0 and use the same documentation.
@bikkelchiefwizard1681
@bikkelchiefwizard1681 4 дні тому
No the PY32F0 can run on 5V something the new ST micros lack
@stepannovotny4291
@stepannovotny4291 6 днів тому
Why do you need a HAL for something like this? The code is on bare metal isn't it? Doesn't the HAL just get in the way of actual hardware capabilities and introduce someone else's bugs?
@No-mq5lw
@No-mq5lw 11 днів тому
I honestly thought this was a new RISC-V chip. My disappointment was palpable when the reveal dropped.
@isoslow
@isoslow 7 днів тому
What's so good about RISC-V??! To me currently nothing. ARM has a huge codebase or ready-made opensource libraries for literally everything, RISC support on the other hand is nonexistent.
@No-mq5lw
@No-mq5lw 7 днів тому
@@isoslow FOSS isa lends itself to completely free resources, Verilog. Also newer ESP32 chips are RISC-V.
@LimbaZero
@LimbaZero 7 днів тому
@@isoslow With ARM cores manufacturer have to pay license to ARM. With those cheap mcu:s it can be risk if it's not paid by manufacturer. Basically all arm cores are from arm. Some have custom core using expanded instruction set but still they pay arm to use instruction set. Edit: STM and others who use ARM cores one reason why those cost more than chinese clones is that they pay that ARM license. For hobby user it can be ok to use those but to use in real product it can be problematic.
@No-mq5lw
@No-mq5lw 7 днів тому
@@isoslow Free ISA under Creative Commons lends itself nicely to free simulators, free Verilog/VHDL/etc soft cores, and the ISA itself can be customized to whatever specification you want including custom Instructions. This makes embedding a RISC-V processor in whatever you want pretty much free. For the moment though, the mid to high end performance tier RISC-V options definitely do have a lot of work ahead of them in order to get them production ready. Espressif is basically jumping ship from Xtensa to RISC-V with their next generation designs like the ESP32 -P4, C6, C3. And imagine how many devices have been shipped utilizing the *proprietary* Xtensa ISA. Just because it's not ARM doesn't mean that's stopping products from being shipped.
@lohikarhu734
@lohikarhu734 8 днів тому
"if we're really being *pedantic*..." Or, am I being too pedantic?
@Kysen10
@Kysen10 День тому
This looks like a clone chip of STM.
@nyeleskettes
@nyeleskettes 6 днів тому
This looks like a cortex clone along with the debug interface and all the drivers.
@tcurdt
@tcurdt 7 днів тому
Is there platformio support? otherwise I'll pass
@awaagrikh8331
@awaagrikh8331 4 дні тому
no for now
@pacsmile
@pacsmile 17 днів тому
everytime you said 10 cent i thought you were saying "tencent", the chinese company
@hitension7
@hitension7 7 днів тому
You buy cheap, you buy twice! This video looks like paid ad.
ESP32 Guide 2024 | Choosing and Using an ESP32 Board
41:06
DroneBot Workshop
Переглядів 201 тис.
EEVblog 1524 - The 10 CENT RISC V Processor! CH32V003
19:55
EEVblog
Переглядів 298 тис.
0% Respect Moments 😥
00:27
LE FOOT EN VIDÉO
Переглядів 33 млн
Спектакль для окупантів та ждунів 🤯
00:47
Радіо Байрактар
Переглядів 546 тис.
How This New Heat Pump is Genius
18:03
Undecided with Matt Ferrell
Переглядів 475 тис.
PCMCIA Cards Hiding in Linksys Routers
34:46
clabretro
Переглядів 265 тис.
The simple, clever sensor behind automatic windshield wipers
11:18
Technology Connections
Переглядів 783 тис.
An Impact Proof Ionic Thruster Inspired By Nature (BTC Mark 3)
16:06
Plasma Channel
Переглядів 433 тис.
The Raspberry Pi Pico WAS Overrated! But that changed!
10:18
GreatScott!
Переглядів 581 тис.
You’ve Never Seen WiFi Like This
20:43
Data Slayer
Переглядів 242 тис.
Use the very attractive new ATTINY chips for your projects
14:34
Andreas Spiess
Переглядів 190 тис.
I tried the Cheapest Arduino Alternative (that Nobody heard of)
13:31
GreatScott!
Переглядів 462 тис.
Make Dumb Electronics Smart for $3
13:13
I Like To Make Stuff
Переглядів 283 тис.
''Бесплатные умные'' домофоны для глупых людей. За чей счет банкет?
12:48
Вадим Шегалов.Оккультные игры элиты
Переглядів 32 тис.
''Бесплатные умные'' домофоны для глупых людей. За чей счет банкет?
12:48
Вадим Шегалов.Оккультные игры элиты
Переглядів 32 тис.
Rabbit R1: Barely Reviewable
19:53
Marques Brownlee
Переглядів 7 млн
Эволюция телефонов!
0:30
ТРЕНДИ ШОРТС
Переглядів 2,7 млн