I am trying to control a solenoid valve with cayenne and arduino. I am trying to have the valve stay open when the button widget is selected and close when the widget is turned off. To the best of my knowledge, the button widget runs like a switch. It stays on until it is pressed again. I am just wondering how to get the solenoid to turn on when the button is pressed and turn off when it is pressed a second time
Do you have any code that works without Cayenne, or is this a fresh project? If you’re starting out fresh then it really depends on your solenoid. Can you post a model number? If you already have code then it will be super easy to merge everything. You are correct in that the button on the dashboard is only an on/off switch for now.
I am using the solenoid as a part of a smart greenhouse project I am working on. I am using the DHT11 temperature and humidity sensor and it is working fine. I can post the code for that if you would like but I do not have any other code for the solenoid. I am using THIS solenoid at the moment but that is subject to change. I am going to be using a TIP120 transistor to regulate the solenoid.
I have the schematics figured out was just wondering about software. How do I tell the fan to turn off. I am using cayenne_out to control it. Does it just turn off when I turn off the button?
I am sorry I am using out to push temp and in for the motor control. I just want to know if it will automatically turn off any code in the cayenne_in brackets or if I need a interupt circuit
I am trying to have a button on the cayenne dashboard that opens a solonoid for a given amount of time than automaticly closes the solonoid and turns off the button. I have this code so far,
//recives solonoid control
if (CAYENNE_IN(V3) == HIGH){
digitalWrite(solenoidPin, HIGH); //opens the solonoid
delay(300000); //waits 5 minutes
digitalWrite(solenoidPin, LOW); //closes the solonoid
Cayenne.virtualWrite(V3, LOW); //turns off switch on cayenne
}
Add a custom button widget and select channel as 1.
// This example shows how to connect to Cayenne using an ESP8266 and send/receive sample data.
// Make sure you install the ESP8266 Board Package via the Arduino IDE Board Manager and select the correct ESP8266 board before compiling.
//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
int x;
// WiFi network info.
char ssid[] = "";
char wifiPassword[] = "";
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "";
char password[] = "";
char clientID[] = "";
unsigned long lastMillis = 0;
void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}
void loop() {
Cayenne.loop();
}
CAYENNE_IN(1)
{
int currentValue = getValue.asInt();
if (currentValue == 1)
{
digitalWrite(4,HIGH);
}
else
{
digitalWrite(4,LOW);
}
}