Narrative:

IFR instructions were to takeoff runway 17; turn heading 190. On runup and check; all instruments were working as normal. After takeoff; I entered the clouds at roughly 800-900 ft. MSL. After reaching a safe altitude 1;100 ft. MSL; being in IMC; I was relying on my instruments. I look down to realize I was off of my runway heading; and was instead on a heading of about 240; indicated by the HSI. This lead me to believe that I had possibly gotten disorientated upon entering the clouds and had inadvertently turned to the right. Based off a heading of 240; I initiated a turn to the left to intercept 190. Upon doing so; ATC started yelling that I was on the wrong heading and needed to turn right. With the information being received from the HSI; I believed that they were wanting me to do a 360 turn in order to intercept 190. I verified the HSI with the compass. While still in the right hand turn; the compass was holding due south and was not moving at all. I consulted ATC and got no assistance; but rather told that I was 'incompetent and couldn't follow directions'. I reported to him that both compasses were impaired and that we were getting wrong readings. I then consulted foreflight and followed the magnetic heading that was reporting on there. After rolling out on the correct heading; the compass came swinging around and was reporting correctly; matching foreflight. The HSI continued to precess; but was frequently corrected for the remaining on the short flight.

Google
 

Original NASA ASRS Text

Title: PA-28 pilot reported deviating from the departure clearance due to a malfunctioning HSI and compass.

Narrative: IFR instructions were to takeoff RWY 17; turn heading 190. On runup and check; all instruments were working as normal. After takeoff; I entered the clouds at roughly 800-900 ft. MSL. After reaching a safe altitude 1;100 ft. MSL; being in IMC; I was relying on my instruments. I look down to realize I was off of my runway heading; and was instead on a heading of about 240; indicated by the HSI. This lead me to believe that I had possibly gotten disorientated upon entering the clouds and had inadvertently turned to the right. Based off a heading of 240; I initiated a turn to the left to intercept 190. Upon doing so; ATC started yelling that I was on the wrong heading and needed to turn right. With the information being received from the HSI; I believed that they were wanting me to do a 360 turn in order to intercept 190. I verified the HSI with the compass. While still in the right hand turn; the compass was holding due south and was not moving at all. I consulted ATC and got no assistance; but rather told that I was 'incompetent and couldn't follow directions'. I reported to him that both compasses were impaired and that we were getting wrong readings. I then consulted ForeFlight and followed the magnetic heading that was reporting on there. After rolling out on the correct heading; the compass came swinging around and was reporting correctly; matching ForeFlight. The HSI continued to precess; but was frequently corrected for the remaining on the short flight.

Data retrieved from NASA's ASRS site and automatically converted to unabbreviated mixed upper/lowercase text. This report is for informational purposes with no guarantee of accuracy. See NASA's ASRS site for official report.