• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

3.1 Web Server: Dislay Sensor Readings

Q&A Forum › Category: ESP32 › 3.1 Web Server: Dislay Sensor Readings
0 Vote Up Vote Down
Edward Wilson asked 3 years ago

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

3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

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

0 Vote Up Vote Down
Edward Wilson answered 3 years ago

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

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Great!
I’ll mark this issue as resolved. If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.