   digitalWrite(AS3935_CS, HIGH);
   pinMode(AS3935_INT, INPUT);
 
-  if( !lightning.beginSPI(AS3935_CS, 2000000) ){ 
-    Serial.println ("debug: Lightning Detector did not start up, freezing!"); 
-    while(1); 
-  }
-  else
-    Serial.println("debug: Lightning Detector Ready!");
+//  if( !lightning.beginSPI(AS3935_CS, 2000000) ){ 
+//    Serial.println ("debug: Lightning Detector did not start up, freezing!"); 
+//    while(1); 
+//  }
+//  else
+//    Serial.println("debug: Lightning Detector Ready!");
 
-  lightning.setIndoorOutdoor(AS3935_OUTDOOR); 
+  //lightning.setIndoorOutdoor(AS3935_OUTDOOR); 
 }
 
 double TMP116_ReadTempSensor(void){

#define AS3935_CS  B_CS
#define AS3935_INT B_INT

SparkFun_AS3935 lightning;

int AS3935_intVal = 0;
int AS3935_noise = 2; // Value between 1-7 

const int TMP116_temp_reg   = 0x00;  // Temperature register
const int TMP116_config_reg = 0x01;  // Configuration register

int counter=10;

bool has_bme = true;

void setup()
{
  Serial.begin(57600);
  Serial.println("MIKROE SAM3X WeatherDemo");

  bme_init();

//  SPI.begin();
//  SPI.setDataMode( SPI_MODE1 );

//  thunder_init();

//  Wire.begin();

//  tmp116_init();
}

void loop()
{
//  double temp = TMP116_ReadTempSensor();
//  Serial.println(temp);
  
//  if(digitalRead(AS3935_INT) == HIGH){
//    AS3935_intVal = lightning.readInterruptReg();
//    if(AS3935_intVal == AS3935_NOISE_INT){
//      Serial.println("debug: Noise."); 
//    }
//    else if(AS3935_intVal == AS3935_DISTURBER_INT){
//      Serial.println("debug: Disturber."); 
//    }
//    else if(AS3935_intVal == AS3935_LIGHTNING_INT){
//      Serial.println("debug: Lightning Strike Detected!"); 
//      // Lightning! Now how far away is it? Distance estimation takes into
//      // account any previously seen events in the last 15 seconds. 
//      byte distance = lightning.distanceToStorm(); 
//      Serial.print("Approximately: "); 
//      Serial.print(distance); 
//      Serial.println("km away!"); 
//    }
//  }

  bme_read();

  counter++;
  if (counter == 100)
  {
    counter = 10;
  }

  delay(5000); // wait 5 seconds for the next I2C scan
}

void bme_init() {
   if (! bme.begin(0x76, &Wire)) {
        Serial.println("Could not find a valid BME280 sensor, check wiring!");
        has_bme=false;
    }  
}

void bme_read() {
    bme.takeForcedMeasurement(); // has no effect in normal mode

    Serial.print("MIKROESAM3X_WC:");
    Serial.print(counter);
    Serial.print(":Temp:");
    float bme_temp_c = bme.readTemperature();
    float bme_temp_f = ((bme_temp_c * 1.8) + 32);
    Serial.print(bme_temp_f);
    Serial.print("F:Press:");
    Serial.print(bme.readPressure() / 100.0F);
    Serial.print("mB:Humidity:");
    Serial.print(bme.readHumidity());
    Serial.println("%:#");
}

void thunder_init()
