RRCI Roof Controller

Hey all, I need help. I am using this, https://projecthub.arduino.cc/cfar/rolling-roof-computer-interface-rrci-a7f9ac, controller to open and close the roll off roof of my observatory. My coding is almost identical. I would like to add a rain sensor to it to close the roof when it rains. How hard will this be, and can someone help me with this? This, https://a.co/d/0am5DvJ, is the sensor I am going to be installing.
Arduino Project Hub
undefined
52 Replies
🍁Stan🍁
🍁Stan🍁OPβ€’3w ago
Just the coding. I used ChatGPT for the first time, ever, last night to see if it could do the coding. I have very little faith in it. I can send my original code and what ChatGPT produced.
ZC123
ZC123β€’2w ago
im sure someone has prolly told you this before but please dont use chatgpt to code if you can avoid it. chatgpt isnt rlly the best coder and if you dont u derstabd how the code works you wldnt be able to debug.
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Thats why I posted both, I have no faith in Chatgpt. I posted it for comparison only. I would prefer if someone here can look at the code I am using and add what I need to have it work correctly. Can no one help with this?
AnonEngineering
AnonEngineeringβ€’2w ago
just saw this, sounds like an interesting project. without first digging into a couple of kb of code, you want to open and close the roof based on time, serial input, and a rain sensor?
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
The way it works now is the software, N.I.N.A. sends the command to open and close the roof when I desire, that works fine. I just want to add a rain sensor to close the roof when it starts to rain. Thank you, by the way.
AnonEngineering
AnonEngineeringβ€’2w ago
ok, adding <fill in your sensor here> is in and of itself trivial. that particular sensor might be fun at a science fair but I wouldn't trust expensive equipment to it πŸ˜‰ from a logic perspective it's just adding "if x, y, or z OR it's raining" close the roof. you probably want a fuller picture of the environment, like if dew point > X close the roof
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Yes. I do get heavy dew and fog where I am. https://a.co/d/88l1PbA, these are the sensors I have.
AnonEngineering
AnonEngineeringβ€’2w ago
which wouldn't trip that sensor (it might have to be raining pretty good to trip it)
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Would adjusting the pot to a lower value trip it quicker?
AnonEngineering
AnonEngineeringβ€’2w ago
those sensors are little better than cutting a zigzag in a sheet of aluminum foil, played with those as a kid in the 70's
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
lol
AnonEngineering
AnonEngineeringβ€’2w ago
you want to close the roof before actual raindrops fall I'm guessing this is an observatory?
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Yes, it is. I do have an star count if statement in my sequence for imaging, so ideally, the roof will close when clouds roll in. But I have been cought twice so far where it didn't kick in in time.
AnonEngineering
AnonEngineeringβ€’2w ago
ok, i didn't analyze the code yet. having "there are no stars anymore" as a parameter is nice. I suppose it could happen that it can rain sideways such that it is still clear where you are looking
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Exactly.
AnonEngineering
AnonEngineeringβ€’2w ago
so the goal is as automated as possible, maximum observing time, but do save the equipment
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Also, I am only about 2 miles from the coast, so cloud, fog, rain or snow can come without any warning at all. Yes. That is the goal.
AnonEngineering
AnonEngineeringβ€’2w ago
challenging conditions on a good day
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
I came here a few years ago in the middle of winter when the forecast was supposed to be clear. Walked into the observatory, got everything set up, rolled the roof of and it was snowing. Closed everything up, put everything away, walked out of the obs and there ws 6 inches of snow on the ground.
AnonEngineering
AnonEngineeringβ€’2w ago
"Everybody talks about the weather, but nobody does anything about it" - Charles Dudley Warner in 1897
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Well I'm trying to avoid it.
AnonEngineering
AnonEngineeringβ€’2w ago
the code you have is decent, but lacks the "rain sensor"?
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Yes.
AnonEngineering
AnonEngineeringβ€’2w ago
adding the OR condition to the "close the roof function" isn't hard, but getting the right sensor will be the trick
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
I did find a video on youtube that offered this code to add to my code, but I have no idea where to put it all. #define BUZZER_PIN 3 void setup() { pinMode(BUZZER_PIN, OUTPUT); Serial.begin(9600); } void loop() { int sensorValue = analogRead(A0); Serial.println(sensorValue); if (sensorValue < 1000) { analogWrite(BUZZER_PIN, 50); } else { analogWrite(BUZZER_PIN, 0);
} delay(1000); } I'm guessing the BUZZER_PIN would go to my relay that actually opens and closes the roof.
AnonEngineering
AnonEngineeringβ€’2w ago
yes, your code would continuously monitor the "rain sensor". IF sensor says "it's raining" THEN close the roof. again, the basic logic is not a big deal, getting good sensor readings will be. that snippet above is the basic idea, you could substitute the roof relay for buzzer the tricky part is
c++
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
if (sensorValue < 1000)
c++
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
if (sensorValue < 1000)
i've seen kids use those sensors for science fair projects where a clothesline is reeled in if it rains
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Yeah, I've watched those videos.
AnonEngineering
AnonEngineeringβ€’2w ago
if your t shirt gets a little damp πŸ€·β€β™‚οΈ dew point is easily obtainable from a low cost sensor, i don't know offhand if that is a good proxy for "it's going to rain soon"
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Dew point would not be a good measure as I can get heavy dew and not get any rain.
AnonEngineering
AnonEngineeringβ€’2w ago
but still be able to observe?
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Yes, I have dew heaters on the lenses of my scopes.
AnonEngineering
AnonEngineeringβ€’2w ago
i just did a quick Google, looks like most folks use a human as a rain detector πŸ˜‰
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
lol One thing that just hit me is that if the rain sensor shuts the roof and my if statement ends the sequence, in my end sequence statement, there is also a close roof command. Is there a way to have the rain statement void the later close roof statement?
AnonEngineering
AnonEngineeringβ€’2w ago
i'd have to look but in general yes, the code can be written to cover any possible combination of events.
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
It's something I may have to play with in the software to figure out.
AnonEngineering
AnonEngineeringβ€’2w ago
"If it is raining" would be a high level thing that overrides any combination of other inputs i would imagine. you might want to open in daytime (for solar observation say) overriding the timer, but you'd never want to open if it's raining
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Here are the settings I can play with to see if I can get things to work the way I want.
No description
AnonEngineering
AnonEngineeringβ€’2w ago
ok, so "SkyRoof" has inputs for all those various readings? and you are looking to add "Moisture detected"?
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Yes. I can also work with one of the contributors to N.I.N.A. to develop a plugin, if needed, to read the rain sensor in NINA. For now, I just want the arduino to read it and close the roof.
AnonEngineering
AnonEngineeringβ€’2w ago
take a look at this tutorial (these folks are better than most) https://lastminuteengineers.com/rain-sensor-arduino-tutorial/ run some experiments with the sensor in a stand alone mode, see if perhaps it would be good enough. note the suggestion to only power the sensor while you are taking a reading, these types of sensors corrode pretty quickly when just sitting out in the world.
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Well, that's the thing. It will not be exposed to weather when the roof is closed. I will put it close to one of the scopes, so when the roof closed, it will be out of the weather. I do have a sky cam to see the sky before I set things in motion to image.
AnonEngineering
AnonEngineeringβ€’2w ago
if it is wet and current is applied it will corrode anyway, just a quick stand alone test should inform whether such a sensor is at all suitable
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
So their code is just to test the sensor?
AnonEngineering
AnonEngineeringβ€’2w ago
if you know a contributor to NINA they must have some idea of what folks use to achieve this yes, very simple "it's raining" or "it isn't"
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
OK, so if it decides it "Is Raining", what coding will need to be added to trip the relay to close the roof.
AnonEngineering
AnonEngineeringβ€’2w ago
i'm looking at your code now, give me a few minutes
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Most just use the If StarCount statement. Np, take your time.
AnonEngineering
AnonEngineeringβ€’2w ago
looks like the logic is there
c++
bool isRaining() {
int rainVal = analogRead(RAIN_SENSOR_PIN);
if (DEBUG) {
Serial.print("Rain Sensor Value: ");
Serial.println(rainVal);
}
return rainVal <= RAIN_THRESHOLD;
}
c++
bool isRaining() {
int rainVal = analogRead(RAIN_SENSOR_PIN);
if (DEBUG) {
Serial.print("Rain Sensor Value: ");
Serial.println(rainVal);
}
return rainVal <= RAIN_THRESHOLD;
}
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Ok, I will give that code a try on the weekend. I have bad weather until then. Thank you so much for your help, I really do appreciate it.
AnonEngineering
AnonEngineeringβ€’2w ago
no problem, you want to hook the sensor's AO pin to the RAIN_SENSOR_PIN (A0)
🍁Stan🍁
🍁Stan🍁OPβ€’2w ago
Will do, again, thank you.
AnonEngineering
AnonEngineeringβ€’2w ago
turn DEBUG on so you can monitor the values you get under various conditions looks like that is the default
c++
#define DEBUG true // Set to false to disable debug messages
c++
#define DEBUG true // Set to false to disable debug messages

Did you find this page helpful?