GPS Plugin P082

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

GPS Plugin P082

#1 Post by Sasch600xt » 11 Sep 2021, 19:09

Hello all :)

Today I made my first experience with the GPS plugin.
First, thank you for this great and easy way to connect a GPS sensor to the esp :)

I know it is in beta phase, but may I say what I recognized today ?

- sometimes I get some impossible values for speed, like I drive about 70 kph, and it jumps down to 20kph or up to 350kph.
- I would love to set the decimal to 0 to get an integer of kph. To format the value is not working at the moment.
- I love the feature to publish my data depends on travelled meters. What about 3 steps to set ? Something like "speed under 10 kph" = 10 meters, "speed between 10 kph and 70 kph" = 100meters, "speed over 70 kph" = 300 meters
with this feature, I could save a little data volume at my sim card in my mobile router :)

It was easy to set up in my car today. Thanks a lot for your great work and have a great day :)
Sascha
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 5552
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: GPS Plugin P082

#2 Post by TD-er » 11 Sep 2021, 19:42

The "interval" in meters was mainly added to be able to store samples with a regular sample interval regardless the speed.
So to store in to flash using the "cache controller".
That's one of the more practical use cases using GPS, as you are likely not in the range of WiFi.

I can have a look at a more stepped interval, but I think it may be a bit difficult in practice as your "speed" may be quite high when standing still at a fixed location.
As a matter of fact, I have been working on filtering the speed reported by the GPS module as this can be a problem on a static location.

As long as the displacement is within HDOP * N you need quite a lot of filtering.
N depends on the used GPS receiver, but is typically between 8 and 30.
HDOP is reported by the GPS and is a standard deviation, expressed in N meters.
HDOP means Horizontal Dilution Of Precision.
It mainly depends on the SNR of the satellite signal and the largest angle between tracked satellites.
A small angle means large error. Just try to pinpoint the point where 2 circles intersect when their center is close to each other.

The speed is not in km/h, but in m/sec.
So you must multiply it by 3.6 to get km/h.
Wherever you use that value, you can already format it to 0 decimals.
See: https://espeasy.readthedocs.io/en/lates ... red-values

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#3 Post by Sasch600xt » 11 Sep 2021, 20:02

Hello TD-er,

I forgot to tell i multiplied by 3.6 already :)
Screenshot 2021-09-11 195155.jpg
Screenshot 2021-09-11 195155.jpg (39.42 KiB) Viewed 3553 times
Thank you for the hint about the post formatting.
I'll have a look right now :)

I do not have Wi-Fi only, I am online all the time with my car.
So for this case I'll have to take care about my data traffic.
This is why I thought it would be a great idea with the speed related upload :)

While my car is not moving, 22 km/h was the maximum I have seen, so this would not too much affect the idea, i guess.

To be honest, the impossible values are what I don't like most.
So for now I try to filter it out of the raw values in my backend of my house control software

Great job of you, like usually :) thank you for your service !
Have a great evening
Sascha
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 5552
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: GPS Plugin P082

#4 Post by TD-er » 11 Sep 2021, 22:40

You can also combine the "distance" and "interval"
For example, if you don't move too much, you probably don't need too many updates.
So you can set the interval to 300 sec (5 minutes) and the distance to 1 km.
When travelling at 120 km/h you have still 2 updates per minute, and when parked only one per 5 minutes.

You can also try to process the items in the rules to apply "filtering" when to send updates.
Still you can't rely on the reported speed when only using a few satellites.
Like I said, there needs to be some filtering implemented in the plugin.

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#5 Post by Sasch600xt » 14 Sep 2021, 10:06

Hello :)

yes, distance and travelled I combine already :)
Thank you for your ideas

I have 4 values in the plugin set up which works good (speed, alt, long,lat)
now I would love to publish a 5th value like ODO.

