Hello, I want to use two Grove Digital Light Sensors TSL2561 on my Arduino Uno R4 WiFi. The Grove Sensor provides three addresses: 0x29, 0x39, 0x49.
Problem is how to define the addresses.
Any thoughts on my code?
#include "WiFiS3.h"
#include "index.h"
#include <Wire.h>
#include <Digital_Light_TSL2561.h>
#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password
#define RELAY_PIN_1 2 // the Arduino pin, which connects to the IN1 pin of relay module
#define RELAY_PIN_2 4 // the Arduino pin, which connects to the IN2 pin of relay module
#define RELAY_PIN_3 7 // the Arduino pin, which connects to the IN3 pin of relay module
#define RELAY_PIN_4 8 // the Arduino pin, which connects to the IN4 pin of relay module
#define TSL2561_Address_1 0x29
#define TSL2561_Address_2 0x39
TSL2561_CalculateLux tsl2561_1; // adress 0x29
TSL2561_CalculateLux tsl2561_2; // address 0x39
// Current time
unsigned long currentTime = millis();
unsigned long previousTime = 0;
// Define timeout time in milliseconds (example: 2000ms = 2s)
const long timeoutTime = 2000;
int status = WL_IDLE_STATUS;
WiFiServer server(80);
void setup() {
Wire.begin();
Wire1.begin();
Serial.begin(9600);
tsl2561_1.init(); // Initialize tsl1 to address 0x29
tsl2561_2.init(); // Initialize tsl2 to address 0x39
}
void loop() {
// read values of Sensor1
uint16_t luxSensor1 = tsl2561_1.readVisibleLux();
if (luxSensor1 != 0xFFFF) {
Serial.print("Sensor 1 Lux: ");
Serial.println(luxSensor1);
} else {
Serial.println("Sensor 1 Error");
}
// read values of Sensor2
uint16_t luxSensor2 = tsl2561_2.readVisibleLux();
if (luxSensor2 != 0xFFFF) {
Serial.print("Sensor 2 Lux: ");
Serial.println(luxSensor2);
} else {
Serial.println("Sensor 2 Error");
}
delay(5000); // 5 seconds delay between measures
}






