PIC18F252 Microcontroller & NRF24L01+ : Wireless Transmitter
by drselim in Circuits > Microcontrollers
2800 Views, 6 Favorites, 0 Comments
PIC18F252 Microcontroller & NRF24L01+ : Wireless Transmitter
In this instructable, we'll learn how to build a wireless transmitter using the PIC18F252 microcontroller and nRF24l01+ transceiver module using Pickit3 and MPLAB X IDE. We'll be using an Arduino Nano and again an nRF24l01+ module at the receiver side and obviously we'll be programming it with Arduino IDE. We'll be sending an 8-element integer array to the receiver and we'll be able to observe the output by the Arduino IDE Serial monitor or any other terminal program that you prefer to use (Putty, etc.)
Let's jump into the project!
Supplies
PIC18F252 Microcontroller from Microchip, Pickit3 Programmer, 8 MHz Crystal Oscillator (4 and 16 will be fine too), 2* 22pF capacitors, jumper cables, external adjustable power supply (optional), 2* nRF24l01+ module (for TX and RX), 2*100uF Capacitors (optional, between the 3.3V and ground for the nRF modules), 1* 10kOhm resistor (to be placed between the MCLR and VDD pins of PIC18F252), external 3.3V power supply (for the TX nRF24l01+)
Connections for TX
In order to program the PIC18F252 with PICKIT3, you need to connect the devices as shown in the first picture. The connection is straightforward. The pin names of the PICKIT 3 are very descriptive. You'll have to connect a 10kOhm resistor between the MCLR and VDD pins, You'll connect the 8MHz crystal between the OSC1 and OSC2 pins (both will be connected to the ground over 22pF Capacitors). As soon as you make the connections you're ready to program your mcu. However it's better to make the nRF24l01+ connections at the same time and that is shown on the second picture,
As a summary, the connections between the PIC18F252 and the nRF24l01+ are:
RC0 -> MOSI, RC1 -> MISO, RC3 -> CSN, RC4 -> SCK, RC5 -> CE
In addition to this you have to use a reliable 3.3V Power supply for the nrf24 module, I used the 3.3V output of an MSP430 Launchpad.
Connections for the RX
In this picture you can see the connections between the Arduino nano and the nRF24l01+ module.
To summarize:
3.3V pin on the Arduino --> Vcc on the nRF24 Module
GND pin on the Arduino --> GND on the nRF24 Module
D8 pin on the Arduino --> CE on the nRF24 Module
D13 pin on the Arduino --> SCK on the nRF24 Module
D7 pin on the Arduino --> CSN on the nRF24 Module
D11 pin on the Arduino --> MOSI on the nRF24 Module
D12 pin on the Arduino --> MISO on the nRF24 Module
Capacitor optional as in the Transmitter.
Code for the Receiver
The code that can be (partially) seen in the picture is available at my related repository:
https://github.com/selimg76/nrf24-PIC18F252/blob/main/receiver_nano_1_pic_tx
you can just copy and paste it on the Arduino IDE and upload it. If you have the necessary libraries installed (RF24), your receiver is ready to go!
Code for the Transmitter
The code for the Tranmitter is available at my related repository:
https://github.com/selimg76/nrf24-PIC18F252/blob/main/pic18f252_nrf24_main
this file is your main.c file
And you have to include the nrf24.h library that I created in the Header Files folder of your project.
https://github.com/selimg76/nrf24-PIC18F252/blob/main/nrf24.h
Make sure that you select your MCU type while creating the MPLAB project and choose the PICKIT3 module that you attached to your PC.
Observing the Output
If your receiver is up and running and the COM connection can be observed in the serial monitor or the terminal program that you prefer, once you upload and run your code on the PIC18F252 MCU, you'll be able to observe the "payload" integer array in the output. Try changing the payload values to make sure your Transmitter is running correctly.
I hope you enjoyed the instructable. If you like it, please consider subscribing to my YouTube Channel to support me for new projects like this.
Thank you for your time and see you in another instructable!