-
-
Notifications
You must be signed in to change notification settings - Fork 3
ySensorsService
Small application running on android. Target is to provide sensors from device to use it where you want it.
Sensors:
- gps
- accelerometer
- magnetometer
Supporting:
- reading gps, accelerometer, magnetometer
- sending data to mqtt
- providing simple nmea informations at :19889 tcp. Fix for bug in <5.0 opencpn if you have problem with jumping boat next to .00 of seconds in your location. On new phones I think it's 64 bit arch problem rounding in <5.0 opencpn have bug. Rounding when conversion is made from decimal location no nmea 0182 $xxRMC there is bug. If fractions of seconds in your location is starting from .0054 you will be at .54 location it's happening at latitude and longitude and jump is appearing. This App is making conversion different way and it's hosted at tcp :19889 of the device running this.
- accelerometer, magnetometer rotation correction (setting and data on mqtt for now)
- adjustable refresh speed
Videos:
https://www.youtube.com/watch?v=mAqlO0_Jui0
I'm assuming that you have finished installation 01 and 02.
next step is to install ySensorsService.apk on device. Idea is that this device will be permanently attache to (in my case boat) so I will have motion on the device the same as the boat. :) Apk file is at main repository in _apk folder get newest version install it at the device. At first start you will have permissions requests. and then main screen will show up. In Mqtt url: set it to your device ip where you have your mosquitto from installation 02
if it's the same device it can be:
tcp://127.0.0.0:10883
press save settings
close the app
turn on your location in android
in termux terminal can by by loging by ssh enter command
$ am broadcast --user 0 -n pl.yoyo.ysensorsservice/.MyBroadcastReceiver -a pl.yoyo.ysensorsservice.intent.START_SERVICE --es socket_output "abc"
it should bring location icon next to clock up. or if you have > 7.0 android it will bring up notification that service is running
to check it enter command in termux
$ mosquitto_sub -t 'and/#' -p 10883 -V mqttv311 -d
it will show messages send by ySensorsService on mqtt layer :) nice !!
CTRL-c will kill process
on different device you can chack tcp layer nmea 0182. on linux in terminal use
@pc$ nc 192.168.43.241 19889
your ip adreess can be different in install 01 you can find how to get it for yours case.
after executing we will see $YSPING,, and $YSRMC,.... lines !
nice
back to oiyshTerminal. open web brawser and go to yours node-red service for me it's http://192.168.43.241:1880
in top right corner in menu select import. past code:
[ { "id": "21d6c7297be499c4", "type": "mqtt in", "z": "c7355d1ee607eb8f", "name": "", "topic": "and/mag", "qos": "2", "datatype": "auto", "broker": "229c7e793ed13195", "nl": false, "rap": true, "rh": 0, "inputs": 0, "x": 120, "y": 220, "wires": [ [ "7f40ad6242497ea5" ] ] }, { "id": "7f40ad6242497ea5", "type": "function", "z": "c7355d1ee607eb8f", "name": "", "func": "node.status({\n text: \"HDG:\"+msg.payload\n \n});", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 300, "y": 220, "wires": [ [] ] }, { "id": "229c7e793ed13195", "type": "mqtt-broker", "name": "MqttAtLocal", "broker": "localhost", "port": "10883", "clientid": "NRclient", "autoConnect": true, "usetls": false, "protocolVersion": "4", "keepalive": "60", "cleansession": true, "birthTopic": "", "birthQos": "0", "birthPayload": "", "birthMsg": {}, "closeTopic": "", "closeQos": "0", "closePayload": "", "closeMsg": {}, "willTopic": "", "willQos": "0", "willPayload": "", "willMsg": {}, "sessionExpiry": "" } ]
at the bottom select new flow. press import. put nodes on canvas.
at top right press deploy. if all is good you will have:
node pinkish "and/mag" line to node "function" and under it HDG: of your device !
NICE
now stop ySensorService by running in termux terminal command
_$ am broadcast --user 0 -n pl.yoyo.ysensorsservice/.MyBroadcastReceiver -a pl.yoyo.ysensorsservice.intent.STOP_SERVICE --es socket_output "abc" _
you will see HDG: under node not updating.
For now it work only on mqtt layer. It's listen at (clientName)/cmd topic some commands.
ping - to get pong
sensorsEvery:? - get current sensor broadcast every iter
sensorsEvery:10 - 10 is how often it will push sensors to mqtt
magOffset:? - get current magnetic hdg offset
magOffset:10 - set magnetic offset to 10
accelCorrect:? - get current accel rotation correction
accelCorrect:90,0,180 - set correction accel rotation by 90,0,180
more is comming
in directory you can find two sub directories. debug and production both are the same but. Debug is for testing if you want to send command to service from example pc by usb cable by adb. Production is for sending command to ySensorsService from termux or nodeRed. So it's not using adb it's directly sending am broadcast.
shDisplayOff.sh - TODO not working currently
shDisplayOn.sh - turn screen on when it's off
shSpeedFast.sh - make sensors reading really fast (not recommend)
shSpeedSlow.sh - make sensors read slow
shSpeedStandBy.sh - make sensors read in standby setting "sensorsEvery:30" is default
shStartService.sh - start service it's not checking if one instance is working. So it can start many times. Not good.
shStopService.sh - stop service