Sending data from imu to lcd through nrf24l01

Hello, I am trying to send data from 3 sensors on one nano to another nano connected to a tca9548a with 4 LCDs on channels 1 to 4 via an nrf24l01. I can send and receive the data through the serial monitor but I cannot get it to print on the LCDs. I have tried ChatGPT and Deepseek to write the code, but it does not work. I want the Accelerator data on one LCD, the Gyroscope data on another, the compass data and angles on another LCD, and the temperatures on the 16x2.
My wiring is:
nRF24L01
miso to D12
mosi to D11
sck to D13
ce to D9
csn to D10.
tca9548a
SCL to A5
SDA to A4
My imu code is:

#include <Wire.h>
#include <QMC5883LCompass.h>
#include <SPI.h>
#include "max6675.h"

// Compass object
QMC5883LCompass compass;

// MAX6675 sensor pins
int thermoDO = 6;
int thermoCS = 5;
int thermoCLK = 13;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

// Gyro and accelerometer variables
float RateRoll, RatePitch, RateYaw;
float AccX, AccY, AccZ;
float AngleRoll, AnglePitch;
float RateCalibrationRoll, RateCalibrationPitch, RateCalibrationYaw;

void initMPU6050() {
  Wire.beginTransmission(0x68);
  Wire.write(0x6B);
  Wire.write(0x00);
  Wire.endTransmission();
  delay(100);
}

void readMPU6050() {
  Wire.beginTransmission(0x68);
  Wire.write(0x3B);
  Wire.endTransmission();
  Wire.requestFrom(0x68, 14);

  int16_t AccXLSB = Wire.read() << 8 | Wire.read();
  int16_t AccYLSB = Wire.read() << 8 | Wire.read();
  int16_t AccZLSB = Wire.read() << 8 | Wire.read();
  Wire.read(); Wire.read();  // Skip temperature
  int16_t GyroX = Wire.read() << 8 | Wire.read();
  int16_t GyroY = Wire.read() << 8 | Wire.read();
  int16_t GyroZ = Wire.read() << 8 | Wire.read();

  RateRoll = (float)GyroX / 65.5 - RateCalibrationRoll;
  RatePitch = (float)GyroY / 65.5 - RateCalibrationPitch;
  RateYaw = (float)GyroZ / 65.5 - RateCalibrationYaw;

  AccX = ((float)AccXLSB / 4096) - 0.05;
  AccY = ((float)AccYLSB / 4096) - 0.02;
  AccZ = ((float)AccZLSB / 4096) + 0.02;

  AngleRoll = atan2(AccY, sqrt(AccX * AccX + AccZ * AccZ)) * (180.0 / PI);
  AnglePitch = -atan2(AccX, sqrt(AccY * AccY + AccZ * AccZ)) * (180.0 / PI);
}

void setup() {
  Serial.begin(57600);
  Wire.begin();
  Wire.setClock(400000);
  delay(250);

  initMPU6050();
  compass.init();

  Serial.println("Calibrating Gyro...");
  for (int i = 0; i < 2000; i++) {
    readMPU6050();
    RateCalibrationRoll += RateRoll;
    RateCalibrationPitch += RatePitch;
    RateCalibrationYaw += RateYaw;
    delay(1);
  }
  RateCalibrationRoll /= 2000;
  RateCalibrationPitch /= 2000;
  RateCalibrationYaw /= 2000;
  Serial.println("Calibration Complete.");

  Serial.println("MAX6675 Initialized");
}

void loop() {
  int x, y, z;
  float azimuth, elevation;

  // Read Compass Data
  compass.read();
  x = compass.getX();
  y = compass.getY();
  z = compass.getZ();

  azimuth = atan2(y, x) * (180.0 / PI);
  elevation = atan2(z, x) * (180.0 / PI);

  Serial.print("---------------------------------------------\n");
  Serial.print("Compass - Azimuth: ");
  Serial.print(azimuth);
  Serial.print("°, Elevation: ");
  Serial.println(elevation);

  // Read Gyroscope and Accelerometer
  
  readMPU6050();
  Serial.print("Gyro - Roll Rate: "); Serial.print(RateRoll);
  Serial.print("°/s, Pitch Rate: "); Serial.print(RatePitch);
  Serial.print("°/s, Yaw Rate: "); Serial.println(RateYaw);

  Serial.print("Accel - X: "); Serial.print(AccX);
  Serial.print(" g, Y: "); Serial.print(AccY);
  Serial.print(" g, Z: "); Serial.println(AccZ);

  Serial.print("Angles - Roll (X-axis): "); Serial.print(AngleRoll);
  Serial.print("°, Pitch (Y-axis): "); Serial.println(AnglePitch);

  // Read MPU6050 Temperature
  Wire.beginTransmission(0x68);
  Wire.write(0x41);
  Wire.endTransmission();
  Wire.requestFrom(0x68, 2);
  int16_t tempRaw = Wire.read() << 8 | Wire.read();
  float sensorTemp = (tempRaw / 340.0) + 36.53;
  Serial.print("Sensor Temp: "); Serial.print(sensorTemp); Serial.println("°C");

  // Read MAX6675 Thermocouple
  float telescopeTemp = thermocouple.readCelsius();
  Serial.print("Telescope Temp: "); Serial.print(telescopeTemp); Serial.println("°C");
  

  delay(2000);
}

This does not include the nRF24L01 part because I am unsure if that is the problem.
Here is a basic illustration of my wiring:


Any help would be much appreciated.

And we're all shocked, simply shocked that ChatGPT and Deepseek let you down.

I see that your sketch doesn't even attempt writing to a single LCD. So begin by writing a sketch that writes something, anything to a single LCD. I strongly suggest writing it without leaning on an AI so that you understand it when it works. Also, so that it actually works. You could begin with one of the basic examples in your chosen LCD library and work from there.

Learn how to set the I2C addresses on LCD I2C backpacks to dispense with the need for an I2C multiplexer. Neither ChatGPT nor Deepseek thought of that? Again, simply shocked.

Expand your single LCD sketch to write to multiple LCDs by creating multiple instances of your LCD object with distinct addresses.

Once you have that mastered, you should have no trouble integrating that code into your existing code.

1 Like

Regarding computers old words say: Shit in, shit out. Your request to AI & Co was shit in relationship to their levels.
So far no project involving AI has turned up working.
Learning coding is the way to go.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.