LoRa transmitting and receiving circuit

This is the code:


//Lora with Transmitter arduino nano

#include <SPI.h>              // include libraries
#include <LoRa.h>
 #include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <LM75A.h>
LM75A lm75a_sensor(false,  // A0 LM75A pin state (connected to ground = false)
                   false,  // A1 LM75A pin state (connected to ground = false)
                   false); // A2 LM75A pin state (connected to ground = false)
// Equivalent to "LM75A lm75a_sensor;"

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);


String outgoing;              // outgoing message
 
byte msgCount = 0;            // count of outgoing messages
byte MasterNode = 0xFF;     
byte Node1 = 0xBB;
 
float ctemp; 
float ftemp;
 
String Mymessage = "";
void setup() {
  Serial.begin(9600);                   // initialize serial
   Wire.begin();
  
  if (!LoRa.begin(433E6)) {       
    Serial.println("LoRa init failed. Check your connections.");
    while (true);                       // if failed, do nothing
  }
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  delay(2000);
  display.clearDisplay();
  display.setTextColor(WHITE);
}
 
void loop() {
 
  float temperature_in_degrees = lm75a_sensor.getTemperatureInDegrees();

  if (temperature_in_degrees == INVALID_LM75A_TEMPERATURE)
  {
    Serial.println("Error while getting temperature");
  }
  else
  {
//    Serial.print("Temperature: ");
//    Serial.print(temperature_in_degrees);
//    Serial.print(" degrees ");
    //Serial.print(LM75A::degreesToFahrenheit(temperature_in_degrees));
    ftemp= LM75A::degreesToFahrenheit(temperature_in_degrees);
//    Serial.print(ftemp);
//    Serial.println(" fahrenheit)");
  
   display.clearDisplay();
  display.setCursor(25,0);  
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.println(" Temperature");
  display.setCursor(10,20);
  display.setTextSize(2);
  //display.print("C: ");
  display.print(temperature_in_degrees);
  display.print((char)247);
  display.print("C");
 
  display.setCursor(10,45);
  display.setTextSize(2);
  //display.print("F: ");
  display.print(ftemp);
  display.print((char)247);
  display.print("F");
  
  display.display();

  
    Mymessage = Mymessage + temperature_in_degrees + "," + ftemp;  
    sendMessage(Mymessage,MasterNode,Node1);
    delay(100);
    Mymessage = "";
  
 
}
}
 
void sendMessage(String outgoing, byte MasterNode, byte otherNode) {
  LoRa.beginPacket();                   // start packet
  LoRa.write(MasterNode);              // add destination address
  LoRa.write(Node1);             // add sender address
  LoRa.write(msgCount);                 // add message ID
  LoRa.write(outgoing.length());        // add payload length
  LoRa.print(outgoing);                 // add payload
  LoRa.endPacket();                     // finish packet and send it
  msgCount++;                           // increment message ID
}

I am struggling to get the Oled LCD screen to show any data collected by the temperature sensor I have connected in the circuit. Would this be a coding issue or is it down to an incorrect wire connection. I am using an arduino nano board as the microcontroller in the circuit.

The Nano is a 5V logic level Arduino, but LoRa modules are 3.3V logic, so how have you got them connected ?

What happens when you test your modules with the LoRaTransmitter and LoRaReceiver examples from the library ?

I put this code onto the arduino cloud, and it had success with it and said there were no errors, but I the old screen didn't show any values.

I used these as the guide, they explain the majority of the connections made in each of my 2 circuits (transmitting and receiving)

'Transmitting side'

'Receiving esp8266 LoRa module'

And it wrong.

The Nano is a 5V logic level Arduino and you should not directly connect a 3.3V logic level LoRa device to it.

oh right, ok, ty. Do you have any suggestions on what connections I could alter?

I have altered the program and made a new one, I will post it some time tomorrow. I have not changed the circuit connections yet.

P. S: I followed exactly what the images and guide instructed me to do, what's on the guide, I have done. Thank you

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