Lora esp32 Adlx345 acelarometer

Hi there i'm making a school project but i'm getting some problems.

i have an adlx345 and it works send data to arduino or an esp8266.

But now i'm trying using Lora esp32 (ggto) and i can see X,Y,Z = -0.04 values on display, but won't recive any data (they are just static)

i don't know if is error code or bad wire connection.

My code on Lora:

//Libraries for LoRa
#include <SPI.h>
#include <LoRa.h>

//Libraries for OLED Display
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
//Libraries Adlx345
#include <Adafruit_Sensor.h>    // Adafruit  sensor library
#include <Adafruit_ADXL345_U.h>  // ADXL345 library

Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified();   // ADXL345 Object
float MaxX, MinX, MaxY, MinY, MaxZ, MinZ;

int BugMinX,BugMaxX,BugMinY,BugMaxY,BugMaxZ,BugMinZ=0;
//define the pins used by the LoRa transceiver module
#define SCK 5
#define MISO 19
#define MOSI 27
#define SS 18
#define RST 14
#define DIO0 26
#define SDA 21
#define SCL 22
//433E6 for Asia
//866E6 for Europe
//915E6 for North America
#define BAND 866E6

//OLED pins
#define OLED_SDA 4
#define OLED_SCL 15 
#define OLED_RST 16
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

//packet counter

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST);

void setup() {

 
  if(!accel.begin())   // if ASXL345 sensor not found
  {
    Serial.println("ADXL345 not detected");
    while(1);
  }
  
  //reset OLED display via software
  pinMode(OLED_RST, OUTPUT);
  digitalWrite(OLED_RST, LOW);
  delay(20);
  digitalWrite(OLED_RST, HIGH);

  //initialize OLED
  Wire.begin(OLED_SDA, OLED_SCL);
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) { // Address 0x3C for 128x32
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }
  
  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);
  display.setCursor(0,0);
  display.print("Ligando...");
  display.display();
  
  //initialize Serial Monitor
  Serial.begin(115200);
  
  Serial.println("LoRa Sender Test");

  //SPI LoRa pins
  SPI.begin(SCK, MISO, MOSI, SS);
  //setup LoRa transceiver module
  LoRa.setPins(SS, RST, DIO0);
  
  if (!LoRa.begin(BAND)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
  Serial.println("LoRa Initializing OK!");
  display.setCursor(0,10);
  display.print("LoRa Initializing OK!");
  display.display();
  delay(2000);

  
}



void loop() {
 sensors_event_t event;
 accel.getEvent(&event);
 
 if (BugMinX < 1) //O Valor minimo por defeito é 0, então só irá mudar quando o valor min de x for menor que 0.
 {
   MinX = event.acceleration.x;
 }
 BugMinX = 1; //Apenas faz uma vez no loop, o valor minimo passa a ser o inicial de X, logo a seguir o valor minimo muda de acordo com o planeado

 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
  if (BugMaxX < 1) 
 {
   MaxX = event.acceleration.x;
 }

 BugMaxX = 1;

 if (BugMinX < 1) 
 {
   MinX = event.acceleration.x;
 }
 BugMinX = 1;
 
  if (event.acceleration.x > MaxX)
 {
    MaxX = event.acceleration.x;
 }
   if (event.acceleration.x < MinX)
 {
    MinX = event.acceleration.x;
 }

//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  
  if (BugMinY < 1) 
 {
   MinY = event.acceleration.y;
 }
 BugMinY = 1; 

 if (BugMaxY < 1) 
 {
   MaxY = event.acceleration.y;
 }
 BugMaxY = 1; 


if (event.acceleration.y > MaxY)
 {
    MaxY = event.acceleration.y;
 }
   if (event.acceleration.y < MinY)
 {
    MinY = event.acceleration.y;
 }
 
 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

if (BugMaxZ < 1) 
 {
   MaxZ = event.acceleration.z;
 }
 BugMaxZ = 1;

 if (BugMinZ < 1) 
 {
   MinZ = event.acceleration.z;
 }
 BugMinZ = 1;
 
  if (event.acceleration.z > MaxZ)
 {
    MaxZ = event.acceleration.z;
 }
   if (event.acceleration.z < MinZ)
 {
    MinZ = event.acceleration.z;
 }
 
 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
/*
 Serial.print("X: ");
 Serial.print(event.acceleration.x);
 Serial.print("  ");
 Serial.print("Y: ");
 Serial.print(event.acceleration.y);
 Serial.print("  ");
 Serial.print("Z: ");
 Serial.print(event.acceleration.z);
 Serial.print("  ");
 Serial.print(" | ");
 Serial.println("  ");

 Serial.print("MaxX:");
 Serial.print("  ");
 Serial.print(MaxX);
 Serial.print(" | ");
 Serial.print("MinX:");
 Serial.print("  ");
 Serial.print(MinX);
 Serial.print("  ");
 Serial.print("MaxY:");
 Serial.print("  ");
 Serial.print(MaxY);
 Serial.print(" | ");
 Serial.print("MinY:");
 Serial.print("  ");
 Serial.print(MinY);
 Serial.print("  ");
 Serial.print("MaxZ:");
 Serial.print("  ");
 Serial.print(MaxZ);
 Serial.print("  ");
 Serial.print("MinZ:");
 Serial.print("  ");
 Serial.print(MinZ);
 Serial.println (" | ");
 
 delay(10);
 */
   
  Serial.print("      Emissor Lora ");

  //Send LoRa packet to receiver
  LoRa.beginPacket();
  LoRa.endPacket();
  LoRa.print(event.acceleration.x);
  LoRa.print(event.acceleration.y);
  LoRa.print(event.acceleration.z);
  delay(1000);
  display.clearDisplay();
  display.setCursor(0,0);
  display.println("     Emissor Lora");
  display.setCursor(0,20);
  display.setTextSize(1);
  display.print("Aceleracao:");
  display.setCursor(0,30);
  display.print("X:");
  display.setCursor(20,30);
  display.print(event.acceleration.x);      
  display.setCursor(0,40);
  display.print("Y:");
  display.setCursor(20,40);
  display.print(event.acceleration.y);        
  display.setCursor(0,50);
  display.print("Z:");
  display.setCursor(20,50);
  display.print(event.acceleration.z);   
  display.display();
  delay(1000);
}

Lora adlx
3.3 -- 3.3
gnd -- gnd
21 -- SDA
22 -- SCL

120820169_404579370559255_4273245593656934670_n.jpg

[/code]

120820169_404579370559255_4273245593656934670_n.jpg

See the post at the top of the forum General Guidance and How to use the forum for details how how to post code so the forum can read it easily.

And can you confirm that the simple LoRa send and receive examples in the library work with your setup ?

yes, i can send example like counter+1
and recive in the other esp32

Wire.begin(OLED_SDA, OLED_SCL);

The problem is this part of the code.

what can i do to solve this?

if i take this part of the code, i cannot view the monitor, but i can send and recive data, a minor problem, still it was good if i can saw the monitor information without compromise the information data.

gabrielnoira:
Wire.begin(OLED_SDA, OLED_SCL);

The problem is this part of the code.

what can i do to solve this?

Maybe you need to replace OLED_SDA and OLED_SCL with the pin numbers that are connectdd to SDA and SCL on the OLED ?

srnet:
Maybe you need to replace OLED_SDA and OLED_SCL with the pin numbers that are connectdd to SDA and SCL on the OLED ?

nop, i’m not using oled, im using pin 21 and 22.

esp32 don’t work with oled, but work with pins 21 and 22 SLC SDA.

the thing is, or i get true data off screen, or bad data on screen.