Im amazed at how close the light it to the buds.
![Idea :idea:](./images/smilies/icon_idea.gif)
Yup, if you look at the first picture here, the drawer sliders can be seen on each side of the drawer. The water tubing and sensor wires had to be routed a certain way as to not pinch but it's worked out well.almostcompost wrote: ↑Wed Dec 23, 2020 5:39 amGood shit, Shimbob! I really like your cabinet build. Great use of space. Did you say that each platform is built on drawer slides? Genius idea!
Code: Select all
//espTwo
//Measures canopy leaf temperature
const char* espName = "espTwo";
int interval = 5000; //ms
#include <ESP8266WiFi.h>
const char* ssid = "";
const char* password = "";
IPAddress staticIP(192,168,2,51);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,0,0);
#include <Wire.h>
#include <PubSubClient.h>
WiFiClient espClient;
PubSubClient client(espClient);
const char* mqtt_server = "192.168.2.1";
char tempString[8];
unsigned char payload[64];
String mesg;
//for IR Heat
#include <Adafruit_MLX90614.h>
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
double temp;
//////////////////////////////////////// SETUP CODE
void wifi_setup() {
WiFi.persistent( false );
WiFi.begin(ssid, password);
WiFi.config(staticIP, gateway, gateway, subnet);
WiFi.setOutputPower(10.0); //0 to 20.5
while (WiFi.status() != WL_CONNECTED)
delay(500);
}
void i2c_setup()
{
Wire.begin();
mlx.begin();
}
void mqtt_connect() {
while (!client.connected()) {
if (!client.connect(espName))
delay(1000);
}
}
void callback(char* topic, byte* payload, unsigned int length);
void mqtt_setup()
{
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
mqtt_connect();
client.subscribe("espTwo/get_status");
client.subscribe("espTwo/setInterval");
client.publish("espTwo/status", "espTwo Online");
}
///////////////////////////////////////////////////////// END SETUP
///////////////////////////////////////////////////////// RUNTIME CODE
void callback(char* topic, byte* payload, unsigned int length) {
if (0==strcmp(topic, "espTwo/get_status")){
mesg = "get_status: interval: ";
dtostrf(interval, 7, 0, tempString);
mesg += tempString;
mesg += "ms";
mesg.toCharArray((char *)payload, 127);
client.publish("espTwo/status", (char *)payload);
}
else if (0 == strcmp(topic, "espTwo/setInterval"))
interval = atoi((char *)payload);
}
void setup()
{
wifi_setup();
i2c_setup();
mqtt_setup();
}
void do_temp()
{
temp = mlx.readAmbientTempC();
dtostrf(temp, 3,1, tempString);
client.publish("canopy/LeafTemp" , tempString);
}
void loop() {
if (WiFi.status() != WL_CONNECTED)
wifi_setup();
if (!client.connected())
mqtt_connect();
do_temp();
client.loop();
delay(interval);
}