How to combine various code for different sensors into 1 .cpp file

Hi

Could you please assist me I have 5 different sensors that I need to combine into 1 program (.cpp file) how do I do this and do i put a separate delay for each sensor else it will read all at once .

Thanks

Currently I have different files for each sensor but need to combine now into 1 program

Hello,

If you have 5 libraries and all are included to the main then it already is one program and all code is merged to one file during build.

According to your request. Basically you probably need to do a copy of content of all files to one without #inlude XXXX line, but I do not understand what this is good for.

BR, Jan

Hi

The thing is i built a weather station and currently have temp&humidity sensor in 1 project then mq-7 in a project then Windspeed and winddirection all in separate projects now i need to merge all of these projects into 1 mbed project so i need help with this thanks

Thanks

Now it makes sense, your first information was not clear.

It is up to you. You have working solutions in separete projects.

  • Create new empty projet (for example) weather_station_final
  • import same libraries into weather_station_final from all separeted projects
  • copy code from all projects into weather_station_final, of cource in a logic
  • avoid pin collision, mean two sensors on same pin
#include "mbed.h"
#include "sensor1.h"
#include "sensor2.h"
#include "sensor3.h"

// here place Global variables, objects from all projects

int main(){

   // init sensor1
   // init sensor2
   // init sensor3

   while(1){

      // read and print or other stuff of sensor1
      // read and print or other stuff of sensor2
      // read and print or other stuff of sensor3

   }
}

I do not know how more I can help you without source.

BR, Jan

Hi

Ok thanks I have however loaded it accordingly compiled it but it not reading the values but if run separately I get the desired outputs please find attached files only the .cpp files as I am comfortable with moving the libraries over .

Regards

(Attachment Anenometer.cpp is missing)

(Attachment Windvanesensor.cpp is missing)

(Attachment Tempretureandhumidity.cpp is missing)

(Attachment MQ-7gassensor.cpp is missing)

Hi

Ok thanks I have however loaded it accordingly compiled it but it not reading the values but if run separately I get the desired outputs pity I cant attach notepad documents so I could send please advise on alternate email address which i can use thanks