The Pi Co-op from Dawn Robotics is an easy to use Arduino add-on board for your Pi, on sale here.

We've created a video showing what it is, and why you might want to buy one here.

Also, we've published a tutorial here showing how you can use Firmata to control the Pi Co-op from a higher level language like Python or Javascript. This essentially turns the Pi Co-op into a really easy to use general purpose I/O board. An Analog to Digital Converter (ADC), 5V I/O pins, PWM signal generation and much more, all in one board.

looks interesting … I've done a fair bit of software or web stuff over 30 years, but seem to have a block on the bare metal aspects of Pi use. I think because I've done so little physical electronics. The 3.5/5v thing has been a cause of caution, partly from stories of dead kit here. Your documentation is rather patchy. A few straight questions then

1. Does this essentially make all i/o into 5 volt?
2. video suggests I plug 5v into the co-op and the Pi powers from that?
presumably down the header pins, is this so?
3. to be clear, the Pi controls the co-op via the UART pins, the riser on the
card are from its own chip? Does this mean that the Pi pins are unavailable?
4. How is an ADC voltage read?
5. what do those female sockets on the board do, is there a map/graphic?
6. six male risers in the graphic above, what do those do?
7. is that a switch? What does that do?

TIA Chris

[edit] googling a bit … firmata doesn't seem all that well documented either. In essence I want to understand what the pins on the co-op are/do and how the firmata protocol sets/reads them

Sorry to be verbose, but this looks interesting. Here's a uno descriptor off the web "Input and Output"

Each of the 14 digital pins on the Arduino Uno can be used as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms. In addition, some pins have specialized functions:

Serial: pins 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.

External Interrupts: pins 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details.

LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it’s off.

The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and the analogReference() function. Additionally, some pins have specialized functionality:

TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire library.

There are a couple of other pins on the board:

AREF. Reference voltage for the analog inputs. Used with analogReference().

Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board.

clearly fewer io's but a pretty useful number. What of the above does it do, or not do please?

Thanks for the questions. The documentation is a bit sparse I'm afraid, but I'm looking to improve it all the time, and your questions give me some good pointers to areas which need to be expanded.

Basically, the Pi Co-op is an Arduino Uno, just one that's more integrated with the Raspberry Pi. All you really need to make an Arduino Uno is an Atmega328 microcontroller, an oscillator, and the open source Arduino bootloader (a program that sits on the Atmega328, and allows it to be programmed over the serial pins). Therefore, anything the Arduino Uno can do software wise, the Pi Co-op can do also. In fact, the Pi Co-op has a slight advantage in that it has 8 analog inputs, whereas a standard Arduino Uno has only 6 (this is because the Uno uses the DIP package Atmega328, and the Pi Co-op uses the surface mount Atmega328).

Keeping in mind that the Pi Co-op is really an Arduino Uno, this makes it a bit easier to answer your questions

1. Does this essentially make all i/o into 5 volt?

Yes, this is because the Atmega328 runs at 5V, and communicated with the Pi using serial. Therefore only the RX/TX lines between the Atmega328 and the Pi need to be level shifted.

2. video suggests I plug 5v into the co-op and the Pi powers from that?
presumably down the header pins, is this so?

Yes, 5V plugged into the Co-op would power the Atmega328 and then go through the fuse to power the Pi. The voltage does need to be regulated 5V, so putting in too high a voltage will still probably damage your Pi, but the fuse should protect the Pi from current spikes when running at 5V.

3. to be clear, the Pi controls the co-op via the UART pins, the riser on the
card are from its own chip? Does this mean that the Pi pins are unavailable?

Yes, yes, and yes. Although we do hope to offer the option of being able to buy the Pi Co-op without the headers soldered on very soon, so that if you wanted too, you could solder on your own extended header pins to get access to the rest of the Pi GPIO pins. We did look at the option of using extended header pins as standard, but it seemed tough to get them at good wholesale prices without buying a really massive quantity of them.

4. How is an ADC voltage read?

After connecting your signal to one of the ADC input pins you would either write an Arduino sketch using the AnalogRead function, as shown in this tutorial. Or alternatively, if you were using PyMata, then it would involve running a Python script something like the one in this pymata_analog_read.py example.

