Program Multiple Sensors on Arduino Mega

Hi,

I am new on this concept of Arduino. As part of a project I need make an atmospheric and vehicle data acquisition using the followings components:

  • Arduino Mega
  • Barometric Sensor (BME280)
  • Light Sensor (TSL2561)
  • GPS
  • Accelerometer ADXL377
  • Micro SD

I perform the codes by separate and all components work correctly, but when I merge the codes in one program, the system does not work. One of the error was that the codes are in different languages. Are there any suggestions to be able to join the codes, or something that can help me with this?

Thanks and Happy Holidays! :)

One of the error was that the codes are in different languages.

Nonsense. If each sketch worked individually, they are all in C++.

Are there any suggestions to be able to join the codes

Yes. Don't use the same pins for different purposes. Don't use Strings.

something that can help me with this?

We need to see your attempt to combine them, and we need to know exactly what the issue is.

Links to the hardware you are using are interesting. Names are not really.

A schematic showing how everything is connected is essential.

Hi,

Thanks for your help.

I attached the codes using for each component… only I haven’t the code for the Micro SD and GPS.
Also, I included the electrical schematic in the attachments.

ELECTICAL SQUEMATIC with GPS.pdf (486 KB)

Codes.pdf (230 KB)

...and links to the libraries you have tried.

Here's a link to my NeoGPS library. It's smaller,faster and more accurate than all other libraries, and the examples are structured to take advantage of the GPS device timing. This usually allows you to add other "things" to be done, like read other sensors or write to an SD card.

NeoGPS is also available from the Arduino IDE Library Manager, under the menu Sketch -> Include Library -> Manage Libraries.

There is even an example for logging GPS data to the SD card. It processes the NMEA characters during the Rx interrupt to avoid losing data while the SD card write is busy. This requires an alternative HardwareSerial library (I.e., Serial) called NeoHWSerial.

This is an advanced example, so I would suggest working through the examples as described in the Installation Instructions: NMEA, NMEAorder, NMEAloc, NMEAisr (requires NeoHWSerial), then NMEASDlog.

Even if you don't use the library, be sure to read the Troubleshooting page. It describes many common problems, especially timing problems.

Cheers, /dev