Shop OBEX P1 Docs P2 Docs Learn Events
Propeller-based wireless sensor using the nRF24L01+ — Parallax Forums

Propeller-based wireless sensor using the nRF24L01+

LeonLeon Posts: 7,620
edited 2011-08-14 03:39 in Propeller 1
I've designed a very simple wireless sensor PCB using a PIC1818F24J11 controller and the low-cost nRF24L01+ modules that have recently become available and 10 prototype PCBs are in transit to me from ITead Studios. I thought that something similar using a Propeller might be of interest, so I spent a few minutes creating this schematic:

http://www.leonheller.com/Propeller/Wireless%20sensor/Wireless%20Sensor(Page1).pdf

Here is one source for the nRF24L01+ modules:

http://iteadstudio.com/store/index.php?main_page=product_info&cPath=7&products_id=53

Details of the nRF24L01+ chip are here:

http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01P

All the spare Propeller I/Os will be brought out to pads, and there will be a sizeable prototyping area. The unit is intended to be powered from three AAA cells. Suggestions are welcome.

I'll be developing a USB interface for the nRF24L01+ modules, so that wireless data can be captured on a PC or a remote system can be controlled. It'll use a USB PIC18F2455. I already have a PCB designed, and basic working USB software for the PIC and PC, but the nRF24L01+ module needs to be added to the board and the software needs to be modified for it.

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-08-04 10:07
    Leon,

    This is very interesting.

    I've often wondered about making the heating and cooling system in our house smarter. One feature I'd like is to be able to automatically adjust the vents to control the temperature in each room. As it is now, there is only one thermostat. Often other areas of the house are either too hot or too cool.

    Your boards might be a great way of adding sensors and possibly motor control (to open and close the vents).

    Do you have any graphics showing the size and layout of the board?

    Duane
  • LeonLeon Posts: 7,620
    edited 2011-08-04 10:11
    Not yet, I'll wait for some comments before I finalise the design. I've attached the layout for the PIC version.
    1024 x 566 - 69K
    WS.jpg 69.2K
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-08-04 12:20
    I like the size of your PIC board.

    As I mentioned elsewhere, it would be nice to have access to all of the Props IO pins.

    I'm sure Robert (AKA RobotWorkshop (IIRC)) would also like a connection for an external reset button.

    I'm not sure if I'd need mounting holes but I've seen others request them on circuit boards. If the dimensions are close enough to an already existing board maybe any added mounting holes could be positioned to line up with the other boards' mounting holes.

    The PIC board isn't much smaller than a QuickStart board. There could be a benefit to having your board's mounting holes line up with the QuickStart's holes.



    Information about these Nordic module for other's reading this thread.

    I wrote an object for these nRF24L01+ modules. The object is based on Leon's C code.

    I haven't added it to the OBEX yet. The object in the OBEX for nRF24L01+ modules doesn't work.

    Here's a link to the thread about the working object. Mark_T posted his driver in post #45 of the thread I just linked to.

    Ron Czapala also wrote code to use these Nordic modules with a Basic Stamp.

    Duane
  • LeonLeon Posts: 7,620
    edited 2011-08-13 07:36
    I've just received my PIC PCBs, and have started building one of them. I'll test it with one of my existing PIC boards which uses a Sparkfun module. If it works OK I'll finish off the Propeller PCB design, incorporating the suggestions, and get some made.

    I've assembled the bare minimum on the PCB - just the PIC, a couple of capacitors, a pull-up for MCLR, and the ICSP connector. It was recognised by my ICD 3 debugger and ran a test program, which is a good start.
  • KMyersKMyers Posts: 433
    edited 2011-08-13 09:51
    @Leon;

    Very cool project! Something I had been thinking of but had not proceeded with. Would make an excellent way for me to monitor the environment of my house. Allot easier to read a display then to take my power chair up and down stairs. Please keep us informed!!!
  • LeonLeon Posts: 7,620
    edited 2011-08-13 10:05
    You are welcome to a couple of my PIC18 PCBs, if you don't want to wait for the Propeller version. They will be inter-operable, of course.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-08-13 10:25
    Leon,

    I was just reading the LE33CD voltage regulator datasheet. It looks like your board could be powered from one Lion cell? I've hoping the LE33CD is a good choice for battery powered devices. (I've still new to reading datasheets so I'm not sure.)

    As I've been working with my QuickStart boards I've thought some more about the board you're working on. I like having an option of having a power LED. Perhaps you could add a few pads to add a smt LED and smt resistor in case someone wants to add a power LED.

    I'm guessing you'll have a Prop Plug connector for programming?

    I've come to love having 64KB EEPROM (or more) on my Propeller boards. I doubt you'll be populating the boards yourself but just a thought (in case you decide to sell some already put together). It's been very useful to store configuration data about a specific board in upper EEPROM and then load a general program with uses the configuration information to set the pins to that particular board correctly.

    What are your thoughts about EEPROM package size? If there is room on the board, a DIP footprint with inner SOIC pads would be a versatile solution. If you need to use smt parts only, that's fine with me. I like how small boards can be made with smt parts.

    I hope resistors and capacitors will be smt. It looks like they're all smt on your PIC board.

    I'm looking forward to seeing what you come up with.

    Duane
  • LeonLeon Posts: 7,620
    edited 2011-08-13 10:49
    I was intending to make the Propeller version mostly SMT, like the PIC board.

    The Propeller isn't a particularly low-power device, unlike the PIC I'm using, so there isn't much point going for maximum battery life. The PIC is one of the newer nanoWatt XLP chips - 13 nA in Deep Sleep mode!

    I'm running the PIC board from two NiMH cells for now, it's intended to use two AAA alkaline cells giving about 3V, or could use a single Li cell. There isn't a regulator. I got the supply connector the wrong way round for my battery packs with connectors, so I removed it and mounted it on the underside of the board. It doesn't matter for anyone else who will be using them.
  • LeonLeon Posts: 7,620
    edited 2011-08-14 03:39
    I've just got my SPI test software working, so I know that I'm communicating with the nRF24L01+ module. I didn't have any joy when I tried it last night, and noticed this morning that I had the module the wrong way round on my PCB. Luckily, I don't seem to have damaged it. I've added an LED to the prototyping area, I should have included one on the PCB in the first place. Communicating with one of my older boards using the Sparkfun module is next.

    My C code for the Microchip C18 compiler might be of interest:
    /*
    ** test.c
    ** SPI test program for PIC18F24J11 and nRF24L01 or nRF24L01+
    ** Checks SPI comms between PIC and wireless chip
    ** LED on RC0
    ** 
    */
    
    #include <p18cxxx.h>
    #include <spi.h>
    
    //function prototypes
    unsigned char spi_Send_Read(unsigned char);
    void dly(void);
    
    // Defines
    #define SPI_SCK		LATCbits.LATC3		// Clock pin, PORTC pin 3 
    #define SPI_SO		LATCbits.LATC5		// Serial output pin, PORTC pin 5 
    #define SPI_SI		PORTCbits.RC4		// Serial input pin, PORTC pin 4 
    #define SPI_CSN		LATCbits.LATC2		// CSN output pin, PORTC pin 2
    #define SPI_CE		LATCbits.LATC1		// CE output pin, PORTC pin 1
    #define SPI_IRQ		PORTBbits.RB0		// IRQ input pin, PORTB pin 0
    #define SPI_SCALE	4              		// postscaling of signal 
    
    // Macros
    #define nop() _asm nop _endasm
    
    void main(void)
    {
    	unsigned char status = 0;
    	unsigned char data[5];
    	int i;
    
    	// run internal oscillator at 8 MHz
    	OSCCON = OSCCON | 0b01110000;
    	while (!OSCCONbits.OSTS)	// wait for OSTS to go high
    		;
    
    	
    
    	OpenSPI(SPI_FOSC_16, MODE_00, SMPMID); //open SPI1
    	TRISCbits.TRISC3 = 0;	// SDO output
    	TRISCbits.TRISC5 = 0;   // SCK output
    	TRISCbits.TRISC2 = 0;	// CSN output
    	TRISCbits.TRISC1 = 0;	// CE output
    	SPI_CSN = 1;		// CSN high
    	SPI_SCK = 0;		// SCK low
    	SPI_CE	= 0;		// CE low
    	TRISCbits.TRISC0 = 0; // RC0 (LED) output
    	nop();
    
    	//write TX_ADDRESS register
    	SPI_CSN = 0;			//CSN low
    	spi_Send_Read(0x30);
    	spi_Send_Read(0x11);
    	spi_Send_Read(0x22);
    	spi_Send_Read(0x33);
    	spi_Send_Read(0x44);
    	spi_Send_Read(0x55);
    	SPI_CSN = 1;			//CSN high
    
    	for (i = 0; i < 5; i++)
    		data[i] = 0;
    
    	LATCbits.LATC0 = 1;		//LED on
    
    
    	//read TX_ADDRESS register
    	//Check that values are correct using the MPLAB debugger
    	SPI_CSN = 0;			//CSN low
    	status = spi_Send_Read(0x10);
    	data[0] = spi_Send_Read(0x00);	// 0x11
    	data[1] = spi_Send_Read(0x00);	// 0x22
    	data[2] = spi_Send_Read(0x00);	// 0x33
    	data[3] = spi_Send_Read(0x00);	// 0x44
    	data[4] = spi_Send_Read(0x00);	// 0x55
    	SPI_CSN = 1;					// CSN high
    
    	while (1)
    		;
    }
    
    
    unsigned char spi_Send_Read(unsigned char byte)
    {
    	SSPBUF = byte;	
    	while(!DataRdySPI())
    		;	
    	return SSPBUF;
    }
    

    I used the Microchip peripheral library.

    All commands sent to the nRF24L01+ return a status value, which can be checked in software. For instance, I get 0x0E returned when setting up the writes and reads to/from the address register.

    It should be quite easy to convert it to Spin, and I'll be doing that when I get my Propeller boards.
Sign In or Register to comment.