Newbe in arduino seeking for programming help

Hello,
My name is Paris and i just started to get to know arduino cause i am planning to build an old, as it seems, project in the community, but i have not found anywhere a build like the one i am planning to do, to get code and of course being totaly newbe i cannot alter code to my specific needs so i am opening this topic for anyone to help with advice, code or any other way....

My plan is to build a solar tracker, this is what got me into arduino in general, but a full scale one, dual axis with actual huge 220 volt linear actuators i already have, using LDR sensor ( which i found directions how to build one in this forum ). I want to use 4 limit switch and 4 relay for direction. The linear actuators i have use 3 wire, one common and 2 for direction, so i can use a double relay for each direction ( up-down and Right -left ) to control the solar tracker.

The solar tracker itself will be build and installed in the roof of my house, using all metal fabrication and will be build to withstand all weather conditions and of course will be build to hold 2 industrial solar panels for now ( which i already own ) but the frame will be build to hold at least 10 solar panels in total.

The solar panels i will use is 36 volt 8amp polycrystal.

i have found many similar projects in the forum, but most of it is just for demonstration and experimentation and as i am really really new to arduino i really dont understand which part of the code i need to change .

I will be using Arduino Uno Rev3 , i guess that is sufficient for the inputs and outputs i need.

Thank you in advance for any help !

Of course i will be posting updates, pictures and progress for the project, for anyone that wants to track it...

Hello vatos

The sketch can use a clock to follow the sun.

thank you for your reply.
i thought of that, but i am thinking in using the 4 array LDR sensor for best results and for usability in other places ( in the future i may move to another house with different direction ) so there will be no need for calibrating the code, the angle and orientation again.

Other than that , it is a simple solution, yes...

Don´t forget you have to clean this sensor regulary to work proper.

1 Like

You're asking for a code solution for unknown hardware. That is impossible.

hello,
please explain to me how exactly is the hardware unknown, since i already mentioned that the system will be using the 4 LDR cross array for sensing, 4 relay for direction and 4 limit switches ( pinned to ground of course ). This is the hardware. what the relay will be controlling does not matter for the code or the arduino itself.

i am planning to 3d print a plexiglass case for the sensor and of course i will be cleaning the panels regularly so i can also clean the sensor every time...

Dont misunderstand me, i will design and print a case which incorporates plexiglass for the light source to be able to hit the sensor and of course to make the sensor waterproof.

No, Those a generic names. To get help you need to identify the actual devices you will use. You cannot begin the program until you know the specifics of each device that will be connected to your Arduino.

Did you buy that already? It's not an ideal type of Arduino for practical projects.

I suggest a classic Nano and breadboard to construct your first prototype. Use 4 outputs to control 4 LEDs representing the up/down/left/right relay signals to begin.

Post a schematic showing how you would wire the LEDs and LDRs to the Arduino and we can check your understanding.

1 Like

The forum introductory guide does a much better job of that, than I can do. Maybe you shouldn't have chosen the option to skip it.

Yes, i have already bought almost everything, i only lack the metal parts to start welding...

I am uploading a sketch of how i think everything should be , according to my knowledge at least, please feel free to correct anything and give me directions...

i know how to handle the 220v side as i have a degree in electrical installations, there will be fuse box, tripping switches and perhaps i will also use high current relays to power the motors , but thats the easy part for me.

LDR will be in this array :
Untitled-1
which i have already printed and solder it.

It's very colourful but indecipherable. Can you post a schematic please? Hand drawn would be ok. I know you will have seen that kind of diagram used a lot to try to describe Arduino circuits. Having a degree in electrical installations, you probably wondered why they are used at all, given their obvious limitations. They are only used by children and beginners, for very basic circuits.

1 Like

I dont know if this is any helpfull, i will take time to do it better at some point.


