{"id":21406108,"url":"https://github.com/jes/fuelsafe","last_synced_at":"2025-10-07T12:40:47.331Z","repository":{"id":137662315,"uuid":"297970980","full_name":"jes/fuelsafe","owner":"jes","description":"Inline fuel sensor","archived":false,"fork":false,"pushed_at":"2020-09-27T09:10:37.000Z","size":3057,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-05T03:45:59.234Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-09-23T12:59:49.000Z","updated_at":"2023-07-20T12:48:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"c763a5dd-5dce-4f9a-9ad5-7b5896319b77","html_url":"https://github.com/jes/fuelsafe","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jes/fuelsafe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jes%2Ffuelsafe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jes%2Ffuelsafe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jes%2Ffuelsafe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jes%2Ffuelsafe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jes","download_url":"https://codeload.github.com/jes/fuelsafe/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jes%2Ffuelsafe/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278778938,"owners_count":26044256,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-22T16:31:18.360Z","updated_at":"2025-10-07T12:40:47.302Z","avatar_url":"https://github.com/jes.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FuelSafe\n\nFuelSafe is an inline fuel sensor. It senses the presence of fuel in the line by shining an LED through a clear hose and\nmeasuring the brightness received on a photoresistor. I made it for my [racing lawnmower](https://incoherency.co.uk/blog/tags/lawnmower.html)\nso that we know if we're about to run out of fuel and can make an early pit stop instead of sputtering to a halt.\n\n(This file is basically just notes to myself, but if you want to build one the same you might find it helpful).\n\n## Principle\n\nA section of clear fuel hose is contained within a 3d-printed housing. An LED shines through the hose, and a photoresistor picks up\nthe light from the LED. There is little to no ambient light leakage due to the housing. The photoresistor is placed as one side of\na voltage divider which allows the reading to be determined using an analogue pin on the microcontroller. The presence or\nabsence of fuel changes the brightness that is detected at the photoresistor. When we detect that there is no fuel present,\nwe switch on the output signal, which is used to power an LED to alert the driver that he is about to run out of fuel.\n\n## Schematic\n\nHere is a sketch of the layout for the circuit board on copper stripboard. It is somewhere between an arbitrary sketch\nand a circuit schematic:\n\n![Sketch of schematic](schematic.jpg)\n\nThe crosses mark where the traces on the stripboard must be broken.\n\nThe 6-pin header at the top is the programming header, and the pins from left to right are:\n\nPin | Function\n--- | ---\n1 | Reset\n2 | Vcc\n3 | Pin 2\n4 | Pin 1\n5 | Pin 0\n6 | GND\n\nThe other connections are labelled with letters:\n\nLabel | Function\n--- | ---\nA | output signal and GND\nB | to photoresistor next to hose\nC | input power and GND\nD | to LED next to hose\n\nThere is a 270 Ohm resistor in series with the LED next to the hose. There is no resistor on the output signal (A), so one must\nbe supplied external to the FuelSafe if it is being used to drive an LED. There is a 4.7K Ohm resistor on the other half of the\nvoltage divider which is used to sense the photoresistor. There is an arbitrary filtering capacitor across the output of the\nLM7805.\n\n## Programming\n\nUsing the above table of pin assignments from the programming header, connect the ATtiny to an Arduino as per any online\ninstructions for programming an ATtiny with an Arduino (e.g. [these instructions](https://create.arduino.cc/projecthub/arjun/programming-attiny85-with-arduino-uno-afb829).\n\nI used [ATTinyCore](https://github.com/SpenceKonde/ATTinyCore) with the following settings:\n\nBoard | ATtiny25/45/85 (No bootloader)\nChip | ATtiny85\nClock | 8 MHz (internal)\n\nand the rest I think don't matter. Points to remember:\n\n - program the ArduinoISP sketch to the programming Arduino before starting\n - make sure there is a capacitor between reset and ground on the programming Arduino when programming the ATtiny85\n\n## Calibration\n\nIt is not convenient to write serial output using the ATtiny85.\nTherefore the code that I have written duplicates the sensor reading using `analogWrite` to pin 0. It can therefore be measured\nusing a multimeter or another Arduino so that you can get an idea of where the threshold should be set.\n\nPlug the system in, run fuel through the hose and observe how the sensor reading changes, and pick a threshold value that will\ndiscriminate between presence and absence of fuel. Note that photoresistors can drift in response to temperature so try\nand pick a wide margin.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjes%2Ffuelsafe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjes%2Ffuelsafe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjes%2Ffuelsafe/lists"}