Robin2:
That seems strange. Post the program and a link to the datasheet for the wifi shield you are using.
What version of the Arduino IDE are you using?
I have not advanced past 1.5.6
...R
Arduino WIfi Shield
It is now running on firmware 1.1.2 which can only be run on Arduino IDE 1.0.2.
/*-----( Import needed libraries )-----*/
#include <LCD03.h>
#include <Wire.h>
#include "DHT.h"
#define DEVICE (0x53) //ADXL345 device address
#define TO_READ (6) //num of bytes we are going to read each time (two bytes for each axis)
#define THRESH_ACT (0x24)
#define THRESH_INACT (0x25)
#define DHTPIN 4
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
LCD03 lcd;
byte buff[TO_READ] ; //6 bytes buffer for saving data read from the device
char str[512]; //string buffer to transform data before sending it to the serial port
// Declare Variable
float voltage; //Analog input voltage from AD8495 thermocouple
float temp; //Temperature variable thermocoupple
float x, y, z; //Acceleration variable
float x1, y1, z1; //Acceleration variable
int tpin = A0; //thermocouple to A0
void writeTo(int device, byte address, byte val) {
Wire.beginTransmission(device); //start transmission to device
Wire.write(address); // send register address
Wire.write(val); // send value to write
Wire.endTransmission(); //end transmission
}
void readFrom(int device, byte address, int num, byte buff[])
{
Wire.beginTransmission(device); //start transmission to device
Wire.write(address); //sends address to read from
Wire.endTransmission(); //end transmission
Wire.beginTransmission(device); //start transmission to device (initiate again)
Wire.requestFrom(device, num); // request 6 bytes from device
int i = 0;
while(Wire.available()) //device may send less than requested (abnormal)
{
buff[i] = Wire.read(); // receive a byte
i++;
}
Wire.endTransmission(); //end transmission
}
void accelerometer()
{
int accelerometer = 0x32; //first axis-acceleration-data register on the ADXL345
readFrom(DEVICE, accelerometer, TO_READ, buff); //read the acceleration data from the ADXL345
//each axis reading comes in 10 bit resolution, ie 2 bytes. Least Significat Byte first!!
//thus we are converting both bytes in to one int
x = (((int)buff[1]) << 8) | buff[0];
y = (((int)buff[3])<< 8) | buff[2];
z = (((int)buff[5]) << 8) | buff[4];
x1 = (x/256)*9807;
y1 = (y/256)*9807;
z1 = (z/256)*9807;
Serial.println("");
Serial.print("Vibration X: ");Serial.print(x1,0); Serial.println(" mm/s^2");
Serial.print("Vibration Y: ");Serial.print(y1,0); Serial.println(" mm/s^2");
Serial.print("Vibration Z: ");Serial.print(z1,0); Serial.println(" mm/^2");
lcd.setCursor(0,0);
lcd.print("Readings in mm/s^2 ");
lcd.setCursor(0,1);
lcd.print("Vibration X:");lcd.print(x1);
lcd.setCursor(0,2);
lcd.print("Vibration Y:");lcd.print(y1);
lcd.setCursor(0,3);
lcd.print("Vibration Z:");lcd.print(z1);
}
void humidity() {
float h = dht.readHumidity();
float t = dht.readTemperature(); // Read temperature as Celsius (the default)
if (isnan(h) || isnan(t)) { // Check if any reads failed and exit early (to try again).
// lcd.println("Failed to read from DHT sensor!");
return;
}
float hic = dht.computeHeatIndex(t, h); // Compute heat index in Celsius
lcd.setCursor(0,1);
lcd.print("Humidity: ");lcd.print(h);lcd.print("%");
lcd.setCursor(0,2);
lcd.print("System_Temp: ");lcd.print(t);lcd.print("C");
lcd.setCursor(0,3);
lcd.print("");
//lcd.print("Heat index: ");lcd.print(hic);lcd.print("*C "); // What is heat index
Serial.print("Humidity: ");Serial.print(h);Serial.println("%");
Serial.print("Temperature: ");Serial.print(t);Serial.println(" ");
//Serial.print("Heat index: ");Serial.print(hic);Serial.print("*C ");
}
void thermocouple() {
int voltage = analogRead(tpin); //Read voltage coming from AD8495
float vout = (voltage * 5)/ 1023.0; //Calculate vout
float temp = (vout - 1.25) / 0.005 ; //Convert to temperature
float tempc = (temp - 10.0);
Serial.print("Thermocouple : "); Serial.print(tempc); Serial.print((char)186); Serial.print(" C");
Serial.println(" ");
lcd.setCursor(0,0);
lcd.print("Temperature: ");lcd.print(tempc);lcd.print("C");
}
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
dht.begin(); //start humidity sensor
writeTo(DEVICE, 0x2D, 0); //Turning on the ADXL345
writeTo(DEVICE, 0x2D, 16); //Turning on the ADXL345
writeTo(DEVICE, 0x2D, 8); //Turning on the ADXL345
lcd.begin(20, 4); //start lcd
lcd.backlight(); // Turn on the backlight
Serial.println("The SenMon");
Serial.println("Created by: Abel, Jerry, Izzat and YukeTin");
Serial.println("Supervisor by: Dr Gan and Dr Eugene");
lcd.print(" The SenMon ");
lcd.print("By: Abel, Jerry, ");
lcd.print(" Izzat and YukeTin");
delay(1500);
lcd.clear();
lcd.print("SIT Supervisor: ");
lcd.print(" Dr Gan ");
lcd.print("NU Supervisor: ");
lcd.print(" Dr Wong ");
delay(1500);
lcd.clear();
}
void loop()
{
accelerometer();
delay(1500);
lcd.clear();
thermocouple();
humidity();
Serial.println();
delay(2000);
lcd.clear();
Serial.write(10);
}
If you are using the Arduino WiFi shield, may i know the firmware and the version of your wifishield and Arduino IDE?
Sorry, just started this final year project.. still in the midst of learning.