Arduino Nano RP2040 Connect Library for Proteus: a colour sorter with a TCS34725 and an SG90 servo on Wi-Fi

Arduino Nano RP2040 Connect Library for Proteus: TCS34725, Servo

2.5K Views
40
700
60
25
60
PCBWay

Hello friends, I hope you all are doing great. Today, I am going to share the Arduino Nano RP2040 Connect Library for Proteus. The Nano RP2040 Connect puts the Raspberry Pi RP2040 microcontroller and a u-blox NINA-W102 Wi-Fi module on Arduino's small Nano board, together with a motion sensor and a microphone. With this library it runs your Arduino sketch in Proteus 8.5 and joins our virtual Wi-Fi network with WiFiNINA, the same library you use on the real board.

Updates

Arduino Nano RP2040 Connect Library for Proteus

Latest version: V1.0 (October 2026, this tutorial)

Helping Tools

For the demo we built a small factory job: a colour sorter. A TCS34725 colour sensor looks at each item on the belt, the board names its colour, an SG90 servo turns the chute to the right bin, the L LED flashes for every item, and a phone and a laptop read the counts on the board's web page.

NOTICE: Proteus has no RP2040 or NINA-W102 model, so our team has put a lot of effort into building this board ourselves: the Nano's pins, Wi-Fi and LEDs are all our own model, and your sketch compiles with our free TEP Boards for Proteus add-on. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below or in the Arduino Nano RP2040 Connect board of our forum. And if our free libraries help you, you can buy us a coffee. So, let's get started with the Arduino Nano RP2040 Connect Library for Proteus:

Arduino Nano RP2040 Connect Library for Proteus: a colour sorter with a TCS34725 and an SG90 servo on Wi-Fi
Figure: The Arduino Nano RP2040 Connect Library for Proteus: a green item has just arrived - the ON and L LEDs lit and the antenna green on Wi-Fi, the TCS34725 on I2C.

What is the Arduino Nano RP2040 Connect?

The Arduino Nano RP2040 Connect came out in 2021 as the first Arduino board with Raspberry Pi's own chip. The RP2040 has two Arm Cortex-M0+ cores at 133 MHz and 264 KB of RAM; on this board it gets 16 MB of flash, and the NINA-W102 module (an ESP32 inside a shielded can) adds Wi-Fi and Bluetooth over SPI, with Arduino's WiFiNINA firmware. Around them sit an LSM6DSOX six-axis IMU, an MP34DT05 digital microphone, an ATECC608A crypto chip and an RGB LED - all on the 45 x 18 mm Nano footprint with 2 x 15 pins.

The two RP2040 Wi-Fi boards
Arduino Nano RP2040 ConnectRaspberry Pi Pico W
MicrocontrollerRP2040, two Cortex-M0+ at 133 MHzRP2040, two Cortex-M0+ at 133 MHz
Flash16 MB2 MB
Radiou-blox NINA-W102: Wi-Fi and BluetoothInfineon CYW43439: Wi-Fi and Bluetooth
Size, pins45 x 18 mm, 2 x 15 pins51 x 21 mm, 2 x 20 pins
ExtrasLSM6DSOX IMU, microphone, crypto chip, RGB LED-
Wi-Fi libraryWiFiNINAWiFi (the Pico core)

Our Raspberry Pi Pico W Library for Proteus is the same chip on Raspberry Pi's own board. The NINA module and WiFiNINA are the same as on the Arduino Nano 33 IoT Library for Proteus and the Arduino MKR WiFi 1010 Library for Proteus, so their network code moves to this board unchanged.

Why the Nano RP2040 Connect?

Pick it when a small board has a lot to do: two fast cores, plenty of flash for web pages and data, Wi-Fi and Bluetooth, and sensors for motion and sound already on the board. It plugs into a breadboard or a Nano carrier, its pins are 3.3 V logic like most modern sensors, and it programs from the Arduino IDE (or in MicroPython). For a sorter, a gesture controller or a sound-triggered logger, the parts are mostly already there.

