ropg / heltec_esp32_lora_v3

Proper working Arduino library for the Heltec ESP32 LoRa v3 board, as well as for Wireless Stick v3 and Wireless Stick Lite v3. Uses RadioLib
MIT License
361 stars 18 forks source link

no I2C #34

Open jo-ei opened 3 months ago

jo-ei commented 3 months ago

Hello everyone, I have been trying for days now to address an RTC clock in order to have the time locally after retrieval via LORA.

With the original lib from heltec and the arduino environment it works and I see the address with the I2C scanner. With this lib it does not work and I always see only

SDA on PIN: 41 SCL on PIN: 42 Scanning I2C Addresses Channel 1 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Scan Completed, 0 I2C Devices found.

is there a special way with this lib?

I have tried many things, here is the latest version of my test code:

#define SDA 41
#define SCL 42

void setup() {
  heltec_setup();
    Wire.begin(SDA, SCL);

  Serial.print("SDA on PIN: ");
  Serial.println(SDA);
  Serial.print("SCL on PIN: ");
  Serial.println(SCL);
}

void loop() {

  Serial.println("Scanning I2C Addresses Channel 1");
  uint8_t cnt=0;
  for(uint8_t i=0;i<128;i++){
    Wire.beginTransmission(i);
    uint8_t ec=Wire.endTransmission(true);
    if(ec==0){
      if(i<16)Serial.print('0');
      Serial.print(i,HEX);
      cnt++;
    }
    else Serial.print("..");
    Serial.print(' ');
    if ((i&0x0f)==0x0f)Serial.println();
    }
  Serial.print("Scan Completed, ");
  Serial.print(cnt);
  Serial.println(" I2C Devices found.");

delay(20000);

}

since i see the clock module with the other code, the wiring must be correct

can you give me a hint what i might be doing wrong?

Thanks

ropg commented 3 months ago

I’ll try to have a look at this later this week.

jo-ei commented 2 months ago

hi, any news about the bug? was it possible to reproduce?

ropg commented 2 months ago

Hello there! I have been operated on my shoulder, and need to have my arm in a sling for another month. So doing anything with electronics and lots of wires is a lot harder now than I would like it to be. Two thoughts:

Good luck!

jo-ei commented 2 months ago

Hi ropg, first of all, get well soon for your shoulder.

Unfortunately, the internal RTC does not continue to run during deep sleep and I don't want to get the times via LoRa every time unnecessarily. (or am I doing something wrong and there is a way to get the time even in deep sleep)

I have the light version without display.

I still set the option for testing and couldn't see any improvement. Is there anything else I can do to provide more information?

Thank you

decodeais commented 1 week ago

I have tested the tested the I2C-scan too and i found that ihave to change the pi number.It found the DIsplay, you should find your RTC too. Here is the program:

/* Heltec Automation I2C scanner example (also it's a basic example how to use I2C1)
 *
 * ESP32 have two I2C (I2C0 and I2C1) bus
 *
 * OLED is connected to I2C0, so if scan with Wire (I2C0), the return address should be 0x3C.
 *
 * If you need scan other device address in I2C1...
 *      - Comment all Wire.***() codes;
 *      - Uncomment all Wire1.***() codes;
 *
 * I2C scan example and I2C0
 *
 * HelTec AutoMation, Chengdu, China
 * 成都惠利特自动化科技有限公司
 * www.heltec.org
 *
 * this project also realess in GitHub:
 * https://github.com/HelTecAutomation/Heltec_ESP32
 * */

#include "Arduino.h"

#ifdef WIFI_LORA_32_V3
  #define HELTEC_POWER_BUTTON
  #include <heltec_unofficial.h>
#else
  #include "heltec.h"
  #endif
#if defined( WIRELESS_STICK_LITE )
  #include <Wire.h>
    #include "oled/SSD1306Wire.h"

    static const uint8_t SCL_OLED = 15;
    static const uint8_t SDA_OLED = 4;
#endif

void setup()
{
#ifdef WIFI_LORA_32_V3
  heltec_setup();
#else
  Heltec.begin(true, false, true);
#endif

    Wire.begin(SDA_OLED, SCL_OLED); //Scan OLED's I2C address via I2C0
    //Wire1.begin(SDA, SCL);        //If there have other device on I2C1, scan the device address via I2C1
}

void loop()
{
    byte error, address;
    int nDevices;

    Serial.println("Scanning...");

    nDevices = 0;
    for(address = 1; address < 127; address++ )
    {
        Wire.beginTransmission(address);
        error = Wire.endTransmission();

//      Wire1.beginTransmission(address);
//      error = Wire1.endTransmission();

        if (error == 0)
        {
            Serial.print("I2C device found at address 0x");
            if (address<16)
            Serial.print("0");
            Serial.print(address,HEX);
            Serial.println("  !");

            nDevices++;
        }
        else if (error==4)
        {
            Serial.print("Unknown error at address 0x");
            if (address<16)
                Serial.print("0");
            Serial.println(address,HEX);
        }
    }
    if (nDevices == 0)
    Serial.println("No I2C devices found\n");
    else
    Serial.println("done\n");

    delay(5000);
}
jo-ei commented 1 week ago

Hello @decodeais, thanks for your answer, but as the title from your code says, there are two I2C buses.

ESP32 have two I2C (I2C0 and I2C1) bus
* OLED is connected to I2C0, so if scan with Wire (I2C0), the return address should be 0x3C.

The one you described is only for the display. Hence the following PIN configuration

static const uint8_t SCL_OLED = 15;
static const uint8_t SDA_OLED = 4;

But I have the model without display, so I can't test your part.

But since I have connected my RTC to Bus1, I used:

#define SDA 41
#define SCL 42
decodeais commented 1 week ago

When I looked to the pinout of the my module it looked like pin 8/9. The numbers you use are so high.

jo-ei @.***> schrieb am Mo., 21. Okt. 2024, 18:50:

Hello @decodeais https://github.com/decodeais, thanks for your answer, but as the title from your code says, there are two I2C buses.

ESP32 have two I2C (I2C0 and I2C1) bus

  • OLED is connected to I2C0, so if scan with Wire (I2C0), the return address should be 0x3C.

The one you described is only for the display. Hence the following PIN configuration

static const uint8_t SCL_OLED = 15; static const uint8_t SDA_OLED = 4;

But I have the model without display, so I can't test your part.

But since I have connected my RTC to Bus1, I used:

define SDA 41

define SCL 42

— Reply to this email directly, view it on GitHub https://github.com/ropg/heltec_esp32_lora_v3/issues/34#issuecomment-2427225549, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEEUKH7TZKB62MZGGMJRU4LZ4UWGHAVCNFSM6AAAAABLGUEWJKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRXGIZDKNJUHE . You are receiving this because you were mentioned.Message ID: @.***>