top | item 19851744

The Amazing $1 Microcontroller (2017)

670 points| howard941 | 6 years ago |jaycarlson.net | reply

195 comments

order
[+] neya|6 years ago|reply
My favorite is the ATTINY 85. It's so cheap and yet, it can do almost most of the things you can do an Arduino. And yes, you can program it using the Arduino IDE as well.

Last year, I started out to digitalize my entire house with these tiny ATTINY 85 chips and with some nrF wireless chips. It has worked really well for me and I'm able to control and monitor any power port in my house as well as my mains.

The overall setup still costed less than a Nest, yet, vastly more powerful. Of course, the downside is you need to write code, have a running server to control it on the cloud. But, no problem for me as I'm a (Google Cloud) consultant and this is what I do for a living.

I use Google Cloud's IAP with AppEngine (I may switch to cloud run now, since it's cheaper tho) and I have a private REST server running that I can access from my own Android app.

The whole thing took me a year to finish, but that's because I worked on it maybe once or twice a week in the weekends and didn't focus on it much.

But, my effort has paid off and it's amazing to me that what is possible with just a dollar investment.

[+] 83|6 years ago|reply
As someone building up some home automation I'd love to know how you are monitoring and controlling power. Remote power strips? Replacement outlets? Something diy?
[+] cr0sh|6 years ago|reply
Are you in the United States?

I'm just curious how your homeowner's insurance feels about this? That is, will they still pay out for a claim should something happen, and they determine your modifications were at fault?

Because if the adjuster or whomever does find you have such modifications - they -will- blame those.

And probably deny your claim and coverage (and probably cancel your policy).

At least that would likely be your experience if you live in the United States.

I've often thought that having such a system would be fun, but the potential downside should anything go wrong has put a damper on it (even if whatever happened was not related to your modifications - they will blame it on them, just to get out of the claim).

The only "inexpensive" way around it is to use UL listed interfaces made by a third party, then interface with those. But there, you don't usually get everything you want.

Of course at that point, the insurance company might just shift the burden on you to "So, did you have this done by a licensed electrician? Where is your inspection report?"...

[+] microtonal|6 years ago|reply
My favorite is the ATTINY 85. It's so cheap and yet, it can do almost most of the things you can do an Arduino. And yes, you can program it using the Arduino IDE as well.

How do you deal with the small number of pins? The NRF24L01+ uses SPI, which requires 4 pins. There are some guides on how to hook up an NRF with 3 pins. I think that only leaves 3 pins (besides VCC and GND)?

The ATtiny seems to be very attractive otherwise, because it works across a relatively large voltage range and does not use a lot of power.

Did you consider the ATtiny84, which has double the GPIO pins?

[+] praveenster|6 years ago|reply
This sounds really interesting and is something I’ve been meaning to do for my house as well. Do you have a blog post with the details or a github page?
[+] amingilani|6 years ago|reply
What? How? Explain please. I've been interested in this for a while, and I know how cheap the ATTINY85 is but I just started experimenting with the Arduino, and just got a relay to switch on/off. Still learning how to get the ArduoCAM to work, and how I can transmit images over WiFi.

My point is, can you link to a tutorial? I'm a newb, but I'm a fairly competent full-stack developer.

[+] penagwin|6 years ago|reply
What's your experience with running your server non-locally? Not judging, just curious as usually those that DIY their home automations are also into homelab stuff and setup a spare laptop or something for the server.

Derp - You're a cloud consultant, oh okay haha. I'm guessing your home ISP network is pretty reliable then? I'm stuck on con-cast so unfortunetly I have to be prepared for occasional high-packet loss/no internet situations. They're fairly rare, but I want to make sure my lights can be controlled 24/7

[+] tmaly|6 years ago|reply
What does your programming environment look like for programming these chips?

Do you have any blog posts showcasing your project?

[+] so_tired|6 years ago|reply
This is such a great setup.

Maybe if we just put 10 of these mini-controllers in each home, we can cover the majority of electricity consumption, and get demand flexibility the cheap way (instead of fitting each home with an expensive smart meter).

(Obviously the cloud/app parts will have to be centralized with consumer opt-in and preferences etc..)

Have u thought about this ?

Has this approach been explored ?

great project..

[+] yeahitslikethat|6 years ago|reply
I'm doing the same thing now. I bet your people think you're as crazy as my people think of me.

My other friends are spending thousands of dollars retrofitting lighting and everything when they could spend a fraction and write some code.

And learn a skill. And not have their privacy invaded. And have more money they always complain about not having enough of.

