Add dir and ino
file for temp controllers.
Included basic working example to setup ethernet and get an IP address using DHCP.
This commit is contained in:
parent
84981a29dd
commit
5d876b035b
13
temp_controller/README.md
Normal file
13
temp_controller/README.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Temperature Control
|
||||
|
||||
Enables basic thermostat control for fermentation, kegerator, etc.
|
||||
|
||||
## Requirements
|
||||
Arduino Nano (clone) with ethernet shield.
|
||||
|
||||
For programing the board:
|
||||
- Board : Arduino Nano
|
||||
- Processor : ATmega328P
|
||||
- Port : /dev/ttyUSB0
|
||||
|
||||
This board/shield combo works with the [EthernetENC](https://github.com/jandrassy/EthernetENC/wiki) library.
|
45
temp_controller/temp_controller.ino
Normal file
45
temp_controller/temp_controller.ino
Normal file
@ -0,0 +1,45 @@
|
||||
/* Built-in */
|
||||
#include <SPI.h>
|
||||
|
||||
/* Extra Libraries */
|
||||
#include <EthernetENC.h>
|
||||
|
||||
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
|
||||
IPAddress ip(192, 168, 1, 177);
|
||||
IPAddress myDns(192, 168, 1, 1);
|
||||
|
||||
// Initialize the Ethernet client library
|
||||
// with the IP address and port of the server
|
||||
// that you want to connect to (port 80 is default for HTTP):
|
||||
EthernetClient client;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
// start the Ethernet connection:
|
||||
Serial.println("Initialize Ethernet with DHCP:");
|
||||
if (Ethernet.begin(mac) == 0) {
|
||||
Serial.println("Failed to configure Ethernet using DHCP");
|
||||
// Check for Ethernet hardware present
|
||||
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
|
||||
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
|
||||
while (true) {
|
||||
delay(1); // do nothing, no point running without Ethernet hardware
|
||||
}
|
||||
}
|
||||
if (Ethernet.linkStatus() == LinkOFF) {
|
||||
Serial.println("Ethernet cable is not connected.");
|
||||
}
|
||||
// try to congifure using IP address instead of DHCP:
|
||||
Ethernet.begin(mac, ip, myDns);
|
||||
} else {
|
||||
Serial.print(" DHCP assigned IP ");
|
||||
Serial.println(Ethernet.localIP());
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
Loading…
Reference in New Issue
Block a user