Work and family have kept me busy just lately. The last few weeks have been extremely busy, flooding at work due to bad weather plus several kids at home breaking everything they touch.
So, as a complete noob with not much spare time to seek specialist help from you guys I need something to concentrate on when the kids are asleep or the weather has overwhelmed the site.
Give me some suggestions for these, a challenge(not too difficult, please) I’ll attempt anything, preferably something useful but anything with these. I’m here to learn so feel free to push my limits, but not too much hopefully.
I like semi-practical projects that help learn and then eventually can be used in reality.
Don’t know about the mouse and tweezers but you could try to wire up all 8 relays (just themselves at first for the clicking and indicator LEDs) and have them trigger in various looping patterns… perhaps with arrays called from the menu widget?
Finally, wire them up to actual lamps for a large scale light show… like oldschool RGB strip lighting
This is Nagini, she’s a Colombian Boa. Had her since she was only 11 inches long, she’s now almost 8 feet. This pic is the only one I have on my phone, she was about 5 feet long back then. She’s a little more sedate now, I can feed her by hand. But a few years ago I had to use large tweezers because I like my fingers with skin on them …
Yes she does and I paid a small fortune for her control gear years ago. Long before I knew anything about code/microprocessors. But that is a great idea, something I will definitely be looking into later on.
Decided to use a Wemos D1 Mini Pro because they will both run on 5v .
5th relay from the left is stuck, not sure why …
I did think of that, so I swapped the Blue and Green leads over to see if the fault swapped too. It didn’t, so I’m pretty sure the relay is faulty. I’ve ordered a replacement. Hopefully they’ll refund me for this this faulty one.
Me Pete, I’m the problem. I’ve seen road kill with better coding skills than me …
However, I refuse to let it beat me.
I’ve cheated, searched this forum and found some snippets of code. Fingers crossed I’ll have at least 1 relay operating via a button on my phone by morning.
After reading all the comments in this post I decided to use @dutchman’s code as a base and build off it. My version of it isn’t the best, and it’s a bit laggy but its works.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "credentials.h"
BlynkTimer timer;
int relay1 = 14;
int relay2 = 12;
int relay3 = 13;
int relay4 = 15;
int relay5 = 2;
int relay6 = 0;
int relay7 = 4;
int relay8 = 5;
int relayVButton1 = 0;
int relayVButton2 = 0;
int relayVButton3 = 0;
int relayVButton4 = 0;
int relayVButton5 = 0;
int relayVButton6 = 0;
int relayVButton7 = 0;
int relayVButton8 = 0;
boolean relayState1 = 1;
boolean relayState2 = 1;
boolean relayState3 = 1;
boolean relayState4 = 1;
boolean relayState5 = 1;
boolean relayState6 = 1;
boolean relayState7 = 1;
boolean relayState8 = 1;
WidgetLED led1(10); //virtual led
WidgetLED led2(11); //virtual led
WidgetLED led3(12); //virtual led
WidgetLED led4(13); //virtual led
WidgetLED led5(14); //virtual led
WidgetLED led6(15); //virtual led
WidgetLED led7(16); //virtual led
WidgetLED led8(17); //virtual led
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass, server, 8080);
timer.setInterval(300L, somefunction);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
pinMode(relay5, OUTPUT);
pinMode(relay6, OUTPUT);
pinMode(relay7, OUTPUT);
pinMode(relay8, OUTPUT);
digitalWrite(relay1, 1);
digitalWrite(relay2, 1);
digitalWrite(relay3, 1);
digitalWrite(relay4, 1);
digitalWrite(relay5, 1);
digitalWrite(relay6, 1);
digitalWrite(relay7, 1);
digitalWrite(relay8, 1);
}
void somefunction()
{
if (relayVButton1 > 0)
{
relayState1 = !relayState1;
}
digitalWrite(relay1, relayState1);
if (relayVButton2 > 0)
{
relayState2 = !relayState2;
}
digitalWrite(relay2, relayState2);
if (relayVButton3 > 0)
{
relayState3 = !relayState3;
}
digitalWrite(relay3, relayState3);
if (relayVButton4 > 0)
{
relayState4 = !relayState4;
}
digitalWrite(relay4, relayState4);
if (relayVButton5 > 0)
{
relayState5 = !relayState5;
}
digitalWrite(relay5, relayState5);
if (relayVButton6 > 0)
{
relayState6 = !relayState6;
}
digitalWrite(relay6, relayState6);
if (relayVButton7 > 0)
{
relayState7 = !relayState7;
}
digitalWrite(relay7, relayState7);
if (relayVButton8 > 0)
{
relayState8 = !relayState8;
}
digitalWrite(relay8, relayState8);
if (digitalRead(relay1) == LOW)
{
led1.on();
}
else
led1.off();
if (digitalRead(relay2) == LOW)
{
led2.on();
}
else
led2.off();
if (digitalRead(relay3) == LOW)
{
led3.on();
}
else
led3.off();
if (digitalRead(relay4) == LOW)
{
led4.on();
}
else
led4.off();
if (digitalRead(relay5) == LOW)
{
led5.on();
}
else
led5.off();
if (digitalRead(relay6) == LOW)
{
led6.on();
}
else
led6.off();
if (digitalRead(relay7) == LOW)
{
led7.on();
}
else
led7.off();
if (digitalRead(relay8) == LOW)
{
led8.on();
}
else
led8.off();
}
BLYNK_WRITE(V1)
{
relayVButton1 = param.asInt();
}
BLYNK_WRITE(V2)
{
relayVButton2 = param.asInt();
}
BLYNK_WRITE(V3)
{
relayVButton3 = param.asInt();
}
BLYNK_WRITE(V4)
{
relayVButton4 = param.asInt();
}
BLYNK_WRITE(V5)
{
relayVButton5 = param.asInt();
}
BLYNK_WRITE(V6)
{
relayVButton6 = param.asInt();
}
BLYNK_WRITE(V7)
{
relayVButton7 = param.asInt();
}
BLYNK_WRITE(V8)
{
relayVButton8 = param.asInt();
}
void loop() {
Blynk.run();
timer.run();
}
man, try to use arrays + for cycles for tasks like this! the above solution is soo lame and not scalable. think about it, what if next time you need to use 500 relays / anythings? you would manually declare 500 variables? no…
I did look at arrays yesterday but gave up as it just complicated getting the code working. I’m still very much a noob plus it’s only 8, not 500. I found the code easier to follow and the errors I made easier to find by having 8 of each.
However, you are correct so now I know the code works I will attempt to use arrays instead.
they seems complicated at the beginning, but after you understand the basic principle, it is quite logical. just do not forget that the first element index is always 0, not 1. this can cause most of the confusion for beginners.
but you can write much cleaner code with them
good luck with the learning!
Got to site early this morning so I’d have a little time to try and solve this array thing before starting work. Unfortunately 5 guys want to leave early so they turned up early too on the off chance I would be here, so not had much Blynk time this morning.
I think I’m close, but no cigar.
So to cheer myself up I’ve ordering 8 small 12v water pumps that I will connect to these relays(once I figure out this array thing) and make a simple version of this:
EDIT.
One of the labourers has just reversed the Manitou into the trench(footings) we’re about to pour concrete into, crushed the reinforcement. Great start to the day.
So if anyone would like to take a look and tell me whats wrong while I’ll clean up this mess I’d really appreciate it because now its not working at all …