// aangepast 03-06-2010 nauwkeuriger gemaakt // OK 45 218 0 213 0 219 39 // device 45 lcd temp 23+0*256, bpm temp 213+0*256, // druk= 219+39*256 // 1 drukknop eerste keer drukken aan // tweede keer drukken uit #include #include #include #include #include "PortsBMP085.h" PortI2C myI2C (1); LiquidCrystalI2C lcd (myI2C); BlinkPlug buttons (4); byte light = 0; PortI2C two (2); BMP085 psensor (two, 3); int readTemp() { int result; // Read temperature sensor against 1.1V reference ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(MUX3); delay(1); // Wait for Vref to settle ADCSRA |= _BV(ADSC); // Convert while (bit_is_set(ADCSRA,ADSC)); result = ADCL; result |= ADCH<<8; result = (result - 133) ; return result; } void setup(){ lcd.begin(16, 2); Serial.begin(9600); rf12_initialize('M',RF12_868MHZ,212); rf12_easyInit(5); psensor.getCalibData(); } void loop(){ char buf[12]; byte pushed = buttons.pushed(); if (pushed) { if (pushed & 1) { if (light == 0) { light = 1; } else { light =0; } } } if (light){ lcd.backlight(); // always on } else{ lcd.noBacklight(); // lights off } if (Serial.available()) { // characters arrive delay(100); // wait lcd.clear(); // clear screen while (Serial.available()> 0) { // read characters lcd.write(Serial.read()); // display characters } } int16_t traw = psensor.measure(BMP085::TEMP); int16_t praw = psensor.measure(BMP085::PRES); struct { int temp1; int temp2; int pres; } payload; int16_t temp2; int32_t pres; psensor.calculate(temp2, pres); payload.temp1 = readTemp(); payload.temp2 = (temp2-8); payload.pres = pres/10; // 900 eraf in deamon 900 erbij rf12_easyPoll(); rf12_easySend(&payload, sizeof payload); rf12_easySend(0,0); // added for transmission without changes }