5. what do those female sockets on the board do, is there a map/graphic?

Those sockets correspond to the sockets on an Arduino Uno, with some extra ones assigned to 5V and ground. You can get a clearer view in the image linked here.

6. six male risers in the graphic above, what do those do?

That is the programming header for the Atmega328. You can use it to program the Atmega328 directly (as opposed to using the Arduino bootloader) by using a programmer such as this one.

7. is that a switch? What does that do?

That is the Arduino reset switch. It could possibly also be read from the GPIO pin used to reset the Arduino from the Pi, although I'd need to check that.

Overall, I believe that combining an Arduino with a Raspberry Pi gives a lot of power and flexibility, in that you have a microcontroller which can do a lot of things for you hardware wise, ADC, level shifting, PWM etc. It can also run general purpose code, which can be very useful if you want to do something and guarantee that it isn't interrupted by another thread etc. Unfortunately, this power and flexibility does come at the price of extra complexity, in that there needs to be serial communication between the Pi and Arduino in order to coordinate things. That's why I've tried to emphasize the use of PyMata, as it can hide a lot of that complexity.

Anyway, if you've made it to the end of this fairly lengthy post, hopefully that makes things a bit clearer.

Came two days later. it is nicely smaller than a "shield" and basically covers about 40% of the Pi board, in from the pins. A 26 way female engages these nicely, the rest of the add-on rests on that famous capacitor on the other side via a silicone rubber blob. I think any pressure there will be small as the reset button is riser side of it.

The female input/outputs are a couple of mm proud of my case, so I cut a hole (Stanley knife, took about 20 minutes). Slight anxious moment on power up, I think boot is a little slower but as I've converted to LAN headless to try this I don't see the boot monologue any more. Eventually I got a ping and puTTy connected nicely. All seems well.

So now all my bare metal i/o is 5v and I feel a lot braver. It's already got me LAN headless. Downsides are that the pins are now hidden (or is that an upside?) and that my UART is committed. Everything will be slower, ms instead of μs, no problem chez moi. Wish me luck. Picture attached. Yes, its a real bread board.

Thanks. I attach a pic (in the orientation I get to see it) and have the female pins well sorted. The 6 pin riser I am not so sure about. Guess I could probe about with a meter with it switched on, but

1. are the P10 riser pins as per the insert from your schematic?
2. They contain an SPI bus? So is that off-board, or from the Pi GPIO?

. If it is off the board, how is it controlled?
. If off the Pi .. presumably shifted to 5V .. or not?

Yes, as Dougie kindly pointed out. This is a standard ISP programming header, which you would connect to using a programmer such as this one. The pins are connected directly to the Atmega328. In general when reading a schematic, pins which have the same name are connected to each other, but the connections aren't shown to try to keep things readable.

You shouldn't need to use the programming header, as the Arduino bootloader has already been put on it, and this allows for programming via the UART lines. Situations in which you might want to use a programmer are if you wanted to reflash the Arduino bootloader for some reason, or if you had a program that used up so much space, that you needed to reclaim the 2K or so used by the bootloader.

Ideally I should also have put some markings on the silkscreen to identify the correct way to plug in the programming header, but you have the correct orientation. You can see the reset line going to the reset button, and if you turn the board over, you should see that the ground pin is connected by a couple of small 'spokes' to the ground plane.

In this situation, the SPI lines can't talk to the Pi. The Arduino can communicate using SPI to other devices, but all communication between the Pi and the Arduino on the Pi Co-op is limited to serial UART.

The SPI lines could be connected to the Pi, but we took the decision not to just because that would have involved more level shifting logic, and we were trying to keep things as simple as possible. Hopefully, as I say, we'll release a version without headers soldered on at some point, so people could use an extended GPIO header pin to access the Pi's SPI pins and wire this up if they wanted to.

There are indeed, many, many Arduino add-on boards for the Pi out there. I think that incorporating an Arduino appears as quite a logical step when trying to integrate the Pi with external electronics. Our aim with the Pi Co-op was really to offer a nicely integrated Arduino, that was as easy to use as possible, hence the focus on Firmata and PyMata which we talk about in this blog post.

