Arduino projects

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Schumed

Well-Known Member
Joined
Feb 26, 2011
Messages
1,111
Reaction score
94
Location
Kansas City
Been seeing a lot of cool Arduino projects lately in the DIY section

Where is a good place to start to learn more about Arduino?
 
www.arduino.cc is where I learned some of the syntax. It's kind of a modified C++ if you have any programming experience. Most parts and shields people use with arduinos have user libraries out there.

Although I've run into frustrations when they upgraded to 1.0 software, they changed the WProgram.h (i think) header file to Arduino.h and killed a lot of include files.
 
There are various websites out there. And some very nice looking books at the bookstore. Finding good information depends a lot on what you want to do with it.
 
I think the best thing you can do is to pick a project, break it down into small components and start looking up information on building each component on google. After you get them all working individually, put them all together and get them working.
 
Hi

What do you want to do? Build a keezer, a brew stand, a fermentor..?

How deep do you want to get? Grab some open source stuff, write some code, build some hardware from scratch?

Where are you starting from? Done some programming, done some hardware, starting from scratch?

Lots of starting points, lots of destinations, lots of ways in-between.

Bob
 
I'm also interested in using Arduino if I ever get around to automating anything. Can it be used stand-alone, or does it need to be connected to a computer to function?
 
Can it be used stand-alone, or does it need to be connected to a computer to function?

Yes.

To answer more clearly, it does what you program it to do. If you program it to work on its own, it will do that. You can also have it tethered to a computer via USB/wireless/etc. UI can be as simple as some switches/LEDs or can be a web interface. All depends on what you want and what you are willing/able to do.
 
I'm also interested in using Arduino if I ever get around to automating anything. Can it be used stand-alone, or does it need to be connected to a computer to function?

Hi

It's a stand alone computer with pretty much noting in it as delivered. You will very much need a computer to put code into it. Like any computer, it can be networked (with the right hardware and software bits and pieces) to other computers.

To get very far, you either will need an open source project to supply firmware images (and a very specific hardware configuration) or you will need to at least do some code on your own.

Bob
 
Arduino Cookbook is a good starting point. Make sure you get the second edition. I've got one that monitors temps using DS18B20 one-wire thermal probes and can serve a web page with the real-time temps over my intranet.
 
Last edited by a moderator:
When I got started and learned a lot from this guy.
http://www.youtube.com/watch?v=fCxzA9_kg6s

I also used this site a lot
http://www.adafruit.com/tutorials

These were great intros to basic electronics if you need it.
http://www.afrotechmods.com/tutorials/

Good luck. It's a ton of fun!


I'll wholeheartedly second the recommendation for the Jeremy Blum videos.
I followed along, pausing and rewinding and going step by step. He covers a lot a material very quickly, and effectively.
 
Arduino Cookbook is a good starting point. Make sure you get the second edition. I've got one that monitors temps using DS18B20 one-wire thermal probes and can serve a web page with the real-time temps over my intranet.

This is exactly what I want to do. Do you have a break down of what materials/wiring/coding you did for this project or examples you used to get yours up and running?
 
Last edited by a moderator:
If you're not as electronic savvy, the netduino is a great platform as well (http://netduino.com/). Gives you the same basic functionality but you build and debug with C# right in visual studio. Make it pretty easy to get started. Microsft gadgeteer would also be a good platform, lots of pre-fab pluggable parts (http://research.microsoft.com/en-us/projects/gadgeteer/).

So many platforms, so little time :)
 
This is exactly what I want to do. Do you have a break down of what materials/wiring/coding you did for this project or examples you used to get yours up and running?

I bought the probes from Brewer's Hardware, I'm using an Arduino Uno, an Ethernet Shield, and an I2C 4x20 LCD Display.

It's all on a breadboard right now, and works with 4 temp probes, but adding more is a trivial exercise.

It currently serves a simple text-based web page of the temps.

Here's a photo:

I2CTempMonitor.png


Here's the code:
Code:
/*
I2C-LCD and Web Temperature monitor utilizes Dallas Semiconductor / Maxim DS18B20
One-Wire Digital Temperature sensors to monitor two freezers used as beer storage coolers.
The temperatures are available from a 20x4 LCD and by accessing a small text based web page
generated in response to a "GET" command.


One-Wire data channel is on digital pin 8, which is pulled up to +5v with a 4K7 resistor.

The ethernet interface is the Wiznet W5100 based Ethernet Shield.

If you are using multiple Arduino/Ethernet shields, each one must have a unique MAC address and
IP Address.

*/

