power problem on Ds18b20 and mega 2560

I used for a long time ds18b20 sensors on arduino duemilanove. Now i moved to arduino mega, and the same device i used for a long time in duemilanove know it does not work. Testing different things i discovered a power problem.

Let me explain the scenario: I have 2 ds18b20 sensors in normal power (not parasitic mode). I know they work because i can read them with the normal library and the device connected to the breadboard. The problema appear in the shield i prepared I power the device from the 5V and ground pins. However, the ground line have a optocoupler such as an interrupt what i power with a digital pin. It works great, because i have other sensors connected to the same ground line and they return values.

When i measure to voltage the pins where i connect the cable with the 2 ds18b20 sensors, i have about 4.6V. I think it is not bad, because the sensors works also with lower voltaje, such as say the datasheet. However, if i connect the cable with the sensors, when the circuit is closed (by activating the optocoupler PC817), the voltaje i can read between vcc and gnd pins in the cable to the sensors is only 0.8V.... consecuently, the serial port only shows -127ÂșC for both sensors.

If i disconnect my shield with the optocoupler and connect the device directly to 5v, gnd and a digital pin, it works...

I tested by connecting a 10uF 5V between vcc and gnd pins of the device... but again 0.8V when the circuit is closed...

So, i suspect that the problem is the way i power the sensors by the optocoupler... i used in this way, because i want to save power since it will be an outdoor device. I will read the sensors (ds18b20, sh15,... an some others) once per hour, so, powering the sensor all the time consume power.

Any idea of what i am doing wrong or how could i solve this issue? Thanks!!

Details of the optocoupler and a diagram of how you have connected it would be very helpful.

I am out of home and i do not have here a software to plot a wiring diagram, but it is somethig like this:

Arduino Shield Sensors

+5v ----------------- +5v --------------------------- +5V | 4K7 (for DS18B20) | Dig.Pin 7 ---------- Data ---------------------------- Data

GND ----------------Optocoupler---------------------- GND | | Dig. Pin 8 ------- 220 ohm --

I hope you could follow this diagram.

So, all the gnd of all the sensors are connected together, as well as the +5V in the shield. Of course, data line from each sensor does to a different digital pin. Also, the 4K7 resistance is only related to the ds18b20 sensor. Sensors are connected in normal power, not parasitic. The others have their own resistances or none. In that way, all the sensores are supossed to receive +5v, and all the sensor are only connected to GND when digital pin 8 is high.

I tested the optocoupler, and it works perfect... so, i do not know where could be the problem. Thanks!!

Update 1: Oh! i tested with other resistances than 4K7, such as 1K2, and 2k2.... with similar results. Update 2: I also checked a 10uF 5V between GND and +5V in the shield, directly to the ds18b20 connector... with similar results.