Problem combining color sensor and temperature sensor program

Hello everyone,

this is my first question on this forum. I'm currently participating in a contest named Cansat. We have to make a satellite with the size of a soda can. I'm now working on the programming of our satellite, but I'm experiencing a problem.

I have two programs: one for a BMP200 sensor, which measures the air temperature and the air pressure and the other program is for a TCS230 color sensor, which measures the RGB values. Both sensors have to send their data wireless back to our ground station. If I use each program separate from each other, they work perfect, but when I combine them, the data only comes through to our ground station when I turn the satellite off, not every second as it is supposed to do.

This is my code:

#include <SoftwareSerial.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP2800.h>

#define S0 5
#define S1 4
#define S2 1
#define S3 6
#define sensorOut 7
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 9
#define BMP_CS 8

// Stores frequency read by the photodiodes
int redFrequency = 0;
int greenFrequency = 0;
int blueFrequency = 0;

SoftwareSerial mySerial(10,11);//RX, TX
int number = 0;

//Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);

void setup() {
  // Setting the outputs
  pinMode(S0, OUTPUT);
  pinMode(S1, OUTPUT);
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);
  
  // Setting the sensorOut as an input
  pinMode(sensorOut, INPUT);
  
 // Setting frequency scaling to 20%
  digitalWrite(S0,HIGH);
  digitalWrite(S1,LOW);

mySerial.begin(9600);
mySerial.begin(9600);
mySerial.println(F("BMP280 test"));
  
if (!bmp.begin()) {  
    mySerial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
    while (1);
  }
}
void loop() {
{
 // Setting RED (R) filtered photodiodes to be read
  digitalWrite(S2,LOW);
  digitalWrite(S3,LOW);
  
  // Reading the output frequency
  redFrequency = pulseIn(sensorOut, LOW);
  
   // Printing the RED (R) value
  mySerial.print("R = ");
  mySerial.print(redFrequency);
  delay(100);
  
  // Setting GREEN (G) filtered photodiodes to be read
  digitalWrite(S2,HIGH);
  digitalWrite(S3,HIGH);
  
  // Reading the output frequency
  greenFrequency = pulseIn(sensorOut, LOW);
  
  // Printing the GREEN (G) value  
  mySerial.print(" G = ");
  mySerial.print(greenFrequency);
  delay(100);
 
  // Setting BLUE (B) filtered photodiodes to be read
  digitalWrite(S2,LOW);
  digitalWrite(S3,HIGH);
  
  // Reading the output frequency
  blueFrequency = pulseIn(sensorOut, LOW);
  
  // Printing the BLUE (B) value 
  mySerial.print(" B = ");
  mySerial.println(blueFrequency);
  delay(100);
}
{  
    mySerial.print(F("Temperature = ")); //Woordje 'temperature' doorgeven
    mySerial.print(bmp.readTemperature()); //gemeten temperatuur doorgeven
    mySerial.println(" *C"); //graden celsius teken erachter zetten
    
    mySerial.print(F("Pressure = ")); //Woordje 'pressure' doorgeven
    mySerial.print(bmp.readPressure()); //gemeten luchtdruk doorgeven
    mySerial.println(" Pa"); //Pascal erachter zetten

    mySerial.print(F("Approx altitude = ")); //Woordje 'Approx altitude' doorgeven
    mySerial.print(bmp.readAltitude(1023.75)); // this should be adjusted to your local forcase
    mySerial.println(" m");
 
    mySerial.println();
  delay(500);                  //1 second delay
}
}

I hope somebody can help me with this question (ps. sorry if my English is bad :b)

Hi,
Welcome to the forum.

What model Arduino are you using?

#define S0 5
#define S1 4
#define S2 1
#define S3 6

If these are your output pins, pin 1 is one of the two programming pins. It is used when you serially communicate with the outside world.
This will explain your problem.

Can you post the two codes that worked before you combined them?

Thanks.. Tom... :slight_smile:

Hi,

I'm using the arduino uno Rev3.

The codes are:

