Send data from local dust sensor to lufdaten

Hello, I have a question if is possible possible take data from my local dust sensor SDS011 send it to https://luftdaten.info/?
Thanks

Well there are some nodes for the SDS011 (I've never used them) so you can see if one of them will work to read the sensor, then it is a matter of sending the data to luftdaten.info. You will have to investigate how they want the data sent.

Thanks for reply.
I'm collecting data from SDS011 and the output is averaged over 24 hours, this is not a problem.
Problem is how send that data to luftdaten.
This is the Luftdaten API. I´m beginner. I don't know if it is possible to sending local data to luftdaten.


Pimoroni’s Enviro+ comes with sample code in Python to connect it to Luftdaten, maybe it will help you figure out how to set it up.

Looks simple enough.

@QSKONE, look at the code @afelix linked to. In particular the function named "send_to_luftdaten".

In node-red, you will need to use the http request node to send the required JSON & don't forget to set the headers.

I´m for test flash luftdaten firmware and this is maybe what sensor send out to luftdaten.
< link to image on external site removed >

Hello, can you help me? I have this error:

{"detail":"Unsupported media type "" in request."}

Imgur

Please don't link to images in an external site, you can paste the image directly into the message box. It is difficult to read what is in the debug window as it is so small but it looks as if you have a string in msg.payload starting with the text "msg.headers = ". I assume what you actually want is msg.headers set to something.
If you don't understand my comment then have a look in the node red docs at the section Working with Messages.

Sorry for links.

This is data from template node:

msg.headers = {},
msg.headers['X-Auth-User'] = 'Content-Type: application/json' ,  
'X-Pin: 1' , 
'X-Sensor: esp8266-568371 ', 

{
  "software_version": "NRZ- 2020129", 
  "sensordatavalues":[
    {"value_type":"P1","value":"66.04"},
    {"value_type":"P2","value":"53.32"}
  ]
}

msg.headers = {},
msg.headers['X-Auth-User'] = 'Content-Type: application/json' ,  
'X-Pin: 11' , 
'X-Sensor: esp8266-568371 ',

{
  "software_version": "NRZ- 2020129", 
   "sensordatavalues":[
     {"value_type":"temperature","value":"22.30"},
     {"value_type":"humidity","value":"34.70"},
     {"value_type":"pressure","value":"98000.00"}
  ]
}

A template node loads everything you put there into a single property of the msg (msg.payload in this case) which you can see from the debug node. As I said that is not what you want, you want to setup msg.headers with the javascript code that you have written. That should be in a function node not a template node.

Hello , here is my solution.
Best regards
QSK

[{"id":"168fbfbd.1b349","type":"tab","label":"Luftdaten","disabled":false,"info":""},{"id":"1813167.141efea","type":"mqtt in","z":"168fbfbd.1b349","name":"BME280+SDS011","topic":"tele/BME280/SENSOR","qos":"2","datatype":"auto","broker":"52473363.c6b6cc","x":150,"y":120,"wires":[["3958a1c6.48df1e"]]},{"id":"3958a1c6.48df1e","type":"json","z":"168fbfbd.1b349","name":"","property":"payload","action":"","pretty":false,"x":310,"y":120,"wires":[["99b86343.2a26a"]]},{"id":"99b86343.2a26a","type":"function","z":"168fbfbd.1b349","name":"function","func":"var msg1 = { payload:msg.payload.SDS0X1[\"PM2.5\"]};\nvar msg2 = { payload:msg.payload.SDS0X1.PM10};\nvar msg3 = { payload:msg.payload.BME280.Temperature};\nvar msg4 = { payload:msg.payload.BME280.Humidity};\nvar msg5 = { payload:msg.payload.BME280.Pressure};\n\n\nreturn [ msg1, msg2, msg3, msg4, msg5 ];","outputs":5,"noerr":0,"x":440,"y":120,"wires":[["e0f51e80.4a238"],["58945644.5999d8"],["1c48056c.70a14b"],["5a3f2910.7e99d8"],[]],"outputLabels":["Temp Max","Current Temp","","",""]},{"id":"e0f51e80.4a238","type":"change","z":"168fbfbd.1b349","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"pm25","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":80,"wires":[["c19b2e0d.beda2"]]},{"id":"58945644.5999d8","type":"change","z":"168fbfbd.1b349","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"pm10","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":140,"wires":[["c19b2e0d.beda2"]]},{"id":"af4e7c2e.af831","type":"function","z":"168fbfbd.1b349","name":"","func":"msg.headers = {\n    \"X-Pin\": \"1\",\n    \"X-Sensor\": \"esp8266-568371\"\n};\nmsg.payload = {\n    \"software_version\": \"NRZ- 2020129\",\n    \"sensordatavalues\": [\n        {\"value_type\": \"P1\", \"value\": parseFloat(msg.payload.pm25)},\n        {\"value_type\": \"P2\", \"value\": parseFloat(msg.payload.pm10)}\n    ]\n};\nreturn msg;","outputs":1,"noerr":0,"x":910,"y":120,"wires":[["68150b40.36a014"]]},{"id":"68150b40.36a014","type":"http request","z":"168fbfbd.1b349","name":"HTTP Request","method":"POST","ret":"txt","paytoqs":false,"url":"https://api.sensor.community/v1/push-sensor-data/","tls":"","persist":false,"proxy":"","authType":"","x":1080,"y":120,"wires":[[]]},{"id":"c19b2e0d.beda2","type":"join","z":"168fbfbd.1b349","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":790,"y":120,"wires":[["af4e7c2e.af831"]]},{"id":"1c48056c.70a14b","type":"change","z":"168fbfbd.1b349","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"temperature","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":200,"wires":[["678f932f.73f8cc"]]},{"id":"5a3f2910.7e99d8","type":"change","z":"168fbfbd.1b349","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"humidity","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":260,"wires":[["678f932f.73f8cc"]]},{"id":"4d7b2016.cae39","type":"function","z":"168fbfbd.1b349","name":"","func":"msg.headers = {\n    \"X-Pin\": \"11\",\n    \"X-Sensor\": \"esp8266-568371\"\n};\nmsg.payload = {\n    \"software_version\": \"NRZ- 2020129\",\n    \"sensordatavalues\": [\n        {\"value_type\": \"temperature\", \"value\": parseFloat(msg.payload.temperature)},\n        {\"value_type\": \"humidity\", \"value\": parseFloat(msg.payload.humidity)},\n        {\"value_type\": \"pressure\", \"value\": parseFloat(msg.payload.pressure)}\n    ]\n};\nreturn msg;","outputs":1,"noerr":0,"x":910,"y":260,"wires":[["bd990f55.fc82e"]]},{"id":"bd990f55.fc82e","type":"http request","z":"168fbfbd.1b349","name":"HTTP Request","method":"POST","ret":"txt","paytoqs":false,"url":"https://api.sensor.community/v1/push-sensor-data/","tls":"","persist":false,"proxy":"","authType":"","x":1080,"y":260,"wires":[[]]},{"id":"678f932f.73f8cc","type":"join","z":"168fbfbd.1b349","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":790,"y":260,"wires":[["4d7b2016.cae39"]]},{"id":"8456d0bc.fbecd","type":"comment","z":"168fbfbd.1b349","name":"Luftdaten","info":"","x":120,"y":80,"wires":[]},{"id":"52473363.c6b6cc","type":"mqtt-broker","z":"","name":"MQTT","broker":"192.168.86.2","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.