// include the library code:
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <Ethernet.h>
#include <OneWire.h>

// Debug defines
// #define SerialDebug

// I2C LCD Defines
#define I2C_ADDR    0x27  // Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

int n = 1;

LiquidCrystal_I2C	lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);


#define backLightPin 3


const int cols        = 20;
const int rows        = 4;
const int tooCold     = 45;
const int tooHot      = 60;
const byte nbsp       = 0x20; //space character
const byte zeroChar   = 0x30; // zero character
const int maxSensors  = 4;
const int dsDataPin = 8;


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
EthernetServer server(80);

/********** OneWire Stuff ************/
OneWire  ds(dsDataPin); // OneWire data bus
float fahrenheit[4];
int cnt = 0;
int maxCnt = 0;


void setup()
{
  // set up the LCD's number of columns and rows: 
  lcd.begin(cols, rows);
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.clear();
  lcd.home();

  // Print a message to the LCD.

// Open serial communications and wait for port to open:
  Serial.begin(9600);
 #if defined SerialDebug
  Serial.println(F("Checking for OneWire Devices"));
 #endif

 byte addr[8];
 
  while ( ds.search(addr)) {
    cnt++;
    delay(500);
  }
  
  ds.reset_search();

  maxCnt = cnt;
  cnt=0;

#if defined SerialDebug
  Serial.println(F("No more addresses."));
  Serial.print(F("maxCnt = "));
  Serial.println(maxCnt);
#endif

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
#if defined SerialDebug
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
#endif
}

void getOneWire(void)
{
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  
#if defined SerialDebug
  Serial.println(F("Checking for OneWire Devices"));
#endif
 
  if (!ds.search(addr))
  {
    maxCnt = cnt;
    cnt=0;
    ds.reset_search();
    delay(500);
#if defined SerialDebug
    Serial.println(F("No more addresses."));
#endif
   return;
  }

#if defined SerialDebug
  Serial.print(F("ROM "));
  Serial.print(cnt);
  Serial.print(F(" = "));
  for( i = 0; i < 8; i++)
  {
    Serial.write(nbsp);
    if(addr[i] < 16){Serial.write(zeroChar);} // prepend hex 0-15 with a 0
    Serial.print(addr[i], HEX);
  }

  if (OneWire::crc8(addr, 7) != addr[7]) {
      Serial.println(F("CRC is not valid!"));
      return;
  }
  Serial.println();
#endif

  // the first ROM byte indicates which chip
  switch (addr[0]) {
    case 0x10:
#if defined SerialDebug
      Serial.println(F("Chip = DS18S20"));  // or old DS1820
#endif
      type_s = 1;
      break;
    case 0x28:
#if defined SerialDebug
      Serial.println(F("Chip = DS18B20"));
#endif
      type_s = 0;
      break;
    case 0x22:
#if defined SerialDebug
      Serial.println(F("Chip = DS1822"));
#endif
      type_s = 0;
      break;
    default:
      Serial.println(F("Not a DS18x20"));
      return;
  } 

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1);         // start conversion, with parasite power on at the end
  
  delay(750);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.
  
  present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE);         // Read Scratchpad

#if defined SerialDebug
  Serial.print(F("  Data = "));
  if(present < 16){Serial.write(zeroChar);} // prepend hex 0-15 with a 0
  Serial.print(present, HEX);
  Serial.write(nbsp);
#endif
  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
#if defined SerialDebug
    if(data[i] < 16){Serial.write(zeroChar);} // prepend hex 0-15 with a 0
    Serial.print(data[i], HEX);
    Serial.write(nbsp);
#endif
  }
#if defined SerialDebug
  Serial.print(F(" CRC="));
  Serial.print(OneWire::crc8(data, 8), HEX);
  Serial.println();
