166 points · by pyprism · 3y ago · 139 comments
I haven't used any Expressif product, but is easy to find a problem or a bug while programming a MCU if you're new with it, and you don't know exactly what registers you need to edit to configure to set up the hardware correctly, or if there are hardware details, like the use of multiplexing in pins, to deal with.
With Arduino you can forget a lot of the smaller details, and you only have to know what pins to use, how you want to use them, what devices use, and the simple functions Arduino gives to you to use them (which are commom across most of boards).
- You don't get any documentation, whereas with something more official you will have a complete schematic (so you know which support components will be used), pinout, information about power supplies etc.
- You can't rely on being able to buy the same thing again. Even if you find something with the same pinout, small changes to the power supply or usb-serial converter can ruin your day.
- Shipping will probably take a while (or you're buying from a local re-seller, increasing the cost). Your company probably doesn't have a process for buying from aliexpress, but orders from digikey all the time.
- I've not had a problem with development boards, but plenty of cheap electronics in the same category are really badly designed; a random memorable example: https://www.aliexpress.com/item/1005001621800502.html . They have had their issues, but arduino stuff does tend to be well designed, and vendor development boards are usually reliable too.
- Stuff like the feather ecosystem can be genuinely helpful when prototyping if the cost isn't an issue.
I chance the cheap stuff for personal projects, but if work is paying I'd go for something more expensive every time (and probably wouldn't have a choice).
You would always make a custom board for an actual mass appeal product. If it's not a mass made product why do you care? Pick the easiest one regardless of cost.
This is essentially a dev kit. With the ability to easily mess with it. You don't care about the cost here because it's not really an expense when amortized.
Many companies easily drop a $10,000+ premium for a prototyping kit every day of the week to get support from a preferred vendor. If you give one employee making 150k/yr a 10% productivity boost, you're saving money. Prototyping cost is often mostly labor. Unit cost doesn't really matter as much until you're talking about the production BOM.
Some rough math, for an employee with a 200k fully loaded cost working 1800/hr/yr, the difference in the price of those boards is about 8-9 minutes of labor. So if it's 10 minutes quicker to get the documentation for the Arduino -- it's cheaper.
For professional prototyping I always buy Arduino, for home use the cheaper variants are fine too.
https://www.udemy.com/course/crash-course-electronics-and-pc...
After that you can have it fabricated and assembled in China. It's not a necessity but it is really convenient for surface mounted parts and it is surprisingly inexpensive.
Once your comfortable doing io boards, try to replicate one of your stm32 board.
I’d recommend starting a little simpler - by making a custom board on a breadboard using pin breakout PCBs - https://www.adafruit.com/product/1377
That will give you an idea about the bare minimum circuit one needs to build a functioning board (crystal, power regulator, boot select buttons, and so on)
First, make a schematic. This covers which things are electrically connected together so it's easier to see what connections there are. There's always "boilerplate" circuitry, so you'll want to start with an existing schematic. Eg https://stm32-base.org/assets/pdf/boards/original-schematic-...
Then you design the board. You take the schematic, and then actually draw the actual wires (traces) on a board, and tell it which parts go where. The output from this step is a series of Gerber files. They look something like https://info.ewmfg.com/hubfs/Gerber-file-East-West-MFG.png
Finally, you send the board files off to a fab for them to make the board, and optionally solder all the parts on. You used to be able to make it yourself but these days, a pcb house, or manufacturing facility is the way to go.
KiCad is the preferred hobbyist software package these days.
/r/PrintedCircuitBoard/ has some good resources for this process.
> How do you program the chip?
These days, via USB. Circuitry is so cheap these days that the easiest thing to do is have a USB port, and a 'program' button, so when you hold the button down, and power up the device, it boots into a special mode where it can be programmed. There are other techniques but they're mostly harder.
Back in the day, you would have a chip programming device where you would burn the code into a chip, and then have to physically put that chip into your circuit. In order to erase it, you would need to uncover a hole in the top of the chip, and then shine UV light on it.
> How can you test your board?
Depending on the level of debugging you need, a multimeter, a oscilloscope or a digital logic analyzer, in addition to printf debugging and using a debugger, possibly via JTAG.
A multimeter is good enough for simple low/high testing. Like why is this single LED not on, it should be one.
An oscilloscope is useful for graphing simple signals that a multimeter can't catch. If you're turning the LED on and off 50 times a second, it'll be dimmer than if it's just on the whole time (PWM), and an oscope is good for looking at those 50 times.
Finally, a digital logic analyzer. If you're using a bus, like I²C or SPI, and are sending bytes and bytes of data, you can read those off an oscilloscope; low, high, low low is a 4, but that gets old real quick. A digital logic analyzer will interpret the signals on the wire and just tell you the bytes.
Most chips will have a serial port so you can do printf/console.log-grade debugging. You may need additional circuitry to talk to this port, or it may happen over USB.
Finally some microcontrollers support in-circuit emulation (ICE) debugging methods. The two big ones are JTAG and SWE. These let you connect your computer to the microcontroller, and then step through your code, line by line, using a debugger.
> How can you prototype on an arduino, if you'll use different architecture STM vs Atmega, etc...
To be clear, that's not recommended. You're writing in C, not assembly so the code you write is largely portable, so it's just a matter of copying your code to a different configuration, updating the code that interacts with the chip's hardware, and then recompiling.
Updating the code may or may not be trivial though. And personally it's not especially fun. I'd just use the same chip for prototyping as I'd want in my production run. If you have your heart set on using an STM32, just use a dev kits for that to prototype with eg https://www.digikey.com/en/products/detail/stmicroelectronic... instead of an Arudino.
And of course, these days, and on the linked article, you can program in MicroPython instead of C, which is easier.
Ps: accidentally posted before I finished the comment and using mobile client without ability to edit comments :d
Ps2: these comments are kinda out of context, but it's something that's bothering me for more than a month now.
[1] https://www.amazon.com/KeeYees-Breakout-ESP-WROOM-32-Microco...
We're talking $4 vs $16 for a board for engineers that cost much more than that an hour. Pick whatever you like. In fact go buy both and play with both the above and this. The cost is literally nothing. These boards are not what goes into a large production run product.
Same deal as the raspberry pi- the Pi isn’t as powerful as a lot of other boards and is more expensive than other boards in its class, but people use it because of the support.
The problem with the ESP32 is that it has some pretty insane peak power draw figures (nearly an amp at times, far higher than the official spec of ~300mA) that catch people off guard in low power battery applications, and the dev/carrier board quality varies a fair bit. A lot of early 8266 and 32 boards had quite high power drain just from the board itself; things like poorly chosen resistor networks for battery voltage monitoring, for example. You used to be able to find reviews covering this sort of thing but that information seems to have fallen by the wayside.
Wemos/Lolin and 1-2 others are the main/best suppliers for ESP boards, generally.
Which one? There’s huge variety of ESP32 modules out there. I’ve been using various since introduction (and before that, the 8266) and don’t recall ever running into this. Do you have some links to share?
The claimed power draw in the data sheets with the modem on is sustained over 200 ma. Part of the problem is that the modem doesn’t have granular control. If you want BLE, which should only consume a few ma, you have to also turn on wifi, which needs a ton of power.
why aren't we seeing feature-rich dev boards based on the same platforms ?
Economies of scale. If they sold hundreds of thousands ESP32 or Arduinos every day, their price would likely fall down to €1 per complete board.
> why aren't we seeing feature-rich dev boards based on the same platforms ?
Because those platforms are closed as hell and their manufacturers have no intention of publishing enough technical data to allow developers to write Open Source drivers.
That's the reason why the engineers at Pine64 had to design the PinePhone from scratch to make it run a real Linux distribution instead of using already available proprietary boards that would indeed be a lot faster and cheaper, but also would be restricted to run only Android with closed device drivers and the same crappy untrustworthy software that plagues cellphones today.
I am sure there are ways to get around this with some cases but it does feel like there are practical issues with the cheapo/used phones. And that's not even getting into having to wrangle the OS.
Maybe someone can make an Android fork that is basically "make this phone a computing device that should last a long time" that you can easily throw onto phones.
Number of units sold has to be enormous to make a profit on low margin items.
The value-add simply is not there, particularly since they lead incredibly heavily on end-users, educators, etc to provide support.
I guess someone has to pay for those 8 week vacations.
You really think that paying $20 for something more powerfull than a PC1512, which when considering inflation, would cost $1722 in todays money, is really being robbed?!?
Really, what a wonderfull thing that for $20 I can get something more powerful than what I used to play Defenders of the Crown on, and it fits on the pocket.
You can program in scratch, javascript, python and even c++. You can even change firmware to Zephyr RTOS if you want to do some low level stuff.
On top of that you have big ecosystem of extension boards or even robot kit. And tons of open source projects
Zephyr (for me at least) felt quite bloated and abstracted away, probably because they need to support so many different SoCs. Albeit my experience is with the Nordic nRF downstream version of Zephyr.. The use of device-tree plus inconsistencies with the nordic api's certainly didn't help.
My experience with ESP-IDF + freeRTOS has been much more straight forward and felt much more nimble.
This board is $21 with headers... I've seen a ton of esp32 boards for much less.
What do you think makes this board worth the extra cost?
Say I go for something else than Arduino, what am I missing out on?
ESP32 boards: surprisingly fast/powerful little SOC with wifi
ESP8266: cheaper+slower. I like the Wemos D1 mini board: smaller and has enough horsepower for most things.
Sourcing: a ton on options on AliExpress. Buy a few extras so if you fry one you aren't waiting for replacements. They are super cheap ($3-$6).
Options to consider for board: memory, CPU speed (ESP32 vs ESP8266), size/form factor, pins/dev board or just solder holes, does it have built in USB controller (and which one), voltage regulator for 5V, USB Micro vs USB C, sensor voltage requirement, etc. Sounds complicated, but they are all pretty similar, and can typically buy a few and make your projects work. Getting one of the "branded" options like Wemos D1 is good bet, comes with all the basics covered, and no surprises like making your own voltage reg.
Sensors: lots to learn on each one. Just did the deep dive on CO2, and there were a ton of details (eCO2 vs CO2, auto calibration quality, manual calibration support, cost, airflow, etc). Went for Senseair S8. If you want easy place to get started, look at AirGradient Kit: https://www.airgradient.com/kits/
I don't know about the RP2040, but the ATMEGAs can't multitask and have pretty low resolution ADC.
In my experience having them calibrated properly is a pain in the ass because they rely on the input voltage and that changes slightly depending on the method of power input.
A computer using USB will give you a different result than on battery power since the USB is going through a diode but no regulator and the battery is going through a regulator or straight into the 5V line. To make it work I ended up cutting the voltage lines on a USB cable and connecting a battery for power.
I'm sure there is an easy way to deal with all that stuff but I'm not good enough to have figured it out.
Here is a tutorial about how to use TinyML to perform image detection on the device: https://dronebotworkshop.com/esp32-object-detect/
Both are cheaper than this yet are the same thing.
When compared to other Arduinos, probably.
Goal is just to play around with a bunch of sensors from Joy-It X40 40 sensor sampler - nothing serious.
Looking at https://forum.micropython.org/ looks like activity is evenly split between various ESP8266 and ESP32 boards.
I have a project in mind, but I've struggled to find this sort of practical answer oonline...
In general you use module instead of chip to save on certification. However for ESP32 the logical choice would be indeed a module from Espressif.
Arduino is presumably using the term "IoT" because they're interested in emphasizing that this device can connect to the internet without buying additional hardware, unlike most Arduinos that have existed.
What do you mean? Tons of IoT devices are powered from mains, not batteries.
And even if they were powered from mains I don't want it to be inefficient. If they don't come with a buck converter with low quiescent current please don't buy it.
And there still is a Vin to power it how ever you want, takes 6-21v. And a USB port makes serial easy.
Where do you start?
Go through a few of the basic modern IoT "hello world" examples, like making a web-enabled temperature sensor. Then google for "ESP32 [foo]", where foo is some random idea that you have for pretty much anything you can imagine that has even the remotest reason to be internet-connected.
Assuming that you are comfortable with at least semi-advanced software development, learning basic embedded stuff with ESP32 or Arduino is pretty easy. There is no operating system, or heavy stack, which can sometimes make things like a Raspberry Pi more overwhelming to start with in terms of embedded stuff.
Looking forward to doing this stuff with my son at some point, but he's only 6 :)
Unfortunate.
AKA its 100% C++ code sitting on top of arduino wrapping various open source libraries. The result is that it can run on multiple microcontrollers after carefully tweaking the C based interrupt registration and a couple other small bits.
I've sorta wanted to play with the Xtensa cores, but haven't found a reason to.
RISC-V support only just landed in ESP-IDF. Give it a couple more years imo to reach full feature parity.
* Arduino SDK does not rely on ESP-IDF, so this doesn't matter.
* Irrespective of when it landed, ESP-IDF already supports RISC-V ESP32 devices well, and will increasingly focus on RISC-V devices thereon, as Espressif is committed to RISC-V going forward.
ISA: https://en.wikipedia.org/wiki/Instruction_set_architecture
Thus, a new Arduino platform is being created out of a deprecated family of MCUs, the Tensilica-based ESP32s.
0. https://www.eenewseurope.com/en/espressif-moves-exclusively-...