- Joined
- Jun 18, 2020
- Messages
- 6,240
- Reputation
- 5,445
- Reaction score
- 25,725
- Points
- 0
- Currently Smoking
- The current harvest
Hey Friends
For those of you, I haven't reached...Happy New Year!!!
The tinkerer in me didn't lay low during the holidays...I've mounted the NodeMCU which controls the Extraction fan. Just disconnected the 'original' potmeter and replaced it with the digital potmeter. Easy peacy...
If there is anyone interested in the code...
Next up I've been working on integrating the heating mat in the system. I've put together a NodeMCU with a Solid State Relay because we are going to switch a resistive load. Didn't think about the placement before gluing the NodeMCU to the casing. Had to cut a piece from the connector to make it fit the USB socket... Stupid
Instead of cutting the wire from the heating mat, I decided on harvesting the outer parts of an extension cable. Surprisingly this costs as much as a male and female plug bought separately, go figure... Should have ordered a couple of buck converters then I could have swiped the power from the 220V AC and I could have parted with the extra usb cable for 5V. Maybe a upgrade project for the future...
This device receives temperature data from another NodeMCU, which has the DHT44 sensor attached and uses that to switch the relay on or off.
In the Blynk App on my phone I can set the desired temperature.
Anyway...the code for this project...
Regards,
Bob
For those of you, I haven't reached...Happy New Year!!!
The tinkerer in me didn't lay low during the holidays...I've mounted the NodeMCU which controls the Extraction fan. Just disconnected the 'original' potmeter and replaced it with the digital potmeter. Easy peacy...
If there is anyone interested in the code...
C++:
#define BLYNK_TEMPLATE_ID "TMPLxxxxxx"
#define BLYNK_DEVICE_NAME "Device"
#define BLYNK_AUTH_TOKEN "Token Here"
// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <FastX9CXXX.h>
//Potmeter pins
#define X9_1_CS_PIN 4
#define X9_1_UD_PIN 2
#define X9_1_INC_PIN 0
char auth[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// Set password to "" for open networks. --> never do this IRL
char ssid[] = "SSID Wifi here";
char pass[] = "Password Wifi here";
FastX9C103 Potentiometer1(X9_1_CS_PIN, X9_1_UD_PIN, X9_1_INC_PIN);
int step1 = 0;
BLYNK_WRITE(V2) {
if (param.asInt()) {
step1 = param.asInt(); // assigning incoming value from pin V2 to a variable
Potentiometer1.JumpToStep(step1, true);
Serial.print("step1 value:");
Serial.println(step1);
Serial.print(F("Potentiometer 1 current resistance: "));
Serial.print(Potentiometer1.GetEstimatedResistance(), DEC);
Serial.println(F(" Ohm\t"));
} else {
}
}
void setup() {
// Debug console
Serial.begin(115200);
Blynk.begin(auth, ssid, pass, "192.168.0.100", 8080); //Use a local Blynk server on a rPi as Blynk IOT is not free anymore!!
}
void loop() {
Blynk.run();
}
Next up I've been working on integrating the heating mat in the system. I've put together a NodeMCU with a Solid State Relay because we are going to switch a resistive load. Didn't think about the placement before gluing the NodeMCU to the casing. Had to cut a piece from the connector to make it fit the USB socket... Stupid
Instead of cutting the wire from the heating mat, I decided on harvesting the outer parts of an extension cable. Surprisingly this costs as much as a male and female plug bought separately, go figure... Should have ordered a couple of buck converters then I could have swiped the power from the 220V AC and I could have parted with the extra usb cable for 5V. Maybe a upgrade project for the future...
This device receives temperature data from another NodeMCU, which has the DHT44 sensor attached and uses that to switch the relay on or off.
In the Blynk App on my phone I can set the desired temperature.
Anyway...the code for this project...
C++:
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "Token here";
char ssid[] = "SSID Wifi here";
char pass[] = "Password Wifi here";
int relay = 4; //relay switch
int i;
float tempData; //input room temperature
float setPoint; //input wanted room temperature from Blynk App
// Timer for blynking
BlynkTimer timer;
void setup() {
Serial.begin(115200);
Blynk.begin(auth, ssid, pass, "192.168.1.155", 8080); //Use a local Blynk server on a rPi as Blynk IOT is not free anymore!!
Blynk.syncAll();
pinMode(relay, OUTPUT);
timer.setInterval(5000L, runMe);
}
void loop() {
Blynk.run();
timer.run();
}
BLYNK_WRITE(V0){
i = param.asInt();
digitalWrite(relay, i);
}
BLYNK_WRITE(V4){
setPoint = param.asFloat();
}
BLYNK_WRITE(V5){
tempData = param.asFloat();
}
void runMe() {
Serial.print("Temp: ");
Serial.println(tempData);
Serial.print("Setpoint: ");
Serial.println(setPoint);
Serial.print("Relay: ");
Serial.println(i);
if (tempData <= setPoint - 0.2) {
digitalWrite(relay, LOW);
Blynk.virtualWrite(V0, LOW);
}
else if (tempData >= setPoint + 0.2) {
digitalWrite(relay, HIGH);
Blynk.virtualWrite(V0, HIGH);
}
}
Regards,
Bob