Full technical documentation available now

2,186 views
Skip to first unread message

Bonifaz

unread,
Apr 15, 2012, 8:53:28 AM4/15/12
to amarino...@googlegroups.com
I decided to publish my master thesis from 2010 describing the Amarino Software Toolkit in great detail.
So that you guys can get a picture of Amarino's architecture and all other technical details making up Amarino.
In particular, the second part of the thesis is describing the toolkit thoroughly.

The download link to my thesis can be found on the Amarino website.
Additionally, made the paper I wrote about Amarino when I was working on Amarino at MIT available for download. You will also find it on the website (look under Contact). 
But be aware, the paper deals with an older version of Amarino (Amarino 1.0). In Amarino 2.0, the current version, almost everything was redesigned.

Cheers,
Bonifaz

Kasper Hansen

unread,
Apr 15, 2012, 8:57:59 AM4/15/12
to amarino...@googlegroups.com
Hi Bonifaz,

Thanks for sharing - I'm reading it right now.

:-) Kasper
MSc.stud / IT-University of Copenhagen

Kasper Hansen

unread,
Apr 15, 2012, 9:29:00 AM4/15/12
to amarino...@googlegroups.com
Hi again,

I can't seem to find anything in your paper about if it's possible to use other pins than standard serial. I would like to use other pins. I looked in the .h file, hoping to find a initialize(rx, tw) or something, but with no luck.

I have another device attached, that also runs per default on the standard serial. However, with SoftwareSerial I can route that to other pins. This gives me two really good things; 1) I don't have to disconnect RX and TX when I'm uploading (which otherwise would result in errors), 2) I can still use Serial.println to print out debug statements in my long program.

On p. 28 you write "Some of the I/O pins have additional functions. Pin 0 (RX) and 1 (TX) can be used for TTL12 serial communication. The Bluetooth shield normally connects to these pins for data transmission.".

Besides power and ground, I've connected my Bluetooth Gold Mate like this;

Bluetooth.RX --> Arduino.10
Bluetooth.TX --> Arduino.9

What I am looking for is a way to use MeetAndroid on the mentioned pins.

Can you give me any pointers?

Thanks,

:-) Kasper

Jose

unread,
Apr 15, 2012, 9:46:45 AM4/15/12
to amarino...@googlegroups.com
Great document! congrats!
Thanks for sharing :)

Bonifaz Kaufmann

unread,
Apr 15, 2012, 11:11:45 AM4/15/12
to amarino...@googlegroups.com

As far as I know, the pins for RX and TX depend on your Arduino board and cannot be changed.

Free Beachler

unread,
Apr 17, 2012, 12:17:35 AM4/17/12
to amarino...@googlegroups.com
Arduino always permitted serial communication on pins besides digital 0/1.  However, the primary builtin serial library "HardwareSerial", which MeetAndroid.c uses, _only_ allows communication on pins 0/1 and has no configuration options to change this.

NewSoftSerial provided an alternative to this for at least a couple of years.  Fortunately, NewSoftSerial is now part of Arduino core!  http://arduiniana.org/libraries/newsoftserial/

I've looked at switching over the core library.  It's looking like 2-4 hours of effort, not including testing for backwards compatibility.  Since MeetAndroid extends the Print class - which SoftwareSerial also extends - MeetAndroid needs to be refactored.  The result would be configurable pins.  Also a significant performance improvement should be possible since the current blocking (CPU stalling) algorithm in MeetAndroid::read() is unnecessary with SoftwareSerial.

Regards,
Free

Kasper Hansen

unread,
Apr 17, 2012, 2:39:46 AM4/17/12
to amarino...@googlegroups.com
This is exactly what I was talking about. And I would love to test it, since I desperately need it for our current project. I'm not that into C/C++ and Arduino that I dare take on such a challenge, but I do hope someone else will. I'm sure it will increase the value of Amarino, since (from what I'm reading) many people stack technologies, that all per default uses serial communication on 0/1, and therefore are in need that their choices are flexible.

Please let me know if you need help to test it, if you actually are going to do it.

Best regards,

:-) Kasper
Message has been deleted
Message has been deleted
Message has been deleted

Kasper

unread,
Sep 6, 2012, 6:03:54 AM9/6/12
to amarino...@googlegroups.com
Since no one has tried to change Amarino to allow for custom communication pins, I've tried to do it myself. However... Something is not working.

What I've done is;

  • Copied the SoftwareSerial.h file into MeetArduino folder

MeetAndroid.h:
  • Removed the inheritance to Print
  • Removed the #include "Print.h"
  • Added a function: void begin(int rx, int tx, int baud)
  • Added an instance: SoftwareSerial* softwareSerial;

