Arduino uno, load cell and selenoid valve close

Hello everybody,
I am new to Arduino. I am working on a filling machine project which contains a load cell and solenoid valve. I want to push a button while the solenoid valve at open position and when the container filled 6kg Arduino will close the valve. Selonoid valve is 12 volt and I will use a relay for controlling it.
I am using HX711. I made all the connections, uploaded the program for measuring the weight. Calibration done and I am done too. This is the first time I am trying to build someting to control with sensors. Can anyone help me how to prepare a code for closing the valve?
Thank you very much.

You read the weight and when 6 kg You switch the relay.
Use 5 volt relay modules. Then the relay coil uses the same power supply as the controller.
Make a drawing, pen and paper do well, showing the schematics.

1 Like

Your relay driver may as well control the solenoid directly,..

I want to push a button while the solenoid valve at open position and when the container filled 6kg Arduino will close the valve.

Why push a button to enable closing the valve… wouldn’t it be better to ‘press to open’, then let the arduino weigh the load, and close the valve at the right moment ? — basically an automatic filler ?

2 Likes

Hint: valves come in normally open and normally closed. Normally open you have to energize to turn off. Normally closed you have to energize to turn on. The type of valve will affect your program.

1 Like

Which Arduino? Is the solenoid DC or AC? How much current or Watts does the solenoid require? If 12V DC, I would buy a module with 12V relay(s) to relieve the Arduino from supplying the 75mA relay coil current or use a MOSFET transistor to switch the solenoid.

1 Like

Hello
For shure.
Post your sketch well formated, with comments and in code tags <"/"> to see how we can help.

1 Like

Thank you all for your messages. I am using a 12V DC selonoid valve , 20 kg load cell, HX711, Arduino Uno clone. Valve is Normally open position. when closed had to open again with hand manually. Sketch of the system is below.

Code I am using to read the mass is below.

*/

#include "HX711.h"

#define DOUT 3

#define CLK 2

HX711 scale(DOUT, CLK);

float calıbration factor = 107000; // calibration factor

void setup() {
Serial.begin(9600);
scale.set_scale(calibration factor ); // calıbration factor defination
scale.tare(); // reseting the scale
}
void loop() {
Serial.print("Mass: ");
Serial.print(scale.get_units()); // printing the scaled mass volume
Serial.println(" kg");
}

Thank you in advance for your helps.

Hello
The sketch is missing the declaration und initialization of the I/O pins for the push botton and relay.
And don´t forget to post your sketch in code tags.

Thank you for all your . I apologize I couldn't thank you all before. I had a traffic accident and had a femur neck fracture on my left leg and the doctor put 3 screws. This is why I couldn't thank you before. While resting I changed some parts and code, but still having some problems. I will add the schematic and codes soon and will ask for your help again.