Go Down

Topic: Arduino - RFID - Gobetwino (Read 966 times) previous topic - next topic

deekin

Hi

I'm quite new to Arduino and even newer to Gobetwino.

I'm trying to read a RFID card and send the ID number to file via Gobetwino. I'm getting the numbers over, however, I'm also getting other characters that I don't want and can't figure out to lose them before the file is written. My intention is to eventually have the numbers identify and open a twitter feed in a web browser although I don't want advice about that (at least not yet :-) I'd rather try and figure it out first!).

As far as I can make out the addition characters are a 'start of text code', a 'carriage return' code, a 'line feed' and an 'end of text' code. Is it possible to drop these from the output before it is written to file? Also how can I make the actual card characters go over rather than their decimal equivalent?

I've identified the additional codes and the actual card numbers in (brackets) in the txt file grab. When I identify the card charcter values as int rather than char (with changes to the code to suit that) they go over as they are in (brackets) but the other codes generate errors in the Gobetwino output and the begin and end text codes come out something like '¬'

Set up - Arduino Uno, Sparkfun ID12 RFID starter kit, Win7 x64

This is my Arduino code

Code: [Select]

//RFID ID12

//this sketch reads the data from a RFID card
//and sends it to the serial port
//it is written to a text file using gobetwino
//it also flashes a LED when the card is swiped

int led = 13; //set up LED

char val = 0; // variable to store the data from the serial port

char str[4]; //array to store variable string

void setup() {

  Serial.begin(9600); //connect to the serial port

  pinMode(led, OUTPUT);   //set the digital pin as an output 
}

void loop () {
 
if(Serial.available() > 0) {
val = Serial.read();       //read the data from the serial port

                   
Serial.print("#S|LOGTEST|[");              //this is the
Serial.print(itoa((val), str, 10));        //gobetwino
Serial.println("]#");                      //command line

digitalWrite(led, HIGH);   // turn the LED on
  delay(50);               
digitalWrite(led, LOW);    // turn the LED off after the delay
}
}


This is the txt file contents

2   (start of text)
53  (5)
48  (0)
48  (0)
48  (0)
56  (8)
70  (F)
70  (F)
54  (6)
57  (9)
49  (1)
66  (B)
56  (8)
13  (C/R)
10  (L/F)
3  (End of text)

This is the Gobetwino status messages

12/08/2012 21:22:58   Serial port : COM4 opened at 9600 baud
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[2]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[53]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[48]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[48]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[48]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[56]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[70]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[70]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[54]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[57]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[49]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[66]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[56]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[13]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[10]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
12/08/2012 21:23:00   Commandstring recieved : #S|LOGTEST|[3]#
12/08/2012 21:23:00   Command parsed OK
12/08/2012 21:23:00   Executing command : LOGTEST
12/08/2012 21:23:00   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt


Thanks for any help/tips etc.

MikMo


How did you hook up the RFID reader to Arduino and the Arduino to the PC ?

deekin

Hi MikMo

The Uno is connected to the PC via USB

The reader is connected with the ID12 TX to Arduino Digital pin0 (Rx) and ID12 Rx to Arduino Digital Pin1 (Tx) (Also 5v &Gnd)

LED is on pin13

(For your info, Gobetwino appears to be working well on Win7 x64)

PaulS

Quote
As far as I can make out the addition characters are a 'start of text code', a 'carriage return' code, a 'line feed' and an 'end of text' code. Is it possible to drop these from the output before it is written to file?

You should look at the difference between Serial.print() and Serial.println(). Half of your problems can be made to go away.

Code: [Select]
Serial.print(itoa((val), str, 10));        //gobetwino
Why is val in parentheses? Why are you calling itoa() at all? Don't you think that Serial.print() is capable of converting the int to a string?


deekin

Hi PaulS

I know what you're saying about Serial.print and Serial.println but Gobetwino requires Serial.println (I'm sure MikMo will confirm this)

Without calling Itoa I can get the values to a file but as I said I then get a start and end of text marker that looks like ¬

Substituting that section of code with the code below (and removing the array buffer str)

Code: [Select]


Serial.print("#S|LOGTEST|["); //this is the
Serial.print(val);            //gobetwino
Serial.println("]#");         //command line



Results in

Written to file

(space)
(Start of text char)
5
0
0
0
8
F
F
9
6
2
4
4
(End of text char)


And Gobetwino


