Garbage Gauge
The average American family of four creates 124 pounds of garbage each week. We are dismissive if we are better or worse. Here we have combined a Particle Photon, scale and scraps to wirelessly log our weekly and life long waste out put with coding to acclimate to blah blah blah...the following is a fart joke.




Particle Photon Code? Sketch? Letters and Numbers
// Garbage Gauge
// Vije Miller

#ifdef SPARK
#include "ThingSpeak/ThingSpeak.h"
#else
#include "ThingSpeak.h"
#endif

#ifdef SPARK
TCPClient client;
#define VOLTAGE_MAX 3.3
#define VOLTAGE_MAXCOUNTS 4095.0
#endif

// ThingSpeak
unsigned long myChannelNumber = CHANNEL;
const char * myWriteAPIKey = "APIKEY";

// Input
int scale = A5;

// Variables
int current = 0;
int tare = 0;
int preweight = 0;
int adjust = 0;

int week = 0;
int total = 0;

int wait = 10800; // 3 Hours

void setup() {

Serial.begin(9600);
ThingSpeak.begin(client);

// Calm Down Power-Up Fluctuation
delay(5000);

// Empty Garbage Bin Weight
tare = analogRead(scale);

delay(5000);

}

void loop() {

// Read Pot
current = analogRead(scale);
// Convert to Pounds
// Pot Turn Limitation 254 Pounds
// Particle Photon is 0 to 4095
preweight = map(current, 0, 4095, 0, 254);
// Subtract Tare
adjust = preweight - tare;

if (adjust < week && preweight < tare) {
// No Barrel? Ignore
}
else if (adjust < week && preweight > tare) {
// Barrel Emptied? Reset Week
week = adjust;
}
else if (adjust == week) {
// No Change? Ignore
}
else if (adjust > week) {
// Remove Previous Week Addition
total = total - week;
// Adjust Week
week = adjust;
// Add to Total
total = total + week;
}

// Total Amount
ThingSpeak.writeField(myChannelNumber, 1, total, myWriteAPIKey);
// Amount Since Emptying
ThingSpeak.writeField(myChannelNumber, 2, week, myWriteAPIKey);

// Low Power During Delay
System.sleep(wait);
delay(wait);
// Allow WIFI Recovery
delay(10000);
}

Archive
https://hackaday.io/project/10654-garbage-gauge

13:44:18 17-016

@pkvi
"...may not meet professional standards."
12,126 miters
0 miters today
202 tenons
Subscribe