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:
Chris Giacofei 2022-01-17 17:27:09 -05:00
parent 84981a29dd
commit 5d876b035b
2 changed files with 58 additions and 0 deletions

13
temp_controller/README.md Normal file
View 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.

View 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() {
}