From 3aace4bb4511f0c19e57e30d8b8a5fb717f81b61 Mon Sep 17 00:00:00 2001 From: nik gaffney Date: Wed, 10 Jun 2009 16:38:49 +0200 Subject: [PATCH 1/3] misc/minor --- comm/mod_mycelium.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/comm/mod_mycelium.erl b/comm/mod_mycelium.erl index ffebc2f..b9a5389 100644 --- a/comm/mod_mycelium.erl +++ b/comm/mod_mycelium.erl @@ -12,7 +12,7 @@ start(_Host, _Opt) -> ?DEBUG("MYCELIUM LOADING...", []). -stop(_Host) -> +stop(Host) -> ?DEBUG("MYCELIUM UNLOADING...", []). %%-define(PROCNAME, ejabberd_mycelium). From b04277bf8029706397bf53017097f29053bc2a93 Mon Sep 17 00:00:00 2001 From: nik gaffney Date: Wed, 10 Jun 2009 17:12:29 +0200 Subject: [PATCH 2/3] basic plant sensor interface --- xylem/README.txt | 14 ++++++++++ xylem/serial->pachube.scm | 55 +++++++++++++++++++++++++++++++++++++++ xylem/xylem.pde | 48 ++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 xylem/README.txt create mode 100755 xylem/serial->pachube.scm create mode 100644 xylem/xylem.pde diff --git a/xylem/README.txt b/xylem/README.txt new file mode 100644 index 0000000..676852b --- /dev/null +++ b/xylem/README.txt @@ -0,0 +1,14 @@ + +Basic plant sensor kit which currently outputs; + - soil humidity + - light levels + - human presence + +Hardware interface based loosly on recollection of Martin Howse's +experiements with the Wheatstone Bridge[1] and incorporates parts of a +design published by Rob Faludi[2] which in turn based on a design by +Forrest Mims, with nods to L. Geroge Lawrence, Botanicalls and the +long and tangled path from Jagdish Chandra Bose. + +[1] during piskel08 +[2] http://www.faludi.com/2006/11/02/moisture-sensor-circuit/ diff --git a/xylem/serial->pachube.scm b/xylem/serial->pachube.scm new file mode 100755 index 0000000..a67dae5 --- /dev/null +++ b/xylem/serial->pachube.scm @@ -0,0 +1,55 @@ + +;; interface to the pachube API +;; http://community.pachube.com/?q=node/127 +;; http://community.pachube.com/api + + +; +; +; +; +; 36.2 +; +; +; + +(module pachube scheme + + (require net/url) + + (provide (all-defined-out)) + + (define source (string->url "http://www.pachube.com/api/1951.xml")) + (define api-key "") + + (define (format-data l m) (string-append " +" l "" m "")) + + (define serial (open-input-file "/dev/cu.usbserial-A6004bp0")) + + (define (read-serial) + (process (read-line serial)) + (read-serial)) + + (define (process str) + (let ([data (regexp-split #rx"," str)]) + (printf "light: ~a, moisture: ~a~n" (list-ref data 1) (list-ref data 2)) + (send-data (list-ref data 1) (list-ref data 2)))) + + ;; retrive data + ;; curl --request GET --header "X-PachubeApiKey: YOUR_API_KEY" "http://www.pachube.com/api/504.csv" + + (define (get-test) + (get-pure-port source (list (string-append "X-PachubeApiKey: " api-key)))) + + ;; update the values from a feed + ;; curl --request PUT --header "X-PachubeApiKey: YOUR_API_KEY" --data "test" "http://www.pachube.com/api/504.csv" + + (define (send-data l m) + (display-pure-port (put-impure-port + source + (string->bytes/utf-8 (format-data l m)) + (list (string-append "X-PachubeApiKey: " api-key))))) + + + ) \ No newline at end of file diff --git a/xylem/xylem.pde b/xylem/xylem.pde new file mode 100644 index 0000000..62429f5 --- /dev/null +++ b/xylem/xylem.pde @@ -0,0 +1,48 @@ +// part of the groworld HPI prototype + +#include + +#define lightpin 1 // light sensor on analog pin 1 +#define humidpin 0 // humidity sensor on analog pin 0 +#define power 8 // power for sensors + +unsigned long then = 0; // timer which will run for < 50 days +unsigned long interval = 1; // interval between reads in seconds + +void setup() +{ + pinMode(power, OUTPUT); + pinMode(humidpin, INPUT); + pinMode(lightpin, INPUT); + + Serial.begin(9600); +} + +int lightlevel () +{ + int light = 0; + light = (analogRead(lightpin)); + return light; +} + +int moisturelevel () +{ + int moist = 0; + digitalWrite(power, HIGH); + moist = (analogRead(humidpin)); + digitalWrite(power, LOW); + return moist; +} + +char display[64]; + +void loop() +{ + if (millis() - then > interval*1000) { + then = millis(); + sprintf(display, "%u,%u,%u\n", (unsigned int)then, lightlevel(), moisturelevel()); + Serial.print(display); + } +} + + From 1b4a9e863fde2d159ffa99c627e931b2da9f4934 Mon Sep 17 00:00:00 2001 From: nik gaffney Date: Wed, 10 Jun 2009 17:15:13 +0200 Subject: [PATCH 3/3] sepllink --- xylem/README.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xylem/README.txt b/xylem/README.txt index 676852b..b004347 100644 --- a/xylem/README.txt +++ b/xylem/README.txt @@ -6,8 +6,8 @@ Basic plant sensor kit which currently outputs; Hardware interface based loosly on recollection of Martin Howse's experiements with the Wheatstone Bridge[1] and incorporates parts of a -design published by Rob Faludi[2] which in turn based on a design by -Forrest Mims, with nods to L. Geroge Lawrence, Botanicalls and the +design published by Rob Faludi[2] which was in turn based on a design +by Forrest Mims, with nods to L. George Lawrence, Botanicalls and the long and tangled path from Jagdish Chandra Bose. [1] during piskel08