The gold plated MOXIE instrument is lowered into the body of the rover; the rover appears in a selfie on Mars; and two female students write code on a laptop.


In this coding challenge, students will use real data from the Perseverance Mars rover to create a system that can monitor and test the functioning of the MOXIE instrument, which converts carbon dioxide in the Martian atmosphere into breathable oxygen.



  • Students should have some knowledge of how to balance chemical equations and/or charges for this lesson.
  • Each student should have their own computer, and it may be helpful for them to follow along on their own device while the instructor introduces the challenge.
  • Groups should be no larger than four students to keep each student actively engaged.


The Perseverance Mars rover landed on the Red Planet in 2021 and is NASA’s most advanced rover to date.

The rover, which operates using programmed instructions it receives from engineers on Earth, carries a suite of advanced science tools to search for signs of ancient life while studying the geology and subsurface of the Red Planet.

Like other missions, Perseverance also brought new technologies to Mars to test them on the Red Planet and push the frontiers of what future missions could do.

One of those new technologies was Ingenuity, the first helicopter to fly on Mars. Performing more than 70 powered flights, Ingenuity showed how helicopters could be a useful tool for future robotic and human explorers on Mars.

Another new technology that traveled to Mars with Perseverance resides within the chassis of the rover: an instrument called MOXIE, which stands for Mars Oxygen In-situ Resource Utilization Experiment. This electrochemical device can create breathable oxygen by using a catalyst to split carbon dioxide in the Martian atmosphere.

Three people in white protective jumpsuits and masks lower a gold cube, the MOXIE instrument, into the box-like body of the rover, which has numerous wires and structures jutting out from it.

MOXIE is lowered into the rover chassis during assembly at NASA's Jet Propulsion Laboratory in 2019. During the mission, MOXIE extracted oxygen from the Martian atmosphere 16 times, testing a way that future astronauts could make rocket propellant that would launch them back to Earth. Credit: NASA/JPL-Caltech | + Expand image | › Full image details

The oxygen produced by MOXIE, or instruments like it, could be used in the future to create breathable air for astronauts, or it could even be combusted and used as fuel for launches from the Martian surface – for example, to send samples from Mars back to Earth.

Join JPL mechanical engineer Mike Meacham to find out how the MOXIE instrument on NASA's Perseverance Mars rover is designed to convert carbon dioxide from Mars' atmosphere into oxygen. Credit: NASA/JPL-Caltech | Watch on YouTube

Because Mars is so far away, testing and evaluating instruments like MOXIE from here on Earth relies heavily on computer science and coding. Scientists and engineers send command codes to the rover when they want to operate MOXIE and when they want to receive data back from the instrument. This includes commands that tell MOXIE when to run and for how long, and how to measure the success of each test of the instrument.

In this challenge, students will look at real data from MOXIE on Mars and design a system that can test and monitor whether the instrument is running properly.


  1. Provide an overview of the MOXIE instrument aboard the Perseverance Mars rover, explaining that it's designed to convert carbon dioxide in the Martian air to oxygen.
    A gold plated cube has various tubes and wires extending from it.

    The MOXIE instrument after being installed inside the Perseverance rover. The largest white tube on the top surface of MOXIE takes in filtered carbon dioxide-rich Martian atmosphere. That CO2 is pressurized and passed through the Solid Oxide Electrolysis unit, where it is split into carbon monoxide and oxygen. The smallest tube snaking across the top of the unit sends the oxygen produced by MOXIE through a composition sensor to measure purity, then vents the oxygen out to the Martian atmosphere. | + Expand image | › Full image details

  2. Divide students into groups and tell them that, in this challenge, they will be using real data from MOXIE to program a system that can monitor and test whether the instrument is running properly.
  3. Review the data set while showing students the MOXIE gas flow schematic below. Point out that there are multiple places where temperature and pressure are monitored and that gas laws can be a valuable starting point to track how these details change over time. Note that carbon dioxide enters at the bottom left as a reactant, then carbon monoxide and oxygen leave as products at the top left and right, respectively.

    This diagram shows the inner workings of the MOXIE instrument and describes where the data from the data sheet orginate. | › View on Google Slides | › Download slide (pptx)

  4. Give students time to plan and map out how they will use the data to track whether or not MOXIE is operating properly. Students should consider what columns they need to successfully complete the task, how the task can be broken into smaller parts for each member of the group, etc.
  5. Students will most likely try to develop a solution using the gas laws from their chemistry course, relating pressure and temperature (Gay-Lussac’s law), like so:

    (P/T)carbon dioxide = (P/T)carbon monoxide + (P/T)oxygen

    Note that the most common mistake students make when using gas laws is forgetting to correct for the number of moles. In this case, encourage students to balance the equation first:

    2CO2 → 2CO + O2

    And add a multiplier in their code for the number of moles using the equation:

    (P/nT)carbon dioxide = (P/nT)carbon monoxide + (P/nT)oxygen


    (P/2T)carbon dioxide = (P/2T)carbon monoxide + (P/1T)oxygen
  6. Have students begin writing their code with each team member completing the task assigned by the group. Providing these hints and tips as needed:

    • The simplest place to begin is with the alarm for whether or not conditions are met. If students are just using Python, a team member can be charge of the parameters for success and the readout:
    • If students are using external devices or microcontrollers, they may want to use lights or sounds:
    • Suggest students create subsets of the data instead of operating off of the entire (very large!) spreadsheet. Which columns do they need for their plan? Can they test on a small set of lines first before running through every line?
    • As team members work through their tasks, they may see opportunities to tie code together into more effective solutions. This will likely include having the code do the calculations line by line and then be fed to the alarm:
    • If students are familiar with libraries, this presents a much faster and effective way to go through the thousands of lines of code:
    • As students test their code, have them look at separate sections of the data as subsets before looking at everything all at once. Does the data trigger more when the device is on or off, hot or cold? This may help students navigate any limitations to their code. Remind students to save small subsets of the original data file and label them clearly.
  7. Have student groups share their code and strategy with each other midway through the challenge to generate new ideas and solutions.
  8. Once they have finished creating their programs, have students share their final solutions, including considerations about the discussion prompts below.


  • Ask students where they set their alarm levels for the mass balance of oxygen produced. Why did they select this level? What could be done to improve it?
  • Encourage students to articulate the strengths and weaknesses of their solutions. Did the code take a long time because it was running line by line? How could it be made to run faster?
  • Thinking about the engineering of MOXIE, what assumptions were made about the process, and how did they affect our outcome? For example, if students used gas laws to get pressure, volume, and temperature, do those equations work in open systems like MOXIE or only in closed systems?


  • Consider using the provided engineering rubric or editing it to highlight your individual learning objectives.

  • Students should be able to evaluate the strengths and weaknesses of their model as well as the models of other students groups. Encourage students to articulate these pros and cons in a writing assignment to help them communicate the advantages of different solutions to the same problem.


If students haven't already tried it, task them with using physics to create a charge balance instead of using chemistry to generate a mass balance. Note that columns in the data should include volts and current. Because electrons have a known charge, it is possible (and more representative of the real MOXIE) to use Ohm’s Law, V = IR, to track how much oxygen is being produced.

Explore More