{"id":19491551,"url":"https://github.com/ev3dev-lang-java/batterymonitor","last_synced_at":"2025-02-25T19:45:28.613Z","repository":{"id":142583940,"uuid":"88273248","full_name":"ev3dev-lang-java/batteryMonitor","owner":"ev3dev-lang-java","description":"A Java/Scripts to monitor the battery to protect EV3Dev hardware","archived":false,"fork":false,"pushed_at":"2017-06-05T21:31:10.000Z","size":12587,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-08T08:46:25.847Z","etag":null,"topics":["bash-script","battery-monitor","brickpi","ev3","ev3dev","java","java-library","lejos","mindstorms","pistorms"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ev3dev-lang-java.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-14T14:14:03.000Z","updated_at":"2019-04-15T10:53:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"2f8cdb61-30db-4ed2-b46b-5fca24ffea3a","html_url":"https://github.com/ev3dev-lang-java/batteryMonitor","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ev3dev-lang-java%2FbatteryMonitor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ev3dev-lang-java%2FbatteryMonitor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ev3dev-lang-java%2FbatteryMonitor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ev3dev-lang-java%2FbatteryMonitor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ev3dev-lang-java","download_url":"https://codeload.github.com/ev3dev-lang-java/batteryMonitor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240738092,"owners_count":19849546,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash-script","battery-monitor","brickpi","ev3","ev3dev","java","java-library","lejos","mindstorms","pistorms"],"created_at":"2024-11-10T21:17:15.966Z","updated_at":"2025-02-25T19:45:28.606Z","avatar_url":"https://github.com/ev3dev-lang-java.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# batteryMonitor\nA Java Battery monitor for EV3Dev hardware.\n\n# User Story\n\n``` gherkin\nFeature: Develop a Java Battery Monitor process to protect Hardware.\n  \nScenario: EV3Dev Startup\nGiven A EV3Dev platform (EV3, Brickpi \u0026 PiStorms)\nWhen The user turn on the Brick \nThen A Java process will start monitoring the battery\n\nScenario: Default configuration\nGiven A EV3Dev platform (EV3, Brickpi \u0026 PiStorms)\nWhen The user turn on the Brick \nThen A Java process will start using default configuration. \nThe default configuration is: \n- THRESHOLD_VOLTAGE = 7.5v\n- LINUX_ACTION = `sudo shutdown now`\n```\n\n# Getting Started\n\nTo install this utility on your EV3 Brick, it is necessary to execute\nthe following steps:\n\n*Brick side*\n\n```\nmkdir batteryMonitor\n```  \n\n*Host side*\n\n``` bash\ngit clone https://github.com/ev3dev-lang-java/batteryMonitor.git\n./gradlew clean fatjar\nscp ./build/libs/batteryMonitor-all-0.1.0.jar robot@192168.1.85:/home/robot/batteryMonitor\nscp ./scripts/logback.xml robot@192168.1.85:/home/robot/batteryMonitor\nscp ./scripts/stop.sh robot@192168.1.85:/home/robot/batteryMonitor\nscp ./scripts/start.sh robot@192168.1.85:/home/robot/batteryMonitor\nscp ./scripts/batteryMonitor-service.sh robot@192168.1.85:/etc/init.d\nrobot@ev3dev:~$ java -server -jar batteryMonitor-all-0.1.0.jar\n```\n\n*Brick side*\n\n```\ncd batteryMonitor\nchmod +x ./start.sh\nchmod +x ./stop.sh\ncd /etc/init.d\nsudo chmod +x batteryMonitor-service.sh\nsudo update-rc.d batteryMonitor-service.sh defaults\nsudo reboot now\n``` \n\nIf now you reboot the system, you should see the process running:\n\n```\nrobot@ev3dev:~/batteryMonitor$ ps aux | grep java\nroot       298 10.3 29.0  87548 17024 ?        Sl   22:51   0:32 java -server -Dlogback.configurationFile=/home/robot/batteryMonitor/logback.xml -jar /home/robot/batteryMonitor/batteryMonitor-all-0.1.0-SNAPSHOT.jar\nrobot      543  0.0  2.2   2620  1300 pts/0    S+   22:56   0:00 grep java\n```\n\n# Customize logging\n\nEV3Dev-lang-java uses Logback as the default logging system and \nthe project includes a default configuration. \n\nIf you need to execute the project with another configuration the way \nto do it, it is simple. Create a new logback.xml file:\n\n``` xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cconfiguration scan=\"true\" scanPeriod=\"60 seconds\"\u003e\n\n    \u003cappender name=\"STDOUT\" class=\"ch.qos.logback.core.ConsoleAppender\"\u003e\n        \u003cencoder class=\"ch.qos.logback.classic.encoder.PatternLayoutEncoder\"\u003e\n            \u003cPattern\u003e\n                %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n\n            \u003c/Pattern\u003e\n        \u003c/encoder\u003e\n    \u003c/appender\u003e\n\n    \u003cappender name=\"FILE\" class=\"ch.qos.logback.core.FileAppender\"\u003e\n        \u003cfile\u003e/home/robot/batteryMonitor/logs/log-${byDay}.log \u003c/file\u003e\n        \u003cappend\u003etrue\u003c/append\u003e\n        \u003cencoder\u003e\n            \u003cpattern\u003e\n                %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n\n            \u003c/pattern\u003e\n        \u003c/encoder\u003e\n    \u003c/appender\u003e\n\n    \u003cappender name=\"STASH\" class=\"net.logstash.logback.appender.LogstashTcpSocketAppender\"\u003e\n        \u003cdestination\u003e192.168.1.100:5000\u003c/destination\u003e\n\n        \u003cencoder class=\"net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder\"\u003e\n            \u003cproviders\u003e\n                \u003cmdc/\u003e\n                \u003ccontext/\u003e\n                \u003cversion/\u003e\n                \u003clogLevel/\u003e\n                \u003cloggerName/\u003e\n\n                \u003cpattern\u003e\n                    \u003cpattern\u003e\n                        {\n                            \"appName\": \"elk-ev3-batteryMonitor\",\n                            \"appVersion\": \"0.1.0\"\n                        }\n                    \u003c/pattern\u003e\n                \u003c/pattern\u003e\n\n                \u003cthreadName/\u003e\n                \u003cmessage/\u003e\n                \u003clogstashMarkers/\u003e\n                \u003carguments/\u003e\n                \u003cstackTrace/\u003e\n            \u003c/providers\u003e\n        \u003c/encoder\u003e\n    \u003c/appender\u003e\n\n    \u003clogger name=\"ch.qos.logback.core\" level=\"OFF\" /\u003e\n    \u003clogger name=\"ev3dev.hardware\" level=\"OFF\" /\u003e\n    \u003clogger name=\"ev3dev.utils\" level=\"OFF\" /\u003e\n    \u003clogger name=\"ev3dev.utils.monitor\" level=\"TRACE\" /\u003e\n\n    \u003croot level=\"TRACE\"\u003e\n        \u003cappender-ref ref=\"STDOUT\"/\u003e\n        \u003cappender-ref ref=\"STASH\"/\u003e\n    \u003c/root\u003e\n\n\u003c/configuration\u003e\n```\n\nand later execute the jar with the following parameter:\n\n```\nrobot@ev3dev:~$ java -server -Dlogback.configurationFile=/home/robot/batteryMonitor/logback.xml -jar batteryMonitor-all-0.1.0.jar\n```\n\nFurther information about Logback configuration here:\n\nhttps://logback.qos.ch/manual/configuration.html\n\n## Logs\n\n```\ntail -f -n10 ./logs/log-20170422T205431.log\n2017-04-22 21:04:26 [main] INFO  e.utils.monitor.BatteryMonitorApp - Battery Monitor starting\n2017-04-22 21:04:39 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8305.9, Threshold: 8000\n2017-04-22 21:05:40 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8306.0, Threshold: 8000\n2017-04-22 21:06:41 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8305.8, Threshold: 8000\n2017-04-22 21:07:41 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8305.9, Threshold: 8000\n2017-04-22 21:08:41 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8305.9, Threshold: 8000\n2017-04-22 21:09:41 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8305.5, Threshold: 8000\n2017-04-22 21:10:41 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8228.0, Threshold: 8000\n2017-04-22 21:11:41 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8218.9, Threshold: 8000\n2017-04-22 21:12:42 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8217.9, Threshold: 8000\n2017-04-22 21:13:42 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8209.8, Threshold: 8000\n2017-04-22 21:14:42 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8207.8, Threshold: 8000\n2017-04-22 21:15:42 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8207.8, Threshold: 8000\n2017-04-22 21:16:42 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8197.7, Threshold: 8000\n2017-04-22 21:17:42 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8198.2, Threshold: 8000\n2017-04-22 21:18:42 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8190.0, Threshold: 8000\n2017-04-22 21:19:42 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8187.9, Threshold: 8000\n2017-04-22 21:20:42 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8187.9, Threshold: 8000\n2017-04-22 21:21:42 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8180.7, Threshold: 8000\n2017-04-22 21:22:42 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8179.8, Threshold: 8000\n2017-04-22 21:23:43 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8179.9, Threshold: 8000\n2017-04-22 21:24:43 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8170.9, Threshold: 8000\n2017-04-22 21:25:43 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8169.9, Threshold: 8000\n2017-04-22 21:26:43 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8169.9, Threshold: 8000\n2017-04-22 21:27:43 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8160.9, Threshold: 8000\n2017-04-22 21:28:43 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8159.9, Threshold: 8000\n2017-04-22 21:29:43 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8159.8, Threshold: 8000\n2017-04-22 21:30:43 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8150.9, Threshold: 8000\n2017-04-22 21:31:43 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8149.8, Threshold: 8000\n2017-04-22 21:32:43 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8149.9, Threshold: 8000\n2017-04-22 21:33:44 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8142.7, Threshold: 8000\n2017-04-22 21:34:44 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8133.9, Threshold: 8000\n2017-04-22 21:35:44 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8130.0, Threshold: 8000\n2017-04-22 21:36:44 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8129.7, Threshold: 8000\n2017-04-22 21:37:44 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8129.0, Threshold: 8000\n2017-04-22 21:38:44 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8120.9, Threshold: 8000\n2017-04-22 21:39:44 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8119.9, Threshold: 8000\n2017-04-22 21:40:44 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8119.9, Threshold: 8000\n2017-04-22 21:41:44 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8110.9, Threshold: 8000\n2017-04-22 21:42:44 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8110.9, Threshold: 8000\n2017-04-22 21:43:44 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8109.0, Threshold: 8000\n2017-04-22 21:44:45 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8105.8, Threshold: 8000\n2017-04-22 21:45:45 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8102.7, Threshold: 8000\n2017-04-22 21:46:45 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8101.9, Threshold: 8000\n2017-04-22 21:47:45 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8101.9, Threshold: 8000\n2017-04-22 21:48:45 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8092.9, Threshold: 8000\n2017-04-22 21:49:45 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8091.9, Threshold: 8000\n2017-04-22 21:50:45 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8091.9, Threshold: 8000\n2017-04-22 21:51:45 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8082.9, Threshold: 8000\n2017-04-22 21:52:45 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8083.8, Threshold: 8000\n2017-04-22 21:53:45 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8081.9, Threshold: 8000\n2017-04-22 21:54:45 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8072.9, Threshold: 8000\n2017-04-22 21:55:45 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8073.8, Threshold: 8000\n2017-04-22 21:56:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8071.9, Threshold: 8000\n2017-04-22 21:57:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8071.8, Threshold: 8000\n2017-04-22 21:58:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8062.9, Threshold: 8000\n2017-04-22 21:59:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8061.8, Threshold: 8000\n2017-04-22 22:00:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8061.9, Threshold: 8000\n2017-04-22 22:01:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8052.9, Threshold: 8000\n2017-04-22 22:02:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8051.9, Threshold: 8000\n2017-04-22 22:03:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8051.0, Threshold: 8000\n2017-04-22 22:04:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8046.8, Threshold: 8000\n2017-04-22 22:05:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8044.5, Threshold: 8000\n2017-04-22 22:06:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8041.7, Threshold: 8000\n2017-04-22 22:07:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8041.6, Threshold: 8000\n2017-04-22 22:08:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8032.9, Threshold: 8000\n2017-04-22 22:09:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8031.8, Threshold: 8000\n2017-04-22 22:10:46 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8031.8, Threshold: 8000\n2017-04-22 22:11:47 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8022.0, Threshold: 8000\n2017-04-22 22:12:47 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8021.9, Threshold: 8000\n2017-04-22 22:13:47 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8021.7, Threshold: 8000\n2017-04-22 22:14:47 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8017.8, Threshold: 8000\n2017-04-22 22:15:47 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8015.4, Threshold: 8000\n2017-04-22 22:16:47 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8014.0, Threshold: 8000\n2017-04-22 22:17:47 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8014.0, Threshold: 8000\n2017-04-22 22:18:47 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8003.9, Threshold: 8000\n2017-04-22 22:19:47 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8004.0, Threshold: 8000\n2017-04-22 22:20:47 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 8003.9, Threshold: 8000\n2017-04-22 22:21:47 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Current voltage: 7994.9, Threshold: 8000\n2017-04-22 22:21:47 [pool-1-thread-1] DEBUG ev3dev.utils.monitor.BatteryTask - Reached battery threshold\n2017-04-22 22:21:47 [main] DEBUG ev3dev.utils.monitor.BatteryExecutor - Thread Pool Shutdown\n2017-04-22 22:21:52 [main] DEBUG ev3dev.utils.monitor.BatteryExecutor - Executing action: sudo shutdown now\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fev3dev-lang-java%2Fbatterymonitor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fev3dev-lang-java%2Fbatterymonitor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fev3dev-lang-java%2Fbatterymonitor/lists"}