Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LILYGO® TTGO LORA32 868/915Mhz ESP32 LoRa OLED - pinouts #16

Closed
pmknowles opened this issue Nov 2, 2022 · 27 comments
Closed

LILYGO® TTGO LORA32 868/915Mhz ESP32 LoRa OLED - pinouts #16

pmknowles opened this issue Nov 2, 2022 · 27 comments
Assignees
Labels
question Further information is requested

Comments

@pmknowles
Copy link

The pinout for this device is different as the SX1278 is hardwired.
GPIO5 -- SX1278's SCK
GPIO19 -- SX1278's MISO
GPIO27 -- SX1278's MOSI
GPIO18 -- SX1278's CS
GPIO14 -- SX1278's RESET
GPIO26 -- SX1278's IRQ(Interrupt Request)

There doesn't seem to be a place to edit the default pins. The board is available in the Boards Manager but I'm not sure if that filters through to your code.

The MQTT output goes online then 25 seconds later goes to dead. I can't get the test versions to compile so not sure whether it an issue from the weather station to the radio or radio to ESP32. Any ideas?

@matthias-bs
Copy link
Owner

You might want to check if https://github.com/matthias-bs/BresserWeatherSensorReceiver/tree/main/examples/BresserWeatherSensorMQTTCustom/src works for you. In this example, the library part is placed in the sub-directory /src of the sketch. In there is the file WeatherSensorCfg.h where you can define the pins as needed.

I also recommend to enable debug output by uncommenting

#define _DEBUG_MODE_ 

at the beginning.

Please try the latest version of the repository instead of any of the releases.

Let me now if the compilation still fails and provide a log file. I just tried to compile for the targets TTGO LoRa32-OLED V1 and TTGO LoRa32-OLED V2.1.6 - both worked.

@matthias-bs matthias-bs self-assigned this Nov 2, 2022
@matthias-bs matthias-bs added the question Further information is requested label Nov 2, 2022
@matthias-bs
Copy link
Owner

What is the difference between the SX1276 and the SX1278?
My library uses SX1276 from https://github.com/jgromes/RadioLib:

static SX1276 radio = new Module(PIN_RECEIVER_CS, PIN_RECEIVER_IRQ, PIN_RECEIVER_RST, PIN_RECEIVER_GPIO);

But RadioLib also provides SX1278 support.

@matthias-bs
Copy link
Owner

As far as I can see from https://www.semtech.com/products/wireless-rf/lora-connect, SX1278 is for 137MHz to 525MHz, while SX1276 for 137MHz to 1020MHz.
Which frequency does your weather sensor use?

@pmknowles
Copy link
Author

pmknowles commented Nov 2, 2022 via email

@matthias-bs
Copy link
Owner

matthias-bs commented Nov 2, 2022

Relation between SX1278 and SX1276 module classes in RadioLib:
https://jgromes.github.io/RadioLib/class_physical_layer.html

Here is an example of the RadioLib Module constructor which has to be used if an alternative SPI port has to be used:
https://github.com/jgromes/RadioLib/blob/df7d1a99fe3638595776781e17d8ea0f1b9aab54/src/Module.h#L49

SPI port config:
https://github.com/espressif/arduino-esp32/blob/master/libraries/SPI/examples/SPI_Multiple_Buses/SPI_Multiple_Buses.ino

@pmknowles
Copy link
Author

pmknowles commented Nov 2, 2022 via email

@matthias-bs
Copy link
Owner

What is G1? And what is actually the problem?
I think you could create an SPI object with your SPI pins and pass this together with the other pins to the Module constructor.

Best regards,
Matthias

@pmknowles
Copy link
Author

pmknowles commented Nov 2, 2022 via email

@franki29
Copy link

franki29 commented Nov 3, 2022

Hi @pmknowles ,
try in WeatherSensorCfg.h with:

// Use pinning for LoRaWAN Node
//#define LORAWAN_NODE

#elif defined(ESP32)
#define PIN_RECEIVER_CS 18

// CC1101: GDO0 / RFM95W/SX127x: G0
#define PIN_RECEIVER_IRQ  26 

// CC1101: GDO2 / RFM95W/SX127x: G1
#define PIN_RECEIVER_GPIO 33

