33
\$\begingroup\$

I'm a computer science student and I'm eager to expand my knowledge on embedded programming and electrical engineering.

I've read here that using tools like the Arduino microcontroller is a good way to start.

I'm primarily a Java and Python programmer but have some experience in C++. Furthermore I have toyed with ArchLinux.

A small project I'd like to do is controlling some lightbulbs via Wi-Fi over my Arduino/Pi.

From what I've read both the Pi and Arduino are intended for students but I can't figure out which is more suitable for someone like me who wants to understand how computers work on the low level.

As a beginner I will run into many questions, so a big and helpful community (which I hear the Pi has) is a big plus.

So which one is more suitable for a self-teaching beginner: Arduino or Raspberry Pi?

Thanks in advance.

Edit:

From your many great answers and also these worthwile articles I came to the following

Conclusions

  1. I choose Arduino as an entry point to embedded programming because it is a simpler system than the Pi and lets me work closer to the metal more easily.

  2. There is value in going deeper: I might study AVR or mbed microcontrollers at a later time to learn more about the low level details of computing.

  3. Both devices allow me to program without an operating system, which is what I want (at first).

  4. I also found projects that use one Pi to control an Arduino. I find this intriguing as both devices are quite affordable and I like to use the power of Linux that can run on the Pi.

  5. Additionally I've found this book that should help me to learn more about electrical engineering while experimenting with Arduino.

  6. It seems difficult to do my lightbulb project with the Arduino. But that's ok. I'm sure I can think of other motivating projects or get inspiration here or here.

Thank you all for your answers.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ The Arduino is simpler. I suggest that's a better starting point for a "self-teaching beginner". The Arduino currently has a bigger community of add-on makers e.g. for "shields" (plug-in daughterboards). The Pi is better value for money but I think has fewer low-level intefaces (GPIO count, I2C etc) than many Arduino variants. I have one of each, if you are less interested in low-level stuff I'd use the Pi. \$\endgroup\$ Commented Dec 10, 2012 at 0:47

6 Answers 6

37
\$\begingroup\$

If you really want "to understand how computers work on the low level", then it could be argued that neither Arduino nor Raspberry Pi are suitable. Both of these platforms (their hardware and software) are designed specifically to hide the low-level details in order to make it easy for people who don't care about those details to accomplish their higher-level goals by creating embedded applications.

Instead, I would recommend picking a CPU family that has a relatively "clean" instruction set architecture, and learning how to program it in assembly language. For example, I did a lot of my early coding on a PDP-11 minicomputer, which has (well, had) a very clean 16-bit architecture. I'm told that the TI MSP430 family is very similar. On modern 8-bit families, it could be argued that AVR is a bit cleaner than PIC. Or you could go old-school and look at the M68K or even the Z80.

So, it really depends on what your goals actually are: Do you want to create embedded applications, or do you want to study the processors themselves?

If you want to start with the former and then shift more to the latter later, maybe you should start with Arduino now, and then migrate to programming the underlying AVR processor at a lower level later.

I make this recommendation partly because of the simple nature of the application you suggested, and partly because of the migration path. It's much more difficult to migrate to low-level programming on the Pi. It's based on a complex SoC that requires quite a bit of software "infrastructure" just to get it going. With the AVR, you can easily program right down to the "bare metal" if you're so inclined.

\$\endgroup\$
3
  • \$\begingroup\$ Thanks, I would like to start with creating embedded applications and maybe later go into studying the processors. \$\endgroup\$ Commented Dec 9, 2012 at 15:08
  • 1
    \$\begingroup\$ You can program a Pi bare metal without any problem, no need to know any infrastructure. Just ignore the video, audio and networking, and you have a speedy ARM chip with plenty of RAM, which is loaded for you from the SD card. Alternatively, put a bootloader on the SD card and download your application to RAM using a serial port. \$\endgroup\$ Commented Dec 9, 2012 at 18:29
  • 2
    \$\begingroup\$ For burn & crash bare metal development, the Arduino with it's ready to go boot loader and drastically simpler startup requirements is going to be far simpler to get going with (ie, treating it as an ATMEGA dev board) \$\endgroup\$ Commented Dec 10, 2012 at 23:28
13
\$\begingroup\$

An Arduino can be used with the Arduino SDE, which provides some functionality in a 'hidden' way, but it can also be used with plain assembler, C, or C++ (and probably with a lot of other languages, but those seem to be less common). There is a wide variety of add-one boards available called shields, is most cases with support software that integrates with the Arduino SDE. Combining multiple shields can be tricky. Ethernet is possible, but that is stretching the capabilities. USB host stack is AFAIK beyond its capabilities.

The original Arduino contains an AVR chip, but there are alternatives based on PICs and LPC (ARM) chips.

The Raspberry Pi is designed to be a single-board computer running a scaled-down Linux. As such it can be programmed in a wide variety of languages (from assembler to Python, and everything inbetween, inlculiding C and C++). It can be an USB host, so it should be no problem to add an USB WiFi dongle. The Pi PCB has an IO connector on which some pins are available, and you can access those pins from your Linux app, but it feels a bit clumsy.

