|
|
Line 11: |
Line 11: |
| | | |
| The arduino code for the first working version of the henmulator can be found at the [https://github.com/agronimo/incubator/blob/master/program/program.ino agronimo github page] | | The arduino code for the first working version of the henmulator can be found at the [https://github.com/agronimo/incubator/blob/master/program/program.ino agronimo github page] |
− |
| |
− | <nowiki>
| |
− | /*
| |
− |
| |
− | *
| |
− |
| |
− | * Hardware
| |
− |
| |
− | * - Arduino hardware (@todo)
| |
− |
| |
− | * - HTU21D
| |
− |
| |
− | *
| |
− |
| |
− | * Ardunio (@todo)
| |
− |
| |
− | *
| |
− |
| |
− | *
| |
− |
| |
− | * HTU21D
| |
− |
| |
− | * SparkFun HTU21D Humidity sensor.
| |
− |
| |
− | * Link to SparkFun's underlying firmware and example code.
| |
− |
| |
− | * https://github.com/sparkfun/HTU21D_Breakout
| |
− |
| |
− | *
| |
− |
| |
− | */
| |
− |
| |
− |
| |
− |
| |
− | // included Arduino libraries
| |
− |
| |
− | #include <HTU21D.h>
| |
− |
| |
− |
| |
− |
| |
− | // global constants
| |
− |
| |
− | #define UPPER_TEMP_THRESHOLD 38 //ideal is 37.5 for hatching 15.5 for holding
| |
− |
| |
− | #define LOWER_TEMP_THRESHOLD 37 //ideal is 37.2 for hatching 13 for holding
| |
− |
| |
− |
| |
− |
| |
− | // local variables
| |
− |
| |
− | int lightState = HIGH;
| |
− |
| |
− | int humidState = HIGH;
| |
− |
| |
− | int lightPin = 11;
| |
− |
| |
− | int humidPin = 13;
| |
− |
| |
− |
| |
− |
| |
− | HTU21D sensorchip;
| |
− |
| |
− |
| |
− |
| |
− | void setup()
| |
− |
| |
− | {
| |
− |
| |
− | Serial.begin(9600);
| |
− |
| |
− | sensorchip.begin();
| |
− |
| |
− | pinMode (lightPin, OUTPUT);
| |
− |
| |
− | pinMode (humidPin, OUTPUT);
| |
− |
| |
− | digitalWrite(lightPin, lightState);
| |
− |
| |
− | digitalWrite(humidPin, humidState);
| |
− |
| |
− | }
| |
− |
| |
− |
| |
− |
| |
− | void loop() {
| |
− |
| |
− | // temperature
| |
− |
| |
− | float temp = sensorchip.readTemperature();
| |
− |
| |
− | if (temp == 988) {
| |
− |
| |
− | return;
| |
− |
| |
− | }
| |
− |
| |
− | else if (temp > UPPER_TEMP_THRESHOLD)
| |
− |
| |
− | {
| |
− |
| |
− | lightState = LOW;
| |
− |
| |
− | digitalWrite(lightPin, lightState);
| |
− |
| |
− | }
| |
− |
| |
− | else if(temp < LOWER_TEMP_THRESHOLD)
| |
− |
| |
− | {
| |
− |
| |
− | lightState = HIGH;
| |
− |
| |
− | digitalWrite(lightPin, lightState);
| |
− |
| |
− | }
| |
− |
| |
− |
| |
− |
| |
− | // humidity
| |
− |
| |
− | float humidity = sensorchip.readHumidity();
| |
− |
| |
− | if (temp == 988) {
| |
− |
| |
− | return;
| |
− |
| |
− | }
| |
− |
| |
− | else if (temp > UPPER_TEMP_THRESHOLD)
| |
− |
| |
− | {
| |
− |
| |
− | lightState = LOW;
| |
− |
| |
− | digitalWrite(lightPin, lightState);
| |
− |
| |
− | }
| |
− |
| |
− | else if(temp < LOWER_TEMP_THRESHOLD)
| |
− |
| |
− | {
| |
− |
| |
− | lightState = HIGH;
| |
− |
| |
− |
| |
− |
| |
− | digitalWrite(lightPin, lightState);
| |
− |
| |
− | }
| |
− |
| |
− | } </nowiki>
| |
Revision as of 11:53, 7 February 2015
The Henmulator (hen emulator) is Agronomo and Jacob Springs Farm's inaugural project to incorporate open source hardware and software into useful farm devices.
Earlier versions
Mike Soltys' engineering class.
Enclosure
Arduino Code
The arduino code for the first working version of the henmulator can be found at the agronimo github page