SPI in lieu of a Serial port - Help on Electron for a project

Hi All,

I am working on a project that has consumed all my hardware UARTS on my Electron.

And I need to add a XBee radio to the application. I see XBee supports SPI, and I do have the pins (A2 thru A5) available on the Electron.

However I do not have experience with SPI and how would I use it in leu of a serial port. Is it similar to Serial? Serial.write(x), Serial.available(x)… I am reading documentation but seems different than serial.

Any suggestions are welcomed before I dive deep into this.

You could give this library a try

If it doesn’t work out the box, porting libraries from Arduion to Particle is always a nice challenge

But if you don’t want the extra hassle and you’d be fine with a baudrate of around 28800 (maybe 38400) then you could use ParticleSoftSerial too.
Or if you have other devices with lower baudrate demands move one of them to ParticleSoftSerial and free the HW USART up for XBee.


Thank you so much.

I like the idea of ParticleSoftSerial, I do have some devices that don’t require too much speed however (A GPS with 19200 would suffice). Let me give it a try. I am a little bit worried that adding complexity can increase issues with the software stability. But I think it will be my best choice for what I have.

1 Like