Hi to everyone, finally i decided to create a new topic to seek some advice. I am new at arduino , c++ , libraries all of this electronics. I have been studying for about 2 months and i use benefit of some links and their prividers such as this and this . But unfortunately i could not integrate their methods or codes to my programme.
I am presently building a RC ship which is around 60 cm long powered by 12 v battery. As electronics i would like to use an Arduino Mega 2560 and Nano 328P . Both are clone and revelant drivers are installed, working good.
Before posting my codes would like to say that , i believe there are easier , simplier or smarter way for writing them. But the thing is, i dont know how to do that and so far proceeding with "try and see" method until now. So, any advice welcomed regarding better syntax.I am a bit stuck and lost since i am not getting expected results.
Please find my setup as below ;
Modules : "1-Ship ( receiver and transmitter ) "
Arduino Mega
Servo motor
-NRF24L01+PA+LNA
-12 V DC motor
-12 v DC pump (motor)
-L298N motor driver to run above 2 dcc motor.
-Temperature sensor
-Water level sensor ( i am stuck here ( unable to set receiver as transmitter to transmit water level sensor values to Nano)
"2-Remote Controller"
Nano
NRF24L01+PA+LNA
10k Potentiometers x 2 pcs
buzzer
led
İ already establish a good communication on 2mbps. i can operate motors and servo using potentiometer. But when i try to set receiver as transmitter to transmit water level values i dont get any results. here is my codes and fritzing scheme(forget to include temperature sensor on drawing , but i am not trying to send it's values)
ok.. i finally figured out what was the problem.(it was radio.stopListening(); command in void setup , so even i call radio.startListening(); in void loop it never listen again).
Now i have working and reliable bidirectional comm between 2 nrf's. Since i can not sleep without problems, i decided to add GPS and compass to my project. I design an enclosure for the modules and i read them to make auto pilot and return_home function. BUT, nrf's stop communication after abt 3-5 mins of reliable comm. When i start digging what was the problem, i found that SCL pin of my QMC5883 - GY-271 compass interferencing with nrf's SCK pin. When i remove SCL pin of my compass i have reliable comm again.
This little girl can not find her way wo compass, does anyone have an idea how can i overcome this problem.
BUT, nrf's stop communication after abt 3-5 mins of reliable comm. When i start digging what was the problem, i found that SCL pin of my QMC5883 - GY-271 compass interferencing with nrf's SCK pin. When i remove SCL pin of my compass i have reliable comm again.
Certainly sounds like a wiring error since the two devices use totally separate processor I/O pins, one is SPI, one is I2C. The I2C pins are digital pins 20/21 and your original drawing shows nothing connected to 20/21. To which pins did you connect the compass? The I2C pins of SDA/SCL pins are quite different than the SPI pins of SCK, SS, MOSI and MISO.
It’s time for a proper schematic, no Fritzings please, or a photograph.
I am using pin 21 for scl of compass and icsp header onthe mega for nrf24 miso, mosi, sck. I belieave i am making some wiring error related to scl and sck. One is spi and other i2c but this pins are common. First dravings are outdated.
thanx for reply. after trying millions of configurations and tries, now i think problem is ;
// gps_pos_spd_crs(); // when i uncommend . program stucks after 50-60 loop.(by the way, i receive gps and compass data to remote controller successfully)
gps connected to Serial3 pins of mega (14,15).
i attach my final codes below. Since they are long ,I had to attach them.