{"id":22468529,"url":"https://github.com/projectweekend/pi-sensor-rpc-service","last_synced_at":"2025-03-27T15:44:47.191Z","repository":{"id":23821414,"uuid":"27198212","full_name":"projectweekend/Pi-Sensor-RPC-Service","owner":"projectweekend","description":"An RPC service providing sensor data from Ar-Starbug (https://github.com/projectweekend/Ar-Starbug) using RabbitMQ","archived":false,"fork":false,"pushed_at":"2014-12-11T11:47:53.000Z","size":260,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T19:29:50.151Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/projectweekend.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-26T22:05:19.000Z","updated_at":"2020-11-18T21:41:22.000Z","dependencies_parsed_at":"2022-08-22T00:00:16.307Z","dependency_job_id":null,"html_url":"https://github.com/projectweekend/Pi-Sensor-RPC-Service","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectweekend%2FPi-Sensor-RPC-Service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectweekend%2FPi-Sensor-RPC-Service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectweekend%2FPi-Sensor-RPC-Service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectweekend%2FPi-Sensor-RPC-Service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/projectweekend","download_url":"https://codeload.github.com/projectweekend/Pi-Sensor-RPC-Service/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245874204,"owners_count":20686726,"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":[],"created_at":"2024-12-06T11:17:17.352Z","updated_at":"2025-03-27T15:44:47.156Z","avatar_url":"https://github.com/projectweekend.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"This project runs on a Raspberry Pi connected, via serial port, to an Arduino ([Ar-Starbug](https://github.com/projectweekend/Ar-Starbug)) that monitors a few sensors. **Pi-Sensor-RPC-Service** connects to a [RabbitMQ](http://www.rabbitmq.com/) server and listens for messages. When a message is received on the appropriate queue, the sensor data is read and returned to the client that sent the message. This architecture makes it simple for any process, running anywhere (like [Holly](https://github.com/projectweekend/Holly)), to access the sensor data as needed.\n\n\n### Installation with Fabric\n\nUsing [Fabric](http://www.fabfile.org/) there is an installation task included in this project's `fabfile`. With the Raspberry Pi connected to the same network as your computer, run the following command:\n\n```\nfab raspberry_pi install\n```\n\nThe task will prompt you for these values:\n\n* `Raspberry Pi:` - The hostname of the Raspberry Pi, for example: `red-dwarf`. Given the example, the Fabric script will attempt to ssh into `red-dwarf.local`.\n* `Loggly token:` - The token from your [Loggly](https://www.loggly.com/) account. The service logs data using Loggly which makes it easier to remotely monitor.\n* `Loggly domain:` - The domain from your Loggly account.\n* `Rabbit URL:` - The connection URL for the RabbitMQ server. If you don't feel like running your own, check out [CloudAMPQ](https://www.cloudamqp.com/).\n\nThe install process will add an [Upstart](http://upstart.ubuntu.com/) script that will handle starting/stopping the service when the Raspberry Pi starts up or shuts down.\n\nTo manually stop it:\n```\nsudo service sensor-rpc stop\n```\n\nTo manually start it:\n```\nsudo service sensor-rpc start\n```\n\n\n### Environment Variables\n\nThe following environment variables can be used to control configuration. The required items are auto-populated via the install task.\n\n* `RABBIT_URL` - Required - The connection URL for the RabbitMQ server. If you don't feel like running your own, check out [CloudAMPQ](https://www.cloudamqp.com/).\n* `LOGGLY_TOKEN` - Required - The token from your [Loggly](https://www.loggly.com/) account. The service logs data using Loggly which makes it easier to remotely monitor.\n* `LOGGLY_SUBDOMAIN` - Required - The domain from your Loggly account.\n* `SENSOR_QUEUE` - Optional - The name of the queue to use. Defaults to `sensor.get`.\n* `SENSOR_LOGGLY_TAG` - Optional - The tag name to use in Loggly when recording items. Defaults to `Pi-Sensor-RPC-Service`.\n* `SERIAL_ADDRESS` - Optional - The serial address to use. Defaults to `/dev/ttyAMA0`.\n* `SERIAL_RATE` - Optional - The baud rate for the serial connection. Defaults to `9600`.\n* `SERIAL_READ_INTERVAL` - Optional - The interval, in milliseconds, used for checking the serial line for new data. Defaults to `50`.\n\n\n### Usage\n\nAny script or program can request data from this sensor provided:\n\n* It has the same `Rabbit URL` value used during installation and can connect to the RabbitMQ server.\n* It sends messages to the correct queue (`sensor.get` in this project).\n\n#### JavaScript Example\n\nThere are plenty of JavaScript client libraries for RabbitMQ. This example uses [Jackrabbit](https://github.com/hunterloftis/jackrabbit).\n\n```javascript\nvar jackrabbit = require( \"jackrabbit\" );\n\n// Use an environment variable for RABBIT_URL\nvar broker = jackrabbit( process.env.RABBIT_URL, 1 );\n\nvar ready = function () {\n    // Send a message to request the sensor data\n    broker.publish( \"sensor.get\", { serialMessage: \"A\" }, function ( err, data ) {\n        if ( err ) {\n            // Do something with the error\n            console.log( err );\n        }\n        // Do something with the sensor data\n        console.log( data );\n        process.exit();\n    } );\n};\n\nvar create = function () {\n  broker.create( \"sensor.get\", { prefetch: 5 }, ready );\n};\n\nbroker.once( \"connected\", create );\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprojectweekend%2Fpi-sensor-rpc-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprojectweekend%2Fpi-sensor-rpc-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprojectweekend%2Fpi-sensor-rpc-service/lists"}