lol, that's what I love programming with Arduino, even with my computer off (when any of my old apps would now be 'off', the Arduino keeps on kicking via USB power) and people obviously
get to see any bug i introduce in real time via a live url which dumps out my raw data..
I'll may as well continue, the problem i'm having is with a Barometer Sensor, many many MANY examples out there and all giving different results, so i'm not sure which one's working... and when it comes to the altitude/millibar reading, I simply took the reading I got eg 22000 and deducted what mr weatherman said the real pressure was, i'm actually at 180m above see level so that's my target number, the hpa, is 20
out (not bad so it's at least working) and the altitude i have no idea...
http://www.bosch-sensortec.com/content/language1/downloads/BMP085_DataSheet_Rev.1.0_01July2008.pdf
is what i'm working from at the moment to correct the errors in my code, math is very weak point of mine lol, I'm more used to working with utilities/string work..
my code here..
#include <Wire.h>
#include <String.h>
#include <NewSoftSerial.h>
#include <SPI.h>
#include <Ethernet.h>
#include <BMP085.h>
#include <utility/w5100.h>
#define ledPinB 6
#define ledPinG 5
#define ledPinR 4
#define SpeakerPin 7
#define ComputerPowerPin 8
#define I2C_ADDRESS 0x77 //77?
// The IP address will be dependent on your local network:
byte mac[] = { 0x0C, 0x00, 0x0C, 0xE, 0xA, 0xB };
byte ip[] = { 192,168,1, 253 };
byte thismsg;
Server server(1234);
NewSoftSerial mySerial(2, 3);
const unsigned char oversampling_setting = 3; //oversamplig for measurement
const unsigned char pressure_waittime[4] = { 5, 8, 14, 26 };
//just taken from the BMP085 datasheet
int ac1;
int ac2;
int ac3;
unsigned int ac4;
unsigned int ac5;
unsigned int ac6;
int b1;
int b2;
int mb;
int mc;
int md;
void setup()
{
Ethernet.begin(mac, ip);
Serial.begin(9600);
server.begin();
mySerial.begin(9600);
pinMode(ledPinB, OUTPUT);
pinMode(ledPinG, OUTPUT);
pinMode(ledPinR, OUTPUT);
pinMode(SpeakerPin, OUTPUT);
pinMode(ComputerPowerPin, OUTPUT);
Serial.begin(9600); // start serial for output
Serial.println("Setting up BMP085");
Wire.begin();
bmp085_get_cal_data();
}
void loop()
{
char c;
int temperature;
long pressure;
long alti;
bmp085_read_temperature_and_pressure(&temperature,&pressure,&alti);
// temperature = temperature - 18;
Client client = server.available();
if (client) {
while (client.connected()) {
{
// char c = client.read();
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("Local IP: 192.168.1.253/WAN IP: 110.175.97.110
");
client.println("Hello from my Arduino!
Helloooo");
client.print("
The Temperature Is (in my bedroom that is lol): ");
client.print(Convert(temperature));
client.print("c");
client.print("
");
client.print("
The Barometer Reading: ");
client.print(Convert(pressure));
client.print("isobars/milibars whatever they are
");
client.print("
");
client.print("Alititude: ");
client.print(alti);
client.print("
");
client.print("
");
client.print("Written by Craig C in Arduino (Crude Weather Station)");
// if (c=='b') client.print(pressure,DEC);
// if (c=='Q') client.stop();
delay(100);
client.stop();
delay(100);
// CheckChar(c);
}
}}
if (mySerial.available())
{
c = (char)mySerial.read();
CheckChar(c);
if (c=='t') mySerial.println(temperature,DEC);
if (c=='b') mySerial.println(pressure,DEC);
}
// Serial.print(temperature,DEC);
// Serial.print(' ');
// Serial.print(pressure,DEC);
// Serial.println();
// delay(200);
}
void CheckChar(char c) {
// if (c=='B') { digitalWrite(ledPinB,HIGH); }
// if (c=='b') { digitalWrite(ledPinB,LOW); }
// if (c=='G') { digitalWrite(ledPinG,HIGH);}
// if (c=='g') { digitalWrite(ledPinG,LOW); }
// if (c=='R') { digitalWrite(ledPinR,HIGH);}
// if (c=='r') { digitalWrite(ledPinR,LOW); }
// if (c=='X') {LightShow1(); }
// if (c=='x') { LightShow2(); }
// if (c=='S') { digitalWrite(SpeakerPin,HIGH); }
// if (c=='s') { digitalWrite(SpeakerPin,LOW); }
if (c=='p') {
digitalWrite(ComputerPowerPin,HIGH);
delay(50);
digitalWrite(ComputerPowerPin,LOW);
}
if (c=='P') {
digitalWrite(ComputerPowerPin,HIGH);
delay(5000);
digitalWrite(ComputerPowerPin,LOW);
}
}
String Convert(long Val)
{
String s = String(Val);
int bc;
int where = s.length()-1;
String part1 = "";
String part2 = "";
for(bc=0; bc<where; bc++)
part1 = part1 + s[bc];
part2 = s[where];
s = part1 + "." + part2;
return(s);
}
//more to be posted as i reached max length for a quote
The bluetooth code was just a small experiment of mine to remotely switch my computer on and off (I removed the push button and wired it up to pin 8 on the Arduino and fed it to a transistor, which then has the ability to forcefully turn it off (if windows hangs) and shut it down gently, soft power off via a button press longer than 4000ms.... i use 50ms for a quick press, works wonderfully, i now use it to restart my server on my pc if it hangs or if the power goes out..... (I also had this working for internet, but figured with the simple checking of each byte it receives, not a good idea as a simple /GET request would shut down the pc if someone stumbled across the IP address and port.
So anyway i'm now comparing the PDF against the code to fine tune it...
I'm hoping it's the code and not some kind of fault with the unit.