Bluetooth Problem

Hello guys,

I have built a project and now i want to make it wireless. I bought a sparkfun mate silver modem and I have connected it on my arduino UNO according to the guide of sparkfun (Can be found here: https://learn.sparkfun.com/tutorials/using-the-bluesmirf/all).

I use CoolTerm on Mac to communicate with the bluetooth. When I power the bluetooth modem through the arduino I can connect on it through the terminal and I can enter the configuration mode of the modem normally.

However, when i try to use the bluetooth to transmit a command (based on a specific code I have previously uploaded on the arduino through usb), it does not work. I think that there is a problem with the RX/TX pins. I have connected the RX of the arduino to the TX of the modem and the other way around. Can I somehow check if the pins are burnt or for some reason don't work? Do you have any idea why this problem might be? Generally, when I connect to the modem the green light of the modem lights up (showing it has connected), so I think the problem is not in that part of the connection.

Hope this makes sense :). I am here to answer any questions you may have so hopefully we can find what is wrong! Thanks in advance

Hi,

If you send characters to the bluetooth module when not in setup mode does the Arduino receive them? If so, can you include your code in your next post so we can see what you're doing on that side?

Geoff

Hi again,

At first I followed the guide from sparkfun so I used their code. However, as I mentioned in the first part (enter configuration and edit name) everything works fine. I cannot work in the second part (Hello Arduino! etc.).

I also tried using the code I created for the project, which is the following:

//Motor
#include <Servo.h>
//Thermometer
#include <OneWire.h>

//Motor
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

//Thermometer
int DS18S20_Pin = 12; //DS18S20 Signal pin on digital 2

// Pressure Sensor
int FSR_Pin = A0; //analog pin 0
//Temperature chip i/o
OneWire ds(DS18S20_Pin); // on digital pin 2

void setup()
{
//Motor
myservo.attach(9); // attaches the servo on pin 9 to the servo object
// initialize serial:
Serial.begin(9600);
//Thermistor
Serial.println(“Thermistor temperature measurement:”);
Serial.println("\n Vo Rt T (C)");
}

void loop()
{
while (Serial.available()) {
char inChar = (char)Serial.read();
switch(inChar) {
case ‘u’:
for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15);
}
break;
case ‘t2’:
{int ThermistorPin = 1; // Analog input pin for thermistor voltage
int Vo; // Integer value of voltage reading
float R = 9870.0; // Fixed resistance in the voltage divider
float logRt,Rt,T;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
Vo = analogRead(ThermistorPin);
Rt = R*( 1023.0 / (float)Vo - 1.0 );
logRt = log(Rt);
T = ( 1.0 / (c1 + c2logRt + c3logRtlogRtlogRt ) ) - 273.15;
Serial.print(" “); Serial.print(Vo);
Serial.print(” “); Serial.print(Rt);
Serial.print(” "); Serial.println(T);
delay(200);
}
break;

case ‘d’:

for(pos = 90; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
break;

case ‘p’:
{
int FSRReading = analogRead(FSR_Pin);

Serial.println(FSRReading);

delay(250); //just here to slow down the output for easier reading
}
break;

case ‘t’:
float temperature = getTemp();
Serial.println(temperature);

delay(100); //just here to slow down the output so it is easier to read
break;
}
Serial.println(inChar);
}
}

//returns the temperature from one DS18S20 in DEG Celsius
float getTemp(){

byte data[12];
byte addr[8];

if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1000;
}

if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println(“CRC is not valid!”);
return -1000;
}

if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print(“Device is not recognized”);
return -1000;
}

ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end

byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad

for (int i = 0; i < 9; i++) { // we need 9 bytes
data = ds.read();

  • }*

  • ds.reset_search();*

  • byte MSB = data[1];*

  • byte LSB = data[0];*

  • float tempRead = ((MSB << 8) | LSB); //using two’s compliment*

  • float TemperatureSum = tempRead / 16;*

  • return TemperatureSum;*

}
I connect with the Bluetooth from a Mac through CoolTerm and when I send commands (e.g. u,d, etc) the TX light of Coolterm lights up, but it does not receive anything (the RX light does not light).
I also tried using only the pre-maid arduino code for a servo motor but the same problem occurs.
Spiros