Dear all ,
I have application php/html , I want to read (via AJAX ) value of sensor via node red ?
Someone has idea how to read value sensor via AJAX ?
thanks
You posted in the incorrect area of the forum.
If I understand it correctly, you want to read a sensor value from your php application. You can accomplish this by setting up an http endpoint. In the documentation you will find the “cookbook” with examples. It comes down to: setup a certain url, get the sensor value, set that as a response.
I want send data to my private dashbord without node red
I want read data sensor via node red and send it to my private dashbord(in php /html)
[{"id":"2c536f36.9fef7","type":"tab","label":"Flow 12","disabled":false,"info":""},{"id":"fae77e41.e4291","type":"inject","z":"2c536f36.9fef7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"power\":500,\"cosphi\":0.98,\"status\":\"ok\"}","payloadType":"json","x":140,"y":100,"wires":[["97e88997.b95288"]]},{"id":"97e88997.b95288","type":"http request","z":"2c536f36.9fef7","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"localhost:1880/test/energie","tls":"","persist":false,"proxy":"","authType":"","x":360,"y":120,"wires":[["1db0a089.213b5f"]]},{"id":"1db0a089.213b5f","type":"debug","z":"2c536f36.9fef7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":560,"y":160,"wires":[]}]
As said, you can do this with a http end-point;
- update the sensor data as a flow variable
- set up an end-point which retrieves the flow variable and expose it to an url.
example flow
[{"id":"e8ab1382.d91dc","type":"http in","z":"2c536f36.9fef7","name":"","url":"/test","method":"get","upload":false,"swaggerDoc":"","x":202,"y":288,"wires":[["c00327db.80111"]]},{"id":"c77d0d3a.702e6","type":"http response","z":"2c536f36.9fef7","name":"","statusCode":"","headers":{"content-type":"application/json"},"x":530,"y":288,"wires":[]},{"id":"1b528541.50d223","type":"inject","z":"2c536f36.9fef7","name":"Sensor data input","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"power\":500,\"cosphi\":0.98,\"status\":\"ok\"}","payloadType":"json","x":234,"y":216,"wires":[["3a483e00.946312"]]},{"id":"3a483e00.946312","type":"change","z":"2c536f36.9fef7","name":"","rules":[{"t":"set","p":"sensor","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":442,"y":216,"wires":[[]]},{"id":"c00327db.80111","type":"change","z":"2c536f36.9fef7","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"sensor","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":368,"y":288,"wires":[["c77d0d3a.702e6"]]}]
- Press the inject node.
- Open a browser tab and go to
http://<yournode-red-ip:1880>/test/
You will get the json output, this url you can use in your custom html application
thanks for your reply
it is working fine
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.