/*
 #include <SoftwareSerial.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP2800.h>

#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 9
#define BMP_CS 8


SoftwareSerial mySerial(10,11);//RX, TX
int number = 0;


//Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);


void setup() {
mySerial.begin(9600);
mySerial.begin(9600);
mySerial.println(F("BMP280 test"));
  
if (!bmp.begin()) {  
    Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
    while (1);
  }
  }

void loop()
{
    mySerial.print(F("Temperature = ")); //Woordje 'temperature' doorgeven
    mySerial.print(bmp.readTemperature()); //gemeten temperatuur doorgeven
    mySerial.println(" *C"); //graden celsius teken erachter zetten
    
    mySerial.print(F("Pressure = ")); //Woordje 'pressure' doorgeven
    mySerial.print(bmp.readPressure()); //gemeten luchtdruk doorgeven
    mySerial.println(" Pa"); //Pascal erachter zetten

    mySerial.print(F("Approx altitude = ")); //Woordje 'Approx altitude' doorgeven
    mySerial.print(bmp.readAltitude(1023.75)); // this should be adjusted to your local forcase
    mySerial.println(" m");
 
    mySerial.println();
  delay(1000);                  //1 second delay
}

and

#define S0 5
#define S1 4
#define S2 1
#define S3 6
#define sensorOut 7

// Stores frequency read by the photodiodes
int redFrequency = 0;
int greenFrequency = 0;
int blueFrequency = 0;

void setup() {
  // Setting the outputs
  pinMode(S0, OUTPUT);
  pinMode(S1, OUTPUT);
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);
  
  // Setting the sensorOut as an input
  pinMode(sensorOut, INPUT);
  
  // Setting frequency scaling to 20%
  digitalWrite(S0,HIGH);
  digitalWrite(S1,LOW);
  
   // Begins serial communication 
  Serial.begin(9600);
}
void loop() {
  // Setting RED (R) filtered photodiodes to be read
  digitalWrite(S2,LOW);
  digitalWrite(S3,LOW);
  
  // Reading the output frequency
  redFrequency = pulseIn(sensorOut, LOW);
  
   // Printing the RED (R) value
  Serial.print("R = ");
  Serial.print(redFrequency);
  delay(100);
  
  // Setting GREEN (G) filtered photodiodes to be read
  digitalWrite(S2,HIGH);
  digitalWrite(S3,HIGH);
  
  // Reading the output frequency
  greenFrequency = pulseIn(sensorOut, LOW);
  
  // Printing the GREEN (G) value  
  Serial.print(" G = ");
  Serial.print(greenFrequency);
  delay(100);
 
  // Setting BLUE (B) filtered photodiodes to be read
  digitalWrite(S2,LOW);
  digitalWrite(S3,HIGH);
  
  // Reading the output frequency
  blueFrequency = pulseIn(sensorOut, LOW);
  
  // Printing the BLUE (B) value 
  Serial.print(" B = ");
  Serial.println(blueFrequency);
  delay(100);
}

Hi,
Did you write these codes yourself?

Have read my comment about

#define S2 1

And what pin 1 is?

Tom... :slight_smile:

Hi,

One of the codes was included with a file from the contest itself. I found the code for the color sensor on the internet.

I don't now exactly what you mean with the pin 1 thing??

Mika

Hi,

#define S2 1

Assigns to value of 1 to a variable called S2.

Then you have this statement in setup;

 pinMode(S2, OUTPUT);

This assigns pin 1 as an OUTPUT, however pin 1 is one of the pins along with pin 0 that is used for programming.

You need to give S2 another pin value and change you circuit accordingly.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:
PS, do you have teachers/instructors that can help teach you to code?

Hi Tom,

I have now connected the cable that was connected to pin 1 to pin 2 and I have changed the code for it. I have tested it and I stil have the same problem: I only get the data when I turn off the arduino.

I don't have any teachers that can help me with this, because they only know how to support us with the contest :b.

Mika

Hi,
Okay, post your new combined code please.

Also post a circuit diagram please.

Thanks.. Tom... :slight_smile:

Hi Tom,

The code i'm now using:

#include <SoftwareSerial.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP2800.h>

#define S0 5
#define S1 4
#define S2 2
#define S3 6
#define sensorOut 7
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 9
#define BMP_CS 8

// Stores frequency read by the photodiodes
int redFrequency = 0;
int greenFrequency = 0;
int blueFrequency = 0;

SoftwareSerial mySerial(10,11);//RX, TX
int number = 0;

//Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);

void setup() {
  // Setting the outputs
  pinMode(S0, OUTPUT);
  pinMode(S1, OUTPUT);
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);
  
  // Setting the sensorOut as an input
  pinMode(sensorOut, INPUT);
  
 // Setting frequency scaling to 20%
  digitalWrite(S0,HIGH);
  digitalWrite(S1,LOW);

mySerial.begin(9600);
mySerial.begin(9600);
mySerial.println(F("BMP280 test"));
  
if (!bmp.begin()) {  
    mySerial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
    while (1);
  }
}
void loop() {
{
 // Setting RED (R) filtered photodiodes to be read
  digitalWrite(S2,LOW);
  digitalWrite(S3,LOW);
  
  // Reading the output frequency
  redFrequency = pulseIn(sensorOut, LOW);
  
   // Printing the RED (R) value
  mySerial.print("R = ");
  mySerial.print(redFrequency);
  delay(100);
  
  // Setting GREEN (G) filtered photodiodes to be read
  digitalWrite(S2,HIGH);
  digitalWrite(S3,HIGH);
  
  // Reading the output frequency
  greenFrequency = pulseIn(sensorOut, LOW);
  
  // Printing the GREEN (G) value  
  mySerial.print(" G = ");
  mySerial.print(greenFrequency);
  delay(100);
 
  // Setting BLUE (B) filtered photodiodes to be read
  digitalWrite(S2,LOW);
  digitalWrite(S3,HIGH);
  
  // Reading the output frequency
  blueFrequency = pulseIn(sensorOut, LOW);
  
  // Printing the BLUE (B) value 
  mySerial.print(" B = ");
  mySerial.println(blueFrequency);
  delay(100);
}
{  
    mySerial.print(F("Temperature = ")); //Woordje 'temperature' doorgeven
    mySerial.print(bmp.readTemperature()); //gemeten temperatuur doorgeven
    mySerial.println(" *C"); //graden celsius teken erachter zetten
    
    mySerial.print(F("Pressure = ")); //Woordje 'pressure' doorgeven
    mySerial.print(bmp.readPressure()); //gemeten luchtdruk doorgeven
    mySerial.println(" Pa"); //Pascal erachter zetten

    mySerial.print(F("Approx altitude = ")); //Woordje 'Approx altitude' doorgeven
    mySerial.print(bmp.readAltitude(1023.75)); // this should be adjusted to your local forcase
    mySerial.println(" m");
 
    mySerial.println();
  delay(500);                  //1 second delay
}
}

I'm going to work on a diagram, but it's going to take me a minute.

Mika

Hi,
Where do you get;

#include <Adafruit_BMP2800.h>

Library from?

Tom... :slight_smile:

Hi,
Your code has too many { and }.
I have commented them out so you can see where your problems could have been.
It compiles, but only you can say if it runs.

#include <SoftwareSerial.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#include <Adafruit_Sensor.h>
//#include <Adafruit_BMP2800.h>


#define S0 5
#define S1 4
#define S2 2
#define S3 6
#define sensorOut 7
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 9
#define BMP_CS 8


// Stores frequency read by the photodiodes
int redFrequency = 0;
int greenFrequency = 0;
int blueFrequency = 0;


SoftwareSerial mySerial(10, 11); //RX, TX
int number = 0;


//Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);


void setup()
{
  // Setting the outputs
  pinMode(S0, OUTPUT);
  pinMode(S1, OUTPUT);
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);


  // Setting the sensorOut as an input
  pinMode(sensorOut, INPUT);


  // Setting frequency scaling to 20%
  digitalWrite(S0, HIGH);
  digitalWrite(S1, LOW);


  mySerial.begin(9600);
  mySerial.begin(9600);
  mySerial.println(F("BMP280 test"));


  if (!bmp.begin()) {
    mySerial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
    while (1);
  }
}
void loop()
{
  //{
  // Setting RED (R) filtered photodiodes to be read
  digitalWrite(S2, LOW);
  digitalWrite(S3, LOW);


  // Reading the output frequency
  redFrequency = pulseIn(sensorOut, LOW);


  // Printing the RED (R) value
  mySerial.print("R = ");
  mySerial.print(redFrequency);
  delay(100);


  // Setting GREEN (G) filtered photodiodes to be read
  digitalWrite(S2, HIGH);
  digitalWrite(S3, HIGH);


  // Reading the output frequency
  greenFrequency = pulseIn(sensorOut, LOW);


  // Printing the GREEN (G) value
  mySerial.print(" G = ");
  mySerial.print(greenFrequency);
  delay(100);


  // Setting BLUE (B) filtered photodiodes to be read
  digitalWrite(S2, LOW);
  digitalWrite(S3, HIGH);


  // Reading the output frequency
  blueFrequency = pulseIn(sensorOut, LOW);


  // Printing the BLUE (B) value
  mySerial.print(" B = ");
  mySerial.println(blueFrequency);
  delay(100);
  //}
  //{
  mySerial.print(F("Temperature = ")); //Woordje 'temperature' doorgeven
  mySerial.print(bmp.readTemperature()); //gemeten temperatuur doorgeven
  mySerial.println(" *C"); //graden celsius teken erachter zetten


  mySerial.print(F("Pressure = ")); //Woordje 'pressure' doorgeven
  mySerial.print(bmp.readPressure()); //gemeten luchtdruk doorgeven
  mySerial.println(" Pa"); //Pascal erachter zetten


  mySerial.print(F("Approx altitude = ")); //Woordje 'Approx altitude' doorgeven
  mySerial.print(bmp.readAltitude(1023.75)); // this should be adjusted to your local forcase
  mySerial.println(" m");


  mySerial.println();
  delay(500);                  //1 second delay
  //}
}

Tom... :slight_smile:

Now that you've got pins zero and one available, I'd start using Serial.print to see how far your sketch gets.

If you no-joy with the current setup, maybe a different approach will work:

#include <SoftwareSerial.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP2800.h>

#define S0 5
#define S1 4
#define S2 2
#define S3 6
#define sensorOut 7
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 9
#define BMP_CS 8

// Stores frequency read by the photodiodes
int redFrequency = 0;
int greenFrequency = 0;
int blueFrequency = 0;

SoftwareSerial mySerial(10,11);//RX, TX
int number = 0;

//Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);

void setup() 
{
    // Setting the outputs
    pinMode(S0, OUTPUT);
    pinMode(S1, OUTPUT);
    pinMode(S2, OUTPUT);
    pinMode(S3, OUTPUT);
  
    // Setting the sensorOut as an input
    pinMode(sensorOut, INPUT);
  
    // Setting frequency scaling to 20%
    digitalWrite(S0,HIGH);
    digitalWrite(S1,LOW);

    mySerial.begin(9600);
    mySerial.begin(9600);
    mySerial.println(F("BMP280 test"));
  
    if( !bmp.begin() ) 
    {  
        mySerial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
        while (1);
    }//if
    
}//setup


bool ReadPhotoDiodes()
{
    static byte
        stateDiodes = DIODE_RED;
    unsigned long
        timeNow;
    static unsigned long
        timeDiode = 0,
        timeDiodeDly = 0;

    timeNow = millis();
    if( (timeNow - timeDiode) < timeDiodeDly )
        return;
        
    switch( stateDiodes )
    {
        case    DIODE_RED:            
            digitalWrite(S2,LOW);   // Setting RED (R) filtered photodiodes to be read
            digitalWrite(S3,LOW);            
            redFrequency = pulseIn(sensorOut, LOW); // Reading the output frequency            
            //
            timeDiode = millis();
            timeDiodeDly = 100;
            stateDiodes = DIODE_GREEN;
            
            return false;
            
        break;

        case    DIODE_GREEN:            
            digitalWrite(S2,HIGH);  // Setting GREEN (G) filtered photodiodes to be read
            digitalWrite(S3,HIGH);          
            greenFrequency = pulseIn(sensorOut, LOW);   // Reading the output frequency
            //
            timeDiode = millis();
            timeDiodeDly = 100;
            stateDiodes = DIODE_BLUE;

            return false;
            
        break;

        case    DIODE_BLUE:            
            digitalWrite(S2,LOW);   // Setting BLUE (B) filtered photodiodes to be read
            digitalWrite(S3,HIGH);            
            blueFrequency = pulseIn(sensorOut, LOW);    // Reading the output frequency
            //
            //
            timeDiode = millis();
            timeDiodeDly = 100;
            stateDiodes = DIODE_REPORT_RSLTS;

            return false;
            
        break;

        case    DIODE_REPORT_RSLTS:
            //print RED (R) value
            mySerial.print("R = ");
            mySerial.print(redFrequency);
            //print GRN (G) value
            mySerial.print(" G = ");
            mySerial.print(greenFrequency);
            //print BLU (B) value
            mySerial.print(" B = ");
            mySerial.print(blueFrequency);
            
            timeDiode = millis();
            timeDiodeDly = 0;
            stateDiodes = DIODE_RED;

            return true;
            
        break;
        
    }//switch
    
}//ReadPhotoDiodes

void ReadWXFactors( void )
{
    mySerial.print(F("Temperature = ")); //Woordje 'temperature' doorgeven
    mySerial.print(bmp.readTemperature()); //gemeten temperatuur doorgeven
    mySerial.println(" *C"); //graden celsius teken erachter zetten
    
    mySerial.print(F("Pressure = ")); //Woordje 'pressure' doorgeven
    mySerial.print(bmp.readPressure()); //gemeten luchtdruk doorgeven
    mySerial.println(" Pa"); //Pascal erachter zetten

    mySerial.print(F("Approx altitude = ")); //Woordje 'Approx altitude' doorgeven
    mySerial.print(bmp.readAltitude(1023.75)); // this should be adjusted to your local forcase
    mySerial.println(" m");
    mySerial.println();
    
}//ReadWXFactors

void loop() 
{
    static unsigned long
        timeThen = millis();
        
    timeNow = millis();
    if( (timeNow - timeThen) >= 1000 )
    {
        timeThen = timeNow;
        
        //read all the diodes at once; done when reports are printed       
        while( !ReadPhotoDiodes() );
        ReadWXFactors();
        
    }//if
    
}//loop

Hello everyone,

Thanks for all your replies. I have tried the script without to many { and } and I have tried the different approach.

The script with too many { and } won't compile in my case.

With the different approach I get an error message that says: 'DIODE RED' was not declared in this scope in this line:

bool ReadPhotoDiodes()
{
    static byte
        stateDiodes = DIODE_RED;

Sorry. Add the following near the top of the program, after the includes:

#define DIODE_RED               0
#define DIODE_GREEN             1
#define DIODE_BLUE              2
#define DIODE_REPORT_RSLTS      3

Hi,

I now get this error message: timeNow was not declared in this scope.

void loop() 
{
    static unsigned long
        timeThen = millis();
        
    timeNow = millis();
    if( (timeNow - timeThen) >= 1000 )
    {
        timeThen = timeNow;
        
        //read all the diodes at once; done when reports are printed       
        while( !ReadPhotoDiodes() );
        ReadWXFactors();
        
    }//if

Mikado_03:
Hello everyone,

this is my first question on this forum. I'm currently participating in a contest named Cansat. We have to make a satellite with the size of a soda can. I'm now working on the programming of our satellite, but I'm experiencing a problem.

I have two programs: one for a BMP200 sensor, which measures the air temperature and the air pressure and the other program is for a TCS230 color sensor, which measures the RGB values. Both sensors have to send their data wireless back to our ground station. If I use each program separate from each other, they work perfect, but when I combine them, the data only comes through to our ground station when I turn the satellite off, not every second as it is supposed to do.

This is my code:

#include <SoftwareSerial.h>

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP2800.h>

#define S0 5
#define S1 4
#define S2 1
#define S3 6
#define sensorOut 7
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 9
#define BMP_CS 8

// Stores frequency read by the photodiodes
int redFrequency = 0;
int greenFrequency = 0;
int blueFrequency = 0;

SoftwareSerial mySerial(10,11);//RX, TX
int number = 0;

//Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);

void setup() {
  // Setting the outputs
  pinMode(S0, OUTPUT);
  pinMode(S1, OUTPUT);
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);
 
  // Setting the sensorOut as an input
  pinMode(sensorOut, INPUT);
 
// Setting frequency scaling to 20%
  digitalWrite(S0,HIGH);
  digitalWrite(S1,LOW);

mySerial.begin(9600);
mySerial.begin(9600);
mySerial.println(F("BMP280 test"));
 
if (!bmp.begin()) { 
    mySerial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
    while (1);
  }
}
void loop() {
{
// Setting RED (R) filtered photodiodes to be read
  digitalWrite(S2,LOW);
  digitalWrite(S3,LOW);
 
  // Reading the output frequency
  redFrequency = pulseIn(sensorOut, LOW);
 
  // Printing the RED (R) value
  mySerial.print("R = ");
  mySerial.print(redFrequency);
  delay(100);
 
  // Setting GREEN (G) filtered photodiodes to be read
  digitalWrite(S2,HIGH);
  digitalWrite(S3,HIGH);
 
  // Reading the output frequency
  greenFrequency = pulseIn(sensorOut, LOW);
 
  // Printing the GREEN (G) value 
  mySerial.print(" G = ");
  mySerial.print(greenFrequency);
  delay(100);

// Setting BLUE (B) filtered photodiodes to be read
  digitalWrite(S2,LOW);
  digitalWrite(S3,HIGH);
 
  // Reading the output frequency
  blueFrequency = pulseIn(sensorOut, LOW);
 
  // Printing the BLUE (B) value
  mySerial.print(" B = ");
  mySerial.println(blueFrequency);
  delay(100);
}

    mySerial.print(F("Temperature = ")); //Woordje 'temperature' doorgeven
    mySerial.print(bmp.readTemperature()); //gemeten temperatuur doorgeven
    mySerial.println(" *C"); //graden celsius teken erachter zetten
   
    mySerial.print(F("Pressure = ")); //Woordje 'pressure' doorgeven
    mySerial.print(bmp.readPressure()); //gemeten luchtdruk doorgeven
    mySerial.println(" Pa"); //Pascal erachter zetten

mySerial.print(F("Approx altitude = ")); //Woordje 'Approx altitude' doorgeven
    mySerial.print(bmp.readAltitude(1023.75)); // this should be adjusted to your local forcase
    mySerial.println(" m");

mySerial.println();
  delay(500);                  //1 second delay
}
}




I hope somebody can help me with this question (ps. sorry if my English is bad :b)

Can somebody help me please, the contest is in 2 days...

See if this helps get you closer. I left the 100mS delays between reads in; not sure if you had a reason for that but it shouldn't affect the 1-second timing.

#include <SoftwareSerial.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>
#include <Adafruit_Sensor.h>
//#include <Adafruit_BMP2800.h>

#define S0 5
#define S1 4
#define S2 1
#define S3 6
#define sensorOut 7
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 9
#define BMP_CS 8

// Stores frequency read by the photodiodes
int redFrequency = 0;
int greenFrequency = 0;
int blueFrequency = 0;

SoftwareSerial mySerial(10,11);//RX, TX
int number = 0;

//Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);

void setup() 
{
    // Setting the outputs
    pinMode(S0, OUTPUT);
    pinMode(S1, OUTPUT);
    pinMode(S2, OUTPUT);
    pinMode(S3, OUTPUT);
  
    // Setting the sensorOut as an input
    pinMode(sensorOut, INPUT);
  
    // Setting frequency scaling to 20%
    digitalWrite(S0,HIGH);
    digitalWrite(S1,LOW);

    mySerial.begin(9600);
    mySerial.println( F("BMP280 test") );
  
    if (!bmp.begin()) 
    {  
        mySerial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
        while (1);
        
    }//if
    
}//setup

void loop() 
{
    static unsigned long
        timeLoop = 0;
    unsigned long
        timeNow;

    timeNow = millis();
    if( (timeNow - timeLoop) <= 1000 )
        return;

    timeLoop = timeNow;
       
    // Setting RED (R) filtered photodiodes to be read
    digitalWrite(S2,LOW);
    digitalWrite(S3,LOW);
  
    // Reading the output frequency
    redFrequency = pulseIn( sensorOut, LOW );
  
    // Printing the RED (R) value
    mySerial.print( F("R = ") ); mySerial.print(redFrequency);
    delay(100);
  
    // Setting GREEN (G) filtered photodiodes to be read
    digitalWrite(S2,HIGH);
    digitalWrite(S3,HIGH);
  
    // Reading the output frequency
    greenFrequency = pulseIn( sensorOut, LOW );
  
    // Printing the GREEN (G) value  
    mySerial.print( F(" G = ") ); mySerial.print(greenFrequency);
    delay(100);
 
    // Setting BLUE (B) filtered photodiodes to be read
    digitalWrite(S2,LOW);
    digitalWrite(S3,HIGH);
  
    // Reading the output frequency
    blueFrequency = pulseIn(sensorOut, LOW);
  
    // Printing the BLUE (B) value 
    mySerial.print( F(" B = ") ); mySerial.println(blueFrequency);

    mySerial.print( F("Temperature = ") ); //Woordje 'temperature' doorgeven
    mySerial.print(bmp.readTemperature()); //gemeten temperatuur doorgeven
    mySerial.println(" *C"); //graden celsius teken erachter zetten
    
    mySerial.print(F("Pressure = ")); //Woordje 'pressure' doorgeven
    mySerial.print(bmp.readPressure()); //gemeten luchtdruk doorgeven
    mySerial.println(" Pa"); //Pascal erachter zetten

    mySerial.print(F("Approx altitude = ")); //Woordje 'Approx altitude' doorgeven
    mySerial.print(bmp.readAltitude(1023.75)); // this should be adjusted to your local forcase
    mySerial.println(" m");
 
    mySerial.println();
    
}//loop

Hey,

thanks for your answer. I now only get the "BMP280 test'' line through. The rest still only comes through when I turn off the arduino.