[+] kickscondor|6 years ago|reply
Totally with you. The tiny original Digispark (with the USB traces on the board itself) is my fave - I use them for teaching school clubs and personal projects/gifts. If I need to go beyond that, it usually means straight to the ESP8266 or ESP32. But that's pretty rare. (With you on the nRFs, too!)
[+] merpnderp|6 years ago|reply
How are you switching mains power safely? I looked into it, but gave up when I realized I'd have to install a rectifier in the wall which just seemed like a fire waiting to happen.
[+] stevetodd|6 years ago|reply
Do you have any write ups or code on this to share?
[+] nerfhammer|6 years ago|reply
I've been using the attiny84, iirc attiny85 doesn't support the lowest of the low power modes
[+] saagarjha|6 years ago|reply
> the downside is you need to write code

You might call that an upside!

[+] dhruvkar|6 years ago|reply
Sounds fascinating!

>> yet, vastly more powerful

What's sorts of things can you now do with this setup?

[+] blhack|6 years ago|reply
I feel obligated to mention in every one of these threads the wemos D1.

I actually have a tough time explaining just how incredible this board is. You can program it in the Arduino environment, meaning if you are doing any hobby electronics, you're probably already really familiar with the programming modalities.

It comes with a programmer, and power regulator. No fussing with anything like you might have to with a bare ESP8266.

It also has WiFi. It is the magic internet of things that I swear everybody was dreaming about 5 years ago. Go buy 10 of them. They're my favorite favorite favorite general purpose dev board right now, and actually they're so cheap that I have no problem putting them into "finished products"[1].

Here they are for about $3: (https://www.aliexpress.com/item/ESP8266-ESP-12F-CH340-CH340G...)

[1]: I build custom/one-off large scale installation pieces and hardware prototypes. Almost every single one of them has an arduino-ish device in it somewhere.

[+] gmiller123456|6 years ago|reply
I actually prefer the Wemos D1 Mini. The D1 you linked has the same header layout as the Arduino, which might confuse a lot of people that you can use Arduino shields. Some of them might work, but probably not without modifying the libraries for them.

The D1 Mini actually has it's own shield format, and several shields are available. Even experienced people will find value in the ability to just plug in a display, or other device and use already available libraries. Maybe not great for production work, but great for prototyping and learning.

I think the big downfall with any ESP8266 board compared to others is going to be power consumption, even with WiFi off. So anyone not plugging theirs into a wall should do some research in that area.

[+] Taniwha|6 years ago|reply
I give these away to local kids - on aliexpress $5 buys you a baggy containing a D1, a proto board, wires, resistors, LEDs, temp/light sensors, switches ....

Great value - program them as if they were an arduino

[+] quickthrower2|6 years ago|reply
I'm using a ESP8266 board from a local shop, $17, I knew you can get cheaper on Ali but starting out I like not to wait and not worry so much about quality. However I will look into these for future boards.

I set up a thermal sensor that updates a Parse (remember them!) clone. Working well but sometimes it just stops updating, not sure if it is the device or the Parse clone's fault or a bit of both. But it works nicely for a day or so at a time.

Just a reminder things might not go smoothly with these devices, they are tricky to debug if they crash. When you are communicating via http the apis are not as nice as I am used to on the desktop.

[+] wolfgke|6 years ago|reply
> I feel obligated to mention in every one of these threads the wemos D1.

Does there exist a similar board with an ESP32?

[+] sickrumbear|6 years ago|reply
this looks really cool! any project write-ups online that show how it can/ is being used?
[+] xondono|6 years ago|reply
my takes from my +10 years on this sector:

- Unless you are building something with high volumes (or something trivially easy), development costs are going to be your biggest expense by far, specially firmware/software.

- Using cheap parts is nice, and if you come from the DIY world you will know many such parts. If you are going to build something commercially, avoid those things like the plague, because they will become the biggest sinkhole of technological debt.

- Software/Apps behave like high-risk investments (natural monopolies, zero-or-nothing situations, low initial costs), electronics behaves more like long term investments (high initial costs, high development path dependency). It's way more profitable to have a product you barely have to touch (but sells well), than several that need constant modifications.

Which leads me to some tips:

- There's not much sense in 8 bit / 16 bit microcontrollers for most projects nowadays. Don't fear going to 32 bit.

- MIPS/AVR are nice, but if you are building something that is not a one-off (or you plan to build on the product), go with ARM (for now).

- Build your PoC and prototypes on manufacturer libraries, but once you have the resources for it, well-thought and tailored libraries will make your life easier.

- When working on libraries, don't write them directly from the datasheet. Go for the family references, target the whole family instead of a single chip.

- Before chosing any component, specially the ones that are hard to replace, price is secondary at best. Availability is way more important.

- If you are willing to take some risk, look at Rust for embedded. The language is still 'young' and there's a lot of stuff that needs to settle down, but man, does it look good.

[+] d21d3q|6 years ago|reply
And for PoC pick one with more memory - e.g. you can find chip (like stm32f0x1) with same pinout, peripherals - you can optimize that later, and don't worry about it while using fat libraries.
[+] iheartpotatoes|6 years ago|reply
Having used half the IDE's this person outlined, I really really really really wish every single one had a "write Makefile" option. Maybe 1/4 or the IDEs I use do that successfully. I always end up using GDB for debugging, and then the IDE for asm-level tweaking (well, I don't do the tweaking, someone smarter than me does :), but I can do 90% of my work in GDB).

