Hi, guys! I have a problem. I use LDR for measuring Luminous intensity in candela. But when I upload code the dashboard is offline and don’t send the dataset. How can I first calculate and then upload the dataset into the dashboard?
This is my code:
CAYENNE_OUT(V3)
{
float LDR_value = analogRead(LDR_PIN);
lux=((250.000000/(ADC_valueLDR_value))-50.000000);
float cd = lux9;
Cayenne.virtualWrite(V3, cd);
}
i did not understand by what you meant above,
I need help, how to measure the luminous intensity.
Because this code doesn’t upload any data from LDR
are you using an arduino, esp8266 or a raspberry pi.
I’m using arduino with esp8266.
First of all, you see if you can get a basic code working and sending data to cayenne, as the code is not meant to work with arduino uno properly.
The code works when compile with arduino, but when I use cayenne it’s not working.
I guess that when I’m using algebraic operations something breaks. This is the serial monitor
can you share the entire code used.
#define CAYENNE_PRINT Serial
#include <OneWire.h>
#include <DallasTemperature.h>
#include <CayenneMQTTESP8266Shield.h>
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “”;
char password = “”;
char clientID = “”;
char ssid = “”;
char wifiPassword = “”;
#define SENSOR_PIN1 2
OneWire oneWire(SENSOR_PIN1);
DallasTemperature sensors(&oneWire);
//DHT11
#include “DHT.h”
#define DHTPIN A2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
//light
float lux=0.00,ADC_value=0.0048828125,LDR_value;
#define LDR_PIN A0
#define EspSerial Serial
ESP8266 wifi(&EspSerial);
void setup()
{
Serial.begin(9600);
Cayenne.begin(username, password, clientID, wifi, ssid, wifiPassword);
sensors.begin();
dht.begin();
//float LDR_value = analogRead(LDR_PIN);
//lux=((250.000000/(ADC_value*LDR_value))-50.000000);
}
CAYENNE_OUT(V0)
{
float t = dht.readTemperature();
Cayenne.virtualWrite(V0, t); //virtual pin
}
CAYENNE_OUT(V1)
{
float h = dht.readHumidity();
Cayenne.virtualWrite(V1, h);
}
CAYENNE_OUT(V2)
{
sensors.requestTemperatures();
float w = sensors.getTempCByIndex(0);
Cayenne.celsiusWrite(V2, w);
}
CAYENNE_OUT(V3)
{
float LDR_value = analogRead(LDR_PIN);
lux=((250/(ADC_value * LDR_value))-50);
float cd = lux * 9;
Cayenne.virtualWrite(V3, cd);
}
void loop()
{
Cayenne.loop();
}
If I paste this part of code in comentar any works
CAYENNE_OUT(V3)
{
float LDR_value = analogRead(LDR_PIN);
lux=((250/(ADC_value * LDR_value))-50);
float cd = lux * 9;
Cayenne.virtualWrite(V3, cd);
}
And I don’t know why?
first of all as the code description mentions, it code it not suitable for arduino uno. the best thing right now is to change you arduino uno to mega if possible or get an ethernet shield for your arduino UNo.
though if you want to continue using there are some topics in which people have got it working.
- power your esp8266 with separate power supply.
- Follow steps from this post Temperature measurement - #63 by fmarkovich