Arduino Climate Control

I switch over from a 300 Watt CMH to a HLG 100 v2. I can confirm with my light sensor that it is 2/3 the light output. The description of the HLG 100 v2 says it is equivalent to a 200 Watt CMH. Temperatures are way down, as expected, so that is good.

After a reboot of the arduino the outdoor sensor is back online. I realized that it is kind of a pain to debug one arduino with tons of pins set up. I can't debug it in the attic so bringing it down is time consuming. I'm thinking of changing directions from one mega arduino with long cable runs to multiple smaller arduinos.
 
After a reboot of the arduino the outdoor sensor is back online. I realized that it is kind of a pain to debug one arduino with tons of pins set up. I can't debug it in the attic so bringing it down is time consuming. I'm thinking of changing directions from one mega arduino with long cable runs to multiple smaller arduinos.

I had the same issue, but found an old laptop on wireless works great. Plug the arduino into the usb port, and then you can use Chrome Remote Desktop to access it, just run a local copy of the arduino ide, and open up the com port monitor.

I have two Mega's plugged into the laptop...

Capture.JPG
 
I had the same issue, but found an old laptop on wireless works great. Plug the arduino into the usb port, and then you can use Chrome Remote Desktop to access it, just run a local copy of the arduino ide, and open up the com port monitor.

I have two Mega's plugged into the laptop...

Capture.JPG

It doesn't fix the long wire issue. Wireless communications would. There are several pre-built module options available including WiFi, Bluetooth, and RF.
 
I like that idea of getting a cheap computer and remoting into it. Looks like that would only be a $100. Plus I might be able to think of other things to do with it.

As for the long wire issue, I'm looking into POE (Power Over Ethernet). I already have a 5 port switch that can supply the power. I'm disappointed that an Arduino with POE is about $40. That can add up fast. But I decided to try one, hopefully it will be here next weekend. I did look into RF, but for now since my longest cable run is 15 feet and I would have to have a power cable anyway, so hopefully just running a single ethernet cable will be easy.
 
I am still in the process of moving to multiple arduinos. I have to separate out some of my code as well as figure out how make the devices communicate with each other. I've started looking at Blynk. It took me less than 30 minutes to install the server and make my code use it. I don't really care about the phone UI aspects of it, though it is pretty cool. But I'm interested in their bridge functionality where one device can read a virtual pin from another device. The virtual pin on the device it is being read from is a function call back so this can happen in real time. So far Blynk has required very little code on my part so I'm happy with the idea of not writing a network client/server program from scratch. I know that it wouldn't be that much code to do it from scratch, but debugging that stuff can be time consuming. Hopefully by the end of the week I will have an arduino inside the tent for the sensors and an arduino outside of the tent for the power relays.

So far, since I closed my tents from fresh air, the CO2 seems to be doing fine, normally in the 450-500 range. Before I was in the 350-450 range, so I guess the Exhale bag is working. Also low humidity was a problem, I was consistently in 20-30% range, once it read 9%. In the last 2 days, the range was 42-52% without a humidifier. Beside the Exhale bag, the only active measures have been the heater. I have a 200 watt cozy legs cubicle leg warmer. With a 62 degree outside temperature when lights were off, the inside of the tent was 67 degrees. My target temperature was 70 degrees, so I guess 200 watts isn't really enough, but it helped.

Overall, since closing the tent, I have had better control over the environment, but I still have a lot of work to do. I know it will be import to get A/C done in the next 30 days. The plants have been doing much better. Here is what they look like now.
1752040
 
Thanks for the updates @bobinca!

I like that idea of getting a cheap computer and remoting into it.

Perhaps a Raspberry Pi or Beagle Bone? Toss a distro on there and remote in for much less than $100.

I'm looking into POE (Power Over Ethernet)

I looked into this and became concerned with the current limitations. If I understand correctly even type4 has a max draw of just under an amp. I know I was pulling 400mA with just a mega2560 and a 4up mechanical relay. It would be nice to daisy chain as well but this would result in even greater demands on a single run. I plan to use five conductor solid copper (18/5 thermostat wire) and run 9V DC over two of the conductors and serial on another pair. I have some RS485 modules and will be trying to implement MQTT over that standard. Any thoughts on that? I'm still not 100% convinced it's the best way to go.
 
@DrewT I think the best part of tinkering with all this is that there are so many options. I hadn't considered running my own extension wire for 9V. I have experience running ethernet at home and even POE security cameras. So I guess that is why my mind went in the POE direction.

As for the small computer in the grow space, I think I was just looking for an excuse for a small Windows box. I have a powerful Linux sever running in a closet and tried to get my security camera set up to run on it. But the Linux security software, like zoneminder, never had the features I was looking for. For me the perfect software for security cameras is Blue Iris, which runs on Windows. For now it runs on my main computer, but I've meaning to move it to its own server. Now this gave me an excuse to kill 2 birds with one stone.
 