i guess the program should start by checking if the system is in starting position which will be the left limit switch and the down limit switch of the system. If not it should trigger the relay corresponding to the Left-Right motor using the appropriate Left or right until the Limit swich clicks, the same with up - down. After that it should start checking the Light and determine the position of the Light source. once the system has determined which LDR has the less light, it should trigger the motor relays to move the system up-down or left-right in such order so all the LDR have more or less the same amount of light. Of course once the system hits the Limit Sensor it should stop giving order for movement in the Limit Switch direction.

I am surprised that a degree course in electrical installation does not include how to make a schematic.

But this diagram is a little clearer than the earlier one. Also it is different to the earlier one. There is no connection from 5V to the limit switches in your new diagram. The resistors before looked like 10K (brown-black-orange) but now they are labelled as 100K.

You should remove the 100K that connect the limit switches to ground because the Arduino will not be able to read the switches like that. The switches can be connected directly from the Arduino pin to ground. The Arduino can then use it's internal pull-ups to prevent its input pins from floating.

You do not indicate whether the NO or NC pins on the limit switches are used. I think I would use the NC pins, because that way, if the cables between the limit switches and the Arduino are damaged or become disconnected, it will appear to the Arduino that the limit switches are activated, causing the Arduino to switch off the motors. I think that would be better for safety reasons.

Your previous diagram indicated that the arduino would be powered by USB. Is that correct? How much current will be available from the USB? How much current will be required to activate the coils of your relays? How many relays will be activated at any time? Will there be enough current from the USB power supply to activate more than one relay?

2 Likes

Thank you for your reply.

I already mentioned that i will do a better schematic once i have spare time, but i dont see the relevance between Electrical schematic and Electronic schematic , totally different fields, i can Draw a schematic for the 220v side of the story , but i dont see where is that usefull in the 12v arduino side of the story.

No, Arduino will not be powered by usb, i will be using 12v 2Amp power supply for the arduino, it is sufficient for everything i guess.

The limit switches i already have, have both NC and NO contacts, so i can use either, it depends on the programming and the ease of build. NO would be easier to use , cause the switch will be in stand by until something hits it. NC would be more difficult cause the switch would have to touch something all the time until a gap lets it open.

Your original diagram included the 220V connections. When I saw how you intended to connect that, my thought was that this would trip the residual current breakers, because the when relays are activated, they would connect the live/hot to ground instead of to the neutral line as I expected. Please explain to me why this is ok.

Are your relays 5V or 12V?

If they are 5V, how will they be powered? The Arduino's built-in regulator may overheat and fail if it is required to provide power for the relays from a 12V input.

Does the term NC have different meanings in the Electrical field compared to the Electronic field? In Electronics it means "Normally closed", meaning that the NC and COM pins are connected until something presses on the switch. What does it mean in the Electrical field?

I dont understand why the 220v side plays any role on how it will be connected in accordance to the arduino which is the 12 or 5 volt side of the story.

First the arduino has to do its job, measure the light and give directions in the relays.

I mentioned in my post that i will probably use 220v Relay for the motors, so the 5volt Arduino Relays will just trip the High Power Relays, maybe i will use 12volt coil relay, this is to be decided later in the project, but all this has nothing to do with the programming i guess.

The only thing the arduino knows and has to know is that when the LDR sensor has a difference in the up-down or Left right direction, it needs to trigger lets say the Pin number 10 for X amount of milliseconds and then start the measurement of the sensor again, and it has to do that until it hits a limit sensor or all the LDR have equal values.

The Relays is 5 Volt and i can, if i need to, use an external power supply , this is not a problem.

Yes NC means normally closed and NO means normally Open , and you are absolutely right as long as this goes, please have in mind that i have to translate in my mind everything from Greek to English , so some things may be misunderstood.

1 Like

What code?

I meant if i use Code from other users project ( there are a lot similar projects which use servo ( 5 volt or 12 volt ) without limit switches , if i knew how to change the code, i could just alter it for my specific needs...

You will never learn until you begin.