arduino 2.4ghz transceiver module
We will learn how to make a wireless communication between two Arduino boards, using the NRF 24 lo1 transceiver module for explaining the wireless communication. We will make two examples. The first one will be sending a simple hello world message from one Arduino to another, and the second example will be a bi directional communication between two Arduino boards, where using the joystick at the first Arduino, we will control the servo motor at the second Arduino and Vice versa, using the push button at the second Arduino, we will control the LED at the first Arduino now let’s take a closer look at the NRF 24 lo1 transceiver module. It uses the 2.4 gigahertz band and it can operate with baud rates from 250 kilobits per. Second, up to 2 megabits per second, if used in open space and with lower body rate, its range can reach up to 100 meters. This module can use 125 different channels, which gives the possibility to have a network of 125 independently working modems in one place. Each channel can have up to 6 addresses, or each unit can communicate with up to 6 other units. At the same time, the power consumption of this module is just around 12 milliamps during transmission, which is even lower than a single LED. The operating voltage of this module is from 1.9 to 3 point 6 volts, but the good thing is that the other pins tolerate 5 volts logic, so we can easily connect it to an Arduino without using any logic level converters three of these pins are for the Spi communication and they need to be connected to the SPI pins of the Arduino, but note that each Arduino have different SPI pins, the pins CSN and I can be connected to any digital pin of the Arduino board.
And they are used for sitting the module in standby or active mode, as well as for switching between transmit or command mode. The last pin is an interrupt pin which doesn’t have to be used, so once we connect the NRF 24 lo1 modules to the ERV. No boards, we are ready to make the codes for both the transmitter and a receiver. First, we need to download and install the RF 24 library and make sure you have the correct one. You can find the download link on the website article, so we need to include the basic spi and newly installed RF 24 libraries and create an RF 24 object. The two arguments here are the CS: N and C II pins. Next, we need to create an array which will represent the address or the so called pipe through which the two modules will communicate. We can change the value of this address to any five letter string, and this enables to choose to which receiver we will talk. So, in our case, we will have the same address at both the receiver and transmitter in the setup section. We need to initialize the radio object and using the radio dot open, riding pipe function. We set the address of the receiver, to which we will send data. The five letter string we previously set on the other side add the receiver using the radio dot set reading pipe function. We set the same address and in that way we enable the communication between the two modules.
Then using the radio dot set PA level function. We set the power amplifier level in in our case, I will set it to minimum value, as my modules are very close to each other note that if you are using a higher level, it is recommended to use a bypass capacitors across the ground and 3.3 volts Of the modules so that they have more stable voltage while operating next, we have the radio dot, stop listening function, which says the module as transmitter and on the other hand, we have the radio dot start listening function, which sets the module as receiver. In the loop section at the receiver, we create an array of characters to which we assign the message. Helloworld. Now using the radio dot write function, we will send the message to the receiver. The first argument here is the variable that we want to be sent by using the ampersand before the variable name. We actually set an indication of the variable that stores the data that we want to be sent and using the second argument, we set the number of bytes that we want to take from that variable. In this case, the function size off gets all bytes of the string text at the end of the program. We just add one second delay on the other side at the receiver in the loop section, using the radio dot available function, we check whether there is data to be received if that’s true.
First, we create an array of 32 elements, called text in which we will save the incoming data. Using the radio dot read function, we read and store the data into the text variable at the end. We just print the text on the serial monitor. So once we upload both programs, we can run the serial monitor at the receiver and we will notice the message. Helloworld gets printed each second next let’s see the second example here’s the circuit schematic, and now we will take a look at the arduino pods what’s different here from the previous example, is that we need to create two pipes or addresses for the bi directional communication in The setup section we need to define both pipes and note that the writing address at the first Arduino needs to be the reading address at the second Arduino and vice versa. The reading address at the first Arduino needs to be the writing address at the second Arduino. In the loop section, using the radio dot stop listening function, we set the first Arduino as transmitter, read and map the value of the joystick from 0 to 1 hundred and eighty and using the radio dot write function, send the data to the receiver. On the other hand, using the radio dot start listening function. We said the second Arduino as a receiver and we check whether there is a valuable data. While there is a valuable data, we will read it save it to the angle V variable and then use that value to rotate the servo motor.
Next we set the first Arduino as receiver and with an empty while loop. We wait for the second Arduino to send data and that’s the data for the state of the push button, whether it is pressed or not. If the button is pressed, the LED will light up. So this process constantly repeats, and both you know, are constantly sending and receiving data that’s.
arduino 2.4ghz transceiver module Video
arduino 2.4ghz transceiver module news
arduino 2.4ghz transceiver module Social
Originally posted 2015-11-01 16:48:49.