In the "real world" IAR Embedded Workshop is the hands-down winner (licenses are $$$$$$), which is unfortunate because despite being so mature it is awfully clunky.

[+] imagiko|6 years ago|reply
Agree so much. Every project I run, I start off working with the available IDE (Keil, Eclipse) that the manufacturer likes and then take the effort of writing a Makefile for it. Absolutely hate dealing with IDEs and their buried settings! Terminal, code editor and gdb FTW :)
[+] ChuckMcM|6 years ago|reply
This was well done.

As I have mentioned in the past, my discussions with people at Microchip and Motorola have conceded that with modern process technology the cost of the silicon is insignificant compared to the cost of packaging and testing. As a result you get to about $1/chip in singles as the low price cut-off but you can put an 8 bit, 16 bit, or 32 bit processor in there and it doesn't change the cost. It can cost more if you add a lot more FLASH or RAM. That takes up silicon real estate and is longer to test so it can reach the point where the dice is once again a meaningful contributor to the cost.

[+] patrickyeon|6 years ago|reply
I guess that makes sense, and it's not a particularly new phenomenon. The MOS 6507 (used in the Atari 2600) was mostly the same silicon as the 6502 (as used in Apple II and many other places), but cheaper because it was in a smaller package.
[+] SlowRobotAhead|6 years ago|reply
The writer was on an episode of Embedded.fm podcast awhile back, one of the rare ones where they really get into embedded in detail. Good episode, I recommend it.

Two take-aways were that he just loved the Silicon Labs EFM series, which is a modern set of peripherals wrapped around an absolutely outdated 8051. For the most part micros are just moving things from one peripheral to another and that can work out just fine. It's nice SI used SWD/JTAG as the debug peripheral so you can program it along side all the ARM parts you're actually going to use.

And two... Having used almost everything on this list. I'm going to chose the ARM M0/M0+ 10 times out of 10 anymore. Maybe I prefer STM's peripherals to Atmel's event-eccentric, or whatever. I just can't honestly see starting a new project today on 8051, PIC16/24, AVR etc. Maybe it's what you're used to. Or maybe for someone making landfill-ready toys with razor thin margins, but I'm glad that's not me.

[+] Darkphibre|6 years ago|reply
Oh, I really like his analysis on "Parametric Reach" for the various architectures:

> If you want to commit to a single architecture, it’s important to know which one gives you the most headroom to move up. I created a fictious “times better” score by comparing the the part tested with the best part available in the same ecosystem — this usually means fairly comparable peripheral programming, along with identical development tools. I multiplied the core speed, package size, flash, and RAM capacities together, ratioed the two parts, and then took the quartic root. Essentially, if every parameter is double, it is considered “2.0 x” as powerful.

[+] copperx|6 years ago|reply
I would love to see a comparison of instruction sets for assembly programming. Sure, only a few people are going to program in asm, but a microcontroller is the best way to play with it.

The MSP430 instruction set is somewhat friendly, but I long for the days of the Motorola MC68hc11. That was a beautiful instruction set, especially for teaching.

Does anybody know how these chips fare for raw assembly programming?

[+] setquk|6 years ago|reply
I'm playing with the PIC10F320 at the moment. Minimalism is fun. $0.50 in 1 off quantities. 6-pin SOT-23 package. 16MHz. 0.5K of program space. 64 bytes of RAM. Waveform generator. ADC. Timers. PWM and the coolest thing a configurable logic cell which works while the CPU is asleep.

I've got a semi-working morse iambic keyer in that and it uses 40uA of current running flat out. I'm working on sleeps now. I reckon I can get it down to 100nA average based on the wake time and 20nA sleep current. I can't actually measure down that low even with my 5.5 digit HP 3478A

