Custom board having SAMD51 and Wifi NINA

Hi all,

We have developed a custom board around Adafruit Feather M4 express. Custom board has SAMD51 microcontroller and Ublox Wifi NINA W152 module. I have been trying to use Wifi and WifiNINA libraries to get Wifi module working. But somehow i cannot connect the module to the WiFi.

I've been wondering how SAMD51 and Wifi nina module are communicating with each other? What exact pins are required according to the WIFININA libraries? Would Wifi module be needed both SPI and UART connections with MCU to get connected to the WiFi?

I've uploaded the image of the pin config of Wifi module with SAMD51 MCU. I believe pinout is correct.

Also, I've made changes few changes to variant.c and variant.h files.

Can anyone please help me out here? I'd appreciate all the help I could get. :slightly_smiling_face:


I cannot be of much help by guessing what you did on your custom board. Posting a schematic, not a frizzy thing and links to technical information on each of the hardware devices will help us help you. Check the schematic and the library source, it will show you what pins are used for what.


Thank you for the quick response.

SAMD51 MCU link: ATSAMD51J19A - 32-Bit SAM Microcontrollers

This is my schematic of Wifi module:

These are the pinouts of how MCU and Wifi module are connected with each other.:

WifiNINA library which i am using... GitHub - adafruit/WiFiNINA

Pin assignment of the wifi module (from the datasheet):

Ublox NINA W152 module datasheet:

What I don't get is so far I've just made modifications to the UART TX and RX signals in the variant files. Do I need to add SPI pins for the WifiNINA as well in the variant files for the W152 module?

Please let me know if you need any other technical information. Thanks for the help.


Hi @Juraj ,

I went through the post "Ublox nina minimum pins". I've got some questions regarding the pins usage here.

  1. Do we really need UART TX/RX pins to get wifi NINA W152 connected to the Wifi (OR) we just need SPI interface? I am asking this because W152 module does not give you the capability to use UART and SPI at the same time. So its one at a time.

  2. As stated in the post NINA itself acts like a microcontroller, which has a ESP32 module integrated in it....Can I use UART RTS/CTS/DSR/DTS pins as 4-SPI pins as they are GPIOs as well? Please refer the images above I posted yesterday. FYI, I haven't connected pins 31,32,35,36, which are dedicated SPI pins, to the SAMD51.

Please let me know.


In my test I didn't connect RX/TX. On boards with NINA It is used only for BLE and esp32 firmware update.
I am not an expert on esp32

So you don't have a clue whether UART RTS/CTS/DSR/DTS can be used as 4-SPI pins or not?

afaik on esp32 (almost) any set of pins can be configured for SPI

Hi @Juraj ,

Alright! Can you also please tell me what module of NINA and MCU you have used in your testing? Have you tested on your own custom board or some other dev boards?

This might shed light to your issue

MKR Zero and esp32 dev board

Hi @hzrnbgy ,

Yes I have already gone through that document. My only question is according to the schematic attached above in my earlier posts, I have connected Tx,Rx,rts,cts,dsr.dtr to the microcontroller and since they are GPIO pins as well, so what if I use them as my 4-SPI pins? According to Wifi and WifiNINA libraries, they use SPI interface in order to get wifi working.

Please give me the suggestions if those 6 GPIOs can be used as SPI pins?


Yes, based on your schematic, you are using SERCOM0. SERCOMs in Atmel Cortex MCU are configurable to either USART, SPI, or I2C.

The problem is, you have those hardwired to the UART pins in the NINA module

The NINA SPI are on a different pin altogether

You might be able to change the SAMD51 side to SPI but you are stuck with the UART pins on the NINA side

I get it what you are saying. I did configure the SERCOM0 as my SPI pins on the SAMD51 side.

But on the other head, according to my schematic above, you also meant to say it is impossible to connect NINA to the WiFi as per the pin connections? Since UART pins also function as GPIOs, can't I use GPIOs as SPI pins?

Technically, you can connect to WIFI whether you have a SAMD51 connected or not since the ESP32 on the NINA itself is a programmable MCU. You are not required to connect the NINA to any external hardware to be able to connect to WIFI.

I am not sure if the pins on the NINA are multiplexed and can be configured just like the SERCOMs on the SAMD51, my guess is not.

I think you have to define the role of each MCU in your project. Is the SAMD51 the main MCU and you are just using the NINA to provide WIFI connectivity? Or vice versa? In either case, the pins you have on the NINA is the UART pins, so my guess is these can only be used as UART pins and not SPI. But that doesn't stop you from connecting to WIFI since the ESP32 itself can be programmed independently from the SAMD51

That's good to hear that I can connect NINA to the wifi.

Yes you are correct that SAMD51 is the main MCU in our custom board and ublox NINA W152 is just integrated to provide WiFi functionality.

Since I cannot configure pins (which I have on NINA) as SPI and its gonna work as UART only. Now the question comes how I can program NINA via UART pins such that it can connect to my Wifi independently from the SAMD51. What libraries should be used in this scenario. I believe WifiNINA uses only SPI interface right?

What are your suggestions and inputs here? I'd appreciate your help.

There are some AT libraries available to talk to an ESP32 running AT firmware. Or you can always write your own and talk to the NINA ESP32 from the SAMD51 using UART and AT commands

Something like (from the SAMD51)


The NINA ESP32 replies with "OK";


The NINA connects to WIFI and replies "connected..."

You have to read through the manual to determine the exact "AT commands" to command the NINA to do something (or use someone else' AT library)

Oh I get that. That way it'd be easier to communicate with NINA module and connect to Wifi.

I searched some AT libraries. Would you recommend any library (perhaps share some links) which is suitable for ARM Cortex MCUs/SAMD micro-controllers?

sendATcommands.ino (1.4 KB)

variant.cpp (8.0 KB)
variant.h (8.0 KB)

I have uploaded the sketch as well as my variant files where Serial1 is my Serial hardware Port. I've made the changes in the variant files acc. to the RX and TX pins.

As you can see on .ino file, I am trying to send command "AT" and i am trying to receive something but I am not receiving anything.

I'd really appreciate if you could please review the files if you have some time and let me know where I could go wrong.

Thanks so much for your time so far.