So, is the trashcan full?
First thing we need to know is the height of an empty trashcan, so the first thing to do when the device is turned on for the first time is send a few pings and remember the distance to the bottom. Subsequent pings will show shorter and shorter distance. Once the distance goes back to around what we measured as empty, we know that the can was emptied. Sherlock stuff right there.
We use cheap and simple to use HC-SR04 ultrasonic rangefinder sensor modules to measure the distance. Arduino sends the impulse, measures the time to echo, and calculates the distance from average speed of sound.
Where is the trashcan?
Built in GPS device gives quite precise directions. AT+CGNSINF command sent to SIM808 returns a total of 21 comma-separated values, most importantly run status (is it on), fix status (did it find out it's poisition), UTC time, longitude and latitude. Things like altitude, speed, course and such are less important in this case, as we are working with stationary objects. UTC time comes in handy though - we don't need an RTC.
SIM808 module is connected to Arduino's general data pins, and controlled via software serial. This setup leaves hardware serial available for debugging.
Is it really working?
Now that's a tricky question. Moisture is a big issue for electronics, and trash inside a tin can is sure to get some condensation going. But this is out of scope for our prototype.
The other issue is temperature: while Arduino and SIM808 are declared to work in -40 C to +85 C range, HC-SR04 works from about -15 C to +70 C. So, leave your trashcan in a sunny spot on a sunny day, and our device might measure whatever. But the temperature also affects the speed of sound, and we need to take it into account for distance calculations. So we added a temperature sensor brick, based on TTC3A103.
Main power source is a 1200 mAh Li-Ion battery, plugged to SIM808 module, that also powers up Arduino. It should allow for more than two hours of peak consumption during data transfer. Supposing the station works a minute every day, it should have enough juice for 200+ days of data collection.
But yet another nice thing with SIM808 is, it's got a micro USB plug, and we got an USB solar panel. Battery charging is enabled by a simple AT command, and it's smart enough to charge the battery only when solar panel provides enough voltage.
And there you go, we got self-sufficient electronics.
Sending the data
SIM808 includes a GSM module, with HTTP available via AT+HTTPPARA command. To make things real easy, we are using simple HTTP GET to deliver all the data.
Request parameters are:
stationId - some unique station identifier, preferably MSISDN read from SIM card
gpsInfo - whatever was returned by AT+CGNSINF
temp - temperature measured
can[1-5] - distance measured in containers 1 to 5.
Collecting the data
A simple Java servlet listens for incoming HTTP requests and stores everything to the database. Request is parsed and parameters stored to a single database table. We use Hibernate, so it should work with any database, though we use posgresql.
To make things easier for anyone willing to experiment, the servlet is open to public at our server: http://www.mikrotron.hr/ecotronserver/upload - all request parameters are optional, but make sure to include stationId, or you won't be able to fetch the data.
Getting the data
There's a few more servlets to display the data, and all require stationId parameter.
Download servlet makes a CSV file containing all the available data for a station.
Last servlet returns last data for a station, as a JSON string.
StationList servlet returns the list of all known stations, as text, one station per line.
Again, they are available to public: