Grove Lightning Sensor - I2C address unknown - Tutorial anyone?

Hello there,
I just bought the Lightning Sensor but can’t seem to make it work.
I connected the I2C cables and copied the only tutorial I could fine from the Wiki.
However nothing happens in the loop.

I would expect the first lines already to have something missing. There it is written:

void loop() {
int c;
int indevice = 0; //device number I2C address, in final application you can assign
//directly the address (for example: indevice = 3;)

//---------------------------------------------------
// read/write functions for I2C mode:
//---------------------------------------------------
//**************************************************************************
//**************************************************************************
int done = 1; //flag to start self test on I2C sensor address
indevice = 0; //reset address value

while (done) {

but I realized already I have no idea about the I2C address.
Does anyone what to insert at indevice?

Or perhaps anyone who might know a better (smaller) tutorial for this sensor? The sample code is almost 1000 lines and not very easy to understand.

Thanks

image
Hi,
You said your module won’t work, is it tutorials using wiki that won’t work? Have you tested electrical sparklers.There are no easy tutorials other than wiki tutorials, maybe you can try to remove some comments and leave only what is needed, it is easy for you to learn the logic in the code

Thanks for your quick reply.

The problem is I don’t even get any output. Not even an error. Only the starting serial output (so the serial monitor works).

Hi, @TobiasR

I recommend trying an I2C device scanner script, making sure to define the I2C pins as well in the Wire.begin function. For example, in the script below, they are GPIO5 and GPIO6. Anyway, I think that, by default, the lightning detector assumes address 3.

On the other hand, it would be useful to know which microcontroller you are using, for example, in the Wiki they do it with Seeeduino V4.3, and it works. However, I tried with the XIAO ESP32S3 board and have not been able to get to work the lightning detector over I2C. I have tried and eidted multiple scripts, debugging at many points to find out what could be happening, but I can’t find what is the issue.

Apparently, there is an issue with addresses 1 to 3, which are reserved (see here), but I have not been able to verify this directly.

Surely someone more knowledgeable can clarify this for us.

Sample script: device scanner over I2C


#define SDA_PIN 5
#define SCL_PIN 6

void setup() {
  Serial.begin(9600);
  delay(1000);
  
  Serial.println("Inicio del escáner I2C...");
  
  Wire.begin(SDA_PIN, SCL_PIN);
  Wire.setClock(100000); // 100 kHz
}

void loop() {
  byte error, address;
  int devicesFound = 0;
  
  for (address = 1; address < 128; address++ ) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0) {
      Serial.print("Dispositivo I2C encontrado en la dirección: 0x");
      if (address < 16) Serial.print("0");
      Serial.println(address, HEX);
      devicesFound++;
      delay(10);
    }
  }

  if (devicesFound == 0) {
    Serial.println("No se encontraron dispositivos.");
  } else {
    Serial.println("Escaneo completado.");
  }

  delay(5000); // Espera 5 segundos para el próximo escaneo
}

Hi, did you follow this step on the wiki, you need to determine the power supply voltage and do a simple solder before using the module.

image

In addition, did you do this step in the wiki to weld two places, otherwise you will make an error on I2C