Concept proof of exchanging data between ArduinoBT and a S60 Mobile Phone (Nokia N73) via Python for S60
Here a proof of concept of interfacing ArduinoBT with a Nokia N73 phone via Python for S60. The Python code is horrible (i am not really a coder) but it works and i hope that this primitive demo leads to further development and postings about BT and S60 mobile phones.

As a side note: the Python part of this demonstration can be with slight modifications used also to connect the mobile phone to any BT serial ports, like a GPS device or a computer running PD, MAXMSP or custom made software.

Note: Please help and make this into a real tutorial !!

Info about python for s60:

http://wiki.opensource.nokia.com/projects/Python_for_S60

Links that helped me:

http://tinker.it/now/2006/12/11/bluetooth-controlled-lamp/ http://mobilenin.com/pys60/menu.htm

What it does: When the python scripts starts it sends ascii 49 to the arduino BT which then returns the numbers 0-60 which are written into a file and stored on the memory card. Stupid i know :-) but its just a test.

ArduinoBT code to communicate with a S60 Mobile Phone via Python for S60

// ArduinoBT with S60 Mobile Phone
// (cleft)Erich Berger 2007
int i = 0; //counter
int LED = 13; // pin for LED
int RESET = 7; //reset pin for bluetooth
int val = 0; // serial port data
int track[61];

void ledblink() {
  digitalWrite(LED, HIGH);
  delay(100);
  digitalWrite(LED, LOW);
  delay(100);
}

void ledblink1() {
  digitalWrite(LED, HIGH);
  delay(500);
  digitalWrite(LED, LOW);
  delay(500);
}

void init_track() {
  for (i=0; i<=60; i++) {
   track[i] = i;
  }  
}  
void reset_bt(){
  // Reset the bluetooth interface
  digitalWrite(RESET, HIGH);
  delay(10);
  digitalWrite(RESET, LOW);
  delay(2000);
}

void config_bt(){  
  Serial.println("SET BT PAGEMODE 3 2000 1");
  Serial.println("SET BT NAME BT_Arduino");
  Serial.println("SET BT ROLE 0 f 7d00");
  Serial.println("SET CONTROL ECHO 0");
  Serial.println("SET BT AUTH * 12345");
  Serial.println("SET CONTROL ESCAPE - 00 1");
}  

void setup() {
  reset_bt();
  config_bt();
  pinMode(LED,OUTPUT);  
  pinMode(RESET,OUTPUT);  
  init_track();
  Serial.begin(115200);
  ledblink();  
}

void loop () {
  val = Serial.read();
  if (val != -1) {
    if (val == 49) {
     ledblink1();
        for (i=0; i<=60; i++) {
          Serial.print(i, BYTE);
          delay(10);
        }
    }
  }
}

Python S60 code to communicate with a ArduinoBT via Python for S60

 

# ArduinoBT with S60 Mobile Phone
# (cleft)Erich Berger 2007

import socket

def bt_connect():
    global sock
    arduino_addr='00:07:80:82:1F:35'   #add your arduino BT adress here
    sock=socket.socket(socket.AF_BT, socket.SOCK_STREAM)
    target=(arduino_addr,1) # serial connection to arduino BT
    sock.connect(target)

def bt_send_data():
    global sock
    test = "1"
    sock.send(test)

def bt_receive_data():
    global sock
    buffer = []
    for i in range(61):
         data = sock.recv(1)
         print str(ord(data))
         buffer.append(data)
    return buffer

bt_connect()
bt_send_data()
track = bt_receive_data()

f = open('e:\\track.txt','w')

for i in range (0,60):
    f.write(str(ord(track[i])))
    f.write("\n")

f.close()

print str("finished")
sock.close()

Share