Dual core Arduino for more pins

There are easy ways of getting more I/O pins for any project; shift registers, I2C expanders, or ADCs will give you plenty of pins for whatever project you have in mind. All these require extra components, though. Enter the ExtraCore library for Arduino, a software library that turns two or more Arduinos into a multi-core microcontroller with more pins than you’ll ever need.

The ExtraCore library comes from [Dustin Andrews], and allows anyone to control the input and output pins of two Arduinos with the same ease as a single Arduino.

The hardware setup is fairly simple – just connect A4, A5, power, and ground on both Arduinos together. After installing the ‘client’ sketch on the second Arduino, you can modify the ‘manager’ sketch to suit whatever project you’re building. From there you’ve nearly doubled the number of Arduino pins your project can control.

It may not be the most practical use of two Arduinos, but it’s certainly impressive. You can pick up [Dustin]’s code over on GitHub.

41 thoughts on “Dual core Arduino for more pins

    1. I wrote the lib and don’t want to sell it short, but I also don’t want to oversell it. :)

      The latency is not “negligible”. Do the video frame by frame and you can see the client LED is a couple of frames or more behind the manager. For things that don’t require timing better than 10ths of seconds it should be fine.

      Also, if you watch the whole video, you will see the client drops at least two frames. So it’s like 99.9% reliable.

      1. Why is the library called ExtraCore if in fact (assuming the write-up above is correct) it has nothing to do with having an extra core? (i.e. you can’t offload tasks onto the other Arduino — make it do work in the background, etc…)

        What is the advantage of spending $30+ on another Arduino when you could just buy a common bit-shifter for a $1. This seems silly… I mean, it’s cool that you did it — but, it’s hardly practical.

        1. 1. Bitshifters don’t have 6 channels of PWM output and 8 channels of analog input.
          2. Now that you offloaded I/O to the second core, you can start thinking about other more complex scenarios like you describe. For example it would be trivial to add a smoothing function to the analog inputs, or debounce the digital ones.
          3. My $10 Arduino compatible for sale on Tindie is called “ExtraCore” and this library is one of the usages I first envisioned for it so I wanted to code it up.
          4. Yep, it was just a cool project to try. The code is free (beer) so please enjoy.

  1. Handy, but this really isn’t “dual core”. Not even close, in fact. There’s no parallel execution going on here, the second Arduino just has its IO slaved to the first one. A similar thing can be achieved using the various SPI/I2C port expander chips already on the market, and for a fair bit less cash, too.

  2. Awesome (sic!) solution! If you can’t do it with one arduino, take 2, if 2 are not sufficient – take 4. And then we see buggu robots with over 18 arduinos at eurobot.
    It’s fun to see what people do, instead of just taking a stm32f103zet6 or any other decent chip. It’s even worse then vendor lockin.

  3. Oh yes, and and there are ready to use i2c gpio expanders, a lot of them and cheaper shift registers. If that’s not sufficient – expanding and i2c into gpio can be done on a cheap cpld with little to effort and can give you over 100 pins.

  4. If it really gives you access to the other Arduino’s peripherals, then it’s great. If it’s literally just adding them as GPIO, then it’s far less interesting and cost-effective. In either case, it’s an interesting example for I2C master/slave.

  5. This is pretty cool – not because this is what I consider a good idea, but because someone took the time to do it. I’d think with a little work you could make the ‘slave’ code do other stuff at the same time (maybe monitor a matrix keypad, read/write to an SD card, etc while the manager is doing other stuff. You could add ‘virtual’ I/O pins to trigger functions on the slave – write a 1 to a virtual I/O that causes the slave to play back a complex sequence of events, etc.

    That said..
    I’ll leave this link right here:
    https://www.sparkfun.com/products/8130

      1. MikrySoft: Your comment is completely correct, and with no side effects, so long as you forget that fully 50% of the Arduino audience does not KNOW what a “bootloader” is.

        Arduino is a package of usability for non EE types. This fact is presented in nearly every article written about Arduino.

        In every HAD post there are always techies who keep missing the point, and pointing out the obvious that [insert other processor/platform here] can do the SAME job for [less money/fewer parts/less power/other favorite micro platform here], where inevitably the “other” thing lacks the Arduino IDE, bootloader, or shields community.

  6. I would like to see this done with an attiny 84 or similar. There have been lots of times I don’t need the power of a 328 but I need more pins than are available on the smaller, cheaper, chips.

      1. A shift register? Those are ok and all but it would be nice if the slave chip had some logic capabilities of its own. Not to mention the smaller attiny chips are cheap enough to be thrown just about anywhere you might consider using a shift register/IO expander.

      1. And if you can get away with just a Atmega88 or less then you would be “wasting” less then $2 which costs less then i2c I/O expanders for the same number of IOs. You can even share the xtal so you just need the IC same as if using an expander.

        I made the conclusion a while ago that it was better to use an extra atmega chip then i2c I/O expanders, but I offload some of the smarts to the secondary boards too (mostly sensor code)

  7. I have expirimented with ExtraCore and I think it is brilliant! The only problem with it is that it is so limited due to the slow speed of I2C communication. I am using two arduino Mega2560 boards and found that my PWM pins wouldn’t all work. Found that the pins have to be the same as the Uno! If the library was written to utilize the SPI communication, I think the Mega could be used with all the pins and run much faster. How hard would it be to create the library to work with the SPI bus instead?

  8. I like it, despite the points made by the “not really dual core” crowd. I believe it can add:
    Offloading some libraries onto the second core if you get creative with the setup, more eeprom to dump into using functions and predefined instructions, more pins of all sorts, 2x the total current output by spreading the outputs over 2 chips, and a library (which expanders don’t generally come with).

    Less hating, where’s your dual core microprocessor library at?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s