NodeRed live location

I need help in how i can plot the coordinates lat , lon, in the map. I'm using serial port to get data from Arduino. what should I do next to plot it

Have a look at the this flow just posted by one of the other prolific authors on here @dynamicdave - shows how to integrate a map and data - should get you going in the right direction

Craig

thanks , but i got my data from NEO-6m and it's appears in debug and I want to plot on map

Did you load his code and have a look at how he did it ? i.e. interacted with a map etc ?

I assume that you

  1. have got the data in NR which you have confirmed
  2. Now need to know how to display a map in NR that accepts the input co-ordinates and then displays the map centred on that location ?

have a look at Dynamic Daves stuff to get you on the right track and then post up a flow when you start experimenting

Craig

i know how to display the map in NR but the coordinates do not go to the map. that's what I need to know how I can do it

What map node are you using - surely it tells you in the help how to post co-ordinates to it ?

It looks like you are using node-red worldmap - by @dceejay ??

If so the help is pretty explicit about what to do

Usage

Plots "things" on a map. By default the map will be served from {httpRoot}/worldmap , but this can be configured in the configuration panel.

Use keyboard shortcut ⌘⇧m , ctrl-shift-m to jump to the map.

The minimum msg.payload must contain name , lat and lon properties, for example

msg.payload = { "name":"Jason", "lat":51.05, "lon":-1.35 }

Is this the correct node ?

In your debug you do not appear to have a name ? and appear to have added a date field

Craig

what about now assigning the value to lat , lon but its field I think is because the data type is string right? if yes how can I convert it ?

In there you have not got the lat and long - they are showing as undefined ? - although you do have a name

So can you confirm which worldmap you are using ?

have you read the help about the options - other than what i posted ?

Craig

i'm using worldmap , and the data is showing as string

Whatever change you made to the processing of lat and long since 04:24 has broken it because they now show as undefined.

you can see here it shows the data from the upper debug, but when it crosses the function looks undefined from lower debug


Yes in your function node you are trying to access the lat and lon as if the information is held in a Javascript object - it isnt - it is a string

  1. Put a name on your debug objects so we know what we are looking at
  2. enable the debug from the serial port and show me what it is showing you

Craig

you will need to split this stuff out to make it accessible. It appears to be some combination of formats so may take a while to get right

I would suggest you try with a JSON node first and tell it to turn it into an object and show us the debug of the complete msg (remember to name the debug node)

You can also try the split node and see if that gives better results

Craig

Just woken up here in the UK.

I agree with @craigcurtin - you need to split out the string to get the 'lat' and 'lon' values.

I've very quickly modified my Wildfires flow and turned it into a very simple position indicator for the ISS.

Once you have split out your values you could probably make use of the last two nodes in this flow.

[{"id":"605c9ce313e4a5a7","type":"ui_worldmap","z":"a9b12d67e974b017","group":"d4d2c5a78449ad8a","order":1,"width":18,"height":14,"name":"fires","lat":"51","lon":"0","zoom":"4","layer":"EsriS","cluster":"","maxage":"","usermenu":"show","layers":"show","panit":"true","panlock":"false","zoomlock":"false","hiderightclick":"true","coords":"none","showgrid":"false","allowFileDrop":"false","path":"/worldmap","overlist":"CO,RA,DN","maplist":"EsriS,EsriT,NatGeo","mapname":"","mapurl":"","mapopt":"","mapwms":false,"x":830,"y":440,"wires":[]},{"id":"060a72676e03f9d3","type":"inject","z":"a9b12d67e974b017","name":"Trigger every 5-secs","props":[{"p":"headers","v":"{\"Accept\":\"text/json\"}","vt":"json"},{"p":"url","v":"http://api.open-notify.org/iss-now.json","vt":"str"}],"repeat":"5","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":200,"y":440,"wires":[["3b88474842c4750d"]]},{"id":"3b88474842c4750d","type":"http request","z":"a9b12d67e974b017","name":"Get ISS coordinates","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":440,"y":440,"wires":[["6b32ca2b8bafb6cf"]]},{"id":"6b32ca2b8bafb6cf","type":"function","z":"a9b12d67e974b017","name":"Extract lat, lon","func":"let out = [];  // Declare an array\n\nlet id  = \"ISS\";\nlet lat = \"\";\nlet lon = \"\";\n\nlon = msg.payload.iss_position.longitude;\nlat = msg.payload.iss_position.latitude;\n\nout.push({\"name\": id, \"lat\": lat, \"lon\": lon, \"layer\": \"ISS track\", \"icon\": \"fa-space-shuttle\"});\n\nmsg.payload = out;\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":440,"wires":[["605c9ce313e4a5a7"]]},{"id":"d4d2c5a78449ad8a","type":"ui_group","name":"World_map","tab":"47ec854f298fe1a9","order":1,"disp":true,"width":"18","collapse":false,"className":""},{"id":"47ec854f298fe1a9","type":"ui_tab","name":"Wild_fires","icon":"dashboard","order":40,"disabled":false,"hidden":false}]

And here is a bit of JSONATA ugliness that could do it for you also (don't blame me i am just learning JSONATA) !!

[{"id":"a5ce70a5.b7ab8","type":"change","z":"c78e3c9a.7b1ca","name":"","rules":[{"t":"set","p":"Lon","pt":"msg","to":"$number($substringAfter($$.payload, \", Lon: \"))","tot":"jsonata"},{"t":"set","p":"Lat","pt":"msg","to":"$number($substringAfter($substringBefore($$.payload, \",\"),\"Lat: \"))","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":420,"wires":[["29f139ab.a1e136"]]},{"id":"95b52563.300cf8","type":"inject","z":"c78e3c9a.7b1ca","name":"Test inject","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Lat: 25, Lon: 29","payloadType":"str","x":230,"y":420,"wires":[["a5ce70a5.b7ab8","d593e94d.836878"]]},{"id":"d593e94d.836878","type":"debug","z":"c78e3c9a.7b1ca","name":"before change","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":360,"wires":[]},{"id":"29f139ab.a1e136","type":"debug","z":"c78e3c9a.7b1ca","name":"after change","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":790,"y":420,"wires":[]}]

Craig

1 Like

Looks like you could be very near to having a solution with @craigcurtin JSONata in the 'change' node.

You just need to move things around so the 'lat' and 'lon' are in the correct places for the Worldmap node.

Thanks so much, but I'm confused now about how I can sort the flow to make it correct cuz I try to replace COM5 with Test inject and still not working


YOu have changed something - before you had more data incoming on the COm Port - for instance the date was in there ?

Show us the output from my test flow that i sent you firstly

And then show us the complete message object from the COM port again

What i showed you was an example with test data - to show you how it could be done

Craig

Craig