I got 2 arduinos talking to each other using blynk. I have to say it was a little harder than I thought it would be. Blynk bridge only allows an arduino to push data, not request it. So if "A" wanted data from "B", it has to send a request to ask for it then wait for it. This is the code I used

"A"
C++:
int fetchRemoteSoilMoisture(int plantId) {
  blynkWaitingForResponse = true;
  bridge1.virtualWrite(V41, plantId);
  for (int i=0;i<10000 && !blynkWaitingForResponse;i++) {
    delayAndResetWatchdog(10);
    Blynk.run();
  }
  if (!blynkWaitingForResponse) {
    SERIAL_PRINTLN(F("fetchRemoteSoilMoisture timed out"));
  }
}

BLYNK_WRITE(V30){
  SERIAL_PRINTLN(F("sensor hardware responded"));
  blynkWaitingForResponse = false;
}

Having a dedicated virtual pin for "B" to signal to "A" that the request was handled isn't really necessary for single pieces of information, but some times I ask for more than one thing at a time and this makes that easier.
 
I got 2 arduinos talking to each other using blynk. I have to say it was a little harder than I thought it would be. Blynk bridge only allows an arduino to push data, not request it. So if "A" wanted data from "B", it has to send a request to ask for it then wait for it. This is the code I used

"A"
C++:
int fetchRemoteSoilMoisture(int plantId) {
  blynkWaitingForResponse = true;
  bridge1.virtualWrite(V41, plantId);
  for (int i=0;i<10000 && !blynkWaitingForResponse;i++) {
    delayAndResetWatchdog(10);
    Blynk.run();
  }
  if (!blynkWaitingForResponse) {
    SERIAL_PRINTLN(F("fetchRemoteSoilMoisture timed out"));
  }
}

BLYNK_WRITE(V30){
  SERIAL_PRINTLN(F("sensor hardware responded"));
  blynkWaitingForResponse = false;
}

Having a dedicated virtual pin for "B" to signal to "A" that the request was handled isn't really necessary for single pieces of information, but some times I ask for more than one thing at a time and this makes that easier.

I had this code running all night where it made a request every 10 seconds. So it seems to work well. If you wanted data every 10 seconds then it would be easier to just have "B" push it every 10 seconds. I need the request to work because for soil sensors you have to power them up then take a reading, you don't want to leave them on all the time because of corrosion. Normally they will push a reading once per hour, but when automatically watering a plant, I want a reading from the overflow sensor 30 seconds after I water, if no overflow, then water a little bit more, etc.
 
I got a small Windows box sitting on top of one of my tents now. It turns out I didn't need to worry about power over ethernet. The USB cables from the box reached all 3 of arduinos. I have one inside the tent for sensors, I have one near the fresh air intake and one next to all the power relays to control heating, fans, etc. I had a few hick ups while working out the bugs the last couple of days. Last night the plants experienced temperatures in the 50s because I programmed the wrong pin for the heater. I have to say, I really like having the arduinos hooked up to a dev environment so that I can make programming changes easily.

I currently have all 3 hooked up to Blynk as well as logging directly to a mysql server so that I can continue to use Grafana.

Still on my todo list,

1) add another tent so that I can separate veg/flower spaces. The tent is already setup, but I need to do the ducting.
2) add a/c
3) do automatic water.

a/c has to be done in the next month or two because summer is coming, automatic watering needs to be fully tested and running for a couple of weeks before my vacation in July. Nothing like a hard deadline to keep one motivated.

Here is my Blynk screen so far, temp 1 / humid 1 / light 1 refer to tent #1. #2 is not hooked up yet. The top 4 led's are green if the device is on, so in the screen shot, the heater and light are on, the outside air fan and dehumidifier are off.

1755166
 
Only five days since the last plant picture. They have really taken off. I originally only planned two plants in the 36x20 inch space (5 sq ft), but when I ordered seeds I got a free seed and wanted to try that too. Now I'm worried how cramped it is going to get. The free one was Pineapple Chunk, the other two I bought were White Widow and Blue Mystic. I believe White Widow is on the left, Pineapple on the bottom and Blue Mystic on the right. Unfortunately when I transplanted them from my colored pots, to all black fabric pots I forgot to label them :)

Even though I monitor conditions by logging temperature, humidity, etc, from the arduino, I really like having a camera where I can see the temperature and humidity on a separate device. It gives me piece of mind. Lately temperature has been +/- 2 and humidity +/- 5 between the monitor and the arduino which isn't too bad. I only physically check on them about 2 times a week, so that is probably a bit unique compared to most people here.

1756062
 
