Arduino Serial Base Class

This page explains how to add a Serial Base Class to the Arduino Serial classes.

What is a Base Class?

A Base Class lays down some guidelines for how you build a bunch of related classes. In our case we're using serial classes. The base class will give us a set of methods that are available in all of the classes that are based upon it.

Why a Serial Base Class?

The short answer: to make things easier.

The long answer: there are a lot of confusing bits when it comes to interfacing with a serial device. Using a Serial Base Class for the serial devices on the Arduino will allow for better hardware abstraction. This way, we don't need to know exactly how a device is connected to our hardware - but we will be able to talk to it in the same way if it were connected to a hardware serial pin or a software serial pin.

How do I add a Serial Base Class?

OK. You've read the stuff above, and you're thinking, “what a bunch of mumbo-jumbo. I don't care. How do I add this silly thing?”. Well you're in luck. Here are the steps:

Arduino IDE 1.0+

With the 1.0+ releases there is a built in software serial interface that will allow your project to work with the rMP3 shield. Here is some example code:

//Use the SoftwareSerial in place of NewSoftSerial.h
#include <SoftwareSerial.h>
#include <RogueMP3.h>
 
//Use SoftwareSerial in place of NewSoftSerial
SoftwareSerial rmp3_serial(6, 7);
RogueMP3 rmp3(rmp3_serial);
 
void setup()
{
  Serial.begin(9600);
  rmp3_serial.begin(9600);
 
  rmp3.sync();
 
  rmp3.playfile("/Daft Punk - Technologic.mp3");
}
 
void loop()
{
}

The NewSoftSerial files do not need to be installed with the Arduino 1.0+ versions.

Arduino IDE V0021+

