A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By bobbyh88
#85087 Hi

Files are here 3 (fritzing breadboard sketch and code also below)

I’m a relative newby, and have embarked on a project for my dad to use on his Farm. I have no doubt I haven’t done things perfectly (and possibly even some things wrong) so I thought I’d share my project and see if anyone has any improvements.

Background: we’ve just installed a bore pump which has a pressure switch to turn itself off once the tank it pumps into is full and the inlet float valve closes. As our tank overflows into a dam he doesn’t want to install the float valve.

Instead, taking advantage of the pipe running straight past the house I decided to put a Solenoid valve controlled via a nodemcu. Although just within the wifi signal of the house, we didn’t want to run power out to the valve and hence has been designed to run off solar/battery. Because of this we changed out the usual 24vac solenoid with a 12vdc latching solenoid (pulse required to open valve and reverse polarity pulse required to close. I.e no constant power required to keep valve open).

Specifics:
Solar Panel
6ah SLA battery
Solar controller
12v adjustable buck step down (to 5V)
https://www.banggood.com/3pcs-LM317-DC- ... rehouse=CN


5V 2 channel relay board with selectable low/high activate. I’ve gone with LOW to activate relay. The two relays are wired to reverse the polarity for open/close commands.
https://www.ebay.com.au/itm/273802234110?ul_noapp=true

Nodemcu
Logic Level converter (to interface from 3.3v nodemcu to the 5V relay board)
https://www.jaycar.com.au/arduino-compa ... e/p/XC4486 1

Additionally I added the following for local control and monitoring:

2 x momentary switches to open/close valve if wifi is down (by grounding the signal line to LLC and hence relay board)
LCD Voltmeter connected through a centre off momentary dpdt switch to either side of the step down voltage regulator. (to check voltages both sides of the step down, but only when at the panel to avoid unnecessary current draw. I believe I could just used a spdt switch and used a common ground for this but i had the dpdt lying around.l)
Fairly simple Blynk setup. Two virtual pins (V10, V11) attached to the Open and closed button pins on Nodemcu. Also chucked in a wifi signal setproperty as the install will be right on edge of the wifi range.

A couple of specific questions.

For setup and testing I’ve been using a constant 12.4V supply from wall wart. When I deploy and connect to Solar/battery obviously the input voltage will range based on how sunny it is and how much we’ve drained from battery. Will this effect the 5V output of the step down, and hence cause issues for the Nodemcu and relay board both powered off the 5V?

The physical buttons are just a direct connections between signal circuit to ground. So when physical button is pressed although the Nodemcu is default HIGH the physical button grounds the signal line to LLC and then relay board. Although functionally this is working I’d like some feedback on whether this is good/best practice.

I havent quite got my head around pull-up/pull-down resistors. Being good practice I have pulled up the D1 Output pin to 5V. Do I need to, or is this done on the board itself?

Any questions/comments would be greatly appreciated as this project has given me a good feel for what is possible.


Code: Select all//To Control Irrigation Solenoid valuve at Farm

//Open button (V10) and close button (V11) to trigger relays forcing solednoid valve to open/close

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

char auth[] = "xxxx";
char ssid[] = "xxxx";
char pass[] = "xxxx";

BlynkTimer timer;

int value;
int relaypin1 = 4;  // digital pin for relay 1
int relaypin2 = 5;  // digital pin for relay 2
String displaywifi;
int wifisignal;

void setup()
{
  // Debug console
  Serial.begin(115200);
  digitalWrite(relaypin1, HIGH);
  digitalWrite(relaypin2,HIGH);
  pinMode(relaypin1,OUTPUT);
  pinMode(relaypin2,OUTPUT);

  Blynk.begin(auth, ssid, pass);
 
  timer.setInterval(1000000L, sendwifi);
   
}

BLYNK_WRITE(V10)
{
  value = param.asInt(); // Get State of Virtual Button
 
  Serial.print("V10 button value is: ");
  Serial.println(value);
 
  if (value ==1){
    digitalWrite(relaypin1,LOW);
  }
  else{
    digitalWrite(relaypin1, HIGH);
  }
}

BLYNK_WRITE(V11)
{
  value = param.asInt(); // Get State of Virtual Button
 
  Serial.print("V10 button value is: ");
  Serial.println(value);
 
  if (value ==1){
    digitalWrite(relaypin2, LOW);
  }
  else{
    digitalWrite(relaypin2,HIGH);
  }
}

void loop()
{
  Blynk.run();
  timer.run();
}
void sendwifi()
{
  wifisignal = map(WiFi.RSSI(), -105, -40, 0, 100);
  displaywifi = String("           Wifi: ") + wifisignal +String("%");
   
  Blynk.setProperty(V10, "label", displaywifi);
  Blynk.setProperty(V11, "label", displaywifi);
 
}

BLYNK_APP_CONNECTED(){
  Blynk.syncAll();
 
}



IMG_1795.jpg

IMG_1797.jpg

IMG_1798.jpg

IMG_1817.jpg

IMG_1921.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
By btidey
#85117 Your step down converter is based on a linear regulator (LM317) even though it is misleadingly described as a buck (switching) converter. This means that whatever current is needed at the 5V level is also drawn from the 12V supply making the efficiency very poor.

You really need to use a proper buck converter for this which then means the current drawn from the 12V supply will be much less.

To give a concrete example, say the 5V current was 100mA then with your current converter the draw from 12V will also be 100mA. With a proper buck the current drawn will be 100mA * 5 / 12 / efficiency. The efficiency is typically 0.9 so current drawn will be about 46mA.

Both linear and buck converters should have very little variation in output voltage as the input varies providing the input is in the operating range (say above 7V).

D1 (GPIO05) does not have an internal pull up on the board. You can program it to activate the on chip pull up (~36K) but it is best to use an external lower value (e.g. 10K) unless your leads to the switch are short.

Best luck for your useful project.
User avatar
By Bonzo
#85119 A nice neat looking project; I think if it looks neat people have more faith in it. You should see some of the lash ups people make where I work.

You could think about using one of the sleep functions to extend battery life and/or a MOSFET to turn the sensor off for a set time. I would have thought you would only need to check the level every 15min or less?

I see you have a good size box; I seem to spend more time finding a suitable enclosure when I do control boxes at work than selecting all the other components!
User avatar
By bobbyh88
#85132 I picked up the box from my local Jaycar before id figured out how it was all going to fit together.
I was worried the box wasnt going to be big enough, and started looking around online (ebay, aliexpress etc) for a larger box and there really isnt much out there.

Glad i managed to get it into the one i had.