#endif
  // convert the data to actual temperature

  unsigned int raw = (data[1] << 8) | data[0];
  if (type_s) {
    raw = raw << 3; // 9 bit resolution default
    if (data[7] == 0x10) {
      // count remain gives full 12 bit resolution
      raw = (raw & 0xFFF0) + 12 - data[6];
    }
  } else {
    unsigned char t_mask[4] = {0x7, 0x3, 0x1, 0x0};
    byte cfg = (data[4] & 0x60) >> 5;
    raw &= ~t_mask[cfg];
  }
  fahrenheit[cnt] = ((((float)raw / 16.0) * 1.8) + 31.0); //the raw value is Celsius, convert to Fahrenheit
#if defined SerialDebug
  Serial.print("  Temperature = ");
  Serial.print(fahrenheit[cnt]);
  Serial.println(" Fahrenheit");
#endif
  cnt++;
}

void checkEthernet(void)
{
 // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println(F("HTTP/1.1 200 OK"));
          client.println(F("Content-Type: text/html"));
          client.println(F("Connnection: close"));
          client.println();
          client.println(F("<!DOCTYPE HTML>"));
          client.println("<html><head>");
                    // add a meta refresh tag, so the browser pulls again every 5 seconds:
          client.println(F("<meta http-equiv=\"refresh\" content=\"5\">"));
          client.println(F("</head>"));
          // output the value of each analog input pin
          client.println(F("<body><table border=\"5\" align=\"center\"><tr>"));
          switch(maxCnt)
          {
            case 0:
             client.println(F("<td align=\"center\" valign=\"center\"><font size=\"10\" color=\"red\">SENSOR FAILURE<br />OR<br />POWER FAILURE!!</td>"));
             break;
             
            case 1:
            case 2:
            case 3:
            case 4:
              for (int n=1; n<=maxSensors; n++)
              {
                if(n<=maxCnt)
                {
                  client.print(F("<td align=\"center\" valign=\"center\"><font size=\"10\">&nbsp;&nbsp;Freezer "));
                  client.print(n);
                  client.print(F("&nbsp;&nbsp;<br />"));
                  if((int)fahrenheit[n-1] > tooHot)
                    {
                      client.print(F("<font color=\"red\">"));
                    }else if((int)fahrenheit[n-1] < tooCold){
                      client.print(F("<font color=\"blue\">"));
                    }else{
                      client.print(F("<font color=\"green\">"));
                    }
                  client.print(fahrenheit[n-1], 0);
                  client.println(F("&deg;F</font></font></td>"));
                }else{
                  client.println(F("<td align=\"center\" valign=\"center\"><font size=\"10\" color=\"red\">SENSOR<br />FAILURE</font></td>"));
                }
              }
              break;

            default:
              client.println(F("<td align=\"center\" valign=\"center\"><font size=\"10\" color=\"red\">SOMETHING IS NOT RIGHT!<br /> TOO MANY SENSORS!!</td>"));
              break;
          }
          client.println(F("</tr></table></body>"));
          client.println(F("</html>"));
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
#if defined SerialDebug
    Serial.println(F("client disonnected"));
#endif
  }
}

void displayLCDTemp()
{
  lcd.home();

  switch(maxCnt)
  {
    case 0:
      lcd.print(F("Sensor Failure!!"));
      lcd.setCursor(0, 1);
      lcd.print(F("Sensor Failure!!"));
      lcd.setCursor(0, 2);
      lcd.print(F("Sensor Failure!!"));
      lcd.setCursor(0, 3);
      lcd.print(F("Sensor Failure!!"));
      break;

    case 1:
    case 2:
    case 3:
    case 4:
      for(int n=1;n<=maxSensors;n++)
      {
        if(n<=maxCnt)
        {
          lcd.setCursor(0, n-1);
          lcd.print(F("Freezer "));
          lcd.print(n);
          lcd.print(F(" = "));
          lcd.print(fahrenheit[n-1],0);
          lcd.print(F("     "));
        }else{
          lcd.setCursor(0,n-1);
          lcd.print(F("Sensor Failure!!"));
        }
      }
     break;

    default:
      lcd.print(F("    SOMETHING IS    "));
      lcd.setCursor(0, 1);
      lcd.print(F("     NOT RIGHT!     "));
      lcd.setCursor(0, 2);
      lcd.print(F("      TOO MANY      "));
      lcd.setCursor(0, 3);
      lcd.print(F("      SENSORS!      "));
    }

}

void loop()
{
  getOneWire();
  checkEthernet();
  displayLCDTemp();
  delay(250);
}
 
Back
Top