Hi,
Quick question, but I can’t find the answer. How compatible are different chips?
All my code so far has been used on Arduino Uno R3’s.
Can I simply change the board and port on the IDE and write to an ESP32 based board?
Will libraries and functions such as millis() work?
Finally, can someone recommend a nano-size Bluetooth board?
Thanks, Al.
Physwiz:
Can I simply change the board and port on the IDE and write to an ESP32 based board?
This is the goal. The standardized, high level Arduino API allows code to be compatible between microcontrollers with very different architecture.
Physwiz:
Will libraries
It really depends on the library. The ESP32 core comes with its own versions of some of the standard Arduino libraries. Some of these libraries have a compatible API so they will work seamlessly with code written for your Uno. Others have used the same API as much as possible, but there are some differences due to hardware differences between the microcontrollers. A good example is the EEPROM library. Unlike the Uno, the ESP32 doesn't actually have any EEPROM memory, so they use a section of flash memory to emulate EEPROM. This requires some differences in how you use the library: When using the EEPROM on the ESP32, you need to set the EEPROM size using EEPROM.begin() and your changes are only written to the "EEPROM" when you call EEPROM.commit() or EEPROM.end().
As for other libraries you find on the Internet, you will find that some of them work fine with either board, even though the author may have never used an ESP32 simply because they don't contain any architecture-specific code. Other libraries will have been written specifically for compatibility with both chips. Other libraries may have an ESP32-specific equivalent. Other libraries have architecture-specific code that was written only for one chip and won't work with the other. For the most part, you can check by installing the ESP32 core for Arduino, selecting an ESP32 board, and compiling an example of the library. If it compiles, there is a good chance it's compatible with the ESP32.
Physwiz:
and functions such as millis() work?
Yes. The ESP32 core for Arduino implements the standard Arduino Core API that provides functions like millis(). There might still be a few exceptions that the developers haven't gotten around to implementing yet, but I'm not sure of that.
Physwiz:
Finally, can someone recommend a nano-size Bluetooth board?
Arduino recently announced that they are making the Arduino Nano 33 BLE, which uses the identical form factor and pinout as the classic Arduino Nano, but uses the much more modern nRF52840 microcontroller, which has BLE capabilities. The board is on pre-order now, expected to ship mid-July:
Physwiz:
Finally, can someone recommend a nano-size Bluetooth board?
Pert has pointed out the upcoming Nano 33 BLE which is the best option if you want something that is Nano- (with a capital N) sized. If you're just looking for something small with Bluetooth then this Beetle BLE is about the smallest Arduino compatible that I've seen.
Hi All,
I’d like to thank you for the really comprehensive answers to both my answers. Great job, it makes the forum really worthwhile. Al.
the best option if you want something that is Nano- (with a capital N) sized.
It's funny that I didn't even consider the word "nano" might be used to refer to anything other than an Arduino Nano board on this forum.
I’d like to thank you
You're welcome. I'm glad if I was able to be of assistance. Enjoy!
Per
How compatible are different chips?
Can I simply change the board and port on the IDE and write to an ESP32 based board?
The chips themselves (say, AVR vs ESP32) are not very compatible at all.
In theory, the Arduino Core software and libraries make the chip incompatibilities invisible to the user sketches, but that is dependent on someone having written the software. millis() is part of the Arduino core, for example, and should be present on anything that claims to support the Arduino IDE. Some libraries are more chip-dependent, and may require some searching (I guess recently I've hear that the Servo library isn't working on some other chips, and the timer1 library is probably dependent on having a "timer1" peripheral, which is an AVR-specific thing (not even all AVRs!)
There are also hardware incompatibilities. An AVR outputs 0 ot 5V on its output pins at up to 40mA, while the ESP32 does 0 or 3.3V at up to 12mA. And an ADC input can be 0 to 5V on an AVR, but not on many other chips.
As Pert said - nano vs. Nano - and more generally with regards to cheaper generic chips, I’ll stick with Arduino, and stick with common or garden libraries such as millis()!
- thanks westfw.