Features of the Arduino Nano RP2040 Connect Library for Proteus

  • The board as it looks: the teal Nano RP2040 Connect with its castellated pins and labels, micro-USB, RESET, the RP2040, the flash, the IMU, the NINA-W102 with its antenna and the ON and L LEDs.
  • Your sketch: a .hex for "Arduino Nano RP2040 Connect (TEP Proteus)" with the Nano's names - D0 to D13, A0 to A7, LED_BUILTIN on D13, Serial, Serial1 on D0 / D1, Wire on A4 / A5, SPI on D10 to D13, Servo, analogRead, analogWrite.
  • Wi-Fi with WiFiNINA: WiFi.begin, WiFiServer, WiFiClient, WiFiUDP and WiFi.getTime on our virtual router TEP-WiFi; the board is 192.168.1.101 in the demo.
  • The panel and the serial monitor: the board's panel (Wi-Fi, Pins, Test) and the built-in serial monitor with Monitor, Plotter and Board tabs - our TEP header, no Windows title bar.
  • A complete package: about 3.7 MB with the board, the add-on, the TCS34725, servo and monitor libraries and the demo, without the source code of the models.

The Arduino Nano RP2040 Connect in Proteus

Arduino Nano RP2040 Connect in Proteus: the board with its 30 pins, the RP2040 and the NINA-W102
Figure: The part as the library draws it: the top row D12 to TX1, the bottom row D13 to VIN, the RP2040, the NINA-W102 with its antenna green on Wi-Fi, the PANEL pad and the ON and L LEDs lit.

Search RP2040 CONNECT in Pick Devices; the device ARDUINO NANO RP2040 CONNECT is in TEPNANORP2040.LIB (Microprocessor ICs, Arduino Wi-Fi Boards), with the prefix U. The board lies with micro-USB on the left and the NINA module on the right. Click the micro-USB to open the serial monitor and the PANEL pad (or the NINA module) to open the board's panel.

Arduino Nano RP2040 Connect in Proteus wired to net labels
Figure: U1 in the demo: D9 (SERVO) and GND fan up to their labels, A4 (SDA) and A5 (SCL) fan down.

The Pins

The pins in the library
PinsWhat the library does with them
D2 to D13GPIO, interrupt, PWM on any pin, Servo
RX0, TX1D0 / D1: Serial1 (not the USB)
A4, A5Wire SDA / SCL (I2C)
D10 to D13SPI SS / MOSI / MISO / SCK; D13 is also the L LED
A0 to A7analogRead 0 to 1023 for 0 to 3.3 V
3.3V, VUSB, GND, RST3.3 V, 5 V, ground, reset
AREF, REC, VINdrawn, not modelled

Download Arduino Nano RP2040 Connect Library for Proteus

Click the button below to download Arduino-Nano-RP2040-Connect-Library-for-Proteus-v1.0.zip (about 3.7 MB, without the source code of the models):

Arduino Nano RP2040 Connect Library for Proteus V1.0
  • README.txt: installation, the demo, the pins, the properties, troubleshooting and the limits.
  • Proteus Library Files: TEPNANORP2040.LIB and the demo's parts: TEPTCS34725.LIB, TEPPCA9685.LIB (the SG90 servo), TEPLAPTOP.LIB and TEPMOBILE.LIB.
  • Proteus Model Files: TEPNET.DLL (the board, the laptop, the phone and the network) and the DLLs of the sensor and the servo.
  • Arduino Code: the demo sketch and the TEP Boards for Proteus add-on 1.21.0.
  • Proteus Simulation: the demo project, its HEX file and copies of the DLLs.

No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.

How to Install Arduino Nano RP2040 Connect Library for Proteus

  1. Close Proteus and extract the whole zip file, for example to your Desktop.
  2. Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
  3. Copy the DLLs from Proteus Model Files into the MODELS folder, replacing an older TEPNET.DLL.
  4. Delete TEPNANORP2040.IDX from the LIBRARY folder if it is there.
  5. For your own sketches, copy Arduino Code\TEP Boards for Proteus\hardware into your Arduino sketchbook (Documents\Arduino) and restart the Arduino IDE; the board is Arduino Nano RP2040 Connect (TEP Proteus).
  6. Start Proteus, press P and search for RP2040 CONNECT.

Demo: a Colour Sorter

Sorting by colour is one of the oldest jobs in a factory: sweets, recycled glass, beads, ripe and unripe fruit. A sorter needs three things - an eye that sees the colour, a brain that decides, and a hand that moves the item. Our sorter uses a TCS34725 as the eye, the Nano RP2040 Connect as the brain and an SG90 servo as the hand: the servo turns a chute so each item slides into its own bin.

