If you have an Arduino Sketch that you want to run e.g in Linux, OS/X or Windows you can include this library with cmake. Here is an example cmake file for an Arduino Audio Sketch).
We provide some alternative implementations:
- Dummy Implementatin which does nothing
- Communicates changes to/from a Microcontroller using UDP
- Rasperry PI
You can run this emulator on an Rasperry PI
- make sure that the -DUSE_RPI cmake option is set to ON
- install libgpiod-dev (sudo apt install libgpiod-dev)
- activate SPI and I2C with raspi-config
I initially really wanted to have an interactive Jupyter environemnt in which I could play around with Arduino commands and when I discovered that Arduino provides a good starting point with their ArduinoCore-API I decided to start this project.
You can also use xeus-cling as a runtime environment to simulate an Arduino Development board and I have added the missing implementation using C or the C++ std library.
Here is a quick demo:
You can activate/deactivate some functionality with the help of the following defines:
- USE_RPI: activates support for Rasperry PI
- USE_REMOTE: activates support for GPIO/SPI/I2C using UDP or Stream
- USE_HTTPS: provide https support using wolfSSL
- SKIP_HARDWARE_SETUP: deactivate all GPIO/SPI/I2C implementations
- SKIP_HARDWARE_WIFI: deactivate WiFi
Execute the following commends in the root of the Arduino-Emulator:
git clone --recurse-submodules https://github.com/pschatzmann/Arduino-Emulator
cd Arduino-Emulator
mkdir build
cd build
cmake -DUSE_RPI=OFF -DUSE_HTTPS=OFF -DCMAKE_BUILD_TYPE=Debug ..
makeAdjust the cmake parameters dependent on your requirements.
- Class documentation.
- You can find further information in the Wiki
To avoid conflicts between system string.h and Arduino’s string library String.h, just do not put (include)/api to include path. Put (include) and (include)/api/deprecated instead.
This usual way to resolve this conflict in all Arduino cores.