MeetAndroid.cpp:
  • Removed the #include "HardwareSerial.h"
  • Implemented the function: MeetAndroid::begin(int rx, int tx, int baud)
  • Changed all references from Serial.print to softwareSerial->print
Then I made a small test program, paired my Android and Bluetooth Mate Gold and executed it;

#include <MeetAndroid.h>
#include <SoftwareSerial.h>
#define writePin 2
#define readPin  4
int onboardLed = 13;
MeetAndroid meetAndroid;
void setup() {
  pinMode(onboardLed, OUTPUT);
  pinMode(readPin, INPUT);
  pinMode(writePin, OUTPUT);
  meetAndroid.registerFunction(testEvent, 'A');  
  meetAndroid.begin(readPin, writePin, 9600);
  
  blinkLed(2, 500);
}
void loop() {
  meetAndroid.receive(); // you need to keep this in your loop() to receive events
}
void blinkLed(int loopCount, int delayInMillis) {
  for (int i = 0; i < loopCount; i++) {
    digitalWrite(onboardLed, HIGH);
    delay(delayInMillis);
    digitalWrite(onboardLed, LOW);
    delay(delayInMillis);
  }
}
void testEvent(byte flag, byte numOfValues) {
  blinkLed(4, 250);
}

But, alas, it does not work. Can anyone help me make this work? I've uploaded all the files in this thread.

Cheers,

:-) Kasper
MeetAndroid.cpp
MeetAndroid.h
SoftwareSerial.h
SSAmarinoTest.ino

Free Beachler

unread,
Sep 6, 2012, 11:38:13 PM9/6/12
to amarino...@googlegroups.com

Again, I must ask this community, why rewrite code I've already written?  Why not contribute instead to projects I've already started?

Best Regatds,
Free Beachler

--
 
 
 
Message has been deleted

Mats Karlsson

unread,
Nov 5, 2012, 5:12:19 AM11/5/12
to amarino...@googlegroups.com
free, Kasper tried to add a functionality to your code. And I see that you wished it in April (2-4 hours work) and now Kasper tried to contribute, lovely.

/Mats

Kasper Hansen

unread,
Nov 5, 2012, 7:56:25 AM11/5/12
to amarino...@googlegroups.com
I just need to clarify something in regards to SoftwareSerial and Arduino / Bluetooth.

In short: It does not work.

I've ended up using UNO/Lilypad's standard 0 and 1 for serial communication. In my current project I'm also using an OpenLog (SD card) on the same standard serial ports. What I do is to direct current (over transistors) for them using other ports, since they are never going to be used at the same time in my project (turning one on, the other off - and the other way around). 

What I would have loved was using Bluetooth on (for example) 4 and 5 and OpenLog on (for example) 10 and 11, and then using SoftwareSerial to communicate over those pins. However, no matter what I did, the bytes received was somehow garbled up. I used a fair about on time on it, before deciding to ditch it for the above mentioned on/off solution. I tried asking about it here, or StackExchange and some electronic variant forum - with no luck.

Maybe someone has more luck coming up with a solution.

Cheers,

:-) Kasper


--
 
 
 

Mats Karlsson

unread,
Nov 5, 2012, 9:06:07 AM11/5/12
to amarino...@googlegroups.com
Hi,

I'm using MultiColorLamp - Amarino - Android - Bluetooth - Arduino - Softserial - decode codes from "MulticolorLamp" app.

And I use standard serial port for debugging.

I had a bit of struggle to do the conversion from byte to int, but I think I have a working solution soon.

So Im a bit confused, why Softserial shouldn't work, is it related to the amarino/Arduino library ?

Regards
Mats

Kasper Hansen

unread,
Nov 5, 2012, 10:41:06 AM11/5/12
to amarino...@googlegroups.com
No, it was not related to Amarino, and that is why I didn't write about it before "in here". In short, data was garbled when read in Arduino. If you can send a text string from Java/Android using bluetooth and receive it on a UNO/Lilypad using pins other than 0 and 1 with SoftwareSerial - then good for you :-)  (and I hope you share your code) :-)

Regards,

:-) Kasper




--
 
 
 

Mats Karlsson

unread,
Nov 11, 2012, 7:17:31 AM11/11/12
to amarino...@googlegroups.com
This is working for me:

My config: MultiColorLamp App - Amarino - Android - Bluetooth - Arduino.

First I used "Analyse_MulticolorLamp", that decodes what is received from the bluetooth serial device.

I use 2 and 3 as SoftSerial for my Bluetooth module.

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
  Serial.println("send any byte and I'll tell you everything I can about it");
  Serial.println();
}