Although it was not designed to be used in such a way, it is no problem to program the Raspberry Pi bare metal (= without any OS). Now you have direct and fast access to the IO pins, but you loose the ability to run Liunux drivers, so adding WiFi will be difficult. AFAIK as yet there are not as many hardware extensions (with accompanying software libraries) for the RaPi as there are for the Arduino, but my gut feeling is that this might change.

All in all I'd say you can't go wrong with either, but if you really want WiFi I'd recommend RaPi with Linux.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ One bad point of Raspberry Pi is the lack of official documentation. It's mostly top-secret proprietary Broadcom stuff which mere mortals can't touch it. If ARM speed is needed, there are other platforms which have much better documentation for bare metal work which are cheap and easier to obtain compared to Raspberry Pi. On the other hand, Raspberry Pi is much closer to a "real computer" than various cheap ARM kits from Texas Instruments, STmicro or Freescale. \$\endgroup\$
    – AndrejaKo
    Commented Dec 9, 2012 at 21:00
  • 3
    \$\begingroup\$ AFAIK the lack of documentation is on video and maybe the audio parts (but I read that the drivers for those parts are now open sourced - so there is at least some form of documentation if you want to use those parts.) If you just pretend those parts are not there you are left with an awful lot of bang (RAM and CPU power) for your bucks. Who cares that there is additional stuff you don't want to use anyway in a typical microcontroller application? I don't need a full-blown graphics engine. And if I need a pixel-level interface it is there. \$\endgroup\$ Commented Dec 9, 2012 at 22:19
  • \$\begingroup\$ It's not just the audio and video, the pi's GPIO documentation is very sparse compared to usual embedded devices. \$\endgroup\$ Commented Dec 10, 2012 at 23:29
  • 1
    \$\begingroup\$ I had no trouble using the GPIOs using the available documentation. Did you find any problems? \$\endgroup\$ Commented Dec 11, 2012 at 7:23
4
\$\begingroup\$

In my opinion it comes down to this: do you want to program in an OS or on the hardware itself (sort of making your own OS)?

With a RaspberryPi you're pretty much going to be using Debian Linux. That's fine and Linux is really useful. If you learn that, you could grow on to other PC's, servers, etc. You'll probably be programming in Python again if you're familiar with it because it's nice and easy to do on the Pi.

If on the other hand you want to see what it's like to program something really tiny, cheap and low-power, try the Arduino. All your code runs on that little chip there, you could even remove it from the board (if it's a DIP one) and put it on a breadboard and see for yourself just how little hardware you need to get a basic little computer working. That was pretty amazing to me at least. Everything you write will be running on that chip itself so its entire "OS" will be your little run-loop. The Arduino IDE/language is nice to get started with but later getting down to C/C++ will be pretty useful to know. If you really get into it at that point, you could use your C skills easily on other micro's like ARM Cortex M chips or TI's MSP430's for really low power.

I'd suggest for you to go toward Arduino if you care more to learn EE and embedded languages, mostly because of how easy it is to make your own circuits for the EE part. You can't very easily remove the Raspberry Pi's chip to your own board or mess with the hardware much; also it's pretty much a Linux system. Just spin up a VM at that point and learn Linux there.

\$\endgroup\$
3
\$\begingroup\$

What is appropriate really depends on the details of the task.

If you need wifi, you will likely find a Raspberry Pi to be a more cost effective solution, since you can use a cheap wifi dongle.

However, the pi has some complexity - on the software side, though you have some experience with linux configuration, and also in its power supply limitations - a few wifi dongles will work directly, for others you will need a powered hub or to solder bypasses around the polyfuses.

On the Arduino path, unless you get a wifi adapter which implements a full network stack and simulates a serial channel, you are going to end up using a large fraction of your available memory for the networking implementation; people do it, but it can be a tight fit.

As a matter of opinion, neither platform is really ideal for this task - the pi turns out to be a bit more of a toy with its power limitations, overhanging SD card mount, and withheld documentation than would be ideal as an embedded building block, and the Arduino has few onboard resources for its price. That said, there aren't a lot of widely popular alternatives which are superior, though there is a long history of hacking digital I/O onto linux-based wifi routers, and some of those are competitively cheap/compact now.

\$\endgroup\$
3
\$\begingroup\$

I would recommend the mbed processor. It has a nice balance of high level abstraction (to get you started) in C++ and then you can drop down to C and start working with at a lower level.

Once you are up to speed and comfortable with interrupts, timings and reading information (both analogue and digital) then move down to a simple PIC. I like the 16F886, this will give you a much better idea of what is actually going on at the register level. Use the Hi-Tech C compiler as a starting point, there's no need to go to assembly unless you really want to.

With the PIC you can start worrying about power consumption, program size, memory, timing delays.

From there you can move back to a larger processor like mbed or arduino knowing that you have a better idea of what is going on inside.

\$\endgroup\$
2
\$\begingroup\$

I started with Arduino and when I understood how it works, I moved to Pic and we could say it succeeded. I made some flashy projects with Arduino, and it's easy because in the web you have a lot of code examples. Raspberry pi is still growing and there isn't that much help as Arduino. So in my opinion, I recommend you to start with Arduino and when you get some level, move to a microcontroller.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ I didnt watch the posted time, it just appeared to me in the suggested topics and I only wanted to help. \$\endgroup\$
    – user58401
    Commented Nov 18, 2014 at 10:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.