So I am creating a heliostat am doing it by integrating 2 50cm long linear actuators which I will use to move the mirror instead of stepper motors as I already have them at home. I have thought of using Inertial Measurement Units(IMU) to give me the data of the Altitude and Azimuth of the mirror along with the location of the heliostat but am not sure if they are the right sensors to use.
I am using the library SunPosition.h library by Ken Wilmot to get teh azimuth and altitude of the sun and DS3231 Lib by Rinky Dinky electronics for my RTC clock
I want to know the altitude and the azimuth of the Sun at real time and that is why I am trying to integrate a RTC with the SunPosition Library code. I'm a beginner coder so am struggling to write the code.
How do I ge the Sun Position using the RTC (DS3231). any help will be greatly appreciated
#include <DS3231.h>
#include <SolarPosition.h>
DS3231 rtc(SDA,SCL);
// number of decimal digits to print
const uint8_t digits = 3;
Time t;
// some test positions:
SolarPosition Toronto(43.653109, -79.386304); // Toronto, Canada
// program begins
void setup()
{
Serial.begin(9600);
Serial.println(F("\tSolar Position Demo"));
t = rtc.getTime();
// set the Time service as the time provider
SolarPosition::setTimeProvider(rtc.getTime()); //I AM CONTINUOUSLY GETTING A ERROR HERE
}
void loop()
{
// now test the real time methods:
//
printTime(RTC.get());
Serial.print(F("Toronto:\t"));
printSolarPosition(Toronto.getSolarPosition(), digits);
Serial.println();
delay(15000);
}
// Print a solar position to serial
//
void printSolarPosition(SolarPosition_t pos, int numDigits)
{
Serial.print(F("el: "));
Serial.print(pos.elevation, numDigits);
Serial.print(F(" deg\t"));
Serial.print(F("az: "));
Serial.print(pos.azimuth, numDigits);
Serial.println(F(" deg"));
}
// Print a time to serial
//
void printTime(time_t t)
{
tmElements_t someTime;
breakTime(t, someTime);
Serial.print(someTime.Hour);
Serial.print(F(":"));
Serial.print(someTime.Minute);
Serial.print(F(":"));
Serial.print(someTime.Second);
Serial.print(F(" UTC on "));
Serial.print(dayStr(someTime.Wday));
Serial.print(F(", "));
Serial.print(monthStr(someTime.Month));
Serial.print(F(" "));
Serial.print(someTime.Day);
Serial.print(F(", "));
Serial.println(tmYearToCalendar(someTime.Year));
}
So I'm trying to integrate a RTC (DS3231) clock to give me the real time of a place and feed that data into a sun position calculator (SunPosition lib by Ken Willmott) to give me the location of the sun in real time.
I'm very new to coding in Arduino and am struggling to write the code. Could you please help me
We strongly recommend to start with the simple examples that come with the Arduino IDE, to learn the special features of Arduino, and to work your way up.
I am not a complete beginner to Arduino but I am not the best programmer. This is project I am doing for university so there is no returning back from here. Any help from you would be really appreciated
As it happens, I was just in the process of posting a complete, fully functional heliostat project. If you use this for your university project, of course you will give due credit to all the contributors and code sources.
Thank you, I had a look at your work and its fantastic. However, I'll be using linear actuators and an IMU for my project.
You mention that for long time tracking I want to add an RTC. So that is where I am stuck at. Could you assist me as to how to use the DS3231 library to and the azimuth and altitude of the Sun using the SunPosition lib
I've fixed the issue. Turns out I was using the wrong DS3231 library from the start. So you need to use the library that is in te original solarTimeRTC code to make it work!
Perhaps. But the library doesn't lock you in to a particular RTC library. It only requires that you include some RTC library and set that libraries 'now()' method as the time sync provider. It does however, depend on the DateTime library for that kind of usage.
So it should be very easy to modify solarTimeRTC to work with any RTC library, including the Rinky Dink Electronics one. You just need to use the correct functions that belong to that library. You are using functions that belong to a different library, that is the source of your errors.