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.

Comments

  1. Mike Rogers says:

    I2C master and slave. Nicely done. I wonder what kind of latency this adds, if it’s negligible or not.

    • Hack Man says:

      a multi-core microcontroller with more pins than you’ll ever need.

      Challenge accepted.

    • 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.

      • Mikey says:

        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. 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.

  2. sdevvoodoo says:

    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.

  3. mmx1337 says:

    I second sdevvoodoo, dual core implies at least that there is shared program memory

  4. pff says:

    “All these require extra components, though.”

    but this doesn’t?

  5. Grant says:

    Wouldn’t it be easier and cheaper to just get an arduino mega with plenty of extra IO already built in?

  6. Necromant says:

    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.

  7. Necromant says:

    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.

  8. joseph says:

    DUAL-MEGAS!!!

    Seriously though, that’s what, 108 digital IO ports? What is the limit to this code? Could you do 3 or more arduinos?

  9. Kaz says:

    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.

  10. Daniel says:

    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

  11. rockets4kids says:

    I heard you like fail with your fail….

    When will the Arduino crowd realize that you can just take any 40 pin AVR mega, throw it on a breadboard, protoboard, or PCB, and download code to it?

    • andres says:

      yes, but it’s the standardized hardware and community that makes it worth it to some people.

      • MikrySoft says:

        ATmega is standarized and Arduino isn’t adding much more than that (power supply, oscillator, rs-232 usb interface). Getting Arduino code working on bare ATmega is just the matter of burning in a bootloader.

      • AC says:

        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.

  12. Thatcher says:

    I think the real question is, what is the maximum number of Arduinos you could control with this?

  13. Hack Man says:
  14. rasz says:

    I wanted you all to know my newest project involves multicore PC computers, I connect 2 PCs to gain additional LPT port!

  15. Bobby S says:

    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.

  16. wowme@wtf.com says:

    Wow, for about $30 you can emulate about $4 worth of i2c I/O expanders and waste about $24.

    • Got a blog post or Instructable detailing how to do that? I’d love to take a look. Buy the way you can get Arduino compatibles to use as an extender for ~$10. So you would only be “wasting” $6.

      • gr0b says:

        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)

    • AC says:

      Wow you’re pretty quick if you paid $30 for your ExtraCore! I’ll sell you mine for HALF OFF, $15! I’ll even buy 10 of them and sell to you at that price.

  17. Thanks AC. :D Maybe I should raise the price instead of lowering it?

  18. Cheezey says:

    I haven’t tried this, but I think that I might build a couple of my own Arduinos on a breadboard to make a dual-core one for less than the price of one :D

  19. Mike S says:

    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?

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

Follow

Get every new post delivered to your Inbox.

Join 96,449 other followers