Wemos Zero Clone and i2c?

I have googled around and as yet have found no answer (or none simple enough for me to understand) to this question, so will risk revealing my ignorance yet again.

I'm used to working with Leonardos and Unos. If you look up, say, the Leonardo spec on arduino.cc, you find that i2c (Wire) is implemented on pins 2 and 3 (SDA and SCL). If you look up the Uno, you find that the i2c pins are A4 and A5. On both these devices, the relevant pins are also ganged to a couple of sockets just above AREF, labelled SDA and SCL; but you can connect directly to pins 2 and 3, or A4 and A5, as the case may be.

I've got used to this and it makes sense to me. When I use i2c I know that even though I might only plug bus wires into the sockets labelled SDA and SCL, I can't use the "real" pins (2 and 3, on a Leo) for any other purpose because they are busy doing i2c. On a Leo, D2 and D3 are used up if you are running the Wire library. So far so good.

Now, in preparation for playing with a Zero M0 clone I ordered, I'm trying to figure out which pins are used for i2c (which pins can I not use for other purposes if I have Wire loaded). I see that above AREF there are the usual 2 sockets labelled SDA and SCL, but I'm having a hard time figuring out which digital or analog pins are the "real" SDA and SCL. This page

reveals this info for many duino models, but not the Zero.

I ran across a writeup at Adafruit about using multiple i2c interfaces (possible because of multiple "serial devices" implemented on the Atmel chip) but it quickly exceeded my experience level and confused me further. Is there a simple answer? I found a circuit diagram of the Zero, but alas it was also rather confusing.

Or, perhaps, is the Zero's labelled SDA (and SCL) actually an independent pin, not ganged to any of the D or A sockets on the board headers?

I realise this is probably a Classic Stupid Question -- but I did google fairly diligently w/o finding an answer at my comprehension level.

Can you link to the board your talking about because AFAIK Wemos don't have a Zero clone and the Arduino boards are either a Zero or an M0 but no Zero M0.

Sorry about the nomenclature. This was the Ebay listing for the board

https://www.ebay.ca/itm/SAMD21-M0-32-bit-ARM-Cortex-M0-Core-Compatible-With-Arduino-Zero-Arduino-M0

but it has been pointed out to me on another thread that Wemos doesn't admit the existence of this board, and some other mfr may have stencilled their name on it w/o permission. Reading the headline more carefully I see that it claims compatibility with Arduino Zero and M0, which I (ignorantly) conflated into "Zero M0".

I've been googling further (sometimes you have to dig!) and found a tutorial

which says that i2c is (by default) found on pins D11 and D12 (SDA and SCL) -- which would answer my question!

As I read more (not understanding a significant chunk of what I'm reading, but starting to get a glimmering) it sounds like the SAMD core has internal support for up to 6 "firmware" serial devices, like 6 different device numbers manageable by an internal driver; and there's a complicated mapping from pads on the smd chip, to pins on the Arduino board, to tx/rx and control signals in the driver. And all this happens in variant.h and variant.cpp.

So I've been staring at variant.h and variant.cpp for a while last night and am starting to get some inkling of what's going on, but still not confident enough to try moving anything around or creating additional serial ports. But if I understand it all correctly, it seems that this chip is so clever that it supports multiple serial ports, possibly multiple i2c buses, multiple SPI buses maybe... though what this EDBG debugger protocol is, I have as yet no clue. Hoping I can ignore it :slight_smile:

At any rate, if the tutorial above is correct, I have at least found out where the default i2c pins are, and that (yes) they are subtracted from the total inventory of digital io pins when Wire is loaded.

[philosophic reflection] One of the dangers of the Arduino world (as well as its great strength) is that complete EE nitwits (like me, for example) can actually build successful projects (even fairly complex ones) using simple MCUs, a friendly IDE, community supported libs, and OTS breakout boards -- all without really understanding anything about microcontroller architecture or the underlying hardware. I don't even know how to use an oscilloscope beyond the most fundamental "look at a square wave" functionality. And yet I can build cool things that work.

This is terrific -- opening up a whole world of Making to people (like me) who would otherwise never get to build cool things. OTOH, it means that we amateurs stumble into a pretty noticeable Ignorance Barrier as soon as we try to graduate to more sophisticated MCUs (like this Zero). Now all of a sudden I have to understand a lot more than I did to use a Uno or Leo; and because the first steps with the simple MCUs were so easy and instantly gratifying, it comes as a bit of a shock :slight_smile: but I'm now resigned to dragging myself up another learning curve; the speed and power of the SAMD device is too attractive to ignore (plus the existence of alternative packaging exposing all the chip's GPIO pins -- zowie!).

The ebay listing has ended but searching for the same item I come up with the below image. Is this correct?


If it is then it looks like it best matches the Arduino M0 and looking at the schematics the SCL/SDA sockets connect back to pins PA23/PA22 on the MCU and they do not appear on any other sockets on the board so you cannot use alternative pins with the default core setup. I'm not to familiar with the M0 but it can use alternate pins for I2C and other peripheral functions so could be moved if really needed but probably not ideal for new users.

Do you have a specific end use in mind when your talking about multiple serial ports etc or is this just general ideas?

Why not just look at the pins_arduino.h variant file for the board?
It will have symbols for SDA and SCL which are the digital pin numbers for the i2c pins.
You could even write a simple sketch to print them out on the serial port if you want to have a simple sketch that will work for any core/board that will show the pins.

--- bill