After collaboration with the people of the Arduino development mailing list, the name of the base class was changed from SerialBase to Stream. Unfortunately, there is still a problem with the Arduino core, so you still need download a modified version.

  1. Install into SKETCHBOOK/hardware folder (create the hardware folder if it doesn't exist).
  2. Start the IDE and select one of the ”(Stream)” version of your board from the Tools|Board menu.
  3. NewSoftSerial and other libraries with Stream modifications can be downloaded from here.

Arduino IDE V0019-0020

These Arduino Versions are messed up. Don't download them.

Arduino IDE V0018

  1. Install into SKETCHBOOK/hardware folder (create the hardware folder if it doesn't exist).
  2. Start the IDE and select one of the ”(SerialBase)” version of your board from the Tools|Board menu.
  3. NewSoftSerial and other libraries with SerialBase modifications can be downloaded from here.

Arduino IDE Versions prior to V0018

  1. Add SerialBase.h to your arduino/hardware/cores/arduino folder.
  2. Make some small changes to HardwareSerial.cpp and HardwareSerial.h in arduino/hardware/cores/arduino.
  3. If you're using NewSoftSerial, you'll need to make some similar changes.

To make it easier, I've already made the changes and they can be downloaded from:

Google Code - Rogue Robotics Libraries for Arduino

SerialBase.h, HardwareSerial.h, HardwareSerial.cpparduino/hardware/cores/arduino.

The modified NewSoftSerial library can replace your existing NewSoftSerial library in arduino/hardware/libraries.

After that, you're ready to go!

Discussion

mowcius, 2010/09/06 17:03

How's this working on 0019, is it still the same as on 0018?

I have also been having some issues and I can't remember what I've done/not done.

Error:

sketch_sep06a.cpp: In function 'void doLCDSpec()':

sketch_sep06a:120: error: 'class RogueMP3' has no member named 'getspectrumanalyzer'

sketch_sep06a.cpp: In function 'void playTrack()':

sketch_sep06a:180: error: 'class RogueSD' has no member named 'entrytofilename'

sketch_sep06a:185: error: 'class RogueMP3' has no member named 'setspectrumanalyzer'

Thanks,

Mowcius

bhagman, 2010/10/18 00:36

Added the information for Arduino IDE 0021.

RE: the RogueSD and RogueMP3 errors you're getting, you need to download the latest versions of the libraries (V0004+ and V0003+ respectively).

b

Don Burns, 2010/10/31 23:42

I have an Arduino Mega board with the Rogue rMP3 shield. I've been trying to download the correct versions and fixes of the software and libraries in order to get the XMAS sample program to work. I'm getting the following error: no matching function for call to 'RogueMP3::RogueMP3(NewSoftSerial&)'C:\Program Files\Arduino\arduino-0018\libraries\RogueMP3/RogueMP3.h:114: note: candidates are: RogueMP3::RogueMP3(SerialBase&)

C:\Program Files\Arduino\arduino-0018\libraries\RogueMP3/RogueMP3.h:107: note: RogueMP3::RogueMP3(const RogueMP3&)

Would it be possible for me to download or receive by email a zipped copy of all the directories and files nessasary to establish communication?

bhagman, 2010/11/01 02:11

Hi Don,

The Arduino Mega should be a snap. Use one of the hardware serial ports instead. Use the rMP3 on an Arduino Mega example to help.

If you need any more help, just email support@roguerobotics.com.

b

test94.23.1.28, 2012/06/27 03:12

I would like to use one of these for the next wearable peonfrmarce piece in a series I call Being Counted The first in the series, which I have already completed, is a neclace which senses when the wearer has swallowed, counts it, and keeps a running led display of the number of times on a pendant. The piece is intended to be worn to perform the action of swallowing. It makes visible the invisible and surveilles the mundane. Our space is becoming increasingly inundated with technologies which watch, count, and measure with little supervision. These technologies have become so embedded in our material world as well as our consciousness that they have become almost invisible to us. In many cases, we desire these objects that infringe on our rights to privacy, other times they are foisted upon us. The piece also speaks to a type of personal surveillance practiced by many who self-consciously pore over every bite of food. By creating a wearable object which counts the seemingly mundane, I seek to create an awareness in the viewer- an awareness that we are all being counted.I chose new materials, sillicone and acrylic, and combined them with old lace patterns to reference restriction and bodily awareness. The necklace/choker is a strip of silicon sheet that I hand punched in a delicate lace pattern. The pendant, the housing for the electronics, is made of lazer-cut clear acrylic in a doilly pattern. The sensing is done with a 4” flex sensor. The signal is read by an arduino lilypad which counts the signals and drives a multiplex 4-digit, 7-segment led display. Ostensibly, the piece could count up to 9999 swallows. The led display has just 12 pins because it is a common cathode display. This presented several challenges in building and programing the work, but enabled me to drive the led directly with the lilypad. In order to make the common cathodes work, I placed a transistor between the pin and the lilypad. This allowed me to selectively activate single digits of the display. Another challenge was presented in the delays necessary to individually light each digit and also in reading the sensor. These were eventually worked out so that the display lights continually and the sensor is read only once a second (so as to avoid multiple readings for the same swallow). The piece is soft in order to interact with the body of the wearer. These material choices were a combination of practicality and aesthetic choices with regards to a victorian-tech idea.I would like to continue this series of banal counters for the body. The next one I plan is a bracelet which counts the number of times the wearer swings their arm.

You could leave a comment if you were logged in.
  • Bookmark at
  • Bookmark "Arduino Serial Base Class" at del.icio.us
  • Bookmark "Arduino Serial Base Class" at Digg
  • Bookmark "Arduino Serial Base Class" at Google
  • Bookmark "Arduino Serial Base Class" at StumbleUpon
  • Bookmark "Arduino Serial Base Class" at Technorati
  • Bookmark "Arduino Serial Base Class" at Facebook
  • Bookmark "Arduino Serial Base Class" at Twitter
  • Bookmark "Arduino Serial Base Class" at Slashdot
  • Bookmark "Arduino Serial Base Class" at Yahoo! Bookmarks
  • Bookmark "Arduino Serial Base Class" at Furl
  • Bookmark "Arduino Serial Base Class" at Reddit
  • Bookmark "Arduino Serial Base Class" at Ask
  • Bookmark "Arduino Serial Base Class" at BlinkList
  • Bookmark "Arduino Serial Base Class" at blogmarks
  • Bookmark "Arduino Serial Base Class" at Ma.gnolia
  • Bookmark "Arduino Serial Base Class" at Netscape
  • Bookmark "Arduino Serial Base Class" at ppnow
  • Bookmark "Arduino Serial Base Class" at Rojo
  • Bookmark "Arduino Serial Base Class" at Shadows
  • Bookmark "Arduino Serial Base Class" at Simpy
  • Bookmark "Arduino Serial Base Class" at Socializer
  • Bookmark "Arduino Serial Base Class" at Spurl
  • Bookmark "Arduino Serial Base Class" at Tailrank
  • Bookmark "Arduino Serial Base Class" at Live Bookmarks
  • Bookmark "Arduino Serial Base Class" at Wists
  • Bookmark "Arduino Serial Base Class" at Yahoo! Myweb
  • Bookmark "Arduino Serial Base Class" at BobrDobr
  • Bookmark "Arduino Serial Base Class" at Memori
  • Bookmark "Arduino Serial Base Class" at Faves
  • Bookmark "Arduino Serial Base Class" at Favorites
  • Bookmark "Arduino Serial Base Class" at Newsvine
  • Bookmark "Arduino Serial Base Class" at myAOL
  • Bookmark "Arduino Serial Base Class" at Fark
  • Bookmark "Arduino Serial Base Class" at RawSugar
  • Bookmark "Arduino Serial Base Class" at LinkaGoGo
  • Bookmark "Arduino Serial Base Class" at Mister Wong
  • Bookmark "Arduino Serial Base Class" at Wink
  • Bookmark "Arduino Serial Base Class" at BackFlip
  • Bookmark "Arduino Serial Base Class" at Diigo
  • Bookmark "Arduino Serial Base Class" at Segnalo
  • Bookmark "Arduino Serial Base Class" at Netvouz
  • Bookmark "Arduino Serial Base Class" at DropJack
  • Bookmark "Arduino Serial Base Class" at Feed Me Links
  • Bookmark "Arduino Serial Base Class" at funP
  • Bookmark "Arduino Serial Base Class" at HEMiDEMi
code/arduino_serial_base_class.txt · Last modified: 2012/12/31 14:12 by tekmage
Valid CSS Recent changes RSS feed Valid XHTML 1.0