Schumed
Well-Known Member
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?
Where is a good place to start to learn more about Arduino?
Can it be used stand-alone, or does it need to be connected to a computer to function?
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?
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!
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?
/*
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\"> Freezer "));
client.print(n);
client.print(F(" <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("°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);
}
Enter your email address to join: