Pressure and wind speed show no serial output when combined

Hi All,

Busy with my 1st Arduino project. I can get the BMP180 sensor and wind speed sensor to produce data and send it to the serial output. I even managed to get python to save it to mySQL. :slight_smile:

When I combine the two I can verify all the code with no errors. When I upload it I don't see any serial output. As soon as I // the BMP180 code the wind speed produce data and vice versa.

I have attached a copy of the code.

Your help will seriously be appreciated.


weather.ino (1.97 KB)

Please learn how to post the code directly into the forum using the code tags... here it is for everyone

/*-----( Import needed libraries )-----*/
#include "TimerOne.h"          // Timer Interrupt set to 2 second for read sensors
#include <math.h>
#include "RTClib.h"
#include <Wire.h>
#include <Adafruit_BMP085.h>

/*-----( Declare Constants and Pin Numbers )-----*/
Adafruit_BMP085 bmp; //BMP180 sensor
#define WindSensorPin (2)

/*-----( Declare objects )-----*/

/*-----( Declare Variables )-----*/
volatile unsigned long Rotations;  // cup rotation counter used in interrupt routine
volatile unsigned long ContactBounceTime;  // Timer to avoid contact bounce in interrupt routine

float WindSpeed;        // speed km per hour

void setup()   /****** SETUP: RUNS ONCE ******/
     pinMode(WindSensorPin, INPUT);
     attachInterrupt(0, rotation, FALLING);

}                  //--(end setup )---

void loop()   /****** LOOP: RUNS CONSTANTLY ******/
    //float Pres = bmp.readPressure();
    //float Temp = bmp.readTemperature();
    //float Alti = bmp.readAltitude();
    //float SeaL = bmp.readSealevelPressure();
      delay (3000);
  //  Serial.print("Temp");
  //  Serial.println(Temp);
  //  Serial.print("Alt");
  //  Serial.println(Alti);
  //  Serial.print("Sea");
  //  Serial.println(SeaL);
}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/
void rotation ()   {

  if ((millis() - ContactBounceTime) > 15 ) {  // debounce the switch contact.
    ContactBounceTime = millis();


void windspeed(){
  Rotations = 0;   //Set NbTops to 0 ready for calculations
  sei();         //Enables interrupts
  delay (3000);  //Wait 3 seconds to average
  cli();         //Disable interrupts

  // convert to mp/h using the formula V=P(2.25/T)
  // V = P(2.25/3) = P * 0.75

  WindSpeed = Rotations * 1.20;

//*********( THE END )***********

why do you have a ! in front of


why the delay for 3 seconds in the print sequence?

      delay (3000);

this is weird:

  sei();         //Enables interrupts
  delay (3000);  //Wait 3 seconds to average
  cli();         //Disable interrupts

the millis timer (and serial communication) are affected by disabling interrupts.

are you sure you merged your codes correctly?

Sorry for not posting the code to the post directly on the first post. Will do it in the future.

I was thinking that it was a timing issue and wasn't sure where to start with it.

I remove the sei() and cli() and it's working. Thank you.

Weird? All this code is weird to me. :slight_smile: