[example] GPS Sensor
-
Ok, my GPS sensor had been collecting dust in the drawer too long so I decided to create a MySensors example on how you could incorporate position data in a MySensors powered home automation setup.
I've used the GY-NEO6MV2 module containing a Ublox GPS which communicates serially with the Arduino.
So what should we use this for in a HA setup you might ask? Well the amount of use cases aren't exactly overwhelming but here are a few:
- Attach it to your robot lawn mower to get a notification when it has stuck somewhere.
- Build a gps tracked pet collar (preferably using the HW RF69 module for long range operation). Used for geo fencing the dog to get a notification when it runs away. Or why not use it while hunting?
- The GPS gives a very accurate (atomic) time information which can be used in the rest of your HA setup.
The (new) message type sent to controller contains latitude, longitude and altitude information.
Wiring it up is very simple:

3v3 or 5V to VCC
GND to GND
A0 to TXYou can of course change the A0 pin to something else in the code.
And here comes the example code. Note that this code only runs on the development branch. Codebender does not host this branch yet so you'll have to build it locally on your computer in the IDE:
https://codebender.cc/sketch:182035The module can be found here:
http://www.ebay.com/itm/390647042336?rmvSB=true
or
http://www.aliexpress.com/item/2pcs-lot-GY-NEO6MV2-new-GPS-module-with-Flight-Control-Flight-Control-EEPROM-MWC-APM2-5/1811853522.htmlOutput from Serial Monitor
send: 2-2-0-0 s=255,c=0,t=17,pt=0,l=10,sg=0,st=ok:1.6.0-beta send: 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0 sensor started, id=2, parent=0, distance=1 Position: 55.722511;13.018091;12 send: 2-2-0-0 s=1,c=1,t=49,pt=0,l=22,sg=0,st=ok:55.722511;13.018091;12 GPS Time: 11/08/2015 22:59:11 Position: 55.722527;13.018097;13 send: 2-2-0-0 s=1,c=1,t=49,pt=0,l=22,sg=0,st=ok:55.722527;13.018097;13 -
Nice example!!!
What I was thinking of, is can it also be a part of the gateway (GPS gateway). In that way things such as(just an example could also be connected to mysensors):
http://www.safewise.com/blog/10-wearable-safety-gps-devices-kids/
-
hi. trying to use the code but i'm getting problems with this line "MyMessage msg(CHILD_ID_GPS, V_POSITION);"
sketch_nov15a:68: error: 'V_POSITION' was not declared in this scope
sketch_nov15a.ino: In function 'void present()':
sketch_nov15a:93: error: 'sendSketchInfo' was not declared in this scope
sketch_nov15a:96: error: 'S_GPS' was not declared in this scope
sketch_nov15a.ino: In function 'void loop()':
sketch_nov15a:125: error: 'send' was not declared in this scope
'V_POSITION' was not declared in this scopeNot getting this to work at all
-
had to insert in the code "MySensor gw;" and some "gw." at sendSketchInfo and present to stop the errors, flash the code to arduino nano but no info at monitor serie or at domoticz gateway can't seem to find the gps...
No understanding the new problem...
-
Ok, my GPS sensor had been collecting dust in the drawer too long so I decided to create a MySensors example on how you could incorporate position data in a MySensors powered home automation setup.
I've used the GY-NEO6MV2 module containing a Ublox GPS which communicates serially with the Arduino.
So what should we use this for in a HA setup you might ask? Well the amount of use cases aren't exactly overwhelming but here are a few:
- Attach it to your robot lawn mower to get a notification when it has stuck somewhere.
- Build a gps tracked pet collar (preferably using the HW RF69 module for long range operation). Used for geo fencing the dog to get a notification when it runs away. Or why not use it while hunting?
- The GPS gives a very accurate (atomic) time information which can be used in the rest of your HA setup.
The (new) message type sent to controller contains latitude, longitude and altitude information.
Wiring it up is very simple:

3v3 or 5V to VCC
GND to GND
A0 to TXYou can of course change the A0 pin to something else in the code.
And here comes the example code. Note that this code only runs on the development branch. Codebender does not host this branch yet so you'll have to build it locally on your computer in the IDE:
https://codebender.cc/sketch:182035The module can be found here:
http://www.ebay.com/itm/390647042336?rmvSB=true
or
http://www.aliexpress.com/item/2pcs-lot-GY-NEO6MV2-new-GPS-module-with-Flight-Control-Flight-Control-EEPROM-MWC-APM2-5/1811853522.htmlOutput from Serial Monitor
send: 2-2-0-0 s=255,c=0,t=17,pt=0,l=10,sg=0,st=ok:1.6.0-beta send: 2-2-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0 sensor started, id=2, parent=0, distance=1 Position: 55.722511;13.018091;12 send: 2-2-0-0 s=1,c=1,t=49,pt=0,l=22,sg=0,st=ok:55.722511;13.018091;12 GPS Time: 11/08/2015 22:59:11 Position: 55.722527;13.018097;13 send: 2-2-0-0 s=1,c=1,t=49,pt=0,l=22,sg=0,st=ok:55.722527;13.018097;13@hek said:
- Attach it to your robot lawn mower to get a notification when it has stuck somewhere.
- Build a gps tracked pet collar (preferably using the HW RF69 module for long range operation). Used for geo fencing the dog to get a notification when it runs away. Or why not use it while hunting?
I'm in. For the mower.
For the radio, the lower frequency the better. But, we need a new gateway no ?
Or there is a trick, like a repeater node with two radio of different frequency ? -
Hi Guys,
new in this forum. really interresting project :-)
trid to follow your recommendations, but still have S_GPS error... do you have any developpment since the last message ?
i added the declared ligne in the MyMessage.h file, V_POSITION, but saw the S_GPS vairiable in the file.
what will need more ?
regards,
Franck
-
@hek said:
ode only runs on the development branch. Codebender does not host this branch yet so you'll have to build it locally on your computer in the IDE:
Thanks Hek for your fast answer. now i can compile it, but i have a radio init failed...
any idea ?
-
@hek said:
ode only runs on the development branch. Codebender does not host this branch yet so you'll have to build it locally on your computer in the IDE:
Thanks Hek for your fast answer. now i can compile it, but i have a radio init failed...
any idea ?
@drock1985 said:
Hey @Pierre-P
Yeah, you would need a new gateway for each radio type.
I found a new mysensors page ! here:
https://www.mysensors.org/download/sensor_api_15#create-repeating-nodesAdvanced initialization
It's also possible to construct an instance with RFM69 radio driver and/or enable signing support. You can choose one of the following radio drivers:
MyTransportNRF24 transport(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);or
MyTransportRFM69 transport(RFM69_FREQUENCY, RFM69_NETWORKID, RF69_SPI_CS, RF69_IRQ_PIN, isRFM69HW, RF69_IRQ_NUM);