That seems like a decent project. What are you going to use for a temp sensor?
I was looking at using a Dallas Semi temp sensor that was aimed at battery packs. It periodically sensed the temperature and maintained a histogram type table. It had one of their 1-wire interfaces so was easy to use. I'll see if I can find a part number for it.
Mike
I have a some DS18S20. Once you have 1-wire working they very easy to use.
I searched for the code that I used. I am not 100% sure if it works, I haven't checked it. Sometimes I modify working code because the goal is just a moving target. At some point I lose interest and the code is not usable anymore. I do use svn, but sometimes I forget to commit the working versions with a decent log message.
So, change your escape character to "43", that is "+". Make a copy of the BT-init program. From experience I can tell you that it is always handy to keep an original BT-init program around, in case you mess things up. Ok, escape sequence is like this:
Serial.println("SET CONTROL ESCAPE 43 08 1");
Then upload the following program. You can type in a WT11 command, this will be executed and the output is stored in the EEPROM. Afterwards this is read back and sent to your serial port. Oh, and install the textstring library.
#include <TextString.h>
#include <EEPROM.h>
int ledPin = 13; // LED connected to digital pin 13
int resetPin = 7; // BT module uses pin 7 for reset
char inByte = 0; // incoming serial byte
TextString incomingString = TextString(50);
int infoSize = 0 ;
long lastTime = 0;
boolean ledon = true;
boolean commandDone = false;
void setup() // run once, when the sketch starts
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
pinMode(resetPin, OUTPUT);
Serial.begin(115200); // start serial at 115200 kbs
}
void loop()
{
if (millis()-lastTime > 300)
{
ledon = !ledon;
lastTime = millis();
}
if (ledon) digitalWrite(ledPin, HIGH);
else digitalWrite(ledPin, LOW);
if(Serial.available() > 1 )
{
getString();
}
else if (commandDone)
{
digitalWrite(ledPin, LOW); // set led LOW
Serial.print("Get string: ");
for(int i=0;i<infoSize;i++) //eeprom print lus
{
Serial.print(EEPROM.read(i));
}
Serial.println();
Serial.print("Cleared string size: ");
Serial.println(infoSize);
commandDone = false;
}
}
void getString()
{
delay(100);
//int stringSize = 3;
int stringSize = Serial.available();
char comStr[stringSize];
for (int i=0;i<stringSize;i++)
{
comStr[i] = getbyte();
}
comStr[stringSize] = 0;
Serial.print("stringSize: ");
Serial.print(stringSize);
Serial.print(" ");
Serial.println(comStr);
doCommand(comStr);
}
void doCommand(char *command)
{
//Serial.print("final test: ");
//Serial.println(command);
int j=0;
digitalWrite(ledPin, HIGH); // set led HIGH
delay(2000);
digitalWrite(ledPin, LOW);
Serial.print("+++");
delay(2000);
digitalWrite(ledPin, HIGH);
Serial.println(command);
for (int i=0; i <= 10; i++){
delay(1000);
while (Serial.available() > 0 && j <512) {
inByte = getbyte(); // get incoming byte
EEPROM.write(j, inByte);
j++;
}
delay(1000);
digitalWrite(ledPin, LOW);
}
infoSize = j;
delay(2000);
digitalWrite(ledPin, HIGH);
Serial.print("+++");
delay(2000);
digitalWrite(ledPin, LOW); // set led low
commandDone = true;
}
char getbyte()
{
while (Serial.available() == 0) { //look for available data
// do nothing, wait for incoming data
}
return Serial.read(); //return data if aviable
}
The program works slowly. You have to wait for the reset times involved with switching between modes. These values are a bit on the safe side. When arduino is waiting for a command led13 flashes. If it is going in command mode the led flashes very slow. Be patient!