Hello
I am new in cayenne and I have this project to control LED, 5V FAN, Solenoid Door Lock, temp DHT11, and motion sensor.
I plug my Arduino and start with the LED and it works, But when I tried to connect the other components it didn’t, I don’t know what is the problem is the connection or I didn’t choose the right widget
DHT11: I choose the generic - digital input
for the Fan I choose it as a button
can your Arduino supply enough power to the FAN?
share the code you are using.
- How Can I know
- This is the code I used
#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 VIRTUAL_CHANNEL_LED 4
#define ACTUATOR_PIN_LED 4 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL_FAN 7
#define ACTUATOR_PIN_FAN 7
#define SENSOR_PIN_DHT 5 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL_DHT 5
void setup()
{
Serial.begin(9600);
pinMode(ACTUATOR_PIN_LED, OUTPUT);
pinMode(ACTUATOR_PIN_FAN, OUTPUT);
Cayenne.begin(username, password, clientID);
}
void loop()
{
Cayenne.loop();
}
// This function is called when data is sent from Cayenne.
CAYENNE_IN(VIRTUAL_CHANNEL_LED)
{
int value = getValue.asInt();
CAYENNE_LOG(“Channel %d, pin %d, value %d”, VIRTUAL_CHANNEL_LED, ACTUATOR_PIN_LED, value);
// Write the value received to the digital pin.
digitalWrite(ACTUATOR_PIN_LED, value);
}
CAYENNE_IN(VIRTUAL_CHANNEL_FAN){
int value = getValue.asInt();
CAYENNE_LOG(“Channel %d, pin %d, value %d”, VIRTUAL_CHANNEL_FAN, ACTUATOR_PIN_FAN, value);
// Write the value received to the digital pin.
digitalWrite(ACTUATOR_PIN_FAN, value);
}
CAYENNE_OUT(VIRTUAL_CHANNEL_DHT)
{
Cayenne.virtualWrite(VIRTUAL_CHANNEL_DHT, digitalRead(SENSOR_PIN_DHT), “digital_sensor”, “d”);
}
And I have a 12V solenoid and I want to use 5V regulator, How can I drag it into the cayenne, Can I choose the simple Button to open/close?
- safety - How much current can I draw from the Arduino's pins? - Electrical Engineering Stack Exchange
- Your code looks fine. Add
#define CAYENNE_DEBUG
and see if you are receiving the data when the button is clicked on the dashboard. - Your code for DHT is wrong. Cayenne-MQTT-Arduino/DHT.ino at master · myDevicesIoT/Cayenne-MQTT-Arduino · GitHub
- You cannot power the 12v solenoid directly from the arduino. you need to use either a transistor or better use 5v relay.
- What do you mean
I want to use 5V regulator,
?