-1

I am using an external ADC (via SPI) and also a GPS receiver (Software Serial). I tried each one of them and it's working fine. Now, when I try to integrate both of them in one sketch, I can only make the ADC work, the GPS is not receiving something.

void setup()
{
  pinMode(ADS1220_CS_PIN, OUTPUT);
  pinMode(ADS1220_DRDY_PIN, INPUT);

  Serial.begin(115200);
  ss.begin(9600);

  //while(!Serial);
  //SPI.begin();                           // wake up the SPI bus.
  //SPI.setBitOrder(MSBFIRST);
  //SPI.setDataMode(SPI_MODE1);

  //ADS1220.begin();
  Wire.begin();
  delay(1000);  // Give things time to "warm-up"

  delay(1000);
  pre_time = millis(); //store current time to be used as "previous" time
}

I found out that in the setup(), when I comment out all those SPI functions, the GPS returns something. What seems to be wrong with this? thank you so much for any help

  • 1
    I suggest editing your question to include a Minimal, Complete, and Verifiable example of code, not just snippets. Also part numbers, datasheet links, and circuit diagram showing terminators etc, and photo of project and scope traces if layout matters. – James Waldby - jwpat7 Jan 10 '17 at 17:24
  • 1
    @jwpat7 i'm sorry for my post, but I managed to solve it already just by changing the Rx pin from 10 to digital pin 4. Thanks for the information by the way, will do better next time – Ralph Jan 10 '17 at 19:46
  • 2
    Ralph, it may often happen that if you try to provide all the info, you solve the problem :) – James Waldby - jwpat7 Jan 10 '17 at 22:59
2

SoftwareSerial is very inefficient. AltSoftSerial is best. See this answer for a complete list of alternatives.

You may want to look at my NeoGPS library. It is smaller, faster and more accurate than all other libraries. The examples are structured better. You don't show your whole sketch -_-, but the loop structure could be your real problem. Be sure to read the Troubleshooting page for more suggestions.

  • 1
    thanks for the advice! I managed to solve my problem already just by changing the Rx pin from 10 to 4, will give AltSoftSerial a try and see the performance difference, thanks! – Ralph Jan 10 '17 at 19:50
  • hey just wanna say thanks for introducing me to AltSofSerial, apparently I've had some issues and was guessing if the problem was the softwareserial library, and it really was since i'm transmitting data and for some moment receiving too. And it really is faster! – Ralph Jan 11 '17 at 23:11
  • You're welcome! Would you mind pressing the green triangle (Accept) to indicate that this is the answer that worked for you? Thanks! – slash-dev Jan 12 '17 at 18:43
  • is there a way to print more than 2 decimal places in altsoftserial? i tried altSoft(float_num,4); but it doesn't work – Ralph Mar 5 '17 at 20:28
  • Did you mean altSoft.print( float_num, 4 );? – slash-dev Mar 6 '17 at 1:10
1

I managed to solve this just by changing the Rx pin to digital pin 4 from digital pin 10, I don't know what causes the problem but it did the job for me

-1

For the Arduino to be SPI master, the SS pin (D10) must be an output. Using it as software serial input (Rx) is no good. If you had used it as the Output, Tx, you would likely have been ok. I try to use 10 as SS for the first SPI device I have connected all the time to avoid that pitfall.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.