seperate stuff to functions, cleanup
This commit is contained in:
parent
c3e6e8dd9e
commit
d7f92f57ba
1 changed files with 14 additions and 48 deletions
|
@ -74,21 +74,6 @@ const unsigned char* bmpallArray[1] = {
|
|||
bmpCanGrow_Logo
|
||||
};
|
||||
|
||||
// I2C moisture sensor measurements
|
||||
// soil moisture value
|
||||
int chirpMoisture;
|
||||
int chirpMoistureOld = 0 ;
|
||||
// temp value from i2c sensor
|
||||
int chirpTemp;
|
||||
int chirpTempOld = 0;
|
||||
// light intensity value
|
||||
int chirpLight;
|
||||
int chirpLightOld = 0;
|
||||
|
||||
// DHT measurements
|
||||
float dhtTemp;
|
||||
float dhtHumidity;
|
||||
|
||||
DHT dht(PINdht, DHTTYPE);
|
||||
|
||||
void writeI2CRegister8bit(int addr, int value) {
|
||||
|
@ -180,6 +165,13 @@ int getSoilmoisture() {
|
|||
return soilmoisture;
|
||||
}
|
||||
|
||||
int getLightchirp() {
|
||||
// get the "light value" from I2C chirp module
|
||||
writeI2CRegister8bit(0x20, 3); //request light measurement
|
||||
int lightchirp = readI2CRegister16bit(0x20, 4);
|
||||
return lightchirp;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// setup pins
|
||||
pinMode(PINfan, OUTPUT);
|
||||
|
@ -225,43 +217,14 @@ void setup() {
|
|||
}
|
||||
|
||||
void loop() {
|
||||
chirpMoisture = readI2CRegister16bit(0x20, 0);
|
||||
|
||||
/*
|
||||
* Test for refresh one value. Test read i2c values
|
||||
Serial.print(readI2CRegister16bit(0x20, 0)); //read capacitance register
|
||||
Serial.print(", ");
|
||||
Serial.print(readI2CRegister16bit(0x20, 5)); //temperature register
|
||||
Serial.print(", ");
|
||||
writeI2CRegister8bit(0x20, 3); //request light measurement
|
||||
Serial.println(readI2CRegister16bit(0x20, 4)); //read light register
|
||||
|
||||
display.setCursor(0,0);
|
||||
display.print("Capacitance: ");
|
||||
|
||||
display.setCursor(73,0);
|
||||
display.setTextColor(SSD1306_BLACK);
|
||||
display.print(chirpMoistureOld);
|
||||
display.display();
|
||||
|
||||
|
||||
display.setCursor(73,0);
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
display.println(chirpMoisture);
|
||||
float chirpMoistureF = chirpMoisture / 10;
|
||||
display.print(chirpMoisture);
|
||||
chirpMoistureOld = chirpMoisture;
|
||||
*/
|
||||
|
||||
|
||||
// set display cursor to top left
|
||||
display.setCursor(0,0);
|
||||
// display text
|
||||
display.print("I2C: ");
|
||||
display.print(getSoilmoisture());
|
||||
display.print(", ");
|
||||
display.println(getTemperature(1));
|
||||
/* display.print(", ");
|
||||
writeI2CRegister8bit(0x20, 3); //request light measurement
|
||||
display.println(readI2CRegister16bit(0x20, 4)); */
|
||||
|
||||
|
||||
display.print("DHT11: ");
|
||||
display.print(getTemperature(0));
|
||||
|
@ -270,10 +233,13 @@ void loop() {
|
|||
display.display();
|
||||
|
||||
|
||||
display.print(":) Water: ");
|
||||
display.print("Water Status: ");
|
||||
display.println(getWaterlevel());
|
||||
|
||||
display.print("light: ");
|
||||
display.println(getLightchirp());
|
||||
|
||||
// print everything on the display
|
||||
display.display();
|
||||
delay(800);
|
||||
|
||||
|
|
Loading…
Reference in a new issue