Open Nano-RP2040-Connect-Color-Sorter.pdsprj. U1 runs RP2040Connect_Color_Sorter.hex. The parts come from our own libraries, each with its article: U2 from the TCS34725 Library for Proteus and SERVO1 from the PCA9685 Servo Driver and SG90 Servo Motor Library for Proteus. The TCS34725 is the Advance version: it opens its pop-up window at Run, with the colour of the item and its counts. PC1 is the Laptop WiFi Monitor and MOB1 the Mobile WiFi Monitor.

Arduino Nano RP2040 Connect Proteus simulation: TCS34725, SG90 servo, laptop and phone
Figure: The whole demo: U1 with its pins on net labels, the TCS34725 at the top right, the SG90 below it, the laptop and the phone.
The wiring of the colour sorter
Part pinNet labelNano RP2040 Connect pinWhat it does
TCS34725 SDA, SCLSDA, SCLA4, A5I2C at 0x29
TCS34725 VIN, GNDVCC, GND3.3V, GNDthe sensor's supply
SG90 SIGSERVOD9the servo pulse, 500 to 2500 us
SG90 V+, GNDVCC, GNDVUSB, GNDthe servo's supply

In the demo the sensor's VIN and the servo's V+ are on labels named VCC - Proteus' power rail: the models read the supply as a digital level, and the board's 3.3V pin is an analog source in Proteus. On a real board the TCS34725 sits on 3.3V and the SG90 on 5 V from VUSB or, better, its own supply.

How the TCS34725 Sees Colour

The TCS34725 has a 3 x 4 grid of photodiodes: some under red filters, some under green, some under blue, and some with no filter at all (the clear channel). Each group feeds its own 16-bit converter, so one reading gives four numbers - red, green, blue and clear. An infrared filter on top keeps heat and sunlight out of the colours, and the white LED on the breakout lights the item evenly from close by. The gain (1x to 60x) and the integration time (2.4 ms to 614 ms) set how sensitive it is; the sketch uses 4x and 50 ms - fast enough for a belt.

Adafruit's library hides the registers: begin() checks the chip's ID and powers it up, and getRawData() returns the four counts:

Adafruit_TCS34725 tcs(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);

From Counts to a Colour

Raw counts depend on the light: a red item under a bright lamp gives bigger numbers than the same item in the shade. So the sketch does not compare counts but shares - how much of the light is red, green and blue. A share over 55 % names the colour; anything more mixed is OTHER:

int classify(uint16_t r, uint16_t g, uint16_t b) {         // RED / GREEN / BLUE when one share is over 55 %
  unsigned long sum = (unsigned long)r + g + b;
  if (!sum) return 3;
  shareR = r * 100UL / sum; shareG = g * 100UL / sum; shareB = b * 100UL / sum;
  if (shareR > 55) return 0;
  if (shareG > 55) return 1;
  if (shareB > 55) return 2;
  return 3;
}

Yellow light is a good test: it is red and green in equal parts, so neither share passes 55 % and the item goes to the OTHER bin. The threshold is a single number to tune for real items - lower it for pale colours, raise it for strict sorting.

Turning the Chute

The SG90 turns to an angle given by the width of a pulse every 20 ms: about 0.5 ms for 0 degrees and 2.5 ms for 180. The Servo library makes the pulse; the sketch only says the angle. Each bin has its own angle:

const int ANGLES[] = {30, 90, 150, 180};
  chute.attach(SERVO_PIN, 500, 2500);

A new item is a change of colour: the sketch counts it, turns the chute and flashes the L LED for one second:

