extern void OWINIT();
-
+extern void EXTERN_SLEEP();
uint8_t owid1[8]={0x28, 0xA3, 0xD9, 0x84, 0x00, 0x16, 0x05, 0x18};/**/
volatile double temperatureC,humidityRH;
volatile double l;
+uint8_t max_adr=0;
int main(void){
PRR|=(1<<PRADC); // adc for save Power
MCUSR=0;
USI_TWI_Master_Initialise();
+ if (checkMAX44009(0)) max_adr=0; else max_adr=1 ;
SHT2x_SoftReset();
SHT2x_ReadUserRegister(userRegister);
//(userRegister & ~SHT2x_RES_MASK) | SHT2x_RES_10_13BIT;
gcontrol=1;
sei();
+ //DDRB|=(1<<PINB1);
while(1) {
if (wdcounter>0) {
+ //PORTB|=(1<<PINB1); //Dauer 440ms
SHT2x_MeasurePoll(HUMIDITY, &sRH);
// --- measure temperature with "Polling Mode" (no hold master) ---
SHT2x_MeasurePoll(TEMP, &sT);
double hhum=(1.0546-0.000216*temperatureC)*(humidityRH);
am2302_hum=0.318*hhum +76.0;
am2302_temp=temperatureC*25.6;
+ //PORTB&=~(1<<PINB1);
wdcounter=0;
}
if (gcontrol==1) {
- l=MAX44009getlux(0);
+ l=MAX44009getlux(max_adr);
if (l<0.030) l=0.030; //Darf nicht 0 sein. minimum -35°C Sensor minimum 0.045
//double l=1000;
l=log(l)*10*16;
//pack.temp++;
alarmflag=af;
sei();
- gcontrol=0;
+ EXTERN_SLEEP();
}
if ((gcontrol==2)||(gcontrol==3)) {
gcontrol=0;
MCUCR|=(1<<SE);
MCUCR&=~(1<<SM1);
}
- //MCUCR&=~(1<<ISC01);
asm("SLEEP");
}