|
| 1 | +# Arduino Emulator: Major Architecture Improvements and Raspberry Pi Support |
| 2 | + |
| 3 | +*October 2025* |
| 4 | + |
| 5 | +I'm excited to share some significant updates to the Arduino Emulator project that make it more robust, easier to use, and better aligned with official Arduino standards. These changes represent a major step forward in cross-platform Arduino development. |
| 6 | + |
| 7 | +## 🔄 Arduino Core as Official Submodule |
| 8 | + |
| 9 | +The most significant architectural change is **migrating to the official Arduino Core API as a git submodule**. Previously, we maintained our own fork of the Arduino Core, but now we point directly to the [official Arduino Core API repository](https://github.com/arduino/ArduinoCore-API) maintained by Arduino. |
| 10 | + |
| 11 | +### Why This Matters: |
| 12 | +- **Always up-to-date**: Automatic access to the latest Arduino API improvements and bug fixes |
| 13 | +- **Perfect compatibility**: 100% alignment with official Arduino function signatures and behavior |
| 14 | +- **Reduced maintenance**: No need to manually sync API changes from upstream |
| 15 | +- **Community trust**: Using the same core API that millions of Arduino developers rely on |
| 16 | + |
| 17 | +This change ensures that your Arduino sketches will behave identically whether running on actual hardware or in the emulator. |
| 18 | + |
| 19 | +## 🍓 Complete Raspberry Pi Hardware Support |
| 20 | + |
| 21 | +The emulator now provides **full hardware abstraction for Raspberry Pi**, enabling real GPIO, SPI, I2C, and Serial communication through the actual hardware interfaces. |
| 22 | + |
| 23 | +### What's New: |
| 24 | +- **Real I2C communication** via `/dev/i2c-1` (GPIO 2/3) |
| 25 | +- **Hardware SPI support** using `/dev/spidev0.0` and `/dev/spidev0.1` |
| 26 | +- **Direct GPIO control** through the modern `gpiod` interface |
| 27 | +- **Serial port access** to physical UART interfaces |
| 28 | + |
| 29 | +### Build with Hardware Support: |
| 30 | +```bash |
| 31 | +# Enable Raspberry Pi hardware support |
| 32 | +cmake -DUSE_RPI=ON .. |
| 33 | +make -j4 |
| 34 | + |
| 35 | +# Run with hardware access |
| 36 | +sudo ./examples/i2c/i2c |
| 37 | +``` |
| 38 | + |
| 39 | +### Before vs. After: |
| 40 | +```cpp |
| 41 | +// This I2C code now generates REAL signals on GPIO 2/3 |
| 42 | +Wire.begin(); |
| 43 | +Wire.beginTransmission(0x3C); |
| 44 | +Wire.write(0xA5); |
| 45 | +Wire.endTransmission(); // Actually sends data to hardware! |
| 46 | +``` |
| 47 | + |
| 48 | +## 🎯 Redesigned Hardware Abstraction Layer |
| 49 | + |
| 50 | +The GPIO, SPI, and I2C implementations have been **completely redesigned** for consistency and extensibility: |
| 51 | + |
| 52 | +### New Architecture Benefits: |
| 53 | +- **Unified interface**: All hardware abstractions follow the same design patterns |
| 54 | +- **Multiple backends**: Easy switching between Mock, Raspberry Pi, FTDI, and Remote implementations |
| 55 | +- **Clean separation**: Hardware-specific code is isolated and modular |
| 56 | +- **Future-proof**: Easy to add support for new platforms |
| 57 | + |
| 58 | +### Implementation Options: |
| 59 | +- **Mock**: For testing and development without hardware |
| 60 | +- **Raspberry Pi**: Direct hardware access via Linux kernel interfaces |
| 61 | +- **FTDI**: USB-to-GPIO/SPI/I2C bridge support |
| 62 | +- **Remote**: Communicate with real Arduino via UDP/Serial |
| 63 | + |
| 64 | +## 🛠️ Simplified CMake Integration |
| 65 | + |
| 66 | +Building Arduino sketches and integrating libraries is now **incredibly simple** with new CMake functions: |
| 67 | + |
| 68 | +### arduino_sketch() Function |
| 69 | +```cmake |
| 70 | +# Before: Complex manual configuration |
| 71 | +add_executable(blink blink.ino) |
| 72 | +set_source_files_properties(blink.ino PROPERTIES LANGUAGE CXX) |
| 73 | +target_compile_options(blink PRIVATE -x c++) |
| 74 | +target_link_libraries(blink arduino_emulator) |
| 75 | +# ... many more lines ... |
| 76 | +
|
| 77 | +# After: One simple line! |
| 78 | +arduino_sketch(blink blink.ino) |
| 79 | +``` |
| 80 | + |
| 81 | +### arduino_library() Function |
| 82 | +```cmake |
| 83 | +# Automatically download and integrate Arduino libraries |
| 84 | +arduino_library(sam "https://github.com/pschatzmann/arduino-SAM") |
| 85 | +arduino_sketch(my_project main.ino LIBRARIES sam) |
| 86 | +
|
| 87 | +# Or use local libraries |
| 88 | +arduino_library(my_sensors ./local/sensors) |
| 89 | +arduino_sketch(sensor_demo demo.ino LIBRARIES my_sensors Wire) |
| 90 | +``` |
| 91 | + |
| 92 | +## 📚 Comprehensive Documentation |
| 93 | + |
| 94 | +All these improvements are thoroughly documented in our **[Wiki](https://github.com/pschatzmann/Arduino-Emulator/wiki)**, including: |
| 95 | + |
| 96 | +- **Getting Started Guide**: From zero to running sketches in minutes |
| 97 | +- **Hardware Setup**: Detailed Raspberry Pi configuration instructions |
| 98 | +- **CMake Reference**: Complete function documentation with examples |
| 99 | +- **Architecture Overview**: Understanding the emulator's design |
| 100 | +- **Platform Support**: Comparison of different backend implementations |
| 101 | +- **Troubleshooting**: Common issues and solutions |
| 102 | + |
| 103 | +## 🚀 What This Means for You |
| 104 | + |
| 105 | +These changes make the Arduino Emulator more powerful and easier to use than ever: |
| 106 | + |
| 107 | +### For Developers: |
| 108 | +- **Faster iteration**: Test Arduino code without uploading to hardware |
| 109 | +- **Better debugging**: Use full IDE debugging capabilities |
| 110 | +- **Cross-platform**: Develop on Linux, macOS, or Windows |
| 111 | +- **CI/CD integration**: Automated testing of Arduino projects |
| 112 | + |
| 113 | +### For Raspberry Pi Users: |
| 114 | +- **Real hardware testing**: Verify I2C/SPI communication with actual devices |
| 115 | +- **Prototype faster**: Test sensor integration before building circuits |
| 116 | +- **Educational tool**: Learn Arduino programming with immediate hardware feedback |
| 117 | + |
| 118 | +### For Project Maintainers: |
| 119 | +- **Simplified builds**: CMake integration reduces configuration complexity |
| 120 | +- **Library ecosystem**: Easy integration with existing Arduino libraries |
| 121 | +- **Future-proof**: Automatic compatibility with Arduino API evolution |
| 122 | + |
| 123 | +## � FTDI USB-to-GPIO Bridge Support |
| 124 | + |
| 125 | +One of the exciting next planned additions is **comprehensive FTDI FT2232HL support**, bringing real Arduino hardware capabilities to any desktop computer via USB. |
| 126 | + |
| 127 | + |
| 128 | +## Try It Now! |
| 129 | + |
| 130 | +Ready to experience the improved Arduino Emulator? Check out the complete documentation in our [Wiki](https://github.com/pschatzmann/Arduino-Emulator/wiki) and start building cross-platform Arduino applications today! |
| 131 | + |
| 132 | +```bash |
| 133 | +git clone --recursive https://github.com/pschatzmann/Arduino-Emulator.git |
| 134 | +cd Arduino-Emulator |
| 135 | +mkdir build && cd build |
| 136 | +cmake -DUSE_RPI=ON .. # Enable Raspberry Pi support |
| 137 | +make -j4 |
| 138 | +./examples/blink/blink # Your first emulated Arduino sketch! |
| 139 | +``` |
| 140 | + |
| 141 | +--- |
| 142 | + |
| 143 | +*The Arduino Emulator continues to bridge the gap between embedded development and modern software practices. These improvements make it an even more powerful tool for Arduino developers working on complex, cross-platform projects.* |
0 commit comments