void loop() {
  // get any incoming bytes:
  if (mySerial.available() > 0) {
    int thisChar = mySerial.read();

    // say what was sent:
    Serial.print("You sent me: \'");
    Serial.write(thisChar);
    Serial.print("\'  ASCII Value: ");
    Serial.print(thisChar);
    Serial.print("     ");

    // Analyze what was sent:
    if(isAlpha(thisChar)) {
      Serial.println("it's alphabetic");
    }
    if(isControl(thisChar)) {
      Serial.println("it's a control character");
    }
    if(isDigit(thisChar)) {
      Serial.println("it's a numeric digit");
    }
  }
}



And then I found some code from the book "Beginning Arduino" that fitted my purpose nicely.

// Project 10 - Serial controlled RGB Lamp
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX

char buffer[18];
int red, green, blue;
int RedPin = 9;
int GreenPin = 10;
int BluePin = 11;

void setup()
{
  Serial.begin(9600);
  Serial.flush();
  mySerial.begin(9600);
  pinMode(RedPin, OUTPUT);
  pinMode(GreenPin, OUTPUT);
  pinMode(BluePin, OUTPUT);
}

void loop()
{
  if (mySerial.available() > 0) {
    int index=0;
    delay(100); // let the buffer fill up
    int numChar = mySerial.available();
    if (numChar>15) {
      numChar=15;
    }
    while (numChar--) {
      buffer[index++] = mySerial.read();
      }
    splitString(buffer);
  }
}

void splitString(char* data) {
  Serial.print("Data entered: ");
  Serial.println(data);
  char* parameter;
  parameter = strtok (data, " ,");
  while (parameter != NULL) {
    setLED(parameter);
    parameter = strtok (NULL, " ,");
  }
  // Clear the text and serial buffers
  for (int x=0; x<16; x++) {
    buffer[x]='\0';
  }
  Serial.flush();
}

void setLED(char* data) {
  if ((data[0] == 'r') || (data[0] == 'R')) {
    int Ans = strtol(data+1, NULL, 10);
    Ans = constrain(Ans,0,255);
    analogWrite(RedPin, Ans);
    Serial.print("Red is set to: ");
    Serial.println(Ans);
    }
  if ((data[0] == 'g') || (data[0] == 'G')) {
    int Ans = strtol(data+1, NULL, 10);
    Ans = constrain(Ans,0,255);
    analogWrite(GreenPin, Ans);
    Serial.print("Green is set to: ");
    Serial.println(Ans);
  }
  if ((data[0] == 'b') || (data[0] == 'B')) {
    int Ans = strtol(data+1, NULL, 10);
    Ans = constrain(Ans,0,255);
    analogWrite(BluePin, Ans);
    Serial.print("Blue is set to: ");
    Serial.println(Ans);
  }
}

And now I have a RGB controlled lamp without using the Amarino library that is using the hardcoded serial port.

/Mats

Kasper Hansen

unread,
Nov 11, 2012, 8:10:14 AM11/11/12
to amarino...@googlegroups.com
Hi Mats,

Glad to see you hacking away! What kind of speeds can you achieve?

Sent from my iPhone
--
 
 
 

Nauman Mufti

unread,
Jan 11, 2013, 8:25:42 PM1/11/13
to amarino...@googlegroups.com
Hi Bonifaz,

My apologies for mailing you here in another thread as well. Needed some advise in a rush...
Hi,

I can't find the Bluetooth device using my Android phone (Samsung Galaxy Q, Gingerbread, 2.3.6). Its because our Android phones can't see Class '0' Bluetooth SPP (Serial) devices. Some phones can, some can't. So I bought an app today...the Bluepair SPP which allows pairing using the MAC address of the Bluetooth device (once you pair the BT device to other phones, other computers, etc. you can find the MAC address of the module from there). But the problem is that Amarino still tries to scan for fresh devices and hence misses the already connected and paired BT device.

Any ideas on how to add an already connected and paired device to the Amarino 2.0 or alternatively to add devices directly using MAC addresses into Amarino 2.0 ?

Thanks so much,
Nooman

Richard David Gordon Hayden

unread,
Jul 13, 2014, 4:50:37 PM7/13/14
to amarino...@googlegroups.com
Is their a way to collaborate and blend a thesis with another? My thesis involves the creation of a new standard in data input. Your code is the doorway to novice inventors to make great projects happen wirelessly. I greatly admire your word, as they say we stand on the shoulders of giants. If you have time take a look at the Tabla AEIOU One Handed Keyboard, it's pretty sweet. Thanks, David Hayden  www.thenewkeyboard.com

Free Beachler

unread,
Jul 13, 2014, 11:49:55 PM7/13/14
to amarino...@googlegroups.com

Hey dont take that too seriously but I'd be happy to get a pull request or add any coder that wants to contribute to the embed project.

--
 
 
 
Reply all
Reply to author
Forward
0 new messages