In 1821 he joined the army and took part in the French expedition in Spain, two years later he was promoted to non-commissioned officer. The result of his six years of service in the army is the memoir "Diary of the Spanish Expedition.