After graduating from the University of Pavia, Cantoni taught at the University of Milan and later became professor of physics at his alma mater. Conducted research on the composition of bodies, theories of heat, electrology, and meteorology. Republican, ardent patriot, journalist, and writer, Cantoni served in many official positions and was appointed Senator.