This Arduino library allows you to control Red Pitaya boards over SCPI commands via UART or Wi-Fi.
0) Installation
- Open Arduino IDE
- Go to Sketch → Include Library → Add .ZIP Library…
- Select the downloaded ZIP of this repository or clone this repo into your Arduino libraries folder:
git clone https://github.com/Aandri99/ArduinoWifiXRedPitayaSCPI.git
(Default Arduino libraries path:
Documents/Arduino/libraries/
)- Restart Arduino IDE
- You should now see ArduinoWifiXRedPitayaSCPI under File → Examples
1) Prerequisites
- Red Pitaya with SCPI server running
- Start it from the web UI (Development → SCPI → RUN)
- Or via SSH:
systemctl start redpitaya_scpi
- Find your Red Pitaya IP/hostname and SCPI port
- Typical ports:
5025
(newer OS) or5000
(older OS)
- For UART: connect Arduino’s TX/RX (3.3 V logic) to Red Pitaya UART pins
- For Wi-Fi: your board (ESP32, ESP8266) must join the same network as Red Pitaya
2) UART Example (AVR / ESP32 / SAMD)
Wire Arduino UART → Red Pitaya UART (3.3 V only!).
Code:
#include <Arduino.h> #include "SCPI_RP.h" #if defined(ARDUINO_ARCH_AVR) #include <SoftwareSerial.h> SoftwareSerial uart(8, 9); // RX=8, TX=9 for SCPI over UART #endif scpi_rp::SCPIRedPitaya rp; uint8_t led_state = 1; void setup() { #if defined(ARDUINO_ARCH_AVR) uart.begin(RED_PITAYA_UART_RATE); rp.initStream(&uart); #elif defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_SAMD) || \ defined(ARDUINO_ARCH_SAM) Serial1.begin(RED_PITAYA_UART_RATE); rp.initStream(&Serial1); #endif rp.dio.reset(); // Reset all DIO pins } void loop() { // Toggle DIO pins in sequence rp.dio.state((scpi_rp::EDIOPin)(led_state), 1); delay(1000); rp.dio.state((scpi_rp::EDIOPin)(led_state), 0); led_state++; if (led_state == 8) led_state = 0; }
Result: sequentially toggles DIO0 → DIO7 on Red Pitaya every second.
3) Wi-Fi Example (ESP32 / ESP8266)
First, create a file
arduino_secrets.h
in your sketch folder:#define SECRET_SSID "YourWiFiSSID" #define SECRET_PASS "YourWiFiPassword" #define SECRET_RP_IP "192.168.1.42" // or "rp-xxxxxx.local" #define SECRET_RP_PORT 5025 // try 5025, use 5000 if needed
Code:
#include "wifiSCPI.h" #include "arduino_secrets.h" // WiFi + Red Pitaya settings WifiSCPI rp; void setup() { // Connect to WiFi and Red Pitaya rp.begin(SECRET_SSID, SECRET_PASS, SECRET_RP_IP, SECRET_RP_PORT); // Set LED0 as output rp.scpi("DIG:PIN:DIR LED0,OUT"); } void loop() { // Blink LED0 on Red Pitaya rp.scpi("DIG:PIN LED0,1"); delay(500); rp.scpi("DIG:PIN LED0,0"); delay(500); }
Result: LED0 on Red Pitaya blinks every 500 ms.
4) Troubleshooting
- No response to
IDN?
or DIO commands - Check that SCPI server is running (
systemctl status redpitaya_scpi
) - Verify port: try
5025
first, then5000
- Ensure Arduino board and Red Pitaya are on the same network (for Wi-Fi)
- Wi-Fi fails to connect
- Double-check SSID/password in
arduino_secrets.h
- Test by pinging your Red Pitaya IP from your PC
- UART not working (AVR boards)
- Use
SoftwareSerial
at 115200 baud or lower - Ensure voltage levels are 3.3 V (Red Pitaya is not 5 V tolerant)
- Oscilloscope / Spectrum app crashes when using SCPI
- Avoid running web applications in parallel with SCPI; they share FPGA resources