I am currently working on Project 3.1 in the Web Server course and it seems to be working fine. I would, however, like to convert the temperature to F and the pressure to mmHg. I see that this question was asked approximately two years ago, but the javascript file has apparently been modified since that time and the answer given does not apply to the current file provided in the course. I would like information on where to do the conversions both in the javascript file and the HTML file. I would not, of course, be doing the conversion in both files simultaneously but would like to test it on both the client side and the server side separately.
Thanks,
Ed Wilson
Hi.
The best way is to make the conversions on the Arduino sketch.
This is the formula to convert to F
tempF = tempC x 1.8 +32
So, you need to change the following line:
readings["temperature"] = String(bme.readTemperature());
To
readings["temperature"] = String(bme.readTemperature()*1.8 + 32);
Proceed similarly to convert pressure.
On the JavaScript file, you can proceed in a similar way. Instead of:
document.getElementById("temp").innerHTML = myObj.temperature;
You should have
document.getElementById("temp").innerHTML = myObj.temperature*1.8 +32;
Regards.
Sara
Sara,
Again, thank you for your response to my question. I did figure out how to do the conversions in the main function, but I wanted to try it in javascript as well.
You may mark this question as resolved.
Ed Wilson