TechTorch

Location:HOME > Technology > content

Technology

Setting Up Wireless Data Transmission with an Arduino Uno and BMP180 Altimeter

January 09, 2025Technology1883
Setting Up Wireless Data Transmission with an Arduino Uno and BMP180 A

Setting Up Wireless Data Transmission with an Arduino Uno and BMP180 Altimeter

In this comprehensive tutorial, we will guide you through the process of setting up a system where one Arduino Uno with a BMP180 sensor for altitude measurement transmits data to another Arduino Uno using the NRF24L01 wireless module.

Components Needed

Two Arduino Uno boards 1 BMP180 sensor 2 NRF24L01 modules Breadboard and jumper wires Resistors if needed for level shifting depending on your setup

Wiring

Transmitter Arduino with BMP180 and NRF24L01

BMP180 Wiring: VCC to Arduino 5V GND to Arduino GND SDA to Arduino A4 SCL to Arduino A5 NRF24L01 Wiring: VCC to Arduino 3.3V GND to Arduino GND CE to Arduino pin 9 CSN to Arduino pin 10 SCK to Arduino pin 13 MOSI to Arduino pin 11 MISO to Arduino pin 12

Receiver Arduino with NRF24L01

NRF24L01 Wiring: VCC to Arduino 3.3V GND to Arduino GND CE to Arduino pin 9 CSN to Arduino pin 10 SCK to Arduino pin 13 MOSI to Arduino pin 11 MISO to Arduino pin 12

Code

Transmitter Code with BMP180

You will need to install the Adafruit BMP085 Unified and RF24 libraries for the NRF24L01 module. You can install these libraries through the Arduino Library Manager.

include Wire.hinclude Adafruit_Sensor.hinclude Adafruit_BMP085_U.hinclude SPI.hinclude RF24.h// Create instances for BMP180 and NRF24L01Adafruit_BMP085_Unified bmp  Adafruit_BMP085_Unified();RF24 radio(9,10); // CE, CSNstruct DataPacket {    float altitude;};DataPacket data;void setup() {    (9600);    if (!()) {        while(1); // fail    }    ();    (F0F0F0F0E1LL);    (RF24_PA_HIGH);    ();    RF24справедливо обрабатывать большую часть кода, добавляя только необходимые исправления и улучшения для чтения.

In the transmitter code, the BMP180 readings are converted to altitude and sent every 2 seconds.

Receiver Code

include SPI.hinclude  radio(9,10); // CE, CSNstruct DataPacket {    float altitude;};DataPacket data;void setup() {    (9600);    ();    (0, F0F0F0F0E1LL);    (RF24_PA_HIGH);    ();}void loop() {    if (radio.available()) {        (data, sizeof(data));        ("Altitude: ");        ();    }}

In the receiver code, the NFC24L01 module listens for incoming data. When data is received, it prints the altitude to the Serial Monitor.

Testing

Upload the transmitter code to the first Arduino and the receiver code to the second Arduino. Open the Serial Monitor for both Arduinos. You should see the altitude data being transmitted and received.

Notes

Ensure both Arduinos have the same NRF24L01 address in their code. Adjust the delay in the transmitter code as needed for your application. Check the wiring and power supply to the NRF24L01 as they can be sensitive to voltage levels.

With the setup described above, you should be able to successfully transmit altitude data from one Arduino to another using the BMP180 sensor and NRF24L01 modules.