Homebrewery (Learning Arduino)

Hi all,

I'm currently learning Arduino - automating the beer brewing lab I've got in the loft as a test. Eventually, the project will do the following...

  1. Monitor temperature (using thermistors) at mashtun output and boiler output.
  2. Activate and de-activate kettle elements in the boiler to maintain temperature.
  3. Vary the voltage to a pump in order to change its flow
  4. Activate solenoids at various points to redirect the flow or wort and water.
  5. Interface with the internet so that I can control everything via a website

At the moment, I'm starting simple - as I've learnt to play with switches, I'll start there; just an array of switches (to be mounted on the front of a cliplock box which contains all the electrics) which will eventually be used to manually control the solenoids (#4) and pump (#5) - and override any web commands (#5).

How does the following look as a circuit plan? I'm guestimating a little bit here, and trying to work out theory whilst planning it.

You might want to switch to 0V so Arduino internal pull-ups can be used. The LED/resistor chains then run from switch terminal to +5V. Note that an LED isn't a good pull-down in your circuit as it won't conduct below its turn on voltage.

The analog input circuit doesn't make sense - the wiper of the pot goes to the analog input pin, the other pins to 0V and +5V. The LED isn't useful there.

Markpeace, is your intention to have the LEDs that are on the inputs light up to show when you are pushing the buttons? Or are you wanting them to stay lit up to indicate a status?

If you have a little more detail on your pumps and solenoids, some people here may be able to recommend a shield or shields that may work for you.

Mark

Thanks guys. I really don't know much about all this, so replies like this are really useful in pointing me in directions for learning the next step of stuff (I've worked through some tutorials, but I think working on an actual project might work better for me). I'm off to find out more about pull up and push down resistors now, and will post back with an update soon.

In regards to the other questions...

  • the LEDs were originally just to show the switch was on, but now I'm thinking about it, maybe I want a separate status array, so that the LEDs can report on solenoids, etc when it's eventually Internet controlled.

  • the pump is this one http://goo.gl/xI51p (it'll be the 14 watt option)

  • I was thinking of these solenoids http://goo.gl/XvvBT

Cheers,
Mark

Ok, I've done some reading and learning on pull-up resistors. Before I go ahead and redesign, does the following look right to you? I'm trying to build the switches above, but using the internal pullup as suggested above.

The resistor labelled pin31 is the internal pullup resistor (the software I'm using will emulate current flow etc. for me if I do it this way) - and I'm using the following code:

void setup()
{
  pinMode(31,INPUT);
  digitalWrite(31,HIGH); 
  Serial.begin(9600);
}
void loop()
{
  Serial.println(digitalRead(31)); 
}

On the output pins, you could easily end up with using pull-up resistors in some places and pull-down resistors in other places.

  1. Activate and de-activate kettle elements in the boiler to maintain temperature.
  2. Vary the voltage to a pump in order to change its flow
  3. Activate solenoids at various points to redirect the flow or wort and water.

...have potential safety issues. I'll use #2 as an example. If the Arduino loses power, the kettle elements should automatically turn off. If the kettle element is controlled by a digital pin where HIGH is "make heat" and LOW is off then you would use a pull-down resistor.

Thanks, that's useful - so to paraphrase, and check I understand, anything that controls an external solenoid, element, etc should be on a circuit that uses a pull-down resistor, rather than the internal pull-up resistor. That way, if the arduino dies - and the voltage reverts to low - it will close/turn off.

I've now redesigned by control panel (doesn't do anything except take switch input and light up LEDs for now). Once I'm confident with it, I'll be building it on a strip board.

Can you see anything I've done wrong?

markpeace:
Thanks, that's useful - so to paraphrase, and check I understand, anything that controls an external solenoid, element, etc should be on a circuit that uses a pull-down resistor, rather than the internal pull-up resistor.

Yes.

That way, if the arduino dies - and the voltage reverts to low - it will close/turn off.

Yes. "Fail safe". For some control points it may not matter. For others (like a heater) it is very important.

Can you see anything I've done wrong?

For the Boiler / Fill LED, where is pin 37 connected?

For the Boiler / Fill LED, where is pin 37 connected?

Sorry, I'm being thick, don't quite understand. Pin 37 is the pin on the arduino mega - isn't it the same as the other LED circuits. I'm probably not noticing something though!

I'm picking on pin 37 not because there is something special about it but because using a single LED line as an example makes the discussion a bit easier.

Along the "pin 37 line", you have +5, the label "pin 37", a 100 ohm resistor, an LED, and then a line with a ground symbol. Where along that line is pin 37 connected?

Ah, ok.

My intention was that the +5v would be the actual Pin, written to HIGH to switch the led on. So from there to the 100 ohm resistor, and onwards to the LED and back to ground. Is this wrong?