// RFM95W/SX127x - GPIOxx / CC1101 - RADIOLIB_NC
#define PIN_RECEIVER_RST  23

At my side it is working with that settings

@pmknowles
Copy link
Author

pmknowles commented Nov 3, 2022 via email

@pmknowles
Copy link
Author

pmknowles commented Nov 3, 2022 via email

@franki29
Copy link

franki29 commented Nov 3, 2022

Hi @pmknowles , can you share your WeatherSensorCfg.h that you are using?

@pmknowles
Copy link
Author

pmknowles commented Nov 3, 2022 via email

@matthias-bs
Copy link
Owner

Looks like you are using one of the old releases (instead of the HEAD of the repository).
I've created release v0.4.0 this morning. With this release it should be possible to compile all variants, enabling debug output should really give you debug output and the code should use the pins you actually define in your header file.
Please give it another try!

@franki29
Copy link

franki29 commented Nov 3, 2022

Hi @pmknowles , so we are now not talking about the TTGO anymore, right?
And what example did you use now for testing?

@pmknowles
Copy link
Author

pmknowles commented Nov 3, 2022 via email

@pmknowles
Copy link
Author

pmknowles commented Nov 3, 2022 via email

@pmknowles
Copy link
Author

pmknowles commented Nov 4, 2022 via email

@matthias-bs
Copy link
Owner

Hi Phil,

I just added a pin definition for TTGO_LORA32 in WeatherSensorCfg.h which uses the defines from the board specific header files. Can we close this issue then?

Best regards
Matthias

@pmknowles
Copy link
Author

I have had another go at this and I think that the issue is in WeatherSensor.cpp with these lines

#ifdef USE_CC1101
    int state = radio.begin(868.3, 8.21, 57.136417, 270, 10, 32);
#else
    int state = radio.beginFSK(868.3, 8.21, 57.136417, 250, 10, 32);
#endif

I think there should be brackets round USE_CC1101

@pmknowles pmknowles reopened this Jan 3, 2023
@pmknowles
Copy link
Author

It would also explain why I couldn't get any output from turning Debug on because all the #ifdef statements for DEBUG_MODE are missing brackets too.

@matthias-bs
Copy link
Owner

matthias-bs commented Jan 3, 2023

I don't think so.
First I had a look at Bjarne Stroustrup: The C++ Programming Language. According to it (chapter R16 in my German version)

#if defined IDENTIFIER
and
#if defined (IDENTIFIER)
and
#ifdef IDENTIFIER
are equivalent.

Next I added the following in WeatherSensor.cpp:

    #ifdef USE_CC1101
        #warning "Building for CC1101"
        int state = radio.begin(868.3, 8.21, 57.136417, 270, 10, 32);
    #else
        #warning "Building for SX1276"
        int state = radio.beginFSK(868.3, 8.21, 57.136417, 250, 10, 32);
    #endif

The warning is printed by the compiler (or actually the pre-processor) according to the selected define in WeatherSensorCfg.h.

I recommend to add some kind of warning in your file to see if the sketch is compiled with the copy of the library files you are expecting.

@matthias-bs
Copy link
Owner

It would also explain why I couldn't get any output from turning Debug on because all the #ifdef statements for DEBUG_MODE are missing brackets too.

Here the order of the define and the macros using it was wrong in a previous version.

@pmknowles
Copy link
Author

pmknowles commented Jan 3, 2023 via email

@Lordcybertracker
Copy link

I've now got a V1 to run.
Since this was without a display, it was just lying around anyway.

But I took it as Lorawan_Node:

// Arduino default SPI pins
//
// Board SCK MOSI MISO
// ESP8266 D5 D7 D6
// ESP32 D18 D23 D19
#if defined(LORAWAN_NODE)
#define PIN_RECEIVER_CS 18

// CC1101: GDO0 / RFM95W/SX127x: G0
#define PIN_RECEIVER_IRQ 26

// CC1101: GDO2 / RFM95W/SX127x: G1
#define PIN_RECEIVER_GPIO 33

// RFM95W/SX127x - GPIOxx / CC1101 - RADIOLIB_NC
#define PIN_RECEIVER_RST 23

@matthias-bs
Copy link
Owner

LORAWAN_NODE was just intended as a define for my own board.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants