Hello community !
I’m looking for add TSL2561 to Blynk app and sketch for esp8266.
Whats better using TSL2561 or simple photoresistor ?
Some body have sketch for tsl2761 ?
Thanks
Hello community !
I’m looking for add TSL2561 to Blynk app and sketch for esp8266.
Whats better using TSL2561 or simple photoresistor ?
Some body have sketch for tsl2761 ?
Thanks
My advice would be to get the sensor working with one of the many non-Blynk demo sketches that are kicking around the internet, then once you’re happy that the device is working as you want it to, incorporate that sketch into your Blynk code.
Don’t forget that with Blynk, the code that takes a reading from the sensor and does something with the results should be in a function which is called using a timer.
Pete.
Ok, i find this sketch who’s working :
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_TSL2561_U.h>
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);
void setup(void)
{
Serial.begin(9600);
Serial.println("Light Sensor Test");
Serial.println("");
/* Initialise the sensor */
if(!tsl.begin())
{
Serial.print("No TSL2561 detected");
while(1);
}
tsl.enableAutoRange(true);
tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS);
Serial.println("");
}
void loop(void)
{
/* Get a new sensor event */
sensors_event_t event;
tsl.getEvent(&event);
/* Display the results (light is measured in lux) */
if (event.light)
{
Serial.print(event.light);
Serial.println(" lux");
}
else
{
Serial.println("Sensor overload");
}
delay(250);
}
But i don’t know how i can adapt for using Blynk…
Ok i think i find solution, i don’t now if it’s good way but it work !
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_TSL2561_U.h>
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <BlynkSimpleEsp8266.h>
#include <ESP8266WiFi.h>
char auth[] = "xx";
char ssid[] = "xx";
char pass[] = "xx";
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);
void setup(void)
{
Blynk.begin(auth, ssid, pass, IPAddress(xx), 8080);
while (Blynk.connect() == false) {
Serial.begin(9600);
Serial.println("Light Sensor Test");
Serial.println("");
/* Initialise the sensor */
if(!tsl.begin())
{
Serial.print("No TSL2561 detected");
while(1);
}
tsl.enableAutoRange(true);
tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS);
Serial.println("");
}
}
void loop(void)
{
/* Get a new sensor event */
sensors_event_t event;
tsl.getEvent(&event);
/* Display the results (light is measured in lux) */
if (event.light)
{
Serial.print(event.light);
Serial.println(" lux");
}
else
{
Serial.println("Sensor overload");
}
delay(250);
{
Blynk.run();
}
{
Blynk.virtualWrite(1, event.light);
}
}
No, it’s not a good way.
Read this…
Then set-up a timer and move all the sensor related code out of your void loop, and remove any delays.
Pete.
I gonna read this, i’ve to learn how i can make clear sketch. For exemple i try to add DHT11 sketch to my TSL2561 sketch, and is not clean…
Hi !
Befoere cleaning i want mix both sketch. It’s probleme only TSL2561 work…