NOTE: Updated code 10-27-2018
In this day and age where everything is measured, recorded, and available remotely (via a REST API most of the time!), it really bothered me that our heating oil tank measured the remaining gallons of oil by a crude plastic dip stick. It’s not accurate, there is no historical data, and there is no way to audit (for honesty, accuracy, or problems/errors).
So the problem is simple enough: Find a quick and easy way to remotely monitor the number of gallons of heating oil in a home, and alert at pre-set intervals (let’s say 75%, 50%, and 25%) of remaining oil in the tank.
After looking for commercial solutions, the cheapest one I found is $120 with a $10/year fee. In my view, that’s simply ridiculous. I decided that I could build something better for 1/3rd of the price ($40), without an yearly fee.
Hardware How-To
Start with this Instructable I created with the exact parts/steps, and with lots of pictures:
https://www.instructables.com/id/Monitor-Heating-Oil-Tank-Gallons-With-Email-SMS-an/
This should take care of the hardware side.
Firmware code and How-To Access Data
Once you have it built – flash your Photon with the code here (see bellow – large code paste).
After that, you should be able to do this from the particle CLI (replace $device-id-here$ with actual device #):
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# This will tell you how many inches away from the sensor the oil is. It is the only "100% accurate" (non-calculated, but actually measured that is) particle get $device-id-here$ distance # This is calculated based on the first one and assuming a 275 gallon tank: particle get $device-id-here$ oil-inches # And using well known charts (like this: http://www.adamspetro.com/residential-heating-tank-chart), gallons are calculated: particle get $device-id-here$ oil-gallons # You can also get a real time stream (every 10 seconds with current firmware code): particle subscribe oil-gallons mine |
If you have not used the Particle Photon, I am going to provide some additional information on the bottom of this post that will walk you through building/flashing the code, and how to setup the web hook. I have also added a lot of pictures of this on the Instructables page to go with the steps.
Particle Photon web IDE code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
// By: Ventz Petkov // LAST UPDATED: 10-27-2018 // This #include statement was automatically added by the Particle IDE. #include <HC_SR04.h> double inches = 0.0; double inches_of_oil = 0.0; double gallons_of_oil = 0.0; int trigPin = D0; int echoPin = D1; int alert1 = 1; int alert2 = 1; int alert3 = 1; int alert4 = 1; int alert5 = 1; int alert6 = 1; int refill_alert = 1; /* Connect an HC-SR04 Range finder as follows: Spark HC-SR04 GND GND 5V VCC D0 Trig D1 Echo The default usable rangefinder is 10cm to 250cm. Outside of that range -1 is returned as the distance. You can change this range by supplying two extra parameters to the constructor of minCM and maxCM, like this: HC_SR04 rangefinder = HC_SR04(trigPin, echoPin, 5.0, 300.0); Inches of oil to gallons: http://www.adamspetro.com/residential-heating-tank-chart */ HC_SR04 rangefinder = HC_SR04(trigPin, echoPin); void setup() { // NOTE: distance is the only TRUE/"non-calculated" measurement away from the sensor Particle.variable("distance", inches); Particle.variable("oil-inches", inches_of_oil); // NOTE: When comparing with physical oil gauges, always read it at the TOP of the "wedge" if it's not a thin "line" type of gague. Particle.variable("oil-gallons", gallons_of_oil); } void loop() { /* NOTE: This assumes a 275 Gallon Vertical Oil tank - the most popular residential ("home") tank. If you have something else, please modify the inches to gallons bellow per the provided URL chart. The max capacity on a 275 gallon tank is 266 gallons, and most companies fill it up to 250-255 gallons. */ inches = rangefinder.getDistanceInch(); inches = rangefinder.getDistanceInch(); inches_of_oil = round((45.89 - inches)*10)/10; if(inches_of_oil == 44) { gallons_of_oil = 275; } else if(inches_of_oil == 43.9) { gallons_of_oil = 274.7; } else if(inches_of_oil == 43.8) { gallons_of_oil = 274.4; } else if(inches_of_oil == 43.7) { gallons_of_oil = 274.1; } else if(inches_of_oil == 43.6) { gallons_of_oil = 273.8; } else if(inches_of_oil == 43.5) { gallons_of_oil = 273.5; } else if(inches_of_oil == 43.4) { gallons_of_oil = 273.2; } else if(inches_of_oil == 43.3) { gallons_of_oil = 272.9; } else if(inches_of_oil == 43.2) { gallons_of_oil = 272.6; } else if(inches_of_oil == 43.1) { gallons_of_oil = 272.3; } else if(inches_of_oil == 43) { gallons_of_oil = 272; } else if(inches_of_oil == 42.9) { gallons_of_oil = 271.6; } else if(inches_of_oil == 42.8) { gallons_of_oil = 271.2; } else if(inches_of_oil == 42.7) { gallons_of_oil = 270.8; } else if(inches_of_oil == 42.6) { gallons_of_oil = 270.4; } else if(inches_of_oil == 42.5) { gallons_of_oil = 270; } else if(inches_of_oil == 42.4) { gallons_of_oil = 269.6; } else if(inches_of_oil == 42.3) { gallons_of_oil = 269.2; } else if(inches_of_oil == 42.2) { gallons_of_oil = 268.8; } else if(inches_of_oil == 42.1) { gallons_of_oil = 268.4; } else if(inches_of_oil == 42) { gallons_of_oil = 268; } else if(inches_of_oil == 41.9) { gallons_of_oil = 267.6; } else if(inches_of_oil == 41.8) { gallons_of_oil = 267.2; } else if(inches_of_oil == 41.7) { gallons_of_oil = 266.8; } else if(inches_of_oil == 41.6) { gallons_of_oil = 266.4; } else if(inches_of_oil == 41.5) { gallons_of_oil = 266; } else if(inches_of_oil == 41.4) { gallons_of_oil = 265.6; } else if(inches_of_oil == 41.3) { gallons_of_oil = 265.2; } else if(inches_of_oil == 41.2) { gallons_of_oil = 264.8; } else if(inches_of_oil == 41.1) { gallons_of_oil = 264.4; } else if(inches_of_oil == 41) { gallons_of_oil = 264; } else if(inches_of_oil == 40.9) { gallons_of_oil = 263.5; } else if(inches_of_oil == 40.8) { gallons_of_oil = 263; } else if(inches_of_oil == 40.7) { gallons_of_oil = 262.5; } else if(inches_of_oil == 40.6) { gallons_of_oil = 262; } else if(inches_of_oil == 40.5) { gallons_of_oil = 261.5; } else if(inches_of_oil == 40.4) { gallons_of_oil = 261; } else if(inches_of_oil == 40.3) { gallons_of_oil = 260.5; } else if(inches_of_oil == 40.2) { gallons_of_oil = 260; } else if(inches_of_oil == 40.1) { gallons_of_oil = 259.5; } else if(inches_of_oil == 40) { gallons_of_oil = 259; } else if(inches_of_oil == 39.9) { gallons_of_oil = 258.5; } else if(inches_of_oil == 39.8) { gallons_of_oil = 258; } else if(inches_of_oil == 39.7) { gallons_of_oil = 257.5; } else if(inches_of_oil == 39.6) { gallons_of_oil = 257; } else if(inches_of_oil == 39.5) { gallons_of_oil = 256.5; } else if(inches_of_oil == 39.4) { gallons_of_oil = 256; } else if(inches_of_oil == 39.3) { gallons_of_oil = 255.5; } else if(inches_of_oil == 39.2) { gallons_of_oil = 255; } else if(inches_of_oil == 39.1) { gallons_of_oil = 254.5; } else if(inches_of_oil == 39) { gallons_of_oil = 254; } else if(inches_of_oil == 38.9) { gallons_of_oil = 253.4; } else if(inches_of_oil == 38.8) { gallons_of_oil = 252.8; } else if(inches_of_oil == 38.7) { gallons_of_oil = 252.2; } else if(inches_of_oil == 38.6) { gallons_of_oil = 251.6; } else if(inches_of_oil == 38.5) { gallons_of_oil = 251; } else if(inches_of_oil == 38.4) { gallons_of_oil = 250.4; } else if(inches_of_oil == 38.3) { gallons_of_oil = 249.8; } else if(inches_of_oil == 38.2) { gallons_of_oil = 249.2; } else if(inches_of_oil == 38.1) { gallons_of_oil = 248.6; } else if(inches_of_oil == 38) { gallons_of_oil = 248; } else if(inches_of_oil == 37.9) { gallons_of_oil = 247.4; } else if(inches_of_oil == 37.8) { gallons_of_oil = 246.8; } else if(inches_of_oil == 37.7) { gallons_of_oil = 246.2; } else if(inches_of_oil == 37.6) { gallons_of_oil = 245.6; } else if(inches_of_oil == 37.5) { gallons_of_oil = 245.0; } else if(inches_of_oil == 37.4) { gallons_of_oil = 244.4; } else if(inches_of_oil == 37.3) { gallons_of_oil = 243.8; } else if(inches_of_oil == 37.2) { gallons_of_oil = 243.2; } else if(inches_of_oil == 37.1) { gallons_of_oil = 242.6; } else if(inches_of_oil == 37) { gallons_of_oil = 242; } else if(inches_of_oil == 36.9) { gallons_of_oil = 241.3; } else if(inches_of_oil == 36.8) { gallons_of_oil = 240.6; } else if(inches_of_oil == 36.7) { gallons_of_oil = 239.9; } else if(inches_of_oil == 36.6) { gallons_of_oil = 239.2; } else if(inches_of_oil == 36.5) { gallons_of_oil = 238.5; } else if(inches_of_oil == 36.4) { gallons_of_oil = 237.8; } else if(inches_of_oil == 36.3) { gallons_of_oil = 237.1; } else if(inches_of_oil == 36.2) { gallons_of_oil = 236.4; } else if(inches_of_oil == 36.1) { gallons_of_oil = 235.7; } else if(inches_of_oil == 36) { gallons_of_oil = 235; } else if(inches_of_oil == 35.9) { gallons_of_oil = 234.3; } else if(inches_of_oil == 35.8) { gallons_of_oil = 233.6; } else if(inches_of_oil == 35.7) { gallons_of_oil = 232.9; } else if(inches_of_oil == 35.6) { gallons_of_oil = 232.2; } else if(inches_of_oil == 35.5) { gallons_of_oil = 231.5; } else if(inches_of_oil == 35.4) { gallons_of_oil = 230.8; } else if(inches_of_oil == 35.3) { gallons_of_oil = 230.1; } else if(inches_of_oil == 35.2) { gallons_of_oil = 229.4; } else if(inches_of_oil == 35.1) { gallons_of_oil = 228.7; } else if(inches_of_oil == 35) { gallons_of_oil = 228; } else if(inches_of_oil == 34.9) { gallons_of_oil = 227.3; } else if(inches_of_oil == 34.8) { gallons_of_oil = 226.6; } else if(inches_of_oil == 34.7) { gallons_of_oil = 225.9; } else if(inches_of_oil == 34.6) { gallons_of_oil = 225.2; } else if(inches_of_oil == 34.5) { gallons_of_oil = 224.5; } else if(inches_of_oil == 34.4) { gallons_of_oil = 223.8; } else if(inches_of_oil == 34.3) { gallons_of_oil = 223.1; } else if(inches_of_oil == 34.2) { gallons_of_oil = 222.4; } else if(inches_of_oil == 34.1) { gallons_of_oil = 221.7; } else if(inches_of_oil == 34) { gallons_of_oil = 221; } else if(inches_of_oil == 33.9) { gallons_of_oil = 220.3; } else if(inches_of_oil == 33.8) { gallons_of_oil = 219.6; } else if(inches_of_oil == 33.7) { gallons_of_oil = 218.9; } else if(inches_of_oil == 33.6) { gallons_of_oil = 218.2; } else if(inches_of_oil == 33.5) { gallons_of_oil = 217.5; } else if(inches_of_oil == 33.4) { gallons_of_oil = 216.8; } else if(inches_of_oil == 33.3) { gallons_of_oil = 216.1; } else if(inches_of_oil == 33.2) { gallons_of_oil = 215.4; } else if(inches_of_oil == 33.1) { gallons_of_oil = 214.7; } else if(inches_of_oil == 33) { gallons_of_oil = 214; } else if(inches_of_oil == 32.9) { gallons_of_oil = 213.3; } else if(inches_of_oil == 32.8) { gallons_of_oil = 212.6; } else if(inches_of_oil == 32.7) { gallons_of_oil = 211.9; } else if(inches_of_oil == 32.6) { gallons_of_oil = 211.2; } else if(inches_of_oil == 32.5) { gallons_of_oil = 210.5; } else if(inches_of_oil == 32.4) { gallons_of_oil = 209.8; } else if(inches_of_oil == 32.3) { gallons_of_oil = 209.1; } else if(inches_of_oil == 32.2) { gallons_of_oil = 208.4; } else if(inches_of_oil == 32.1) { gallons_of_oil = 207.7; } else if(inches_of_oil == 32) { gallons_of_oil = 207; } else if(inches_of_oil == 31.9) { gallons_of_oil = 206.3; } else if(inches_of_oil == 31.8) { gallons_of_oil = 205.6; } else if(inches_of_oil == 31.7) { gallons_of_oil = 204.9; } else if(inches_of_oil == 31.6) { gallons_of_oil = 204.2; } else if(inches_of_oil == 31.5) { gallons_of_oil = 203.5; } else if(inches_of_oil == 31.4) { gallons_of_oil = 202.8; } else if(inches_of_oil == 31.3) { gallons_of_oil = 202.1; } else if(inches_of_oil == 31.2) { gallons_of_oil = 201.4; } else if(inches_of_oil == 31.1) { gallons_of_oil = 200.7; } else if(inches_of_oil == 31) { gallons_of_oil = 200; } else if(inches_of_oil == 30.9) { gallons_of_oil = 199.3; } else if(inches_of_oil == 30.8) { gallons_of_oil = 198.6; } else if(inches_of_oil == 30.7) { gallons_of_oil = 197.9; } else if(inches_of_oil == 30.6) { gallons_of_oil = 197.2; } else if(inches_of_oil == 30.5) { gallons_of_oil = 196.5; } else if(inches_of_oil == 30.4) { gallons_of_oil = 195.8; } else if(inches_of_oil == 30.3) { gallons_of_oil = 195.1; } else if(inches_of_oil == 30.2) { gallons_of_oil = 194.4; } else if(inches_of_oil == 30.1) { gallons_of_oil = 193.7; } else if(inches_of_oil == 30) { gallons_of_oil = 193; } else if(inches_of_oil == 29.9) { gallons_of_oil = 192.3; } else if(inches_of_oil == 29.8) { gallons_of_oil = 191.6; } else if(inches_of_oil == 29.7) { gallons_of_oil = 190.9; } else if(inches_of_oil == 29.6) { gallons_of_oil = 190.2; } else if(inches_of_oil == 29.5) { gallons_of_oil = 189.5; } else if(inches_of_oil == 29.4) { gallons_of_oil = 188.8; } else if(inches_of_oil == 29.3) { gallons_of_oil = 188.1; } else if(inches_of_oil == 29.2) { gallons_of_oil = 187.4; } else if(inches_of_oil == 29.1) { gallons_of_oil = 186.7; } else if(inches_of_oil == 29) { gallons_of_oil = 186; } else if(inches_of_oil == 28.9) { gallons_of_oil = 185.3; } else if(inches_of_oil == 28.8) { gallons_of_oil = 184.6; } else if(inches_of_oil == 28.7) { gallons_of_oil = 183.9; } else if(inches_of_oil == 28.6) { gallons_of_oil = 183.2; } else if(inches_of_oil == 28.5) { gallons_of_oil = 182.5; } else if(inches_of_oil == 28.4) { gallons_of_oil = 181.8; } else if(inches_of_oil == 28.3) { gallons_of_oil = 181.1; } else if(inches_of_oil == 28.2) { gallons_of_oil = 180.4; } else if(inches_of_oil == 28.1) { gallons_of_oil = 179.7; } else if(inches_of_oil == 28) { gallons_of_oil = 179; } else if(inches_of_oil == 27.9) { gallons_of_oil = 178.3; } else if(inches_of_oil == 27.8) { gallons_of_oil = 177.6; } else if(inches_of_oil == 27.7) { gallons_of_oil = 176.9; } else if(inches_of_oil == 27.6) { gallons_of_oil = 176.2; } else if(inches_of_oil == 27.5) { gallons_of_oil = 175.5; } else if(inches_of_oil == 27.4) { gallons_of_oil = 174.8; } else if(inches_of_oil == 27.3) { gallons_of_oil = 174.1; } else if(inches_of_oil == 27.2) { gallons_of_oil = 173.4; } else if(inches_of_oil == 27.1) { gallons_of_oil = 172.7; } else if(inches_of_oil == 27) { gallons_of_oil = 172; } else if(inches_of_oil == 26.9) { gallons_of_oil = 171.3; } else if(inches_of_oil == 26.8) { gallons_of_oil = 170.6; } else if(inches_of_oil == 26.7) { gallons_of_oil = 169.9; } else if(inches_of_oil == 26.6) { gallons_of_oil = 169.2; } else if(inches_of_oil == 26.5) { gallons_of_oil = 168.5; } else if(inches_of_oil == 26.4) { gallons_of_oil = 167.8; } else if(inches_of_oil == 26.3) { gallons_of_oil = 167.1; } else if(inches_of_oil == 26.2) { gallons_of_oil = 166.4; } else if(inches_of_oil == 26.1) { gallons_of_oil = 165.7; } else if(inches_of_oil == 26) { gallons_of_oil = 165; } else if(inches_of_oil == 25.9) { gallons_of_oil = 164.3; } else if(inches_of_oil == 25.8) { gallons_of_oil = 163.6; } else if(inches_of_oil == 25.7) { gallons_of_oil = 162.9; } else if(inches_of_oil == 25.6) { gallons_of_oil = 162.2; } else if(inches_of_oil == 25.5) { gallons_of_oil = 161.5; } else if(inches_of_oil == 25.4) { gallons_of_oil = 160.8; } else if(inches_of_oil == 25.3) { gallons_of_oil = 160.1; } else if(inches_of_oil == 25.2) { gallons_of_oil = 159.4; } else if(inches_of_oil == 25.1) { gallons_of_oil = 158.7; } else if(inches_of_oil == 25) { gallons_of_oil = 158; } else if(inches_of_oil == 24.9) { gallons_of_oil = 157.3; } else if(inches_of_oil == 24.8) { gallons_of_oil = 156.6; } else if(inches_of_oil == 24.7) { gallons_of_oil = 155.9; } else if(inches_of_oil == 24.6) { gallons_of_oil = 155.2; } else if(inches_of_oil == 24.5) { gallons_of_oil = 154.5; } else if(inches_of_oil == 24.4) { gallons_of_oil = 153.8; } else if(inches_of_oil == 24.3) { gallons_of_oil = 153.1; } else if(inches_of_oil == 24.2) { gallons_of_oil = 152.4; } else if(inches_of_oil == 24.1) { gallons_of_oil = 151.7; } else if(inches_of_oil == 24) { gallons_of_oil = 151; } else if(inches_of_oil == 23.9) { gallons_of_oil = 150.2; } else if(inches_of_oil == 23.8) { gallons_of_oil = 149.4; } else if(inches_of_oil == 23.7) { gallons_of_oil = 148.6; } else if(inches_of_oil == 23.6) { gallons_of_oil = 147.8; } else if(inches_of_oil == 23.5) { gallons_of_oil = 147; } else if(inches_of_oil == 23.4) { gallons_of_oil = 146.2; } else if(inches_of_oil == 23.3) { gallons_of_oil = 145.4; } else if(inches_of_oil == 23.2) { gallons_of_oil = 144.6; } else if(inches_of_oil == 23.1) { gallons_of_oil = 143.8; } else if(inches_of_oil == 23) { gallons_of_oil = 143; } else if(inches_of_oil == 22.9) { gallons_of_oil = 142.3; } else if(inches_of_oil == 22.8) { gallons_of_oil = 141.6; } else if(inches_of_oil == 22.7) { gallons_of_oil = 140.9; } else if(inches_of_oil == 22.6) { gallons_of_oil = 140.2; } else if(inches_of_oil == 22.5) { gallons_of_oil = 139.5; } else if(inches_of_oil == 22.4) { gallons_of_oil = 138.8; } else if(inches_of_oil == 22.3) { gallons_of_oil = 138.1; } else if(inches_of_oil == 22.2) { gallons_of_oil = 137.4; } else if(inches_of_oil == 22.1) { gallons_of_oil = 136.7; } else if(inches_of_oil == 22) { gallons_of_oil = 136; } else if(inches_of_oil == 21.9) { gallons_of_oil = 135.3; } else if(inches_of_oil == 21.8) { gallons_of_oil = 134.6; } else if(inches_of_oil == 21.7) { gallons_of_oil = 133.9; } else if(inches_of_oil == 21.6) { gallons_of_oil = 133.2; } else if(inches_of_oil == 21.5) { gallons_of_oil = 132.5; } else if(inches_of_oil == 21.4) { gallons_of_oil = 131.8; } else if(inches_of_oil == 21.3) { gallons_of_oil = 131.1; } else if(inches_of_oil == 21.2) { gallons_of_oil = 130.4; } else if(inches_of_oil == 21.1) { gallons_of_oil = 129.7; } else if(inches_of_oil == 21) { gallons_of_oil = 129; } else if(inches_of_oil == 20.9) { gallons_of_oil = 128.3; } else if(inches_of_oil == 20.8) { gallons_of_oil = 127.6; } else if(inches_of_oil == 20.7) { gallons_of_oil = 126.9; } else if(inches_of_oil == 20.6) { gallons_of_oil = 126.2; } else if(inches_of_oil == 20.5) { gallons_of_oil = 125.5; } else if(inches_of_oil == 20.4) { gallons_of_oil = 124.8; } else if(inches_of_oil == 20.3) { gallons_of_oil = 124.1; } else if(inches_of_oil == 20.2) { gallons_of_oil = 123.4; } else if(inches_of_oil == 20.1) { gallons_of_oil = 122.7; } else if(inches_of_oil == 20) { gallons_of_oil = 122; } else if(inches_of_oil == 19.9) { gallons_of_oil = 121.3; } else if(inches_of_oil == 19.8) { gallons_of_oil = 120.6; } else if(inches_of_oil == 19.7) { gallons_of_oil = 119.9; } else if(inches_of_oil == 19.6) { gallons_of_oil = 119.2; } else if(inches_of_oil == 19.5) { gallons_of_oil = 118.5; } else if(inches_of_oil == 19.4) { gallons_of_oil = 117.8; } else if(inches_of_oil == 19.3) { gallons_of_oil = 117.1; } else if(inches_of_oil == 19.2) { gallons_of_oil = 116.4; } else if(inches_of_oil == 19.1) { gallons_of_oil = 115.7; } else if(inches_of_oil == 19) { gallons_of_oil = 115; } else if(inches_of_oil == 18.9) { gallons_of_oil = 114.3; } else if(inches_of_oil == 18.8) { gallons_of_oil = 113.6; } else if(inches_of_oil == 18.7) { gallons_of_oil = 112.9; } else if(inches_of_oil == 18.6) { gallons_of_oil = 112.2; } else if(inches_of_oil == 18.5) { gallons_of_oil = 111.5; } else if(inches_of_oil == 18.4) { gallons_of_oil = 110.8; } else if(inches_of_oil == 18.3) { gallons_of_oil = 110.1; } else if(inches_of_oil == 18.2) { gallons_of_oil = 109.4; } else if(inches_of_oil == 18.1) { gallons_of_oil = 108.7; } else if(inches_of_oil == 18) { gallons_of_oil = 108; } else if(inches_of_oil == 17.9) { gallons_of_oil = 107.3; } else if(inches_of_oil == 17.8) { gallons_of_oil = 106.6; } else if(inches_of_oil == 17.7) { gallons_of_oil = 105.9; } else if(inches_of_oil == 17.6) { gallons_of_oil = 105.2; } else if(inches_of_oil == 17.5) { gallons_of_oil = 104.5; } else if(inches_of_oil == 17.4) { gallons_of_oil = 103.8; } else if(inches_of_oil == 17.3) { gallons_of_oil = 103.1; } else if(inches_of_oil == 17.2) { gallons_of_oil = 102.4; } else if(inches_of_oil == 17.1) { gallons_of_oil = 101.7; } else if(inches_of_oil == 17) { gallons_of_oil = 101; } else if(inches_of_oil == 16.9) { gallons_of_oil = 100.3; } else if(inches_of_oil == 16.8) { gallons_of_oil = 99.6; } else if(inches_of_oil == 16.7) { gallons_of_oil = 98.9; } else if(inches_of_oil == 16.6) { gallons_of_oil = 98.2; } else if(inches_of_oil == 16.5) { gallons_of_oil = 97.5; } else if(inches_of_oil == 16.4) { gallons_of_oil = 96.8; } else if(inches_of_oil == 16.3) { gallons_of_oil = 96.1; } else if(inches_of_oil == 16.2) { gallons_of_oil = 95.4; } else if(inches_of_oil == 16.1) { gallons_of_oil = 94.7; } else if(inches_of_oil == 16.0) { gallons_of_oil = 94; } else if(inches_of_oil == 15.9) { gallons_of_oil = 93.2; } else if(inches_of_oil == 15.8) { gallons_of_oil = 92.4; } else if(inches_of_oil == 15.7) { gallons_of_oil = 91.6; } else if(inches_of_oil == 15.6) { gallons_of_oil = 90.8; } else if(inches_of_oil == 15.5) { gallons_of_oil = 90; } else if(inches_of_oil == 15.4) { gallons_of_oil = 89.2; } else if(inches_of_oil == 15.3) { gallons_of_oil = 88.4; } else if(inches_of_oil == 15.2) { gallons_of_oil = 87.6; } else if(inches_of_oil == 15.1) { gallons_of_oil = 86.8; } else if(inches_of_oil == 15) { gallons_of_oil = 86; } else if(inches_of_oil == 14.9) { gallons_of_oil = 85.3; } else if(inches_of_oil == 14.8) { gallons_of_oil = 84.6; } else if(inches_of_oil == 14.7) { gallons_of_oil = 83.9; } else if(inches_of_oil == 14.6) { gallons_of_oil = 83.2; } else if(inches_of_oil == 14.5) { gallons_of_oil = 82.5; } else if(inches_of_oil == 14.4) { gallons_of_oil = 81.8; } else if(inches_of_oil == 14.3) { gallons_of_oil = 81.1; } else if(inches_of_oil == 14.2) { gallons_of_oil = 80.4; } else if(inches_of_oil == 14.1) { gallons_of_oil = 79.7; } else if(inches_of_oil == 14) { gallons_of_oil = 79; } else if(inches_of_oil == 13.9) { gallons_of_oil = 78.3; } else if(inches_of_oil == 13.8) { gallons_of_oil = 77.6; } else if(inches_of_oil == 13.7) { gallons_of_oil = 76.9; } else if(inches_of_oil == 13.6) { gallons_of_oil = 76.2; } else if(inches_of_oil == 13.5) { gallons_of_oil = 75.5; } else if(inches_of_oil == 13.4) { gallons_of_oil = 74.8; } else if(inches_of_oil == 13.3) { gallons_of_oil = 74.1; } else if(inches_of_oil == 13.2) { gallons_of_oil = 73.4; } else if(inches_of_oil == 13.1) { gallons_of_oil = 72.7; } else if(inches_of_oil == 13) { gallons_of_oil = 72; } else if(inches_of_oil == 12.9) { gallons_of_oil = 71.3; } else if(inches_of_oil == 12.8) { gallons_of_oil = 70.6; } else if(inches_of_oil == 12.7) { gallons_of_oil = 69.9; } else if(inches_of_oil == 12.6) { gallons_of_oil = 69.2; } else if(inches_of_oil == 12.5) { gallons_of_oil = 68.5; } else if(inches_of_oil == 12.4) { gallons_of_oil = 67.8; } else if(inches_of_oil == 12.3) { gallons_of_oil = 67.1; } else if(inches_of_oil == 12.2) { gallons_of_oil = 66.4; } else if(inches_of_oil == 12.1) { gallons_of_oil = 65.7; } else if(inches_of_oil == 12) { gallons_of_oil = 65; } else if(inches_of_oil == 11.9) { gallons_of_oil = 64.3; } else if(inches_of_oil == 11.8) { gallons_of_oil = 63.6; } else if(inches_of_oil == 11.7) { gallons_of_oil = 62.9; } else if(inches_of_oil == 11.6) { gallons_of_oil = 62.2; } else if(inches_of_oil == 11.5) { gallons_of_oil = 61.5; } else if(inches_of_oil == 11.4) { gallons_of_oil = 60.8; } else if(inches_of_oil == 11.3) { gallons_of_oil = 60.1; } else if(inches_of_oil == 11.2) { gallons_of_oil = 59.4; } else if(inches_of_oil == 11.1) { gallons_of_oil = 58.7; } else if(inches_of_oil == 11) { gallons_of_oil = 58; } else if(inches_of_oil == 10.9) { gallons_of_oil = 57.3; } else if(inches_of_oil == 10.8) { gallons_of_oil = 56.6; } else if(inches_of_oil == 10.7) { gallons_of_oil = 55.9; } else if(inches_of_oil == 10.6) { gallons_of_oil = 55.2; } else if(inches_of_oil == 10.5) { gallons_of_oil = 54.5; } else if(inches_of_oil == 10.4) { gallons_of_oil = 53.8; } else if(inches_of_oil == 10.3) { gallons_of_oil = 53.1; } else if(inches_of_oil == 10.2) { gallons_of_oil = 52.4; } else if(inches_of_oil == 10.1) { gallons_of_oil = 51.7; } else if(inches_of_oil == 10) { gallons_of_oil = 51; } else if(inches_of_oil == 9.9) { gallons_of_oil = 50.3; } else if(inches_of_oil == 9.8) { gallons_of_oil = 49.6; } else if(inches_of_oil == 9.7) { gallons_of_oil = 48.9; } else if(inches_of_oil == 9.6) { gallons_of_oil = 48.2; } else if(inches_of_oil == 9.5) { gallons_of_oil = 47.5; } else if(inches_of_oil == 9.4) { gallons_of_oil = 46.8; } else if(inches_of_oil == 9.3) { gallons_of_oil = 46.1; } else if(inches_of_oil == 9.2) { gallons_of_oil = 45.4; } else if(inches_of_oil == 9.1) { gallons_of_oil = 44.7; } else if(inches_of_oil == 9) { gallons_of_oil = 44; } else if(inches_of_oil == 8.9) { gallons_of_oil = 43.4; } else if(inches_of_oil == 8.8) { gallons_of_oil = 42.8; } else if(inches_of_oil == 8.7) { gallons_of_oil = 42.2; } else if(inches_of_oil == 8.6) { gallons_of_oil = 41.6; } else if(inches_of_oil == 8.5) { gallons_of_oil = 41; } else if(inches_of_oil == 8.4) { gallons_of_oil = 40.4; } else if(inches_of_oil == 8.3) { gallons_of_oil = 39.8; } else if(inches_of_oil == 8.2) { gallons_of_oil = 39.2; } else if(inches_of_oil == 8.1) { gallons_of_oil = 38.6; } else if(inches_of_oil == 8) { gallons_of_oil = 38; } else if(inches_of_oil == 7.9) { gallons_of_oil = 37.3; } else if(inches_of_oil == 7.8) { gallons_of_oil = 36.6; } else if(inches_of_oil == 7.7) { gallons_of_oil = 35.9; } else if(inches_of_oil == 7.6) { gallons_of_oil = 35.2; } else if(inches_of_oil == 7.5) { gallons_of_oil = 34.5; } else if(inches_of_oil == 7.4) { gallons_of_oil = 33.8; } else if(inches_of_oil == 7.3) { gallons_of_oil = 33.1; } else if(inches_of_oil == 7.2) { gallons_of_oil = 32.4; } else if(inches_of_oil == 7.1) { gallons_of_oil = 31.7; } else if(inches_of_oil == 7) { gallons_of_oil = 31; } else if(inches_of_oil == 6.9) { gallons_of_oil = 30.4; } else if(inches_of_oil == 6.8) { gallons_of_oil = 29.8; } else if(inches_of_oil == 6.7) { gallons_of_oil = 29.2; } else if(inches_of_oil == 6.6) { gallons_of_oil = 28.6; } else if(inches_of_oil == 6.5) { gallons_of_oil = 28; } else if(inches_of_oil == 6.4) { gallons_of_oil = 27.4; } else if(inches_of_oil == 6.3) { gallons_of_oil = 26.8; } else if(inches_of_oil == 6.2) { gallons_of_oil = 26.2; } else if(inches_of_oil == 6.1) { gallons_of_oil = 25.6; } else if(inches_of_oil == 6) { gallons_of_oil = 25; } else if(inches_of_oil == 5.9) { gallons_of_oil = 24.4; } else if(inches_of_oil == 5.8) { gallons_of_oil = 23.8; } else if(inches_of_oil == 5.7) { gallons_of_oil = 23.2; } else if(inches_of_oil == 5.6) { gallons_of_oil = 22.6; } else if(inches_of_oil == 5.5) { gallons_of_oil = 22; } else if(inches_of_oil == 5.4) { gallons_of_oil = 21.4; } else if(inches_of_oil == 5.3) { gallons_of_oil = 20.8; } else if(inches_of_oil == 5.2) { gallons_of_oil = 20.2; } else if(inches_of_oil == 5.1) { gallons_of_oil = 19.06; } else if(inches_of_oil == 5) { gallons_of_oil = 19; } else if(inches_of_oil == 4.9) { gallons_of_oil = 18.5; } else if(inches_of_oil == 4.8) { gallons_of_oil = 18; } else if(inches_of_oil == 4.7) { gallons_of_oil = 17.5; } else if(inches_of_oil == 4.6) { gallons_of_oil = 17; } else if(inches_of_oil == 4.5) { gallons_of_oil = 16.5; } else if(inches_of_oil == 4.4) { gallons_of_oil = 16; } else if(inches_of_oil == 4.3) { gallons_of_oil = 15.5; } else if(inches_of_oil == 4.2) { gallons_of_oil = 15; } else if(inches_of_oil == 4.1) { gallons_of_oil = 14.5; } else if(inches_of_oil == 4) { gallons_of_oil = 14; } else if(inches_of_oil == 3.9) { gallons_of_oil = 13.5; } else if(inches_of_oil == 3.8) { gallons_of_oil = 13; } else if(inches_of_oil == 3.7) { gallons_of_oil = 12.5; } else if(inches_of_oil == 3.6) { gallons_of_oil = 12; } else if(inches_of_oil == 3.5) { gallons_of_oil = 11.5; } else if(inches_of_oil == 3.4) { gallons_of_oil = 11; } else if(inches_of_oil == 3.3) { gallons_of_oil = 10.5; } else if(inches_of_oil == 3.2) { gallons_of_oil = 10; } else if(inches_of_oil == 3.1) { gallons_of_oil = 9.5; } else if(inches_of_oil == 3) { gallons_of_oil = 9; } else if(inches_of_oil == 2.9) { gallons_of_oil = 8.6; } else if(inches_of_oil == 2.8) { gallons_of_oil = 8.2; } else if(inches_of_oil == 2.7) { gallons_of_oil = 7.8; } else if(inches_of_oil == 2.6) { gallons_of_oil = 7.4; } else if(inches_of_oil == 2.5) { gallons_of_oil = 7; } else if(inches_of_oil == 2.4) { gallons_of_oil = 6.6; } else if(inches_of_oil == 2.3) { gallons_of_oil = 6.2; } else if(inches_of_oil == 2.2) { gallons_of_oil = 5.8; } else if(inches_of_oil == 2.1) { gallons_of_oil = 5.4; } else if(inches_of_oil == 2) { gallons_of_oil = 5; } else if(inches_of_oil == 1.9) { gallons_of_oil = 4.7; } else if(inches_of_oil == 1.8) { gallons_of_oil = 4.4; } else if(inches_of_oil == 1.7) { gallons_of_oil = 4.1; } else if(inches_of_oil == 1.6) { gallons_of_oil = 3.8; } else if(inches_of_oil == 1.5) { gallons_of_oil = 3.5; } else if(inches_of_oil == 1.4) { gallons_of_oil = 3.2; } else if(inches_of_oil == 1.3) { gallons_of_oil = 2.9; } else if(inches_of_oil == 1.2) { gallons_of_oil = 2.6; } else if(inches_of_oil == 1.1) { gallons_of_oil = 2.3; } else if(inches_of_oil == 1) { gallons_of_oil = 2; } else if(inches_of_oil == 0.9) { gallons_of_oil = 1.8; } else if(inches_of_oil == 0.8) { gallons_of_oil = 1.6; } else if(inches_of_oil == 0.7) { gallons_of_oil = 1.4; } else if(inches_of_oil == 0.6) { gallons_of_oil = 1.2; } else if(inches_of_oil == 0.5) { gallons_of_oil = 1; } else if(inches_of_oil == 0.4) { gallons_of_oil = 0.8; } else if(inches_of_oil == 0.3) { gallons_of_oil = 0.6; } else if(inches_of_oil == 0.2) { gallons_of_oil = 0.4; } else if(inches_of_oil == 0.1) { gallons_of_oil = 0.2; } else if(inches_of_oil == 0) { gallons_of_oil = 0; } Particle.publish("oil-gallons", String(gallons_of_oil,1), PRIVATE); delay(10000); // Reset all of the alert flags! /* if(gallons_of_oil > 240 && refill_alert) { Particle.publish("Alert", "Oil REFILLED!", PRIVATE); alert1 = 1; alert2 = 1; alert3 = 1; alert4 = 1; alert5 = 1; alert6 = 1; refill_alert = 0; } else if(gallons_of_oil > 125 && gallons_of_oil < 187.5 && alert1) { */ if(gallons_of_oil > 125 && gallons_of_oil < 187.5 && alert1) { Particle.publish("Alert", "Oil Level bellow 75%", PRIVATE); alert1 = 0; refill_alert = 1; } else if(gallons_of_oil > 65 && gallons_of_oil < 125 && alert2) { Particle.publish("Alert", "NOTICE: Oil Level bellow 50%", PRIVATE); alert2 = 0; alert1 = 1; refill_alert = 1; } else if(gallons_of_oil > 75 && gallons_of_oil < 87.5 && alert3) { Particle.publish("Alert", "NOTICE: Oil Level bellow 35%", PRIVATE); alert3 = 0; alert1 = 0; alert2 = 0; refill_alert = 1; } else if(gallons_of_oil > 62.5 && gallons_of_oil < 75 && alert4) { Particle.publish("Alert", "WARNING: Oil Level bellow 30% - Refill Soon", PRIVATE); alert4 = 0; alert1 = 0; alert2 = 0; alert3 = 0; refill_alert = 1; } else if(gallons_of_oil > 50 && gallons_of_oil < 62.5 && alert5) { Particle.publish("Alert", "CRITIAL: Oil Level bellow 25% - Call to Refill", PRIVATE); alert5 = 0; alert1 = 0; alert2 = 0; alert3 = 0; alert4 = 0; refill_alert = 1; } else if(gallons_of_oil < 50 && alert6) { Particle.publish("Alert", "EMERGENCY: Oil Level bellow 20% - Get Delivery ASAP!", PRIVATE); alert6 = 0; alert1 = 0; alert2 = 0; alert3 = 0; alert4 = 0; alert5 = 0; refill_alert = 1; } } |
Now that you have everything you need, the last part is to web hook the “Alert” publish call into something that actually alerts you. The easiest way to do this is to create a JSON “custom” webhook, which allows you to “hook” a publish event. In this case, I will hook the “Alert” published event, and redirect it to Pushbullet. You can just as easily call a 3rd party SMS service (Twilio), Email (Sendgrid, Mailgun, etc), or some other custom notification/hook.
Here is the Pushbullet config (please replace “Access-Token” with your token):
Web Hook for Notifications (free with Pushbullet)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
{ "eventName": "Alert", "url": "https://api.pushbullet.com/v2/pushes", "requestType": "POST", "headers": { "Access-Token": "#REPLACE-WITH-YOUR-PUSHBULLET-ACCESS-TOKEN", "Content-Type": "application/json" }, "json": { "type": "note", "title": "Particle Alert - {{PARTICLE_PUBLISHED_AT}}", "body": "{{PARTICLE_EVENT_VALUE}}" }, "deviceID": "", "mydevices": true, "source": "{{PARTICLE_DEVICE_ID}}", "published_at": "{{PARTICLE_PUBLISHED_AT}}" } |
Or, if you are using Pushover
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
{ "event": "Alert", "url": "https://api.pushover.net/1/messages.json", "requestType": "POST", "rejectUnauthorized": true, "noDefaults": false, "headers": { "Content-Type": "application/json" }, "json": { "token": "#APP-API-TOKEN-KEY-HERE#", "user": "#USER-KEY-HERE#", "title": "Particle Alert - {{PARTICLE_PUBLISHED_AT}}", "message": "{{PARTICLE_EVENT_VALUE}}" }, "deviceID": "", "mydevices": true, "source": "{{PARTICLE_DEVICE_ID}}", "published_at": "{{PARTICLE_PUBLISHED_AT}}" } |
You will note that I have added a whole lot of pictures showing the steps around the Photon code build/flash and the Webhooks on the Instructables page. Here is some more informations/detials:
What if you have never used a Particle Photon? Detailed Help on setup/code/flashing!
I made the assumption that a most people who would be interested in a hardware project like this one would be very familiar with Particle’s photons/arduino, and I think this is a bad assumption. If you have not used these before, here is a step by step walk thru what to do from the software side in order to get this to work.
1.) Start by following this: https://docs.particle.io/guide/getting-started/start/photon/#step-1-power-on-your-device
2.) After you have initialized/”set up” your photon, go to: https://build.particle.io
3.) On the left side, under “Current Apps” (where it says “Title”) create an app called “oil-tank”.
Paste the large code from “Particle Photon web IDE code:” above, and click on the top-left “Save” (folder icon)
4.) On the left, click on “Libraries” (bookmark icon) and under “Community Libraries” search in the box for “HC_SR04”.
5.) Click on the found “HC_SR04” and click the blue “INCLUDE IN PROJECT” button. Then select from the list “oil-tank” (what you called your app in step #3), and click the blue “CONFIRM” button.
6.) At this point, make sure there is only ONE line that looks like this:
1 2 3 4 |
// This #include statement was automatically added by the Particle IDE. #include <HC_SR04.h> |
at the top of the file.
7.) Now clic on “Devices” and click on the star icon next to the device you setup in step #1 — this selects it for flashing the firmware.
8.) Go back to your “Code” for “oil-tank” and click “Verify” (check icon above “Save”) and then “Flash” (lightning bolt icon above “Verify”)
9.) That’s it — you have now flashed the firmware on your Photon.
What are these Web Hooks/Notifications – step by step instructions
1.) Go to: https://console.particle.io/devices
2.) Click on “Integrations” (star-looking icon above the Billing icon) and click on “New Integration”, and click on “Webhook”.
3.) There are TWO differentways to do this – using the “WEBHOOK BUILDER” step by step, OR pasting the whole JSON in the “CUSTOM TEMPLATE” section. No matter which you do, the only thing to really pay attention to is the “Event Name”. It always needs to be “Alert” (unless you change the Particle.publish in your firmware. This is what hooks that notifications into some “real world” notifcation – alert, SMS, Email, etc.)
4.) If you use the “CUSTOM TEMPLATE”, you can paste the “Web Hook for Notifications (free with Pushbullet)” code.
Alternative, and let’s say if you want SMS for example, you can go to the “WEBHOOK BUILDER” section, and follow something like this: https://www.twilio.com/docs/guides/sms-mms-messages-particle-photon#sign-into-or-sign-up-for-a-twilio-account, specifically following this sub-section: https://www.twilio.com/docs/guides/sms-mms-messages-particle-photon#example-1-a-simple-example-of-sending-smses-with-a-particle-photon (the “Set Up a Particle Webhook” part, and noting that the “Event Name” should be “Alert”).
5.) That’s it — you now have a method to “Alert” to external services. Generally, look for the REST POST URL, and either place it in your “WEBHOOK BUILDER” section, or into the JSON template I provided above.
Is your oil sensor still working? Are you powering it with an AC adapter? Do you have a photo of how you ran the cord into the pipe. Oil tanks can see 5-7PSI when being filled. How airtight is your design? I’d hate to come home and find my basement full of oil :-O
Chris – Yes – I’ve been using my solution for a little 2 years now, with no issues other than the Photon needing to be rebooted one time as it stopped connecting due to some wifi changes (I believe this was the old photon firmware which did not handle SSID changes gracefully 100% of the time).
Quite a few co-workers built one after I showed it to them, and from what I’ve heard, no one has had any issues.
I actually have 2 Photons on our oil tank for testing/making sure originally that the numbers were accurate, and since then I’ve left both.
This gives me an easy way to “sanity check” the numbers. I have one on the most left and one on the most right, which given the slight tilt, provides me with a pretty exact real average.
I am powering them with AC adapters, which are plugged into one of those very thin 3-outlet extension cords (looks like this: https://www.cmple.com/content/images/thumbs/3-outlet-power-extension-cord-white-6-feet_NID0013781.jpeg)
I drilled a hole in the cap from the Instructables I posted, placed the micro-usb cable through, and then epoxy glued the hole. You can get away with a much cleaner/”better” design by using the micro-usb cable from something like the Wyze camera which uses a flat cable. For an “ideal” design, I would cut the cable and re-connect it through the cap, but again, there was no need in my case. It’s faster/cheaper/easier just to buy a new cap for a few cents and drill it if you ever need one.
The wiring to the units is not fancy/pretty, but given that my tank is in a basement corner, there’s no need for it to be pretty. It also makes it easy to unplug/reset/swap out the photon if I ever needed to — which was quite handy initially while building this.
You don’t have to worry about oil coming out of this at all. The typical/average 275 gallon tank is only filled to ~250 gallons. The whistle mechanism they use to fill the tank prevents the tank from overfilling past ~250 galoons (you will see it go potentially up to ~260 gallons at most if they are careless when filling it, but never past that). You will never come home to find any oil in your basement through the bung holes (that’s really what they are called! :)) in your oil tank.
I was actually much more paranoid than you (mostly about fire/sparks/etc), and I scheduled an appointment with the fire chief to get this inspected and looked at, along with a few different oil companies for their input. While I never went through any certifications, it’s as safe as it can get.
I would suggest wrapping thread seal (or “pfte/teflon/plumbers” tape) tape before you screw it into the oil bung holes – this way you won’t get any smell, but even that is not an issue health wise (I checked!)
Since the original post, other than the Pushbullet (or Pushover, preferred by some over Pushbullet) alerts at the different percent intervals, I’ve added a Siri Shortcuts. This is actually my favorite since it’s polling the photon and it’s truly instant, plus it can be activated with voice from any apple device, including the Apple Watch.
Good luck, and hope you find this useful. I actually cannot believe something like this isn’t built by default into every oil tank at this point, but I guess there is a relatively small “US market” for oil (compared to gas/propane/etc) – mostly in the northeast and a few other remote areas.
Thanks for the update. I wish I had found your site before I made a very similar unit. I also used a particle proton and hc ping sensor. I designed / 3D printed an insert for a 2” pipe. In my code I tried both a 5th order polynomial fitted to table data and trig formulas to convert ping distance to remaining gallons. I’m using IFTTT to send alerts. I used Blynk to create an iPhone app that plots history and shows a gauge.
Yea – It’s a “hacky” (but effective) way of eliminating sensor hardware read errors. Every once in a while the sensor will read invalid values — either be it due to Hardware issues or a library issue. This re-init takes care of that. I have only seen this problem twice so far, but with the double call, it always fixes itself on the 2nd call. It could be because I am using cheap sensors — I bought a bulk bag of them from Amazon for less than $10.
I forgot to ask. Does this need to be called 2 times on line #59?
59: inches = rangefinder.getDistanceInch(); inches = rangefinder.getDistanceInch();
Thanks guys! 🙂 Appreciate it.
Thanks. It was actually peekay123 on the Particle forum that saw my error. I just did not want anyone else to trip on it.
Thought you would like to know that the instructable shows: D1 to Trig & D2 to Echo, your code says D0 to Trig & D1 to Echo.
Hi Bruce — thanks for pointing it out. It’s a typo on the Instructable. I am assuming at some point “wire 1” and “wire 2” somehow translated incorrectly to the writeup. The pictures are correct however, and the code matches those. It should be D0 and D1, although technically it doesn’t matter as long as 2 digital pins are used, and the same ones are in the code 🙂 Either way, I just updated the Instructable.
Thanks again for finding this and pointing it out!
I got an answer from them,’Each device can only trigger a webhook 10 times per minute.’.May the device request webhook service too frequent.
I would be surprised if that’s preventing you from creating a webhook though (it seems unrelated).
Also, in reality you are sending a single call every 10-15 days. The worst case is on bootup – but even then, if your tank is almost empty, you should never generate more than 4-5 calls. By the way – check out the new code I released a couple of days ago. I think it greatly improves a whole bunch of stuff.
Hi,Ventz
I foolishly deleted the custom template integration of webhook.it’s been working ever since i followed your direction.Then when i try to build a new one.the ‘create webhook’button on Particle webhook webpage is grey.very weird,have you met this situation before.
How many other web hooks do you have? One reason I can think of the create being greyed out is if you have hit the free limit on the # of hooks you can have (can’t remember if it was 5 or 20 — if it’s 20, that’s probably not the issue).
Try simple things like login out and back in/another browser/etc.
You can also try to see what the CLI says/creating a webhook with the cli: https://docs.particle.io/guide/tools-and-features/cli/photon/
I personally do everything from the CLI. It’s really great for a lot of things (flash firmware, get variables, stream events, check console, and even compile code and flash it)
For webhooks, you can do “particle webhook list”.
You can also create the webhook from the code I provided directly with the CLI if you put it in a JSON file.
As a last resort, try contacting their support (hello@particle.io) – in my opinion, they are incredible.
Post when you figure out what causes this. I am personally curious 🙂
Hi,Ventz
Thanks for your follow-up explaination.now i can hook them up.it works,one thing i thought is about the pushbullet.it uses google account to login. so i am thinking if it wll work with ‘pushover’.which no need to use google accrount.
Funny you should mention this — I actually just switched my alerts yesterday to Pushover because I wanted a dedicated app JUST for alerts (PushBullet is good, but seems bloated. Also, they lowered the free tier to 500 msgs).
Here is the exact Webhook you need:
Thanks, Ventz, I am making one! I have not used Pushbullet before (or Particle Photon until yesterday), but now have it in my browser. I am having trouble getting node.js installed properly so I can use the Pushbullet CLI.
Any advice on that?
AND:
When you say, “Here is the Pushbullet config (please replace “Access-Token” with your token):”
Where does your subsequent code go? In the app that gets flashed into the Photon? If so, where exactly?
Or is there somewhere in Pushbullet I am supposed to enter this code?
Thanks!
Steve, replied on Instructables, but just so you have it here — I’ve added two new sections:
What if you have never used a Particle Photon? Detailed Help on setup/code/flashing!
and
What are these Web Hooks/Notifications – step by step instructions
These should provide the much needed clarifications.
At last – I have uploaded a bunch of new screenshots to go with with both sections (on the Instructables post) for the software side of the Photon and the Webhooks.
Let me know if these help and especially if something could use some more clarifications.
Thanks for posting this.nice tutorial.
No problem – I am glad people are finding it useful.