Hallo to everyone. Im kinda new to this and im trying to automate some stuff around my house. My problem is that i want to make a relay to open when i press the button from the dashboard stay on for x amount of time and then close. Ive tried doing it like the guidelines say but no luck. Could you please help?
Yes.
Post your sketch, well formated, with comments and in so called code tags "</>" and schematic to see how we can help.
Have a nice day and enjoy coding in C++.
Adding to @paulpaulson
- Schematic will also be useful.
- List of the components that you're using. And don't say 'relay' but give the exact details (e.g. link).
Is that the dashboard of your car that is parked kilometers away from your house where the relay is?
Read this thread:
I want to make my water heater over wifi with a sensor to monitor him. I have made in the arduino cloud a button and in the button loop i want to tell it that when i press the virtual button you count 30’ and then you close.
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
CloudTemperatureSensor burner;
CloudTemperatureSensor temp;
bool fos;
bool fos2;
bool nero;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
bool neroOld;
unsigned long currentMillis;
const long interval = 5000;
unsigned long startMillis;
void setup() {
pinMode(14, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
// Your code here
}
/*
Since Fos is READ_WRITE variable, onFosChange() is
executed every time a new value is received from IoT Cloud.
*/
void onFosChange() {
if(fos){
digitalWrite(14, HIGH);
}
else{
digitalWrite(14,LOW);
}
// Add your code here to act upon Fos change
}
/*
Since Fos2 is READ_WRITE variable, onFos2Change() is
executed every time a new value is received from IoT Cloud.
*/
void onFos2Change() {
if(fos2){
digitalWrite(12, HIGH);
}
else{
digitalWrite(12,LOW);
}
}
// Add your code here to act upon Fos2 change
/*
Since Nero is READ_WRITE variable, onNeroChange() is
executed every time a new value is received from IoT Cloud.
*/
void onNeroChange() {
unsigned long startMillis = millis();
If(nero){
digitalWrite(13,HIGH);
currentMillis = millis();
if (currentMiliis-startMillis >= interval){
digitalWrite(13,LOW);
}
stratMillis = currentMillis;
}
}
This is how I tried it !! Im very confused with millis !!
In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.
Use the </> icon from the ‘reply menu’ to attach the copied sketch.
Please note that strat and start are not the same thing
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.