void sortItem(int colour) {
  current = colour;
  counts[colour]++; items++;
  chute.write(ANGLES[colour]);
  digitalWrite(LED_BUILTIN, HIGH);
  ledOff = millis() + 1000;

WiFiNINA and the Page

Joining the network is one line with WiFiNINA: WiFi.begin() blocks until the board has an address or gives up, so the sketch simply tries again:

  while (WiFi.begin(ssid, pass) != WL_CONNECTED) { Serial.println("Not joined yet - trying again"); delay(2000); }

The web server reads the request's first line and takes the path: / is the page for the phone, /json the values for a program and /reset clears the counts:

  if (path == "/reset") resetCounts("the web page");

The loop does four things in turn - the sensor, the LED, the web server and the monitor:

void loop() {
  readColour();
  if (ledOff && millis() >= ledOff) { ledOff = 0; digitalWrite(LED_BUILTIN, LOW); }
  serveClients();
  readMonitor();
}

Run the Demo

Press Run. The serial monitor opens; the sensor answers, the board joins TEP-WiFi and the first item - a red one - is already under the sensor:

Nano RP2040 Connect Colour Sorter - The Engineering Projects
TCS34725 ready
Connecting to TEP-WiFi
Sorter page: http://192.168.1.101/
Item #1: RED (R 80 % G 12 % B 6 %) - chute to 30 degrees
Arduino Nano RP2040 Connect serial monitor in Proteus: the colour sorter starts
Figure: The serial monitor: the TCS34725 ready, the page's address, item #1 RED - the chute to 30 degrees.
Arduino Nano RP2040 Connect colour sorter running in Proteus
Figure: The demo running: the antenna green on Wi-Fi, the sensor on I2C, the servo on D9, the laptop and the phone on TEP-WiFi.
TCS34725 Advance pop-up in Proteus: a red item
Figure: The TCS34725's pop-up: a red item under the sensor and the counts the sketch read over I2C.
Arduino Nano RP2040 Connect panel in Proteus: on TEP-WiFi at 192.168.1.101
Figure: The board's panel: on TEP-WiFi, the router's list, the address 192.168.1.101.

Open the Page

On the laptop click Browser and Go (the home page is http://192.168.1.101/json, the values for a program); on the phone the same with http://192.168.1.101/, the page with its links:

Laptop WiFi Monitor in Proteus showing the Nano RP2040 Connect sorter JSON
Figure: The laptop: the JSON - the last item, its colour shares and the counts.
Mobile WiFi Monitor in Proteus showing the Nano RP2040 Connect sorter page
Figure: The phone: the last item RED, the counts and the chute at 30 degrees.

A Green Item: the L LED On

On the TCS34725's pop-up click GREEN: a green item is under the sensor. The sketch sees the change, counts item #2, turns the chute to 90 degrees and lights the L LED next to the ON LED for a second:

TCS34725 Advance pop-up in Proteus: a green item
Figure: The TCS34725 with a green item: GREEN dominant.
Arduino Nano RP2040 Connect in Proteus with the ON and L LEDs lit
Figure: The running Nano RP2040 Connect with its LEDs on: ON, and L for the new item; the antenna green on Wi-Fi.
Mobile WiFi Monitor in Proteus: the sorter page after a green item
Figure: The phone after REFRESH: the last item GREEN, the chute at 90 degrees.

Blue and Yellow Items

Click BLUE: item #3, the chute to 150 degrees. Then YELLOW: half red and half green, no share over 55 % - item #4 goes to OTHER and the chute swings all the way to 180 degrees:

TCS34725 Advance pop-up in Proteus: a blue item
Figure: The TCS34725 with a blue item: item #3, BLUE.
SG90 servo in Proteus: the chute at 180 degrees for the OTHER bin
Figure: The SG90 at 180 degrees: the yellow item goes to the OTHER bin.
Laptop WiFi Monitor in Proteus: the sorter JSON after four items
Figure: The laptop after Go: four items - one of each colour.
The run
StepColour shares (R / G / B)ColourThe chute
Run80 / 12 / 6 %RED30 degrees
GREEN on the pop-up0 / 100 / 0 %GREEN90 degrees
BLUE on the pop-up0 / 0 / 100 %BLUE150 degrees
YELLOW on the pop-up50 / 50 / 0 %OTHER180 degrees

Reset the Counts

Tap RESET on the phone: the sketch clears the counts and logs who asked. The same works from the serial monitor with the RESET command.

Mobile WiFi Monitor in Proteus: the sorter counts after RESET
Figure: The phone after RESET: the counts back to zero.

The built-in serial monitor, in the look of our TEP Serial Monitor Advance for Proteus, logs every item and every page:

Page /json for 192.168.1.21
Page / for 192.168.1.41
Item #2: GREEN (R 0 % G 100 % B 0 %) - chute to 90 degrees
Page / for 192.168.1.41
Item #3: BLUE (R 0 % G 0 % B 100 %) - chute to 150 degrees
Item #4: OTHER (R 50 % G 50 % B 0 %) - chute to 180 degrees
Page /json for 192.168.1.21
Counts reset (the web page)
Page /reset for 192.168.1.41
Arduino Nano RP2040 Connect serial monitor in Proteus: the sorter log
Figure: The serial monitor after the run: four items, the pages and the reset.
Arduino Nano RP2040 Connect serial monitor Board tab in Proteus
Figure: The monitor's Board tab: every pin live, the ON and L LEDs, RESET.

Try It Yourself

  • Drag the pop-up's colour sliders slowly from red to green: watch where the item stops being RED and becomes OTHER.
  • Lower the brightness on the pop-up: the counts drop, but the shares - and the colour - stay the same.
  • Type STATUS in the monitor for the counts and the address, or RESET to clear them.
  • Change the 55 in classify() and rebuild: a lower threshold sorts paler items too.

Ideas to Extend the Colour Sorter

  • Add a second servo as a gate, so one item at a time drops in front of the sensor.
  • Teach the colours: store the shares of a sample item for each bin instead of fixed RED, GREEN and BLUE.
  • Send each item to the laptop over WiFiUDP and draw a live chart.
  • On a real board, use the LSM6DSOX to stop the belt when the machine is knocked.

Your Own Sketches

Write the sketch in the Arduino IDE with the board Arduino Nano RP2040 Connect (TEP Proteus), use Sketch > Export Compiled Binary and set the board's PROGRAM property to the .hex. The same sketch compiles for a real Nano RP2040 Connect with the "Arduino Mbed OS Nano Boards" package and the WiFiNINA library - select "Arduino Nano RP2040 Connect" there and upload. Adafruit's TCS34725 library comes from the Library Manager.

Things to Know Before Using a Real Nano RP2040 Connect

  • 3.3 V logic: the pins are not 5 V tolerant; the TCS34725 breakout runs on 3.3 V.
  • A6 and A7: on the real board they are read through the NINA module and are analog inputs only.
  • The servo's supply: an SG90 can draw several hundred milliamps when it starts; give it its own 5 V supply with a common ground rather than the board's pins.
  • The NINA firmware: update it with the IDE's firmware updater when WiFiNINA asks for a newer version.
  • Serial1: Serial is the USB and Serial1 is on D0 and D1.

Properties of the Arduino Nano RP2040 Connect

Double-click the Nano RP2040 Connect to change them
PropertyWhat it does
PROGRAMthe sketch: a .hex from TEP Boards for Proteus (board "Arduino Nano RP2040 Connect")
WIFISSID, WIFIPASSthe router in range (TEP-WiFi, 12345678)
MONITOR, BAUD, AUTOOPENthe built-in serial monitor: on, its baud rate (115200), open at Run
TIMEthe clock WiFi.getTime() gives the sketch: PC or a fixed UTC time

Troubleshooting

  • "TCS34725 NOT FOUND": SDA on A4, SCL on A5; the sensor's VIN on the power rail.
  • The servo does not move: its SIG on D9 and V+ on the power rail.
  • The board stays on "Not joined yet": the sketch's SSID and password must match WIFISSID and WIFIPASS.
  • A number goes wrong above 32767: int is 16 bits in the simulation - use long.
  • The page shows old values: use REFRESH; the monitors do not reload by themselves.

Limitations of the Simulation

  • Your sketch gets 8 KB of RAM in the simulation and runs slower than on the RP2040's two cores at 133 MHz with 264 KB; there is no second core and no PIO.
  • The LSM6DSOX IMU, the MP34DT05 microphone, Bluetooth, the NINA's RGB LED and the crypto chip are drawn, not modelled.
  • The router, the addresses and the windows are TEP additions.
  • Arduino and Nano are trademarks of Arduino S.r.l., RP2040 a name of Raspberry Pi Ltd and NINA-W102 of u-blox; this library is not made or endorsed by them or by Labcenter.
  • Tested in Proteus 8.5 in October 2026 (the demo as shipped, about 27 s of simulation). Proteus 7 is not supported.

So, that was all about the Arduino Nano RP2040 Connect Library for Proteus. I hope it helps you build and test your Nano projects before you touch the hardware - the sensor, the servo, the Wi-Fi and the web page in one simulation. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!


Comments

0

Join the conversation