How to display sensor values to a local web server?


Hi, I have a simple project where I want to display a DHT sensor values to a local web server.

I have managed to display the values through AWS and Losant. But, I haven’t managed to display the values locally. I have no clue what syntax or code in Mongoose I should use to connect the .js file and .html file.

If you have some other way to display the values locally, please feel free to suggest it.
Thanks in advance.

Here’s some references for the code I used :
DHT sensor
This is my goal:



Create a RPC function which returns a json string, eg. {temp: 23, humid: 45}
Call this function in your html code and display the data.

You will need the rpc-common, http-server and if you want to use websockets the rpc-ws libraries to be added in mos.yml.

1 Like

Thank you for replying

I added the libraries you mentioned and these lines on my js code:

let t = dht.getTemp();
let h = dht.getHumidity();

RPC.addHandler('StatusDHT', function(){
  return JSON.stringify({
      temp  : t,
      humid : h

Are these lines correct for defining an RPC function?

And sorry I’ve tried searching, but I still don’t know how to call an RPC function on my html file.
I’ve added this line on html to connect both files.

<script src="init.js"></script>

Could you help me on how to call the function?
Thanks again for helping.


Have a look at wifi-setup-web and wifi-setup-web-ui