[+] FrojoS|6 years ago|reply
For those who needs something more beefy, check out https://www.nxp.com/support/developer-resources/evaluation-a... They are about 60 USD per board, though if you want only the chip for a final product, it will become much cheaper.

We use these development boards in combination with freeRTOS (bare C based) for lots of projects in our lab that require high sampling rates (e.g. 8 analog sensor readings at 1 kHz) motor control loops etc.

There is a very good blog on these chips at mcuoneclipse.com

[+] sgt|6 years ago|reply
I like MSP430 a lot but the tooling leaves a bit to be desired. Maybe that's been improved upon recently by TI but a few years back you were left with few choices other than installing some kind of IDE on Windows.
[+] pmorici|6 years ago|reply
TI distributes a pre-compiled version of GCC [0] for the MSP430 along with a command line MSP-flasher [1] utility for flashing code to the device. It all works really well on Linux. I haven't had to touch any of their windows tools. It can be slightly confusing getting started because there are 101 different ways to develop and compilers you could use so you have to wade though examples that may not be applicable to your chosen development environment. Once you get past that it isn't hard. I really like the tutorial series on simplyembeded [2] they to a great job of covering the MSP430 basics.

[0] http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430... [1] http://www.ti.com/tool/MSP430-FLASHER [2] http://www.simplyembedded.org/tutorials/

[+] rhodysurf|6 years ago|reply
You can use open sourced MSP-GCC developed by RedHat now and it makes things a bit better and more flexible about how you want to develop
[+] peter_d_sherman|6 years ago|reply
Amazing article! (I was utterly unaware that this amount of choice and selection of microcontrollers exist, much less at this price point(!) -- before having read this article... you put a lot of work into this article and it shows.)

This will be my new, first, go-to article, if I begin any new projects involving microcontrollers in the future...

[+] tombert|6 years ago|reply
I very recently started getting into microcontroller programming, and have subsequently purchased a plethora of different ESP chips on Banggood for roughly $3-8 a pop (though all of them have WiFi built in, and a few even came with cameras).

I would actually be curious how these controllers compare to a $1 chip.

[+] pinewurst|6 years ago|reply
This is great but it should be noted that it dates from 2017.
[+] ThePhysicist|6 years ago|reply
It is really mind-bogging how fast processors are these days. A few days ago I read the marketing copy for the iPad Pro on the Apple website, where they said that their neural processor can perform more than five trillion operations per second. Initially I thought they translated it wrong from English to German (one trillion is "eine Billion" in German), but I rechecked it and it seems correct and actually makes sense for a highly parallel architecture that runs at a few GHz per second. Granted it costs more than $1 (though the production cost without factoring in R&D might actually be in that range) but it's still amazing that you can just carry such a thing around in your pocket.
[+] spacedog11|6 years ago|reply
The title is misleading because only the chip by itself costs $1. If you buy the microcontroller( chip + peripherals), it costs more than $1. For example MSP430: https://www.mouser.com/ProductDetail/Texas-Instruments/MSP-E...
[+] patrickyeon|6 years ago|reply
"Microcontroller" refers to everything on the chip (usually, we would talk about it having a "core" roughly akin to memory + ALU + such, and "peripherals" which are on-chip dedicated hardware that migh be eg. I2C or USB communications, timers, ADCs, etc). What you're linking to we would call a "development board" (dev board), "demo board", "eval(uation) kit".

I don't consider the title misleading, as the article is aimed at the people who are designing their own (hobbyist probably, but not exclusively) boards, and will be integrating the chip, not a dev board, into their project.

[+] boomlinde|6 years ago|reply
That's not what microcontroller means.
[+] sand500|6 years ago|reply
Yeah, I probably wouldn't be concerned about the cost of the actual chip but rather the cost of w/e dev board I would need for my hobbyist project. Maybe the complexity of wiring everything up if I were to put the microcontroller on a custom designed PCB.
[+] ryukoposting|6 years ago|reply
Those Infineon chips are incredible for how inexpensive they are. I've worked with an XMC1400 at work (another one of their M0-based offerings) and it was insane how sophisticated the peripherals on those things are, despite being a dirt cheap part.

That said, their IDE sucks (well, every manufacturer-provided IDE sucks, but whatever). Life is way easier with a couple makefiles and Ozone.

[+] roland35|6 years ago|reply
This is a great round up of cheap microcontrollers - I would love to take that approach of "scoring" peripherals to be able to compare various vendor's offerings up and down the lineups!

As of right now it is hard to compare families at the start of a project, most of the time we just go with what we are comfortable with (and haven't been burned by in the last project!)