One of my outdoor temperature sensors went down. I replaced the sensor and still had the same problem. I did some research on the DHT22 and found that some people had the same problems and blamed timing issues. Turns out they had a board that was a little faster than the uno/mega. My board was faster too, it was a M4. So I swapped out the board with a mega and now it works. Kind of ridiculous to use a mega with just one sensor hooked up. But as of now my code won't run on a uno because the program is too big. I have 3 arduinos and to keep it simple I use the same sketch on all 3, but with different configs. Weird that it worked for a week on the M4 with no problem.
 
My DHT22's keep doing the same, and I'm using Mega's. Unplugging them and plugging them back in seems to work (the sensor). I even power them from a digital pin so I can toggle the power off and on when it fails, but that doesn't always work. I will probably look for an alternative sensor. I currently have 3 of them in use.
 
My DHT22's keep doing the same, and I'm using Mega's. Unplugging them and plugging them back in seems to work (the sensor). I even power them from a digital pin so I can toggle the power off and on when it fails, but that doesn't always work. I will probably look for an alternative sensor. I currently have 3 of them in use.

I started researching this and I like the idea of I2C interface for this. The SHT31 looks promising.
 
Wired directly to the Wemos Mega. They will work for a while, then start reporting 0's, or nan. Powering them down and back up does not fix the problem, or at least, rarely fixes it. Strangely, unplugging it and plugging it back in seems to correct it.
 
Great topic! I am currently running a wemos mini d1 reading a dht22 sensor and a ds18b20 water sensor. I am running hydro dwc so these help me keep a good growing environment. I am currently working on a pH monitor but looks like I am going to have to buffer a bunch of readings over a period of time since the readings that I am currently getting are all over the place due to air bubbles.

@bobinca What GUI or SW are you running for your readings? Looks pretty neat!
 
@Dro I've posted two UIs so far, the last one was Blynk, the other one which just show graphs is Grafana. I have a Linux server running mysql, grafana and blynk. Blynk is fun, but to really look at my data over time I prefer Grafana.

For Grafana, the arduino will post the data by constructing a url

C++:
void sendData() {
  char url[256];
  int len;
 
  strcpy(url, "/data/adddata.php?deviceid="); 
  str_append(url, config.deviceid, 256);
  str_append(url, "&temperature=", 256);
  str_append(url, data.lastTemp, 256);

The server, via php, will insert the data from the post into mysql
PHP:
<?php

    $username = "";
    $pass = "";
    $host = "localhost";
    $db_name = "logdata";
    $con = mysqli_connect ($host, $username, $pass);
    $db = mysqli_select_db ( $con, $db_name );

    $sql_insert = "INSERT INTO device_data (deviceid, temperature, outdoorTemperature, humidity, outdoorHumidity, lux, co2) VALUES ('".$_GET["deviceid"]."', '".$_GET["temperature"]."', '".$_GET["outdoorTemperature"]."', '".$_GET["humidity"]."', '".$_GET["outdoorHumidity"]."', '".$_GET["lux"]."', '".$_GET["co2"]."')";
    //echo $sql_insert;
    if(mysqli_query($con,$sql_insert))
    {
        echo "Done";
        mysqli_close($con);
    }
    else
    {
        echo "error is ".mysqli_error($con );
    }
?>
 
@Dro I've posted two UIs so far, the last one was Blynk, the other one which just show graphs is Grafana. I have a Linux server running mysql, grafana and blynk. Blynk is fun, but to really look at my data over time I prefer Grafana.

For Grafana, the arduino will post the data by constructing a url

C++:
void sendData() {
  char url[256];
  int len;

  strcpy(url, "/data/adddata.php?deviceid=");
  str_append(url, config.deviceid, 256);
  str_append(url, "&temperature=", 256);
  str_append(url, data.lastTemp, 256);

The server, via php, will insert the data from the post into mysql
PHP:
<?php

    $username = "";
    $pass = "";
    $host = "localhost";
    $db_name = "logdata";
    $con = mysqli_connect ($host, $username, $pass);
    $db = mysqli_select_db ( $con, $db_name );

    $sql_insert = "INSERT INTO device_data (deviceid, temperature, outdoorTemperature, humidity, outdoorHumidity, lux, co2) VALUES ('".$_GET["deviceid"]."', '".$_GET["temperature"]."', '".$_GET["outdoorTemperature"]."', '".$_GET["humidity"]."', '".$_GET["outdoorHumidity"]."', '".$_GET["lux"]."', '".$_GET["co2"]."')";
    //echo $sql_insert;
    if(mysqli_query($con,$sql_insert))
    {
        echo "Done";
        mysqli_close($con);
    }
    else
    {
        echo "error is ".mysqli_error($con );
    }
?>
That's awesome! Yeah I was talking about Grafana, it looks neat. I have been using just adafruit free site for right now but looking for some other options.

I am a big blynk fan but I like to use that for more controls than monitoring.
 
Back
Top Bottom