in rules i try:
Publish,"%sysname%/GPS/Distanz Trigger/ODO", [GPS#dist]

But it doesn't work so far ? Can i only publish values which are set up in the plugin ?
Do you see where I am doing something wrong here ?

Thank you and have a great day :)
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 5552
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: GPS Plugin P082

#6 Post by TD-er » 14 Sep 2021, 10:44

Yep, you cannot (yet) access the other values, not assigned to the task values.
However, it is useful to have it, so I was already thinking about allowing to reference other values, in a taskvalue like format to be used in rules.
For example the Eastron plugin would greatly benefit from it.

There is some catch here though. Some plugins only fetch whatever is defined as an output value, so the others may not be present.
The GPS pushes its messages anyway, so there is no gain in not fetching it, but for example Modbus devices may need to query them explicitly which takes time.

So this is for sure something that will be added in the future, but is not yet available.

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#7 Post by Sasch600xt » 14 Sep 2021, 10:48

YAY, that means I am doing nothing wrong here !!! LOL :)

Would it be easy to just add a 5th field for the plugin for now ?
otherwise, i will swap the value alt to dist
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 5552
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: GPS Plugin P082

#8 Post by TD-er » 14 Sep 2021, 11:21

Nope, that's not easy at all as this "4" of vars per task is used a lot in the code.
For example it wil render the settings incompatible.

It is easier to add this extra check for variables not sent via a controller to all plugins. :)

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#9 Post by Sasch600xt » 14 Sep 2021, 12:05

ok :)

i did swap alt with dist for now.

if i can breath i know i am below 6000 meter, so easy to check :)
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 5552
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: GPS Plugin P082

#10 Post by TD-er » 14 Sep 2021, 12:11

The reported altitude isn't really useful anyway.

You really need quite a lot of tracked satellites and even then the margin of error can be as high as 100m.
At least that's what I've seen on the Chinese uBlox clones.
So the margin of error is greater than the total altitude difference in the Netherlands ;)

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#11 Post by Sasch600xt » 14 Sep 2021, 12:33

hahahahaha, ok :)

by the way......do you know where i can buy an uBlox M8N ORIGINAL and not a clone ?
I would love to have a "real" one instead of the clones I have here...


Do you have an idea how I can store and publish the stored ODO value ?
At the moment always the ESP reboots, the ODO is zero again.
So i would love to have the "old ODO" somehow survive, add to the new one and publish.

Thank you so much for your help :)
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 5552
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: GPS Plugin P082

#12 Post by TD-er » 14 Sep 2021, 12:38

Hmm the ODO values are not stored in RTC, so they are indeed lost.
You could store them in a dummy, to at least survive a crash/reboot without loosing power.
But you cannot restore the ODO, so not sure if that's useful.

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#13 Post by Sasch600xt » 14 Sep 2021, 12:50

ok, i´ll try to solve this in my backend software behind the ESP :)
"the flat earth society has members all around the globe"

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#14 Post by Sasch600xt » 14 Sep 2021, 22:16

Hello,

i come right now back from more tests about the gps plugin and found a strange behavior.


i found out, my conversation in the plugin like %value%*3.6 for m/s into kph or %value%/1000 for meters into kilometers ist not always working and is been ignored sometimes and published without conversation.

Hope that helps
Sascha
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 5552
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: GPS Plugin P082

#15 Post by TD-er » 14 Sep 2021, 23:58

What build?
And also where do you put the conversion? How do you fetch the values?

If you address the values directly and not from the event, then I think I know what is happening here.

The plugin does put the values in the UserVar (the task value array) directly, while the formula is only called after a PLUGIN_READ was successful.
So if you need consistent behavior, you either need to use the values only from the eventvalues in the rules, or compute it in the rules using the let command.

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#16 Post by Sasch600xt » 15 Sep 2021, 09:00

Good morning :)

this build:
Screenshot 2021-09-15 085225.jpg
Screenshot 2021-09-15 085225.jpg (52.45 KiB) Viewed 3390 times


