Hello, I want to communicate with the nrf24 module using the atmega processor. There is a receiving side and a transmitting side in the circuit. I am using esp32 and nrf24l01 module on the receiving side. There is Arduino nano and nrf module on the transmitter side. The system works flawlessly as it is. However, when I connect only the circuit of the atmega328pb processor and the spi pins of the nrf module on the transmitter side, after energizing the processor, it cuts off communication after communicating with the receiving side 2 or 3 times. What could be the reasons?
a bug or feature in the code we do not see?
but when i use arduino nano there is no problem
Transmitter codes
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>
#include <HX711.h>
#include <EEPROM.h>
#define CE_PIN A3
#define CSN_PIN A2
const int analogPin = A0; // Gerilim ölçümü için kullanılacak analog pin
const int numReadings = 10; // Ölçüm sayısı
int readings[numReadings]; // Ölçüm değerlerinin tutulacağı dizi
int index = 0; // Dizi indeksi
float voltage = 0; // Ortalama voltaj değeri
RF24 radio(CE_PIN, CSN_PIN);
const byte transmitterID = 9; // Verici ID'si
//const byte address2[5] = {0xAA, 0xBB, 0xCC, 0xDD, 0x02};
//const byte address[6] = "00001";
//const uint64_t pipe2 = 0xF0F0F0F066;
const uint64_t pipe1 = 0xF0F0F0F0AA;
//const uint64_t pipe3 = 0xF0F0F0F011;
//const uint64_t pipe4 = 0xF0F0F0F022;
//const uint64_t pipe5 = 0xF0F0F0F033;
// float pil =3.3;
const float referenceUnit =2; // Referans birim değerini burada ayarlayabilirsiniz
HX711 scale; // HX711 DT pin to Arduino pin A1, SCK pin to Arduino pin A0
const int HX711_dout = 6; //mcu > HX711 dout pin
const int HX711_sck = 5; //mcu > HX711 sck pin
void setup() {
Serial.begin(115200);
scale.set_scale(4560);
scale.begin(HX711_dout, HX711_sck);
for (int i = 0; i < numReadings; i++) {
readings[i] = 0;
}
//radio.setAutoAck(false);
radio.begin();
radio.openWritingPipe(pipe1);
}
struct Data {
byte transmitterID;
float basinc;
float voltage;
} __attribute__((__packed__)) ;
void loop() {
float weight= scale.get_units(referenceUnit);
//pil kısmı
// Ölçüm yap ve değeri oku
int sensorValue = analogRead(analogPin);
// Değerleri dizide güncelle
readings[index] = sensorValue;
index = (index + 1) % numReadings;
// Ölçüm değerlerinin ortalamasını hesapla
float total = 0;
for (int i = 0; i < numReadings; i++) {
total += readings[i];
}
voltage = (total / numReadings) * (5.0 / 1023.0) * 2;
float basinc=weight/100;
if (basinc<0)
{
basinc= basinc*-1;
}
Data sendData;
sendData.transmitterID = transmitterID;
sendData.basinc = basinc;
sendData.voltage = voltage;
radio.write(&sendData, sizeof(Data));
delay(1000);
}
After programming with USBASP, I connect the spi pins to nrf
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.