Compare commits

..

No commits in common. "2acaa92a6ac2b5dc08a94c546926ad0c66fcf031" and "2cdfdb68c520f682f9307e80499c774b7ad6ff5a" have entirely different histories.

View file

@ -1,33 +1,9 @@
/*
* CanGrow - simply DIY automatic plant grow system (for cannabis).
*
* Pin assignment
* ==============
*
* D0 - DHT11
* D1, D2 - I2C
* D3 - MOSFET Fan
* D4 - MOSFET Pump
* D5 - MOSFET Grow LED, PWM
*
*/
#include <SPI.h> #include <SPI.h>
#include <Wire.h> #include <Wire.h>
#include <Adafruit_GFX.h> #include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h> #include <Adafruit_SSD1306.h>
#include "DHT.h"
uint8_t PINdht = D3;
uint8_t PINfan = 3;
uint8_t PINpump = 4;
uint8_t PINled = 5;
#define WIRE Wire #define WIRE Wire
#define DHTTYPE DHT11
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &WIRE); Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &WIRE);
// 'CanGrow_Logo', 128x32px // 'CanGrow_Logo', 128x32px
@ -73,22 +49,15 @@ const unsigned char* bmpallArray[1] = {
}; };
// I2C moisture sensor measurements
// soil moisture value // soil moisture value
int chirpMoisture; int soilMoisture;
int chirpMoistureOld = 0 ; int soilMoistureOld = 0 ;
// temp value from i2c sensor // temp value from i2c sensor
int chirpTemp; int temp1Val;
int chirpTempOld = 0; int temp1ValOld = 0;
// light intensity value // light intensity value
int chirpLight; int lightVal;
int chirpLightOld = 0; int lightValOld = 0;
// DHT measurements
float dhtTemp;
float dhtHumidity;
DHT dht(PINdht, DHTTYPE);
void writeI2CRegister8bit(int addr, int value) { void writeI2CRegister8bit(int addr, int value) {
Wire.beginTransmission(addr); Wire.beginTransmission(addr);
@ -113,28 +82,23 @@ void setup() {
writeI2CRegister8bit(0x20, 6); //reset writeI2CRegister8bit(0x20, 6); //reset
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x32 display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Address 0x3C for 128x32
pinMode(PINdht, INPUT); display.display();
dht.begin(); delay(1000);
display.clearDisplay(); display.clearDisplay();
display.display(); display.display();
display.drawBitmap(0, 0, bmpCanGrow_Logo, 128, 32, WHITE); display.drawBitmap(0, 0, bmpCanGrow_Logo, 128, 32, WHITE);
display.display(); display.display();
delay(2500); delay(5000);
display.clearDisplay();
display.display();
display.setTextSize(1); display.setTextSize(1);
display.setTextColor(SSD1306_WHITE, SSD1306_BLACK); display.setTextColor(SSD1306_WHITE);
} }
void loop() { void loop() {
chirpMoisture = readI2CRegister16bit(0x20, 0); soilMoisture = readI2CRegister16bit(0x20, 0);
/*
* Test for refresh one value. Test read i2c values
Serial.print(readI2CRegister16bit(0x20, 0)); //read capacitance register Serial.print(readI2CRegister16bit(0x20, 0)); //read capacitance register
Serial.print(", "); Serial.print(", ");
Serial.print(readI2CRegister16bit(0x20, 5)); //temperature register Serial.print(readI2CRegister16bit(0x20, 5)); //temperature register
@ -147,33 +111,16 @@ void loop() {
display.setCursor(73,0); display.setCursor(73,0);
display.setTextColor(SSD1306_BLACK); display.setTextColor(SSD1306_BLACK);
display.print(chirpMoistureOld); display.print(soilMoistureOld);
display.display(); display.display();
delay(800);
display.setCursor(73,0); display.setCursor(73,0);
display.setTextColor(SSD1306_WHITE); display.setTextColor(SSD1306_WHITE);
display.println(chirpMoisture); display.print(soilMoisture);
float chirpMoistureF = chirpMoisture / 10; soilMoistureOld = soilMoisture;
display.print(chirpMoisture);
chirpMoistureOld = chirpMoisture;
*/
display.setCursor(0,0);
display.print("I2C: ");
display.print(readI2CRegister16bit(0x20, 0));
display.print(", ");
display.print(readI2CRegister16bit(0x20, 5));
display.print(", ");
display.print(readI2CRegister16bit(0x20, 5));
writeI2CRegister8bit(0x20, 3); //request light measurement
display.println(readI2CRegister16bit(0x20, 4));
display.print("DHT11: ");
display.print(dht.readTemperature());
display.print(", ");
display.print(dht.readHumidity());
//display.println(readI2CRegister16bit(0x20, 0)); //display.println(readI2CRegister16bit(0x20, 0));
display.display(); display.display();