Suggestions

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. :confounded:

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. :wink:

I like semi-practical projects that help learn and then eventually can be used in reality.

Don’t know about the mouse and tweezers :stuck_out_tongue_winking_eye: 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 :stuck_out_tongue:

1 Like

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 … :laughing:

Now that idea I like, flashy blynky, always hits the spot … :smiley:

1 Like

Does Nagini need lights and/or heater pads turning on/off at certain times, or controlled based on temperature/humidity?

If so then maybe use the relays and ESP32 to do the control?

Pete.

1 Like

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. :+1:

Decided to use a Wemos D1 Mini Pro because they will both run on 5v . :grinning:
5th relay from the left is stuck, not sure why … :expressionless:

Now to Blynkify it.

That pin is shared with the built in LED, so the relay is probably not getting a proper signal? Not sure how to fix that short of “chiseling” it off :stuck_out_tongue:

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.

Relay isn’t faulty. It was my error, voltage was to low, only 4.6v. I’ve now regulated the voltage to 5.1v and all relays are working perfectly. :smiley:

I’ll be “Blynkifying” it soon as I get chance …

1 Like

RELAYS + BLYNK !

1 Like

:joy::joy::joy::joy::joy:

Whats the problem?

Pete.

Oh… that GIF ‘relay’ hurts my eyes (and head) :laughing:

1 Like

Me Pete, I’m the problem. I’ve seen road kill with better coding skills than me … :confounded:

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. :exploding_head:

2 Likes

Hey… I taut we was fwends :stuck_out_tongue:

I thought you have all the relays running in sequence quite nicely, should be relatively simple to call some or all of that from Blynk…

Post yer code, and all :smiley:

1 Like

Hell Yeh! … :+1:

I did it! :star_struck:

Well I sort of did it. :grimacing:

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. :smiley:

#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();
}
1 Like

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…

study this topic:

and arrays in general:

1 Like

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. :grimacing:

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 :wink:
good luck with the learning!

1 Like

I think I’m going to need lots more luck … :joy::joy:

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. :unamused:

I think I’m close, but no cigar. :frowning:
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. :disappointed_relieved:

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 …

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#include "credentials.h"

BlynkTimer timer;

int relay[] = {14, 12, 13, 15, 2, 0, 4, 5};

int relayVButton[] = {0};

boolean relayState[] = {1};

WidgetLED led[] = {10, 11, 12, 13, 14, 15, 16, 17};

int count = 0;

void setup() {
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass, server, 8080);

  timer.setInterval(300L, somefunction);

  for (count = 0; count < 7; count++) {
    pinMode(relay[count], OUTPUT);
  }
  for (count = 0; count < 7; count++) {
    digitalWrite(relay[count], 1);

  }
}

void somefunction() {

  if (relayVButton[count] > 0)
  {
    relayState[count] = !relayState[count];
  }
  digitalWrite(relay[count], relayState[count]);


  if (digitalRead(relay[count]) == LOW)
  {
    led[count].on();
  }
  else
    led[count].off();
}

BLYNK_WRITE(V1)
{
  relayVButton[count] = param.asInt();
}
BLYNK_WRITE(V2)
{
  relayVButton[count] = param.asInt();
}
BLYNK_WRITE(V3)
{
  relayVButton[count] = param.asInt();
}
BLYNK_WRITE(V4)
{
  relayVButton[count] = param.asInt();
}
BLYNK_WRITE(V5)
{
  relayVButton[count] = param.asInt();
}
BLYNK_WRITE(V6)
{
  relayVButton[count] = param.asInt();
}
BLYNK_WRITE(V7)
{
  relayVButton[count] = param.asInt();
}
BLYNK_WRITE(V8)
{
  relayVButton[count] = param.asInt();
}

void loop() {
  Blynk.run();
  timer.run();
}