diff --git a/examples/javascript/mhz16.js b/examples/javascript/mhz16.js index cfa410fd..71ded009 100644 --- a/examples/javascript/mhz16.js +++ b/examples/javascript/mhz16.js @@ -47,16 +47,17 @@ console.log(outputStr); outputStr = "but rather the temperature of the sensor elements."; console.log(outputStr); -var gas = CO2_lib.new_intp(); -var temp = CO2_lib.new_intp(); - function writeCO2data() { - myCO2_obj.getData(gas, temp); - outputStr = "CO2 concentration: " + CO2_lib.intp_value(gas) + - " PPM, " + - "Temperature (in C): " + CO2_lib.intp_value(temp); - console.log(outputStr); + if (!myCO2_obj.getData()) + console.log("Failed to retrieve data"); + else + { + outputStr = "CO2 concentration: " + myCO2_obj.getGas() + + " PPM, " + + "Temperature (in C): " + myCO2_obj.getTemperature(); + console.log(outputStr); + } } var myInterval; setTimeout(function() diff --git a/examples/python/mhz16.py b/examples/python/mhz16.py index 33f5ac98..4fa0615a 100644 --- a/examples/python/mhz16.py +++ b/examples/python/mhz16.py @@ -56,16 +56,15 @@ print ("Make sure that the sensor has had " "The temperature reported is not the ambient temperature,\n" "but rather the temperature of the sensor elements.") -gas = upmMhz16.new_intp() -temp = upmMhz16.new_intp() - time.sleep(1) while(1): - myCO2.getData(gas, temp) - outputStr = ("CO2 concentration: {0} PPM, " - "Temperature (in C): {1}".format( - upmMhz16.intp_value(gas), upmMhz16.intp_value(temp))) - print outputStr + if (not myCO2.getData()): + print "Failed to retrieve data" + else: + outputStr = ("CO2 concentration: {0} PPM, " + "Temperature (in C): {1}".format( + myCO2.getGas(), myCO2.getTemperature())) + print outputStr time.sleep(2)