(In the case of the switches, I've paired the 20K resistor alongside the +5 to signify a pin with its internal pull-up resistor on).

I'm thinking, though, that I could use pins more efficiently; I'm going to be using them to turn solenoids on and off eventually - I guess the high/low that is sent to trigger an NPN transistor could also branch off and light an LED on the monitor panel.

M.

markpeace:
My intention was that the +5v would be the actual Pin, written to HIGH to switch the led on. So from there to the 100 ohm resistor, and onwards to the LED and back to ground. Is this wrong?

No, not wrong.

If you use red LEDs, the current will be 32 milliamps per LED. With 11 LEDs all on, the total is 352 milliamps. The total or the various combinations may exceed the maximum allowed for the processor. In addition, 32 milliamps may exceed the maximum value for your LEDs. You may need to use bigger resistors to limit the total current and the individual current.

What I do ... connect the LED to a potentiometer and a small but reasonably valued resistor. Adjust the potentiometer to larger values until I can just tell that the LED got dimmer. Or, go the other way. Make the LEDs brighter until they reach a level that is clearly visible. For the red LEDs I use, 220 ohms seems to be the "magic spot".

(In the case of the switches, I've paired the 20K resistor alongside the +5 to signify a pin with its internal pull-up resistor on).

How did you choose 20 K?

I'm thinking, though, that I could use pins more efficiently; I'm going to be using them to turn solenoids on and off eventually - I guess the high/low that is sent to trigger an NPN transistor could also branch off and light an LED on the monitor panel.

Yes. Which helps when troubleshooting.

Thanks for that, these replies are really useful in making making me think things through.

I read (possibly misread) somewhere that the internal pull up resistors were the equivalent of 20k - not right?

I'll do the potentiometer thing - hypothetically, what happens if the load is too high?

markpeace:
Thanks for that, these replies are really useful in making making me think things through.

You are welcome.

I read (possibly misread) somewhere that the internal pull up resistors were the equivalent of 20k - not right?

20 K to 50 K. But, the internal pull-up is considered "weak". In general, 10 K is a good starting point.

hypothetically, what happens if the load is too high?

The processor will be damaged.

Woo, that doesn't sound fun. I've not been paying attention to the load that's being pulled from the Arduino; I guess that a good practice would be to just keep a running total of amps being pulled per pin, and overall.

I'm also thinking it might be an idea to develop more iteratively; the solenoid valves will be a much later addition - so maybe I should leave all that out for now.

The core functionality (the stuff I really need to get working to make the existing setup loads better) is effectively a PID controller. So I need to be able to ....

  • Measure temperature at boiler out and Mash Tun
  • Activate the pump
  • Activate two independent kettle elements to control balance of heat

Now, I'm thinking solid-state relay switches for the elements (and ensuring that they're off in when no power is supplied!), but I'm not sure which I need. The elements are 240v / 2.2kW each - so I'm calculating that I need them to cope with 10amps? Not finding much in the way of these which can be activated from a 5v feed from the arduino though. I guess, at a push, I'll be running 12v in anyway to supply the pump, so I could run the 240 volt relays off that. Any suggestions?

M

I'm also thinking it might be an idea to develop more iteratively

Very good idea.

Any suggestions?

Two things...

  1. Understand that mains power is capable of damaging property, injuring people, and even killing. Consider involving a professional electrician.

  2. I can only provide a tiny bit of help regarding the hardware: I'm a big fan of Opto-22. While I believe some of Opto-22 products will work with the Arduino, I have no experience combining the two.

Great, thanks. One other question....

I've been playing with thermistors - much safer - and have got them happily talking to a visual basic monitoring programme on my desktop. Ive used it as an opportunity to learn about voltage dividing, which has been useful to get a better sense of why I'm using resistors.

My general question is: as a rule of thumb, is it better to use higher resistors - on the basis that it will keep the pull of current down. So for instance, I've a 100k thermistor - should I use this with as high a resistor as possible.

Also, whilst im thinking should the resistor and thermistor be balanced (e.g. 100k therm with 100k resistor), or can I just try different resistors till I get them as high as possible.

I've been playing with thermistors ... happily talking

Excellent. I'm glad it's going well.

My general question is: as a rule of thumb, is it better to use higher resistors

For voltage dividing, that's what I do. But I've been building battery powered things and every bit of energy saved is a bit longer battery life.

For thermistors, I have no idea what is appropriate.

Ok, thermistor working nicely. How does this look for the circuitry to control heating elements (which will just be on/off) and the pump (to which I would like to vary the voltage).

It looks good to me. I did a similar circuit to contol some solinoids using 12v and it worked fine.