Adafruit Huzzah + TSL2561. No data displayed on Cayenne dashboard.
Log:
[xxxxx] <msg xx,xxx,xx
<vw3lum,lux=%.3f - reply form Cayenne.luxWrite?
127.00 lux - this is read actual data from sensor
Where is issue ?
Adafruit Huzzah + TSL2561. No data displayed on Cayenne dashboard.
Log:
[xxxxx] <msg xx,xxx,xx
<vw3lum,lux=%.3f - reply form Cayenne.luxWrite?
127.00 lux - this is read actual data from sensor
Where is issue ?
Hi there @viktoras,
It would be most helpful if you could post your code, since I’m not sure what the issue is yet.
Thanks!
-B
Device Adafruit Huzzah(ESP8266) Issue is TSL2561 data not displayed on Console.
Part of log:
<msg 20,29,17
<vw3lum,lux=%.3f
>msg 20,30,4
Code:
#define CAYENNE_DEBUG // Uncomment to show debug messages
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include "CayenneDefines.h"
#include "BlynkSimpleEsp8266.h"
#include "CayenneWiFiClient.h"
#include "Wire.h"
#include "Adafruit_Sensor.h"
#include "Adafruit_TSL2561_U.h"
char token[] = "";
char ssid[] = "";
char password[] = "";
#define VIRTUAL_PIN_1 V1 //PIR
#define VIRTUAL_PIN_2 V2 //Relay
#define VIRTUAL_PIN_3 V3 //LUX
const int motionSensorPin = 14;
const int relayPin = 13;
const int address = TSL2561_ADDR_FLOAT;
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(address, 12345);
void setup()
{
Serial.begin(9600);
Cayenne.begin(token, ssid, password);
pinMode(relayPin, OUTPUT);
if (!tsl.begin())
{
CAYENNE_LOG("No TSL2561 detected");
while (1);
}
tsl.enableAutoRange(true);
/* Changing the integration time gives you better sensor resolution (402ms = 16-bit data) */
tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS); /* fast but low resolution */
// tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS); /* medium resolution and speed */
// tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS); /* 16-bit data but slowest conversions */
}
/*
* 220V relay
*/
CAYENNE_IN(VIRTUAL_PIN_2)
{
// get value sent from dashboard
int currentValue = getValue.asInt(); // 0 to 1
// assuming you wire your relay as normally open
if (currentValue == 0) {
digitalWrite(relayPin, HIGH);
} else {
digitalWrite(relayPin, LOW);
}
}
/*
* PIR
*/
CAYENNE_OUT(VIRTUAL_PIN_3)
{
// Send the command to get luminosity.
sensors_event_t event;
tsl.getEvent(&event);
if (event.light)
{
// Send the value to Cayenne in lux.
Cayenne.luxWrite(VIRTUAL_PIN_3, event.light);
}
else
{
/* If event.light = 0 lux the sensor is probably saturated
and no reliable data could be generated! */
CAYENNE_LOG("Sensor overload");
}
}
void loop()
{
Cayenne.run();
checkSensor();
}
/*
* TSL2561
*/
int previousState = -1;
int currentState = -1;
unsigned long previousMillis = 0;
void checkSensor()
{
unsigned long currentMillis = millis();
// Check sensor data every 250 milliseconds
if (currentMillis - previousMillis >= 250) {
// Check the sensor state and send data when it changes.
currentState = digitalRead(motionSensorPin);
if (currentState != previousState) {
Cayenne.virtualWrite(VIRTUAL_PIN_1, currentState);
previousState = currentState;
}
previousMillis = currentMillis;
}
}
Hi There,
I have the exact same issue. Not sure what is happening here. Do you know of any solution.
Thanks
@viktoras @soubir wanted to follow up here.
Perhaps you can reference these posts to help get the TSL2561 sensor working?
Hi @bestes,
I couldn’t get it to work on esp but got it working on a raspberry pi.