Gas sensor (1, 20), in particular an oxygen sensor, which gas sensor (1, 20) comprises: - a main elongate gas chamber with a supply opening arranged on a first end of the main gas chamber and a discharge opening positioned opposite of the supply opening and arranged on the second end of the main gas chamber, such that gas can flow through the main gas chamber; - magnetic field means for providing a magnetic field in the main gas chamber; - an ultrasonic transmitter and receiver sensor arranged on either the first or second end of the main elongate gas chamber to direct an ultrasonic wave along the longitudinal axis of the main elongate gas chamber, wherein the opposite end of the main elongate gas chamber is reflective for the ultrasonic wave or an ultrasonic transmitter sensor arranged on a first end of the main elongate gas chamber and an ultrasonic receiver sensor arranged on a second end of the main elongate gas chamber; and - control means for controlling the ultrasonic transmitter and receiver sensor and to determine the time of flight of the ultrasonic wave (8, 9) between transmitting and receiving the ultrasonic wave, to obtain a value which corresponds to the concentration of gas in the main elongate gas chamber, characterized by, a reference elongate gas chamber which is arranged in parallel fluid connection with the main elongate gas chamber and a second ultrasonic transmitter and receiver sensor arranged on either the first or second end of the reference elongate gas chamber, wherein the opposite end of the reference elongate gas chamber is reflective for the ultrasonic wave or a second ultrasonic transmitter sensor arranged on a first end of the main elongate gas chamber and a second ultrasonic receiver sensor arranged on a second end of the main elongate gas chamber, wherein the reference elongate gas chamber is arranged outside of the magnetic field generated by the magnetic field means and wherein the second ultrasonic transmitter and receiver sensor is controlled by the control means to provide a reference signal. - a main elongate gas chamber with a supply opening arranged on a first end of the main gas chamber and a discharge opening positioned opposite of the supply opening and arranged on the second end of the main gas chamber, such that gas can flow through the main gas chamber; - magnetic field means for providing a magnetic field in the main gas chamber; - an ultrasonic transmitter and receiver sensor arranged on either the first or second end of the main elongate gas chamber to direct an ultrasonic wave along the longitudinal axis of the main elongate gas chamber, wherein the opposite end of the main elongate gas chamber is reflective for the ultrasonic wave or an ultrasonic transmitter sensor arranged on a first end of the main elongate gas chamber and an ultrasonic receiver sensor arranged on a second end of the main elongate gas chamber; and - control means for controlling the ultrasonic transmitter and receiver sensor and to determine the time of flight of the ultrasonic wave (8, 9) between transmitting and receiving the ultrasonic wave, to obtain a value which corresponds to the concentration of gas in the main elongate gas chamber,