Career
In 112, Zhang was summoned to the court of Emperor An of Han (r. 106–125), who had heard of Zhang's expertise in mathematics. When he was nominated to serve at the capital, Zhang was escorted by carriage—a symbol of his official status—to Luoyang, where he became a court gentleman working for the Imperial Secretariat. He was promoted to Chief Astronomer for the Han court under Emperor An, serving his first term from 115–120 and his second under the succeeding emperor from 126–132. As Chief Astronomer, Zhang was a subordinate of the Minister of Ceremonies, the latter one of Nine Ministers ranked just below the Three Excellencies. In addition to recording heavenly observations and portents, preparing the calendar, and reporting which days were auspicious or not, Zhang was also in charge of an advanced literacy test for all candidates of the Imperial Secretariat and Censorate (who were expected to know at least 9,000 Chinese characters and all major writing styles). Under Emperor An, Zhang also served as Prefect of the Majors for Official Carriages under the Ministry of Guards, in charge of the reception of memorials (containing policy and administrative suggestions) submitted to the throne as well as nominees for official appointments.
A Western Han terracotta cavalier figurine wearing robes and a hat. As Chief Astronomer, Zhang Heng earned a fixed salary and rank of 600 bushels of grain (which was mostly commuted to payments in coinage currency or bolts of silk), and so he would have worn a specified type of robe, ridden in a specified type of carriage, and held a unique emblem that marked his status in the official hierarchy.When the government official Dan Song proposed the Chinese calendar should be reformed in 123 to adopt certain apocryphal teachings, Zhang opposed the idea. He considered the teachings to be of questionable stature and believed they could introduce errors. Others shared Zhang's opinion and the calendar was not altered, yet Zhang's proposal that apocryphal writings should be banned was rejected. The officials Liu Zhen and Liu Taotu, members of a committee to compile the dynastic history Dongguan Hanji (東觀漢記), sought permission from the court to consult Zhang Heng.However, Zhang was barred from assisting the committee due to his controversial views on apocrypha and his objection to the relegation of Emperor Gengshi's (r. 23–25) role in the restoration of the Han Dynasty as lesser than Emperor Guangwu's. Liu Zhen and Liu Taotu were Zhang's only historian allies at court, and after their deaths Zhang had no further opportunities for promotion to the prestigious post of court historian.
Despite this setback in his official career, Zhang was reappointed as Chief Astronomer in 126 afterEmperor Shun of Han (r. 125–144) ascended to the throne. His intensive astronomical work was rewarded only with the rank and salary of 600 bushels, or shi, of grain (mostly commuted to coin cash or bolts of silk). To place this number in context, in a hierarchy of twenty official ranks, the lowest-paid official earned the rank and salary of 100 bushels and the highest-paid official earned 10,000 bushels during the Han. The 600-bushel rank was the lowest the emperor could directly appoint to a central government position; any official of lower status was overseen by central or provincial officials of high rank.
In 132, Zhang introduced an intricate seismometer to the court, which he claimed could detect the precise cardinal direction of a distant earthquake. On one occasion his device indicated that an earthquake had occurred in the northwest. As there was no perceivable tremor felt in the capital his political enemies were briefly able to relish the failure of his device, until a messenger arrived shortly afterwards to report that an earthquake had occurred about 400 km (248 mi) to 500 km (310 mi) northwest of Luoyang in Gansu province.
A pottery miniature of a palacemade during the Han Dynasty; as a palace attendant, Zhang Heng had personal access to Emperor Shun and the right to escort him
A year after Zhang presented his seismometer to the court, officials and candidates were asked to provide comments about a series of recent earthquakes which could be interpreted as signs of displeasure from Heaven. The ancient Chinese viewed natural calamities as cosmological punishments for misdeeds that were perpetrated by the Chinese ruler or his subordinates on earth. In Zhang's memorial discussing the reasons behind these natural disasters, he criticized the new recruitment system of Zuo Xiong which fixed the age of eligible candidates for the title "Filial and Incorrupt" at age forty. The new system also transferred the power of the candidates' assessment to the Three Excellencies rather than the Generals of the Household, who by tradition oversaw the affairs of court gentlemen. Although Zhang's memorial was rejected, his status was significantly elevated soon after to Palace Attendant, a position he used to influence the decisions of Emperor Shun. With this prestigious new position, Zhang earned a salary of 2,000 bushels and had the right to escort the emperor.
As Palace Attendant to Emperor Shun, Zhang Heng attempted to convince him that the courteunuchs represented a threat to the imperial court. Zhang pointed to specific examples of past court intrigues involving eunuchs, and convinced Shun that he should assume greater authority and limit their influence. The eunuchs attempted to slander Zhang, who responded with a rhapsody called "Contemplating the Cosmos". Rafe de Crespigny states that Zhang's rhapsody used imagery similar to Qu Yuan's (340–278 BC) poem "Li Sao" and focused on whether or not good men should flee the corrupted world or remain virtuous within it.