-
API use
10/20/2017 at 17:38 • 0 commentsOct 20, 2017
One last note: Early in my project (and in previous logs) I reference the analysis code that determined actions needed for composting. My final prototype moves this logic off of the microprocessor and into the AWS cloud. I do this for a few reasons:
- ease of making programming/code updates
- simplifying the work the microprocessor does (allowing for increased battery life)
- ability to leverage machine learning capabilities (especially as I get more data about how the system reacts in expanded use)
- using location information (gathered during the registration process) to get additional weather information (rainfall, sunlight, outside temperature, etc). This reduces the number of sensors needed in the Compost Bin, reducing the overall cost
- ability to persist data and make this data available to other channels (Alexa, web dashboard, phone app, etc)
That being said, I strongly believe in this project and I want others to duplicate it, so access to those APIs is free. I will publish data on the APIs shortly, but in the interim, you can use the API calls as-is in the Arduinio code.
I'll create a registration process in the next month for use (to better track who is using the APIs and restrict the number of API calls to a reasonable amount). If there are any questions on the API use, reach out to be directly (in the comments or Twitter) and I'll provide additional guidance. -
The Science of Composting
10/20/2017 at 04:05 • 0 commentsThere a a few sites that I relied heavily on when writing the analytics system.. wanted to pass these along:
- Cornell Composting - http://compost.css.cornell.edu/
- The University of Illinois - Composting For The Home Owner - https://web.extension.illinois.edu/homecompost/science.cfm
- Home Composting Made Easy - http://www.homecompostingmadeeasy.com/
- The Compost Gardener - http://www.the-compost-gardener.com/
-
Fritzing Diagrams
10/20/2017 at 04:00 • 0 commentsOct 19 2017 -
Fritzing Diagrams are embedded in the build instructions, but wanted to post them here as well.
-
3D Files
10/20/2017 at 03:42 • 0 commentsOctober 19, 2017
I printed my early prototypes, cases, etc on my home 3D printer (a Monoprice Maker Select Plus, which I highly recommend). I used a 3D printing service for my final prototype prints. Pictures below. STL files on thingiverse - https://www.thingiverse.com/thing:2586719
-
Creating a New User Interface
10/01/2017 at 05:34 • 0 commentsOct 1, 2017
Version 2 of Compost Professor used a web-based GUI to inform users of the status of their compost, and actions they needed to take. I initially planned to make the GUI a phone application that would provide information via Bluetooth... however, based on my own experiences, I went a different direction.
In my house, my kids are responsible for putting our kitchen scraps into the compost bin (it's one of their chores). I can barely get them to do their chores... there was NO WAY that they were going to look at a phone app to determine if they should add "green", water the compost, or stir the compost.
So I went with a battery powered "kitchen" unit that provides explicit directions on the screen.
There are still a few things to work out:
- The voltage divider that I use to read the battery status slowly drains the battery. I added a capacitor is series with one of the voltage divider sensors (as recommended on another site), but I don't think it's going to do. Ultimately I think I'll use a transistor to turn "on/off" the voltage divider
- I'm using an ESP8266 - primary because of the low cost. I'm thinking of switching to sending data via radio packets (to the "base hub, which has internet and RFM69 capability). I believe this will help with battery management as well.
- I put the ESP8266 into deep sleep, but that means it's about 3 seconds to "wake-up" the device. Might not seem like a long time, but it is when you're standing at the counter waiting to take scraps outside after dinner.
- The TFT screen back-light stays on even when the ESP8266 is asleep. There weren't great options to deal with that on the prototype TFT screen I am using. Other TFTs require a pin to pull HIGH for the back light to turn on... this would resolve the problem.
-
Starting Final Prototype Build
09/26/2017 at 03:44 • 0 commentsSept 25 2017
Been a while since I last wrote a log... I've successfully ported the code from Arduino 101 to ESP8266 and ATMega32u4 bases. I'm using Adafruit feathers for the prototypes. These are great boards for prototyping:
- They have feathers/wing for multiple chip types and functions (I've played with the ESP8266, ATMega and M0 Cortex models, with "add ons" for RFM69 packets and TFT screens)
- VCC is 3.3 V - this restricts some sensors (namely gas sensors). I'm ok with the trade off, as it reduces battery consumption.
- There's a wealth of documentation available.
It hasn't been perfect, there are some challenges - specifically, I struggled to get the RFM and TFT components to work together (though this isn't because of the Adafruit construction - it's due to the way the RFM libraries are written).
I've also started to design and print the cases for the components (building on the files provided by Adafruit).
-
Major Changes to the MVP
08/30/2017 at 03:50 • 0 commentsAugust 29, 2017
I've started work on the new prototype. Key changes:
- Moving from Arduino 101 board to Adafruit Feathers (RFM and ESP8266). The feathers (and their associated wings) have a smaller form factor and lower power requirements (3.3v v 5.0 volts).
- Adding a physical compost bin
- Adding a physical display (a TFT screen). I may still use a web app/bluetooth phone app, but I thought seeing the feedback as easy as possible made the most sense.
-
MVP - Solar Powered Smart Compost System
08/14/2017 at 21:59 • 0 commentsAug 14 2017 -
It's been a busy few months since my last log. I've updated the solution as follows:- communication between devices using radio packets
- solution waterproof and solar powered
- solution integrated into Alexa skill
- solution notifies users of status via a kitchen compost bin
The good news is that I've tested the logic and feel comfortable with the analysis algorithm.
The bad (or good, depending on the point of view) is that the solution still requires work:
- I originally designed the solution as an "add-on" to an existing compost bin. Based on user feedback, I need to create an "all-encompassing solution", which includes an outdoor compost bin
- I am unable to power the entire solution (servo, Arduino, and pump) with one rechargeable battery.
I'm in the process of making design changes, now. The goal is to have a more robust prototype available for testing by early September.
-
Analyze Sensors and Take Action Code
06/11/2017 at 05:10 • 0 comments6/11/2017 -
I am still waiting for my LoRa sensors to arrive; in the meantime, I've started writing the logic that will interpret the sensor data. This code will run on the base station. The flow is:
- Base station requests sensor data
- Satellite station returns sensor values
- Base station interprets data and sends commands to satellite station
- Satellite station takes requested action (water compost, open vent, etc)
- Base station saves sensor data to database
- Base station saves UI data (warning colors, messages) to database for easy retrieval
The first pass of the code is below:
from datetime import timedelta, datetime import json def main: # TODO implement #return 'Hello from Lambda' tempMessageArray = [ "Your compost is at optimal levels.", #0 "Your compost is ready for use. At your convenience, move your sensors to a new compost pile/layer.", #1 "Your compost heating cycle is complete and is in a 'curing stage'.", #2 "Your compost has reached an unsafe temperature. Immediately turn the compost and add water.", #3 "Your compost has reached unhealthily temperature. At your convenience, turn compost and add 'brown' (Carbon-rich) materials.", #4 "Your compost temperature is slightly higher than optimal. You may want to turn the compost and add 'brown' materials.", #5 "Your compost temperature is slightly higher than optimal, but is staring to cool off. I will let you know if any action is required.", #6 "Your compost is at optimal temperature.", #7 "Your compost temperature is slightly lower than optimal, but is staring to warm up. I will let you know if any action is required.", #8 "Your compost temperature is slightly lower than optimal, and is continuing to cool. At your convenience, turn compost and add 'green' (Nitrogen-rich) materials.", #9 "Your compost temperature is slightly lower than optimal, and is continuing to cool. The ambient temperature is low, so you should cover your compost to continue aerobic composting." #10 ] moistureMessageArray = [ "Your compost moisture content is too high. Turn your compost and add 'green' (Nitrogen-rich) materials.", #0 "Your compost moisture content is too high but is starting to dry out. I will let you know if any action is required.", #1 "Your compost is at optimal moisture levels.", #2 "Your compost moisture content is too dry, but is starting to reach optimal moisture. I will let you know if any action is required.", #3 "Your compost is too dry and requires your attention. You need to turn and water your compost." #4 ] #warnings success = "alert alert-success" info = "alert alert-info" warning = "alert alert-warning" danger = "alert alert-danger" #Limits tempDanger = 175 tempHigh = 160 tempOK = 140 tempLow = 90 moistHigh = 60 moistLow = 40 #get inputs for analysis sensorDataJSON = getSensorData() trendDataJSON = getTrendData() days = handleDateLogic() #set variables tempF = sensorDataJSON["tempF"] tempC = sensorDataJSON["tempC"] moisture = sensorDataJSON["moisture"] methane = sensorDataJSON["methane"] waterLevel = sensorDataJSON["waterLevel"] ambientTemp = sensorDataJSON["ambientTemp"] tempTrend = trendDataJSON['tempTrend'] moistTrend = trendDataJSON['moistTrend'] tempAlert = info moistAlert = info methaneAlert = info waterLevelAlert = info OverallMsg = tempMessageArray[0] msgPriority = 3 #1 = trumps all other actions, #2 additive if days > 35: OverallMsg = tempMessageArray[1] elif days > 25: OverallMsg = tempMessageArray[2] else: # the compost is not ready ################################################################ #Handle Temperatures if tempF > tempDanger: addWater() openVent() tempAlert = danger OverallMsg = tempMessageArray[3] msgPriority = 1 elif tempDanger >= tempF > tempHigh: addWater() openVent() tempAlert = danger OverallMsg = tempMessageArray[4] msgPriority = 1 elif tempHigh >= tempF > tempOK: if tempTrend < 1: openVent() tempAlert = warning OverallMsg = tempMessageArray[5] msgPriority = 2 else: tempAlert = warning OverallMsg = tempMessageArray[6] msgPriority = 2 elif tempOK >= tempF > tempLow: tempAlert = success OverallMsg = tempMessageArray[7] msgPriority = 3 else: closeVent() if tempTrend > 0: tempAlert = warning OverallMsg = tempMessageArray[8] msgPriority = 2 else: if ambientTemp =="low": tempAlert = danger OverallMsg = tempMessageArray[10] msgPriority = 1 else: tempAlert = warning OverallMsg = tempMessageArray[9] msgPriority = 2 ####################################################################### #handle Moisture content if moisture> moistHigh: if moistTrend>=0: moistAlert = danger if msgPriority > 1: #this message will trump any other message besides temp priority 3 OverallMsg = moistureMessageArray[0] openVent() msgPriority = 1 else: moistAlert = warning if msgPriority == 2: # this message is appended to any existing P2 messages OverallMsg = OverallMsg + " " + moistureMessageArray[1] openVent() msgPriority = 2 elif msgPriority == 3:#this message is replaces any P3 messages OverallMsg = moistureMessageArray[1] openVent() msgPriority = 2 elif moistHigh >=moisture> moistLow: moistAlert = success else: if moistTrend<1: moistAlert = danger if msgPriority > 1: #this message will trump any other message besides priority 1 OverallMsg = moistureMessageArray[4] closeVent() addWater() msgPriority = 1 else: moistAlert = warning if msgPriority == 2: # this message is appended to any existing P2 messages OverallMsg = OverallMsg + " " + moistureMessageArray[3] addWater() msgPriority = 2 elif msgPriority == 3:#this message is replaces any P3 messages OverallMsg = moistureMessageArray[3] addWater() msgPriority = 2 ####################### #Handle Water Level if waterLevel <= 0: waterLevelMsg = "Refill" waterLevelAlert = danger else: waterLevelMsg = "Ok" waterLevelAlert = success ####################### #Handle Methane Level if methane > 50000: methaneAlert = danger elif 50000 >= methane > 10000: methaneAlert = warning else: methaneAlert = success writeToDatabase() return OverallMsg ##################################################### def getSensorData(): #stub to get sensor data #read request and recieve data from sensors #return data to function tempF = 85 tempC = (tempF - 32) * 5/9 ambientTempF = 50 if ambientTempF <=40: ambientTemp = "low" else: ambientTemp = "high" return {"tempF":tempF, "tempC": tempC, "ambientTemp": ambientTemp, "moisture":30, "methane": 23.1, "waterLevel": -1} def getTrendData(): #stub to get trend data #analyze historical data #set thresholds for what up/down/and steady #return data to function return {"tempTrend":1,"moistTrend":1} def handleDateLogic(): #stub to handle date logic #settings for readiness daysWhenReady = 35 daysAtSafeTempLevel = 25 today = datetime.today() #calculations based on trends - hardcoded for testing calcDaysAtSafeTempLevel = 1 #will need to read from database dateOfLastTemp = datetime.strptime('2017-06-01', "%Y-%m-%d") #will need to read from database if calcDaysAtSafeTempLevel >= daysAtSafeTempLevel: dateOf25thDay = datetime.strptime('2017-05-25', "%Y-%m-%d") daysSince25th = abs((today - dateOf25thDay).days) return daysSince25th + daysAtSafeTempLevel else: return calcDaysAtSafeTempLevel def addWater(): #stub to send command to satellite station to add water return 'ok' def openVent(): #stub to send command to satellite station to open vent return 'ok' def closeVent(): #stub to send command to satellite station to close vent return 'ok' def writeToDatabase(): #stub to write values to database return 'ok' def persistSensorData(): #stub to write values to database for trend analysis return 'ok'
-
Logic/Alerts/Actions based on Temperature and Moisture readings
06/09/2017 at 03:16 • 0 comments6/8/2017 -
I am in the process of writing the logic that drives alerts and actuators (water pump and vent open/close). I've create a few tables that will help me to write the AI.
Temperature Logic
Moisture Logic