 |
|
06-13-2012, 06:49 PM
|
#11
|
|
Feedback Score: 0 reviews
Join Date: Sep 2008
Location: Rochester, MN
Posts: 229
Liked 2 Times on 2 Posts
|
There is also the netduino if you already program in c#.
|
|
|
06-14-2012, 12:28 AM
|
#12
|
|
Senior Member
Feedback Score: 0 reviews
Join Date: Feb 2010
Location: Jacksonville, FL
Posts: 270
Liked 10 Times on 7 Posts Likes Given: 17
|
Quote:
Originally Posted by cjang
|
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.
|
|
|
06-28-2012, 04:50 PM
|
#13
|
|
Feedback Score: 0 reviews
Join Date: Sep 2010
Location: Lafayette, IN, Indiana
Posts: 89
Likes Given: 3
|
Quote:
Originally Posted by jimmayhugh
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?
|
|
|
06-29-2012, 12:36 AM
|
#14
|
|
Feedback Score: 0 reviews
Join Date: Oct 2011
Location: PORTLAND, OR
Posts: 18
|
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 
|
|
|
06-29-2012, 01:31 AM
|
#15
|
|
Turgid Member
Feedback Score: 0 reviews
Join Date: Feb 2011
Location: Las Vegas, NV
Posts: 459
Liked 26 Times on 24 Posts Likes Given: 2
|
Quote:
Originally Posted by Gunslinger711
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:
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\"> 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);
}
|
|
|
06-29-2012, 02:28 AM
|
#16
|
|
Feedback Score: 0 reviews
Join Date: Jul 2011
Location: Cranberry Twp, PA
Posts: 16
Liked 3 Times on 3 Posts Likes Given: 3
|
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
|
|
|