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). diff --git a/xylem/README.txt b/xylem/README.txt new file mode 100644 index 0000000..b004347 --- /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 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 +[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); + } +} + +