Can I use normal pins as Vcc or GND?

I have a strip board design here and it would make things easier to use redundant pins as Vcc or GND to simplify wiring. Is this doable with

pinMode(2, OUTPUT); 
pinMode(3, OUTPUT); 
... 
// new additional Vcc
digitalWrite(2, HIGH);

// new additional GND
digitalWrite(3, LOW);

no high current only for driving a DS18B20. Any cons I'm not aware?

I have done this without a problem . the DS18B20 doesn't draw much power so I would give it a try.

I'd be inclined to measure the current your sensor draws, or check its datasheet.

The reference page (for a Uno for example) reminds us:

Each of the 14 digital pins on the Uno ... can provide or receive a maximum of 40 mA

That is a very bad idea.
Simplifying wiring is not sufficient reasion.

Grumpy_Mike:
That is a very bad idea.
Simplifying wiring is not sufficient reasion.

To me it's an inelegant solution, but Mike is there a real technical reason for not doing this? (....always assuming the current's within limits in the first place, of course.)

Reading the datasheet on page 3 it says

Another feature of the DS18B20 is the ability to operate without an external power supply. Power is
instead supplied through the 1-Wire pullup resistor via the DQ pin when the bus is high. The high bus
signal also charges an internal capacitor (CPP), which then supplies power to the device when the bus is
low. This method of deriving power from the 1-Wire bus is referred to as “parasite power.” As an
alternative, the DS18B20 may also be powered by an external supply on VDD

Read for yourself. It's right here

Grumpy_Mike:
That is a very bad idea.
Simplifying wiring is not sufficient reasion.

Assuming you don't exceed limits, how is this really different than using the microcontroller as an LED driver? As an LED driver, the microcontroller acts as a power supply with at least one and sometimes both of VCC and GND.

I agree this is odd with an ATMega, though, unless you are trying to power-up and power-down (perhaps for power saving) an external low-power IC. Then I would say it makes a lot of sense.

I have seen some other microcontrollers with built-in regulators where the manufacturer specifically provides regulated power to a dedicated pin so the end-user can pull power off the microcontroller in order to simply the BOM by eliminating the need for a separate external regulator. Of course the manufacturer describe the limits of that regulator in the datasheet. This is a different scenario, but I wanted to mention it.

JimboZA:
is there a real technical reason for not doing this?

If everything goes perfectly? No.

But the world is imperfect. What if there's a bug in your program, or you upload the wrong sketch...?

fungus:

JimboZA:
is there a real technical reason for not doing this?

If everything goes perfectly? No.

But the world is imperfect. What if there's a bug in your program, or you upload the wrong sketch...?

Sounds like user error, like wiring a chip's power backwards. It happens. Get a new chip. Or maybe include diodes if the voltage drops don't cause a problem.

A potential problem is the voltage drop. AVR pins effectively have an internal resistance. For example, at 15mA the voltage will be about 4.6V. At 20mA the voltage will be below 4.5V. For some things the lower voltage could cause problems. For the DS18B20 the slightly lower voltage will not make a difference.

JimboZA:

Grumpy_Mike:
That is a very bad idea.
Simplifying wiring is not sufficient reasion.

To me it's an inelegant solution, but Mike is there a real technical reason for not doing this? (....always assuming the current's within limits in the first place, of course.)

Yes Coding Badlly has the main reasion. Look at the data sheet and you will see that the output voltage at even 20mA can drop quite a lot.
Then you will want to put decoupling caps on the sensors, that will mean the output current is exceeded every time it is switched on. Also the high output impedance of the supply could upset the sensors.
Finally the system is that bit more unreliable and prone to fail as you have an extra component ( the output transistor ) that is a potential point of failure.

Does anyone read the manual (or even the previous entries on this thread.

IT DOESN'T NEED ANYTHING ON VDD

KenF:
Does anyone read the manual (or even the previous entries on this thread.

IT DOESN'T NEED ANYTHING ON VDD

Yes, this is right for parasite mode, see also http://openenergymonitor.org/emon/buildingblocks/DS18B20-temperature-sensing for a wiring diagram. I think parasite is sufficient for me (two sensors, 100 cm cable each).

Switching Vcc looks not too odd for me you do it also with a blinking LED. It seems not necessary for a low power
DS18B20 project https://lowpowerlab.com/forum/index.php/topic,219.msg1089.html#msg1089 but can be helpful to save power.

So to the "other side of the battery": I have some Arduino pins 2,54 mm away from the DS18B20 cable. Any objection to use this as GND with OUTPUT / digitalWrite(3, LOW); beside a higher risk in case you make mistakes? Why it is "a very bad idea"?

Why it is "a very bad idea"?

Because you then have a ground that is floating 0.7v above the true ground.

Using the “parasite power” method derives power from VDD, but it's passed through the pullup resistor. As such, there will be no loading on the Arduino pin when HIGH. If there is a slight voltage drop, it would be due to the DS18B20 deriving power from this wire.

EDIT: For controlling the Arduino pin for 1-wire communication, I don't think it should even go logic HIGH (isn't it 3-state or high-impedance as in I2C?).

The grounds are just connected together as normally done. Should be no issues here either.

In summary, my answer to the question "Can I use normal pins as Vcc or GND?" would be "Its not applicable and not advisable to do this".

I have a strip board design here and it would make things easier to use redundant pins as Vcc or GND to simplify wiring. Is this doable with

I made something similar to TEST one of those distance sensors (this way it fitted directly in the UNO header!). It worked.

I wouldn't let it this way in a final approach:

  1. Make things such a way that electrons pass through the minimum possible parts.

  2. For general highyenic reasons ;).

Regards

Grumpy_Mike:

Why it is "a very bad idea"?

Because you then have a ground that is floating 0.7v above the true ground.

So I understand--not a reliable solution for GND! Many thanks for this and all other replies!

What are you doing this for?

Simplify wiring is not a good idea at all. You should use proper VCC or GND pins as those are high-power stuff. (those add up quickly.)

If you are controlling power to an device you should use a MOSFET to handle the power. Look into International Rectifier's portfolio for common high power MOSFETs that can be driven by Arduino's digital outputs, and for smaller power usage, the NXP PMV48XP (a logic level P-channel MOSFET with 50 milliohm Rdson, SOT-23 package) is a good option.

@technix, you need to have a word with your SSL provider...

This Connection is Untrusted

You have asked Firefox to connect securely to en.maxchan.info, but we can't confirm that your connection is secure.

Normally, when you try to connect securely, sites will present trusted identification to prove that you are going to the right place. However, this site's identity can't be verified.
What Should I Do?

If you usually connect to this site without problems, this error could mean that someone is trying to impersonate the site, and you shouldn't continue.

en.maxchan.info uses an invalid security certificate. The certificate is not trusted because no issuer chain was provided. (Error code: sec_error_unknown_issuer)

I don't have the money to buy a proper SSL certificate so I used an CACert one, but I need HTTPS for technical reasons. If you can donate me money for one wildcard certificate I would be grateful and fix this immediately.