[Souliss tech mailinglist] Use nRF24L01 with SPI in Software

206 views
Skip to first unread message

Di Maio, Dario

unread,
Dec 9, 2014, 9:09:45 AM12/9/14
to sou...@googlegroups.com
Hi,

starting from commit a561329dab6f is possible the use of emulated (in software) SPI instead of the hardware SPI provided with the microcontroller.

This is generally not required out of some specific cases, like:
1) You need to share the SPI bus with two transceivers (e.g.: Ethernet and a radio) but you haven't a buffer the decouple the MISO lines.
2) You want to use Itead Studio boards that have a dedicated socket for nRF24L01 but doesn't share the SPI lines, so you are obliged to use an emulated SPI.
3) You want to lose some time :)

As additional case, this can be useful for people that are having reliability problem with those radios. This can be a try.

Using an emulated SPI in quite simple, let suppose that you want to use DigitalIO from William Greiman that support SoftwareSPI (https://github.com/greiman/DigitalIO-beta)

At begin of your sketch (before the includes) add:

...
#define nRF24SPI_INSKETCH
#include "DigitalIO.h"

// Define the pins that you are willing to use
#define	SOFT_SPI_NRF24_MISO_PIN	16
#define	SOFT_SPI_NRF24_MOSI_PIN	15
#define	SOFT_SPI_NRF24_SCK_PIN	14
#define	SPI_NRF24_MODE			0
SoftSPI<SOFT_SPI_NRF24_MISO_PIN, SOFT_SPI_NRF24_MOSI_PIN, SOFT_SPI_NRF24_SCK_PIN, SPI_NRF24_MODE> nRF24SPI;
// from here continue with the Souliss Sketch
....

Please share feedbacks.

Regards,
Dario.

Juan Pinto

unread,
Dec 9, 2014, 12:17:00 PM12/9/14
to sou...@googlegroups.com
Good work, Regards

Di Maio, Dario

unread,
Dec 9, 2014, 12:25:46 PM12/9/14
to sou...@googlegroups.com

Will you try it.

Dario.

From Mobile.

--
You received this message because you are subscribed to the Google Groups "souliss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to souliss+u...@googlegroups.com.
To post to this group, send email to sou...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/souliss/b4ca3074-c035-4776-bc37-c59e9060db57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Juan Pinto

unread,
Dec 9, 2014, 12:33:11 PM12/9/14
to sou...@googlegroups.com
I didn't need to use other pins to nRF, its working ok (i think) with ENC.

Di Maio, Dario

unread,
Dec 9, 2014, 12:37:05 PM12/9/14
to sou...@googlegroups.com

Your nRF24 is hanging? If so try this and move the pins using the software SPI.

Dario.

From Mobile.

Juan Pinto

unread,
Dec 9, 2014, 12:52:16 PM12/9/14
to sou...@googlegroups.com
Yes, I've some hangs on communications over nRF, I've 5 nodes
connected and most of time the health 2 of the nodes (which are far of
the GW) are Null, and state of Sensors are STALE on the APP. I'll try
with softspi but I think it's a distance problem.

I testing OH too, and I'll test if this problem it's on this interface too.

I hasn't free pins on my GW node based on Atmega1284 :( I'll update
to a MEGA+5100 soon as possible, but my pocket is empty.:((

Regards
> You received this message because you are subscribed to a topic in the
> Google Groups "souliss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/souliss/i0On6w4iOZc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> souliss+u...@googlegroups.com.
> To post to this group, send email to sou...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/souliss/CAKGhMPKoFefdxdRBjVY2QVG%2BAwixvVPOvii86gRmVJC9uZTXdQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages