Thank you very much for your time.
Right now the code is too big to be able to publish within the post, so I've attached it.
I have not found a solution to my problems on the Internet, because I have a specific programming problem, because as I have written before "I am not an experienced programmer", only an amateur.
I tell you my problems
At first I got the code I made, as they are now working on the two Arduinos, and I do not know why, it has stopped working properly, the codes compile, but I suspect that when using the Serial communication between the two Arduinos, and use a MPU6050 gyroscope, that's what can create me conflicts
I go on to explain the project I intend to carry out
The idea is that with 2 Arduinos Mega 2560, one inside the ROV called Slave, and another on a surface called Master, and a PS2 controller, control the movements of ROV, and that on a 5-inch Nextion screen of the Basic type, show me the data of the different sensors that I have punctured in the Arduino Slave.
I'm using the Library of Bill Porter PSXLib, known to many of you, which I will attach in this publication, along with all the ones I've used for the project, to control the PS2 command.
Now I go on to list the sensors I'm using, they're very normal, but for this project I think they're the right ones for their value for money
I have 3 DHT22 temperature and humidity sensors, known to everyone you've messed up a little bit with Arduino.
I'm also using a DS18B20 temperature sensor, with its metal encapsulation, and connected by a resistance of 4.7 k.
I am also using a HK3025 5MP pressure sensor, which will definitely have to be 2, one to mark the internal pressure of the ROV, and try not to burst, and another to mark the outside pressure to know how deep the ROV is.
I'm also using an E18D80NK infrared sensor,
Also a relay module to turn on a spotlight, which will later be 2 spotlights, but for the moment for testing with one that works it's good for me, in the final assembly, I don't know if I'll put 2 relays, one for focus, or if I can fix myself with a single relay for the two spotlights , that will be seen in the not too distant future
Two brushless motors, with its speed inverter, which I have been able to check on various Internet pages, are controlled just like a servo, this in principle has no greater control problem
And as not a servo that will move me an axle where the motors will be placed, and will move according to the needs up and down to sink the ROV, or bring it to the surface
I also have connected a GY 5121 MPU6050 gyroscope, so that I mark the inclinations of the ROV, on the axes of the three planes X, Y, Z, to know in what position the ROV is in
The current for now I'm pulling it out of a PC ATX source, so as not to expend batteries with project tests, and the cables are connected to an Arduino power board called YFRobot
And of course in the electrical assembly all the masses are connected to each other, both those of the tracks of the protoboarding, as the GNDs of the Arduinos, and the black cables, Negative of the PC source
For the transmission of data between one Arduino and another, for the moment, as I have everything on the table, with two dupont type bridge cables, for the time being can serve me, but then that transmission will be done with a CAT5 network cable , 100 meters, which I already got at the time and that is waiting for you to use it.
For live video streaming I'm not going to complicate my life, I'm going to use a Raspberry Pi3+, a USB camera, and a laptop.
The video system works as follows.
The Raspberry Pi3+, is connected a video camera via USB, starts the Raspberry and directly from the computer, with a program called VLC media player, it is sent to play a web address, which is the ip address of the Raspberry , and you're already watching the video on your computer.
The only thing to do to the Raspberry is to load the operating system, update everything, and to show you its ip address, I have not complicated myself with the programming language, I have only followed the tutorial of the start of the official Raspbery page. I already have enough programming problems with a single language the C++, arduino, as for learning the other from the Raspberry, the Python.
Well so far the project exhibition, I hope I've explained enough that you understand the idea and can help me.
Now I'm starting to explain the problem I have.
So far, I've been incorporating sensor to sensor, one at a time, first connecting only the new sensor on a board and in a new program.
Then I connected it in an Arduino, and through Serial Communication, by the RX and TX pins, to another Arduino, to check that the assembly works, and that I can see the data through the Serial Monitor.
And then incorporating it into the program where the rest of the instructions are, both in the Arduino Maestro, and in the Slave, and connecting it in place, to check that it works.
This has worked well for me, until it has suddenly stopped working, without being able to find a coherent explanation why the fault.
Suddenly it has stopped reacting to the command orders of the PS2, and it is not because the batteries of the controller are worn out, as one can tell me, it has been by incorporating the gyroscope, and I think there is some order that is interfering in the program , and I do not find what it is, in principle there is no Arduino pin that in the program does two functions, I have checked the electrical installation of the circuit several times and I think I can ensure that there is no connection failure, I lean more towards a programming problem.
With the Slave program, if I can see the data on the Serial Monitor, and they are quite consistent, it gives me the temperature of the 4 sensors, the humidity of the three DHT22, marks the battery voltage.
But the infrared sensor does not mark well, it randomly marks the proximity of an object or not, without cutting off the sensor light.
And the gyroscope data doesn't vary depending on the tilt, it's fixed in a number.
And the Master Series monitor, goes to your air, or marks nothing, or just prints the lines of text without any value, or displays random sensor data and the failure of any of them.
I've already tried to change the two Arduinos, and change the controller, in case it was any failure of these, but nothing I can fix it.
I attach the two programs, and of course I offer to clarify any doubts you have about the project that I have not explained well in this publication.
I have already been told by a colleague of the forum, which could be a problem caused by the many "serial. Print", which is in the program, necessary to control the proper functioning of the sensors, if you look at the code, I have started two serial ports, to separate the data that I want to be sent from one Arduino to another, from the data that I want to be seen in the Serial Monitor.
I have also been told by another partner, and I have implemented a "DEBUG 0" command, so that the data is not printed on the Serial Monitor, or "DEBUG 1", so that if the data is printed on the Serial Monitor.
Greetings to all