onewire library and pwms interfering

Hi I got a problem I have two dallas ds18s20 on one wire (pin 4) and I got two mosfets on pin 3 and 11. when the pwm is 0 or 255 the temp sensors work perfectly. when the pwm is set to any value in between it always gives 85.12°C as the temperature for both sensors. any idea?
Ive listed a couple relevant functions I believe sending the entire code would just confuse

#include <OneWire.h>
#include <DallasTemperature.h>
void setpowerlevel()
{
  if(power > 100) power = 100;
  if(power < 0) power = 0;
  level = map(power, 0, 100, 0, 255);
  Serial.print("Power=");
  Serial.print(power);
  Serial.print(" PLevel=");
  Serial.println(level);
  analogWrite(pwmpin1, level); //Write this new value out to the port
  analogWrite(pwmpin2, level); //Write this new value out to the port
}
void SendTemperature()
{
  sensors.requestTemperatures(); // Send the command to get temperatures
  float t[numberOfDevices];
  for(int i=0;i<numberOfDevices; i++) // parse through all temperature sensors
  {
    t[i]=sensors.getTempCByIndex(i);
    
    if (t[i]==-127)
    {
      delay(50);
      i-=1; //read again after 50ms
    }
  }
  char buffer[25];
  String T1=ftoa(buffer, t[0], 2);
  String T2=ftoa(buffer, t[1], 2);
  Serial.println("Sensor 1: "+T1+" Sensor 2: "+T2);
  
}

ftoa converts floats or doubles to char arrays.
I really need your help I got no idea why this happens.
thanks

Just a guess, but it sounds like a timer resource conflict.

can you tell me more about this How do I find out if it is a timer resource conflict?
And how would I start to fixing it?

KOR:
can you tell me more about this How do I find out if it is a timer resource conflict?
And how would I start to fixing it?

Read the library documentation and/or source code and see if the PWM and One Wire libraries are using the same hardware timer. If they are, you have to change one of them to use a different timer, or give up.

How do I find out if it is a timer resource conflict?

I do not believe that this is the case. I can patch analogWrite(3,127) and analogWrite(11,127) into a sketch using OneWire and ds18b20 and can see no effect.

In my quick look through the OneWire library I can't see any use of Timer2 which is where the pwm for pin 3 and 11 is generated. You can also try move your pwm any other pwm pins which will be on Timer 0 and Timer 1.

I'd be looking else where for the root cause of your problem.

Try disconnecting the power circuit that the mosfets are driving. There might be some power supply interference going on. Meanwhile, if you want us to consider software possibilities, you should post your entire sketch.

Very probably interference - have you proper star-grounding and paid attention to layout of
high current paths?

today I tried the same thing and it worked for some reason. I can't reproduce the error right now.

So for some reason the error is back. if I unplug the 12v supply which is regulated by the pwm. the readings are perfect. I know that it worked before. Since I only have a rough idea what star grounding is I probably didn't pay attention to it.

and me again. I fiddeled around with the cables comming of my prototype shield to the high current heaters and the sensorsit turns out that the interference is in the cables.if I put them as far apart as I possibly can the interference is gone.
Is there a way to reduce the interference in the cables?
To get no interference I have to flip the board upside down and some other inconvenient stuff.