New build, work in progress.

The fruits of our labor. We welcome all types of plants, but grows posted here must be legal.
Shimbob
LED Wizard
LED Wizard
Reactions:
Posts: 642
Joined: Mon Nov 27, 2017 11:29 pm

About a week left. I think I finally made a dent in the gnats problem, it's gnat funny how many there were.
IMG_20200922_235039.jpg
IMG_20200921_224048.jpg
Shimbob
LED Wizard
LED Wizard
Reactions:
Posts: 642
Joined: Mon Nov 27, 2017 11:29 pm

Chopped!
That's it for round 2. Round 3 will start when we're back from a short road trip.
IMG_20200927_193335-r.jpg
IMG_20200927_193523-r.jpg
IMG_20200927_200222-r.jpg
NLDhunt
LED-Curious
LED-Curious
Reactions:
Posts: 24
Joined: Tue Sep 03, 2019 9:12 am

Great job, Shimbob!

Those chunky little fatties look great. Dont tell em i said, they dont like being called chunky. :D

Thanks for posting.
Shimbob
LED Wizard
LED Wizard
Reactions:
Posts: 642
Joined: Mon Nov 27, 2017 11:29 pm

The hlg-185 I'm running in this 2x5 is underpowered, but the hlg-320-42ab I want to upgrade to is impossible to find!
Shimbob
LED Wizard
LED Wizard
Reactions:
Posts: 642
Joined: Mon Nov 27, 2017 11:29 pm

In preparation of moving sensors to esp8266 nodes, I cobbled this code together while waiting for the hardware to arrive. Hasn't been tested yet.
Instead of having the rPi's i2c bus run all the way down to the plants, which I think is too long and corrupting data, my new plan is to have an esp8266 down by the plants with the AM2315 temp/humi sensor and an ADS1115 with 4 capacitive soil moisture sensors. Connected over wifi with MQTT.

Code: Select all

//for WIFI
#include <ESP8266WiFi.h>
const char* ssid = "teehee"; //Enter SSID
const char* password = "poopoo"; //Enter Password
IPAddress staticIP(192,168,2,50);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,0,0);

//for i2c
#include <Wire.h>

//for MQTT
#include <PubSubClient.h>
WiFiClient espClient;
PubSubClient client(espClient);
const char* mqtt_server = "192.168.2.1";
#define MSG_BUFFER_SIZE  (50)
char msg[MSG_BUFFER_SIZE];
char tempString[8];


//for soil moisture
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads(0x48);

//for am2315
#include <Adafruit_AM2315.h>
Adafruit_AM2315 am2315;

//this device's name
const char* espName = "espOne";
//loop delay ms
const int interval = 5000; 

void wifi_setup() {
   WiFi.persistent( false );
   WiFi.begin(ssid, password);
   WiFi.config(staticIP, gateway, subnet);
   WiFi.setOutputPower(10.0); //0 to 20.5
  
  while (WiFi.status() != WL_CONNECTED) 
  {
     delay(500);
     Serial.print("*");
  }
}

void i2c_setup()
{
  Wire.begin();
  
  ads.begin();

  if (! am2315.begin()) {
     Serial.println("am2315 not found, check wiring & pullups!");
     while (1);
  }
  
}

void mqtt_connect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");

    // Attempt to connect
    if (client.connect(espName)) { 
      
      Serial.println("connected");
      // Once connected, publish an announcement...
      client.publish("outTopic", "espOne Online");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

void mqtt_setup()
{
    client.setServer(mqtt_server, 1883);
    client.setCallback(callback);
    mqtt_connect();
}

void read_ads()
{
  int16_t adc0, adc1, adc2, adc3;
 
  adc0 = ads.readADC_SingleEnded(0);
  adc1 = ads.readADC_SingleEnded(1);
  adc2 = ads.readADC_SingleEnded(2);
  adc3 = ads.readADC_SingleEnded(3);
  
  dtostrf(adc0, 4, 1, tempString);
  client.publish("soil/moisture/0", tempString);

  dtostrf(adc1, 4, 1, tempString);
  client.publish("soil/moisture/1", tempString);
  
  dtostrf(adc2, 4, 1, tempString);
  client.publish("soil/moisture/2", tempString);

  dtostrf(adc3, 4, 1, tempString);
  client.publish("soil/moisture/3", tempString);
}

void read_am2315()
{
    float temperature, humidity;
    
    if (! am2315.readTemperatureAndHumidity(&temperature, &humidity)) {
      Serial.println("Failed to read data from AM2315");
      return;
    }
  
      Serial.print("Temp *C: "); Serial.println(temperature);
      Serial.print("Hum %: "); Serial.println(humidity);

      dtostrf(temperature, 4, 1, tempString);
      client.publish("canopy/temperature", tempString);

      dtostrf(humidity, 4, 1, tempString);
      client.publish("canopy/humidity", tempString);
}

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
  }
  Serial.println();

  //this is where we received a message and need to reply?
}

void setup()
{
  Serial.begin(115200); 
  wifi_setup();
  i2c_setup();
  mqtt_setup();
}

void loop() {
  unsigned long lastMsg = 0;  
  unsigned long now = 0;

  if (WiFi.status() != WL_CONNECTED) {
    wifi_setup();
  }

  if (!client.connected()) {
    mqtt_connect();
  }

  now = millis();
  if (now - lastMsg > interval) {
    lastMsg = now;
    
    read_ads();

    read_am2315();
  }
  
  client.loop();
}
Shimbob
LED Wizard
LED Wizard
Reactions:
Posts: 642
Joined: Mon Nov 27, 2017 11:29 pm

Hell yeah, worked on first try!
IMG_20201102_174442.jpg
User avatar
LEDG
Site Admin
Reactions:
Posts: 1599
Joined: Sun Jun 04, 2017 8:15 pm

Shimbob wrote:
Tue Nov 03, 2020 1:46 am
Hell yeah, worked on first try!
IMG_20201102_174442.jpg
What?!

That never happens. You're lying. :lol:
Want to Support the Site?

Use this Amazon referral link and any purchase you make within 24 hrs will earn LEDgardener a commission at no cost to you!
Shimbob
LED Wizard
LED Wizard
Reactions:
Posts: 642
Joined: Mon Nov 27, 2017 11:29 pm

Bonafide genuine truth.
Can you tell where I watered?
IMG_20201102_220857.jpg
Shimbob
LED Wizard
LED Wizard
Reactions:
Posts: 642
Joined: Mon Nov 27, 2017 11:29 pm

What's weird though is that overnight after watering, moisture crept up slowly. I don't know why, yet.
IMG_20201103_130844.jpg
Shimbob
LED Wizard
LED Wizard
Reactions:
Posts: 642
Joined: Mon Nov 27, 2017 11:29 pm

Screenshot_20201121-103816_Chrome_Beta.png
Automation of watering is happening very soon...
Post Reply