Led+phoresistor+Cayenne

Hello Dear Master community of Arduino.

I need your help to create on cayenne a system based on Arduino one +ethernet W5100 which is turning a led on when there is no light or another settings could be turning different LEDs on depending on the light or a third setting might be changing colour of rgb led. Those 3 options are just ideas, my concept is when lux is down do something with a led.

I found a guide how to this remotely but not on cayenne. Do you have any idea?

Thank you for your support in advance

Best regards

Gesuelemi

I have an idea that this is not an installation or troubleshooting issue.

Otherwise, simply too vague

Your topic was MOVED to its current forum category as it is more suitable than the original

What is a cayenne?

A Porsche

1 Like

Got it. Thanks!

1 Like

Sure and it is also a iot platform Cayenne Features - Developer | myDevices.com

@gesuelemi i see you have asked this question on the cayenne forum.

This is a better place to ask than here where most people I believe have never come across a cayenne before.

Thank you for your reply! I am trying everywhere to be honest. Here I am sure I find the master of arduino, there the masters of cayenne :slight_smile:

I think I am clarifying my project at the moment. Basically what I want to reach is:

turn a led on if photoresistance value is > of a constant value.
this is the code which is loading the photo resistance data but I think I made something wrong with the if else due to the fact that I have still to click on the led switcher
here is the code:

/*
Cayenne Photoresistor Example

This sketch shows how to send Photoresistor Sensor data to the Cayenne Dashboard.

The CayenneMQTT Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.

Steps:
1. Attach a photoresistor to an analog pin on your Arduino.
   Make sure to use an analog pin, not a digital pin.
   Schematic:
   [Ground] -- [10k-resistor] -- | -- [Photoresistor] -- [5V]
                                 |
                            Analog Pin
2. Set the SENSOR_PIN value below to the pin number you used when connecting the sensor.
3. Set the VIRTUAL_CHANNEL value below to a free virtual channel (or the virtual channel of a Photoresistor Sensor widget you have added) in the Dashboard.
4. Set the Cayenne authentication info to match the authentication info from the Dashboard.
5. Compile and upload this sketch.
6. Once the Arduino connects to the Dashboard it should automatically create a temporary display widget (or update the Photoresistor Sensor widget you have added) with data.
   To make a temporary widget permanent click the plus sign on the widget.
*/

#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneMQTTEthernet.h>


// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "*****************************************";
char password[] = "*****************************************";
char clientID[] = "*****************************************";


#define SENSOR_PIN A3 
#define VIRTUAL_CHANNEL_4 8
#define VIRTUAL_CHANNEL_3 3
#define ACTUATOR_PIN 8 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
int SENSOR_VALUE;

void setup()
{
  Serial.begin(9600);
  pinMode(ACTUATOR_PIN, OUTPUT);
  Cayenne.begin(username, password, clientID);
}

void loop()
{
  Cayenne.loop();

}

// This function is called at intervals to send sensor data to Cayenne.
CAYENNE_OUT(VIRTUAL_CHANNEL_4)
{
  Cayenne.virtualWrite(VIRTUAL_CHANNEL_4, analogRead(SENSOR_PIN), "analog_sensor", "null");
}

// This function is called when data is sent from Cayenne.

CAYENNE_IN(VIRTUAL_CHANNEL_3)
{
  int value = getValue.asInt();
  CAYENNE_LOG("Channel %d, pin %d, value %d", VIRTUAL_CHANNEL_3, ACTUATOR_PIN, value);
  // Write the value received to the digital pin.
  digitalWrite(ACTUATOR_PIN, value);
  SENSOR_VALUE = analogRead(SENSOR_PIN);
  if (SENSOR_VALUE >599)
  {
  digitalWrite(8,HIGH);
  }
  else 
  {
    digitalWrite(8,LOW);
    delay (100);
  }
}

Any help is really appreciated

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.