i do the conversation right in the plugin:
Screenshot 2021-09-11 195155.jpg
Screenshot 2021-09-11 195155.jpg (39.42 KiB) Viewed 3390 times
I have a display connected to the ESP in my car and i want the gps speed update every second.
So display and gps is set to 1 second interval.

this is why i do not publish all data to openHub Controller every second.
instead i use rules to do so.

Code: Select all

On Rules#Timer=2 do
  Publish,"%sysname%/GPS/Distanz Trigger/Speed", [GPS#spd#d2.0]
  Publish,"%sysname%/GPS/Distanz Trigger/Longitude", [GPS#long]
  Publish,"%sysname%/GPS/Distanz Trigger/Latitude", [GPS#lat]
  // Publish,"%sysname%/GPS/Distanz Trigger/Altitude", [GPS#alt#d0.0]
  Publish,"%sysname%/GPS/Distanz Trigger/ODO", [GPS#dist#d0.0]
  timerSet,2,120
endon

on GPS#travelled do
  Publish,"%sysname%/GPS/Distanz Trigger/Speed", [GPS#spd#d2.0]
  Publish,"%sysname%/GPS/Distanz Trigger/Longitude", [GPS#long]
  Publish,"%sysname%/GPS/Distanz Trigger/Latitude", [GPS#lat]
endon

Do you have an example how to use the let command in my case ?

Thank you very much ! :)
Sascha
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 5552
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: GPS Plugin P082

#17 Post by TD-er » 15 Sep 2021, 21:13

Code: Select all

on GPS#travelled do
  let,1,[GPS#spd#d2.0]*3.6 // Store speed in km/h in variable #1
  Publish,"%sysname%/GPS/Distanz Trigger/Speed", [int#1]
  Publish,"%sysname%/GPS/Distanz Trigger/Longitude", [GPS#long]
  Publish,"%sysname%/GPS/Distanz Trigger/Latitude", [GPS#lat]
endon
You first store the speed in km/h in variable #1.
When accessing this via [var#1] you get it as a floating point value.
But since you try to format it anyway, you can also fetch it as an integer value. [int#1]

You can store values in as many variables as you like.
For example you can also compute the average speed, since the GPS does output a new value every second.

Code: Select all

on GPS#travelled do
  let,1,[GPS#spd#d2.0]*3.6 // Store speed in km/h in variable #1
  let,2,[var#1}+[var#2] // collect the sum of all speeds in var#2
  let,3,[int#3]+1 // Count how many stored in the sum
  Publish,"%sysname%/GPS/Distanz Trigger/Speed", [int#1]
  Publish,"%sysname%/GPS/Distanz Trigger/Longitude", [GPS#long]
  Publish,"%sysname%/GPS/Distanz Trigger/Latitude", [GPS#lat]
endon

On Rules#Timer=2 do
  Publish,"%sysname%/GPS/Distanz Trigger/Speed", [GPS#spd#d2.0]
  Publish,"%sysname%/GPS/Distanz Trigger/Longitude", [GPS#long]
  Publish,"%sysname%/GPS/Distanz Trigger/Latitude", [GPS#lat]
  // Publish,"%sysname%/GPS/Distanz Trigger/Altitude", [GPS#alt#d0.0]
  Publish,"%sysname%/GPS/Distanz Trigger/ODO", [GPS#dist#d0.0]
  if [int#3] > 0
    let,4,[var#2]/[int#3]
  endif
  Publish,"%sysname%/GPS/Distanz Trigger/AvgSpd", [var#4#d2.0]
  let,2,0
  let,3,0
  timerSet,2,120
endon
The let command allows for all kinds of calculations.
In theory you could also do the computations in the publish command, but the calculations are then not always run as expected.
Using the let command it is way more predictable ;)

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#18 Post by Sasch600xt » 15 Sep 2021, 22:24

this is soooooo cool !!!

now i send traveled distance converted in km to my display which is connected to the ESP but at the same time publish it in meters to my controller hub.
This is amazing !! I love it :)
tomorrow i do some tests about the conversation errors in the plugin (which i dont need anymore be cause i´ll do it with custom variables)

maybe during winter i change my setup to an ESP32.

i am so exited lol :)

this is how it looks in my Software so far:
Screenshot 2021-09-15 172240.jpg
Screenshot 2021-09-15 172240.jpg (314.18 KiB) Viewed 3351 times
"the flat earth society has members all around the globe"

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#19 Post by Sasch600xt » 15 Sep 2021, 22:39

i want my display in my car refresh every second with the gsp speed.

ist it ok to have a timerinterval of one second, or is this too often ?

Code: Select all

On Rules#Timer=3 do
  let,1,[GPS#spd]*3.6 // Store speed in km/h in variable #1
  timerSet,3,1
endon
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 5552
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: GPS Plugin P082

#20 Post by TD-er » 15 Sep 2021, 22:55

1 sec interval is OK, as the GPS will output the same sequence of NMEA messages every second.

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#21 Post by Sasch600xt » 15 Sep 2021, 23:03

great :)

by the way, another esp with espeasy:
(have a look for uptime :))
Screenshot 2021-09-15 230158.jpg
Screenshot 2021-09-15 230158.jpg (43.5 KiB) Viewed 3344 times
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 5552
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: GPS Plugin P082

#22 Post by TD-er » 15 Sep 2021, 23:16

Close to 1 million minutes :)
Great :)

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#23 Post by Sasch600xt » 16 Sep 2021, 08:48

Good morning :)

I solved it at my backend software and i could also solve it in rules now,
but for next update, you could maybe change the value after reset.
The value for distance is "-1" after reset. If it could be "0" would great :)

It is also very dangerous on the highway !!!!
Consider driving with 120 km/h and the ESP resets, car do an emergency stop, drive back one meter and accelerate to 120 km/h again........
Not sure my breakfast would stay where it was before......
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 5552
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: GPS Plugin P082

#24 Post by TD-er » 16 Sep 2021, 08:51

The "-1" is a good indication it is not set. So you can check for it in the rules.
About your example... it gets even worse, as it is a distance and not speed.
That would mean you have to teleport back to the starting point (and beyond) and start over again.

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#25 Post by Sasch600xt » 16 Sep 2021, 09:00

your right :(
when i do a long ride over hundreds of kilometer and close to the goal the esp resets..... that would be depressing !
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 5552
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: GPS Plugin P082

#26 Post by TD-er » 16 Sep 2021, 12:20

On the other hand, if you need to get home quickly (e.g. stuck in a traffic jam), a reset of the ESP would be a nice feature :)
Let's hope nobody else is then parked on your spot.

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#27 Post by Sasch600xt » 16 Sep 2021, 12:42

at least not one meter behind my old spot ^^
"the flat earth society has members all around the globe"

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#28 Post by Sasch600xt » 16 Sep 2021, 21:34

i am back from testdrive :)

just want to let you know, the conversation in rules works perfect now !
no errors anymore, straight values every second.
Thank you for all your great hints :)

I am looking forward to use more then 4 parameters, but i can wait a long time for.

The "must" is working perfect now :)

Have a great evening
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 5552
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: GPS Plugin P082

#29 Post by TD-er » 16 Sep 2021, 21:44

Great to hear it is running fine now :)
Let's hope you still keep an eye on the road while driving.

User avatar
Sasch600xt
Normal user
Posts: 156
Joined: 10 Sep 2018, 16:37

Re: GPS Plugin P082

#30 Post by Sasch600xt » 16 Sep 2021, 22:17

my dashcams are connected to the esp and a few servos controlling the car.
most of the time i´m in the back, sleeping.

no, serious, my girlfriend helped me out and where looking at the tablet and the display.
so all was safe :)
"the flat earth society has members all around the globe"

TD-er
Core team member
Posts: 5552
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: GPS Plugin P082

#31 Post by TD-er » 16 Sep 2021, 22:37

Ah, so the WAF is strong in this one :)

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests