levijtrose / Heliostat-project

Code for arduino heliostat program
9 stars 4 forks source link

Is it possible to run this code using ESP32 ? #1

Open happytm opened 3 years ago

happytm commented 3 years ago

I wanted to use ESP32 and MPU-6050 to make heliostat to target fixed window on north side. Is it possible to use your code?

Thanks.

levijtrose commented 3 years ago

Hi!

My setup used an Arduino Uno, but you should be ok to use an esp32 if you upload it through the arduino IDE or similar. The project is made for a 9-axis LSM-303 which includes an accelerometer and a magnetometer (compass) to give direction and pitch readings. With MPU-6050 you only have accelerometer and gyroscope so I don't think it can give you the heliostat's current direction/heading. However, you can probably adjust the code to keep track of the heliostat's direction in onboard memory if you want. Of course you're welcome to use the code however you want, but you'll need to adjust some variables to suit your location (brislatitude, brislongitude, brismeridian, targetheading, targetpitch) Also make sure yearday and hourangle are calculating appropriately for your setup. Fyi for convention I used 0 degrees azimuth as North.

Anyway good luck and let me know if I can help anymore

Thanks!

http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Virus-free. www.avg.com http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Wed, Mar 10, 2021 at 2:30 PM happytm notifications@github.com wrote:

I wanted to use ESP32 and MPU-6050 to make heliostat to target fixed window on north side. Is it possible to use your code?

Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/levijtrose/Heliostat-project/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGGLHFADLQRK6GE2IVZR3Z3TC3RTVANCNFSM4Y5D5WHA .

happytm commented 3 years ago

Thank you for detailed response. I think I can use MPU-9250 which allow 9 DOF data.

Can you please explain below part? I have lot of freedom (own flat & hilly land on north side ) to chose targetpitch & targetheading. What should be the best heliostat location if windows are on north side?


brislongitude, brismeridian, targetheading, targetpitch)
Also make sure yearday and hourangle are calculating appropriately for your
setup.
Fyi for convention I used 0 degrees azimuth as North.

Thanks.
happytm commented 3 years ago

I found following sun tracker code with pan tilt platform using 2 servos. To experiment I want to use servos first using the code below but I do not know how to implement fixed north side window as a target in the code. That way it will be simpler hardware as there is no need for RTC chip, stepper drivers or MPU chip.What is the logic involved to add target variable in the code below ?

https://www.youtube.com/watch?v=R1tFOd0s6uk https://github.com/G6EJD/ESP32_2D_Sun_Tracker

Thanks.

levijtrose commented 3 years ago

To reflect light onto your window you need the program to face your heliostat halfway between the sun's position and your target (the window in your case). To do that you need variables describing the sun's position and the window's position relative to your heliostat (you need direction and elevation for both so 4 variables total). Then you need to face your heliostat at the point halfway between these two points. (ie find the mean direction and elevation)

The sun tracker code looks good, you just need to add const variables for your window position and then to use Azi_servo.write and Ele_servo.write to target the heliostat in the right direction instead of straight at the sun.

add something like

int target_direction = (whatever it is); int target_elevation = (whatever it is); int heliostat_direction; int heliostat_pitch;

then add and change lines 63 to 65 :

heliostat_direction = (sun_azimuth + target_direction) / 2; //calculate the point in between for direction heliostat_pitch = (sun_elevation + target_elevation) / 2; //calculate point in between for elevation

Azi_servo.write(map(heliostat_direction, 90, 270, 180, 0)); // Align to azimuth if (sun_elevation < 0) heliostat_pitch = 0; // Point at horizon if less than horizon Ele_servo.write(145 - heliostat_pitch); // map(value, fromLow, fromHigh, toLow, toHigh)

should work

If you want to use my code you'll need to update the variables I mentioned, they're used to calculate sun's position:

brislongitude - > set to the longitude of your location (Brisbane, Australia longitude for me) brislatitude - > set to your latitude brismeridian - > set to your local GMT offset*15 eg in Brisbane Australia it's GMT+10 so for me =150 targetheading -> direction of your target window relative to heliostat targetpitch -> elevation of your target window relative to heliostat note - for me these two variables were functions of time because I wanted my target to move around but you can just set them to single constant values for your window.

Both my code and the sun tracker use the current time to calculate the sun's position but if you can connect to ESP32 Wifi sounds like that won't be a problem without RTC! If you're in the north hemisphere I recommend placing your heliostat to the north of your window. If you're in the southern hemisphere place it to the north-east or north-west. Anyway sorry for the long response, hope it all made sense!

On Thu, Mar 11, 2021 at 10:59 AM happytm notifications@github.com wrote:

I found following sun tracker code with pan tilt platform using 2 servos. To experiment I want to use servos first using the code below but I do not know how to implement fixed north side window as a target in the code. That way it will be simpler hardware as there is no need for RTC chip, stepper drivers or MPU chip.What is the logic involved to add target variable in the code below ?

https://www.youtube.com/watch?v=R1tFOd0s6uk https://github.com/G6EJD/ESP32_2D_Sun_Tracker

Thanks.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/levijtrose/Heliostat-project/issues/1#issuecomment-796337623, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGGLHFHOA2SEKYG7C3BVNALTDABUPANCNFSM4Y5D5WHA .

happytm commented 3 years ago

Thank you for your clear to understand and detailed answer.Now I have all information I need. I am in northeast USA so I will be using north side of window of my house. I will be experimenting with servos inside my house first and then use your code for out side with stepper motors to move bigger mirror.

Thank you so much for your help.

levijtrose commented 3 years ago

No worries! Hope I helped! One more thing I forgot to mention. You may need to subtract 180 degrees (or whatever the correct offset value is) from the heliostat_direction variable before passing it to the Azi.servo.write() function to account for it's facing southward instead of north (which would be 0 deg). I'm not 100% how the servo function will work to be honest but you can experiment! Good luck!

On Thu, Mar 11, 2021 at 7:34 PM happytm @.***> wrote:

Thank you for your clear to understand and detailed answer.Now I have all information I need. I am in northeast USA so I will be using north side of window of my house. I will be experimenting with servos inside my house first and then use your code for out side with stepper motors to move bigger mirror.

Thank you so much for your help.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/levijtrose/Heliostat-project/issues/1#issuecomment-796601913, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGGLHFCLI2IFDRIJ7U5Q6D3TDB6CPANCNFSM4Y5D5WHA .