13/08/2012 00:46:44   Serial port : COM4 opened at 9600 baud
13/08/2012 00:46:48   Commandstring recieved : #S|LOGTEST|[]#
13/08/2012 00:46:48   Command parsed OK
13/08/2012 00:46:48   Executing command : LOGTEST
13/08/2012 00:46:48   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
13/08/2012 00:46:48   Commandstring recieved : #S|LOGTEST|[5]#
13/08/2012 00:46:48   Command parsed OK
13/08/2012 00:46:48   Executing command : LOGTEST
13/08/2012 00:46:48   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
13/08/2012 00:46:48   Commandstring recieved : #S|LOGTEST|[0]#
13/08/2012 00:46:48   Command parsed OK
13/08/2012 00:46:48   Executing command : LOGTEST
13/08/2012 00:46:48   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
13/08/2012 00:46:48   Commandstring recieved : #S|LOGTEST|[0]#
13/08/2012 00:46:48   Command parsed OK
13/08/2012 00:46:48   Executing command : LOGTEST
13/08/2012 00:46:48   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
13/08/2012 00:46:48   Commandstring recieved : #S|LOGTEST|[0]#
13/08/2012 00:46:48   Command parsed OK
13/08/2012 00:46:48   Executing command : LOGTEST
13/08/2012 00:46:48   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
13/08/2012 00:46:48   Commandstring recieved : #S|LOGTEST|[8]#
13/08/2012 00:46:48   Command parsed OK
13/08/2012 00:46:48   Executing command : LOGTEST
13/08/2012 00:46:48   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
13/08/2012 00:46:48   Commandstring recieved : #S|LOGTEST|[F]#
13/08/2012 00:46:48   Command parsed OK
13/08/2012 00:46:48   Executing command : LOGTEST
13/08/2012 00:46:48   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
13/08/2012 00:46:48   Commandstring recieved : #S|LOGTEST|[F]#
13/08/2012 00:46:48   Command parsed OK
13/08/2012 00:46:48   Executing command : LOGTEST
13/08/2012 00:46:48   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
13/08/2012 00:46:48   Commandstring recieved : #S|LOGTEST|[9]#
13/08/2012 00:46:48   Command parsed OK
13/08/2012 00:46:48   Executing command : LOGTEST
13/08/2012 00:46:48   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
13/08/2012 00:46:48   Commandstring recieved : #S|LOGTEST|[6]#
13/08/2012 00:46:48   Command parsed OK
13/08/2012 00:46:48   Executing command : LOGTEST
13/08/2012 00:46:48   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
13/08/2012 00:46:48   Commandstring recieved : #S|LOGTEST|[2]#
13/08/2012 00:46:48   Command parsed OK
13/08/2012 00:46:48   Executing command : LOGTEST
13/08/2012 00:46:48   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
13/08/2012 00:46:48   Commandstring recieved : #S|LOGTEST|[4]#
13/08/2012 00:46:48   Command parsed OK
13/08/2012 00:46:48   Executing command : LOGTEST
13/08/2012 00:46:48   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
13/08/2012 00:46:48   Commandstring recieved : #S|LOGTEST|[4]#
13/08/2012 00:46:48   Command parsed OK
13/08/2012 00:46:48   Executing command : LOGTEST
13/08/2012 00:46:49   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt
13/08/2012 00:46:49   Commandstring recieved : #S|LOGTEST|[
]#
13/08/2012 00:46:49   While checking the command name Gbt an exception was generated
13/08/2012 00:46:49   Object reference not set to an instance of an object.
13/08/2012 00:46:49   The parameters in the command : #S|LOGTEST|[
]# are not correct for the command type
13/08/2012 00:46:49   Commandstring recieved : #S|LOGTEST|[
]#
13/08/2012 00:46:49   While checking the command name Gbt an exception was generated
13/08/2012 00:46:49   Object reference not set to an instance of an object.
13/08/2012 00:46:49   The parameters in the command : #S|LOGTEST|[
]# are not correct for the command type

13/08/2012 00:46:49   Commandstring recieved : #S|LOGTEST|[]#
13/08/2012 00:46:49   Command parsed OK
13/08/2012 00:46:49   Executing command : LOGTEST
13/08/2012 00:46:49   Data logged to C:\Users\Deekin\Desktop\gobetwino\LOGTESTLOG.txt

Note the errors generated (in bold) near the end of the status report above

While I appreciate that the data written to the file in this example is closer to how I want it I still have additional characters I'd like to drop.

Thanks for responding, I appreciate it.

MikMo

Ups, i forgot to follow this thread.

From the GoBetwino output i can see that you are trying to log data around 50 times a second, this might be a little more than GoBetwino can handle.

try to slow it down a bit and see what happens.

Go Up