Also, if you consider that we're a robotics company with some Arduino robot kits that we'd like to get working with the Raspberry Pi, then our plans for world domination should become clear.

Sorry, missed this part. It looks like SPI isn't currently supported by Firmata, although there is a proposal to add it.

You can however make use of SPI by writing you own Arduino sketch and using the Arduino SPI library. Serial communication back to the Pi is also easy using the Arduino serial library, and then you'd use a serial library in the language of your choice to control it.

Thanks Alan. I rose with the lark this morning My desktop interface via xming is a little bit slow so I used the methods in your Appendix A, double checking everything (as you do). The (recommended test) blink module compiles and and I got a nice Xming pop up window in desktop. Did what the progress bar gets to about 90%. There it hangs. After about 10 minutes I hit ctrl-C. Then I tried again and went off to watch Andrew Marr .. on return it had autokilled. Logs etc attached below in case you can see an obvious flaw. I still feel optimistic as it's only falling at the last hurdle; but I'm not sure why

...
Just to add that the whole Pi in hung at this point! I get my linux "Pi~>" prefix, but all keyboard input (including ctrlC/D/X) resulted only in a line feed. Shutting the PuTTy window allowed a successful re-login, which seems entirely normal. TIA

It looks for some reason as if the code to reset the Arduino (and thus prepare the bootloader to receive code) is not being called. I'm a bit confused though, is this the same SD card that you've been running the PyMata examples on?

Also, I take it from the fact that you're following the Appendix that you're not running Raspbian? Which distribution and version are you using so that I can have a go at reproducing the bug?

no problem, I've been out all day too.
1
I bought my Pi in November and found the HDMI interface absolutely horrible on a small Wifi keyboard and my TV. after some advice here [thanks] I installed the UART interface which has worked very well. In order to make "co-op" work I "obviously" needed another interface and I got the PuTTy SSH LAN address sign in system working in order to use it. That xming made your arduino system pop up windows on Windows. and seemed a nice bonus.

My SD card is a raspian download in late November; as updated every week or so. i "think" I did all the mods on your appendix A. I updated apt-get update to the latest system this morning, (as instructed) So far i've never had opportunity to run a working pymata. So, I guess, current build? Your own software was downloaded "as per PDF" at approx 8 am this morning.

If you've got a spare SD card available, could you try using the current version of Raspbian (2014-01-07-wheezy-raspbian.zip) and then following the steps in the 'Simple Installation Process' section? I've just done this at my end and everything works fine.

The script run in the Simple Installation Process just carries out the steps detailed in the Appendix so I'm thinking that there could be a small mistake or omission in the list of instructions, or perhaps something wasn't conveyed well enough for when you were following them. Either way, if we could test to see if the installation script works then we could hopefully see if it's a problem with the software setup or the hardware.

Also, just on the off chance that it's something simple. Can you check that it definitely says 'Arduino Uno on /dev/ttyS0' in the bottom right corner of the Arduino IDE? Also, can you check that the Pi Co-op is definitely on the GPIO pins correctly and not one row up or down?

Any chance you can help. I'm an Arduino newbie. But basically I followed another tutorial to hack some IKEA DIODER Lights, you remove the controller, wire to Red, Green, Blue, a common ground and common +5v. The following .ino works when uploaded via the Arduino IDE...
**********************************************************************************************
// color swirl! connect an RGB LED to the PWM pins as indicated
// in the #defines
// public domain, enjoy!

**********************************************************************
I was hoping to have similar control over the LEDs using the PyMata, however I'm having trouble finding an example that uses PWM and allows analog writes.

I thought something like this would work but it seems to output nothing. Do you have any suggestions?

***************************************************************************************
import time

try:
# run in a loop over and over again forever:
while True:
#for r in range (0,256,1):
firmata.analog_write( REDPIN, 255 )
firmata.analog_write( GREENPIN, 0 )
firmata.analog_write( BLUEPIN, 255 )
time.sleep(1.0) # wait for a second