Powering through the converter CC-CC LM2596

If I use the converter CC-CC LM2596 to get 5V output it's better to use a 12V battery than a 9v battery despite the mAh?

Do I need to put some capacitos and a diode or does it already have?

And do I put a Switch on/off between the battery and the buck converter or between the buck converter and the Arduino Nano, or is the same?

If I use the converter CC-CC LM2596 to get 5V output it's better to use a 12V battery than a 9v battery despite the mAh?

The higher the voltage the lower the capacity in mAh needed for the same amount of time before the battery is discharged. Which is 'better' is for you to decide. If by 9V battery you mean the small batteries that go in smoke alarms and the like they are too small to be much use.

Do I need to put some capacitors and a diode or does it already have?

If you mean the bare chip then it needs 2 capacitors, a Schottky diode and an inductor, see data sheet. If you mean a ready built module it should have the right components already.

Do I put a Switch on/off between the battery and the buck converter or between the buck converter and the Arduino Nano, or is the same?

Put the switch between the battery and the converter, otherwise the converter will continue to draw current when the Nano is off.

I meant like normal 9V and 12V battery for exemple such as duracell's.
And i need to power a circuit which consumes ~130mA.
It´s better the 12V or the 9V?

Your question is too vague to answer. There are lots of kinds of batteries. All I can say for certain is that the small rectilinear 9V batteries used for smoke alarms are no good for anything other than smoke alarms.

If you know the capacity of the battery in mAh then:
Life time = capacity / consumption
For example if you use a 2000mAh battery and draw 130mA the life will be 2000/130 = 15.3h

If you use a higher voltage and a buck converter then:
130mA @ 5V from a 12V battery becomes:
(5*130)/12 = 55mA @12V
So the life of a 2000mAh 12V battery becomes:
2000/55 = 36h

However, that ignores that inefficiency of the converter, which will waste anything up to about 15%, giving a more realistic time of 85% * 36h = 30h.

Without knowing the capacity of the batteries you propose it's not possible to answer.

I saw some 12V battery going from 20mAh to 55mAh. How much would they last?

All I want is to get 5V output to power my project but I don't know if this is the best option.

55mAh means 55mA for an hour, through a buck converter you might get your 130mA for 45 minutes if you are lucky. How long do you need it to last?

As long as possible.
What if I use the module LM2577 DC-DC Step-Up what's the range of input voltage needed to have 5V output?
Since these batteries with 3.7V or 3V have more mAh.

As long as possible.

That is meaningless. If you buy some big electric car batteries it will probably run all year on 1 charge, would that be OK?

I need it to last for atleast 2-3 hours.

Would it be better if I use the module LM2577 DC-DC Step-Up to get 5V output with a battery of 3.7V since these batteries could have 2000mAh?

a 3V7 2000mAh battery when stepped up to 5V will give you:
(5 * 130) / 3.7 = 175mA from the battery, ignoring the inefficiency of the converter.
2000mAh / 175 = over 11h
As I ignored the inefficiency of the converter you won't get 11h, maybe 85% of 11h, so 9.7h, which is more than you want.

It's better than using a 12V battery that won't last an hour.

If i connected 2 batteries 3.7V and 2000mAh each in series i get 7.4V and 2000mAh?

If i connected 2 batteries 3.7V and 2000mAh each in series i get 7.4V and 2000mAh?

Correct.
Doing that with a buck converter will last roughly twice as long as a single battery and a boost converter.

But if I use a boost converter can I get the 5V output even with above voltage on the input like those 7.4V?

griffnater:
But if I use a boost converter can I get the 5V output even with above voltage on the input like those 7.4V?

No, a boost converter increases the voltage, a buck converter reduces the voltage, so you need to know which way you are going.

I saw one module using the XL6009 almost identical to the boost converter that could give 5V output with more and less voltage. Is it a buck/boost converter?

Is it a buck/boost converter?

Yes, correct. I think, but I am not sure, that buck/boost converters are less efficient that buck or boost converters, so if that's correct using one would shorten the battery life. As you can plan to used either a lower or a higher voltage decide what you want and use a buck or a boost converter as needed.

Do you know any boost converter that allows lower input voltage (1V-3V) so I can get more off the 3.7V battery?
The ones I saw have a minimum of 3V input.

How's 0.5V?

Can't imagine it'd be good for a rechargeable battery tho.

griffnater:
Do you know any boost converter that allows lower input voltage (1V-3V) so I can get more off the 3.7V battery?
The ones I saw have a minimum of 3V input.

If you discharge a lithium ion battery that far you will damage it. I don't know what the lower limit is but you should find out or maybe someone else here will tell you.

What type of battery can I discharge to 1V for example?

Or there is a better way to power my project with 5V (~130mA) using some other small battery so it can last for a couple of hours?