our project is a part of a bigger project: an intelligent living room. Information will allow us to adapt the atmosphere of the room to those of the shoot.
For the temperature/humidity we use an SHT11 (Wayne's Raging Reality: Ardunio and the SHT15)
the pressure : MPXA4115A6U
luminosity :TSL252R
and an arduinoBT with GPS (http://www.libelium.com/squidbee/index.php?title=GPS_module)
for all component we found in arduino forum or in the web how to use them with arduino ^^
the difficulty was the communication bluetooth between the pda and the board (I knew nothing about bluetooth ^^)
a part of the source code :
on the arduino board :
//--------MAIN----------
void loop(){
Serial.println("Elements mesures: ");
float vP = analogRead(pressurePin); //take and print the pressure
capteurPression(vP);
float vL = analogRead(lightPin); //take and print the luminosity
//capteurLumiere1(vL);
capteurLumiere2(vL);
int temp_raw = getTempSHT(); //take the temperature
Serial.print(" *Temperature: ");
float temp_degc = (temp_raw * D2) + D1; // temperature in degree
serialPrintFloat(temp_degc);
Serial.print(" degC"); // print temperature
Serial.println();
int rh_raw = getHumidSHT(); // take the humidity
Serial.print(" *Humidity(%RH): ");
float rh_lin = C3 * rh_raw * rh_raw + C2 * rh_raw + C1;
float rh_true = (temp_degc * (T1 + T2 * rh_raw) + rh_lin);
serialPrintFloat(rh_true);
Serial.println();
localisationGPS(); //GPS
dormeur(); //Sleep
}
//--------------------------------------------[ch8195]
The Sleep function for that we use information in arduino.cc website:
//----Sleep function----------
void dormeur(){
Serial.println("Pour une mesure appuyez sur une touche, puis faites 'entrer' ");
Serial.println();
Serial.println();
delay(100);
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
attachInterrupt(0,wakeUpNow, LOW);
sleep_mode();
sleep_disable();
detachInterrupt(0);
}
//--------------------------------------------------
and a part of the c# code implanted on the pda which do the communication between pda and arduino:
i use the inTheHand Bluetooth library (32feet.NET v2.0 Beta 1 Available – In The Hand Ltd)
BluetoothClient client = new BluetoothClient(); //create a bluetooth client
-- to connect to the arduino --
private void connectionArduino(BluetoothClient client){
InTheHand.Net.BluetoothAddress adresseBt;
adresseBt = BluetoothAddress.Parse("000780861AD1"); // arduinoBT adress
BluetoothEndPoint ep = new BluetoothEndPoint(adresseBt, BluetoothService.SerialPort);
try
{
client.Connect(ep); // connect
label1.Text = label1.Text + "connection a " + adresseBt + "etablie \n";
}
catch(Exception e) {
label1.Text = label1.Text + "connexion echouée";
Connection = false;
}
}
--- to wake up the arduino and receive information --
private void ReveilArduino(BluetoothClient client)
{
Stream peerStream = client.GetStream(); // open a stream between arduino and pda
Byte[] buffer = System.Text.Encoding.ASCII.GetBytes("a");
peerStream.Write(buffer, 0, buffer.Length); // send something to wake up the board
peerStream.Flush(); // close send stream
StreamReader sr = new StreamReader(peerStream); // open a read stream
String Donnees = "";
StreamWriter writer = new StreamWriter("\Storage Card\Sense\" + "Shoot" + DateTime.Now.ToString("ddMMyy-HHmm") + ".txt"); // name of the.txt
for (int i = 0; i < 6; i++)
{
Donnees = sr.ReadLine(); // read the information from arduinoBT
writer.WriteLine(Donnees); // write them in a .txt
}
writer.Close(); // close the stream wich write in .txt
peerStream.Close(); // fermeture du flux de lecture bluetooth
client.close() ;
}