Skip to content

Commit

Permalink
Connecting to real components
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlynch committed Jan 20, 2017
1 parent e824f3d commit 5edff46
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 51 deletions.
41 changes: 0 additions & 41 deletions greenpithumb/fake_sensors.py

This file was deleted.

20 changes: 12 additions & 8 deletions greenpithumb/greenpithumb.py
@@ -1,7 +1,10 @@
import argparse
import time

import fake_sensors
import Adafruit_DHT

import clock
import dht11
import humidity_sensor
import light_sensor
import moisture_sensor
Expand All @@ -13,13 +16,14 @@ class SensorHarness(object):
"""Simple container for GreenPiThumbs that polls their values and prints."""

def __init__(self, wiring_config):
# TODO(mtlynch): Hook wiring_config up to components that depend on it.
self._adc = fake_sensors.FakeAdc(
light_start=500.0, moisture_start=600.0)
self._light_sensor = light_sensor.LightSensor(self._adc)
self._moisture_sensor = moisture_sensor.MoistureSensor(self._adc)
self._dht11 = fake_sensors.FakeDht11(
temperature_start=35.0, humidity_start=150.0)
local_clock = clock.LocalClock()
self._light_sensor = light_sensor.LightSensor(
self._adc, wiring_config.adc_channels.light_sensor)
self._moisture_sensor = moisture_sensor.MoistureSensor(
self._adc, wiring_config.adc_channels.soil_moisture_sensor)
self._dht11 = dht11.CachingDHT11(
lambda: Adafruit_DHT.read_retry(Adafruit_DHT.DHT11, wiring_config.gpio_pins.dht11),
local_clock)
self._temperature_sensor = temperature_sensor.TemperatureSensor(
self._dht11)
self._humidity_sensor = humidity_sensor.HumiditySensor(self._dht11)
Expand Down
4 changes: 2 additions & 2 deletions greenpithumb/wiring_config.ini.example
Expand Up @@ -13,5 +13,5 @@ mcp3008_cs_shdn: 25
# adc_channels section maps which GreenPiThumb component is connected to which
# channel of the MCP3008 ADC.
[adc_channels]
soil_moisture_sensor: 0
light_sensor: 6
soil_moisture_sensor: 7
light_sensor: 0

0 comments on commit 5edff46

Please sign in to comment.