Arduino Ethernet Webservers ENC28J60 With Thermometer DS18B20 and Power Over Ethernet POE For ZABBIX IOT Data Logging
Arduino Ethernet Webservers ENC28J60 With Thermometer DS18B20 and Power Over Ethernet POE For ZABBIX IOT Data Logging
Arduino Ethernet Webservers ENC28J60 With Thermometer DS18B20 and Power Over Ethernet POE For ZABBIX IOT Data Logging
and Power Over Ethernet POE for ZABBIX IOT data logging
Low-cost Arduino Ethernet webservers are reliable and attractive for wide range of sensor monitoring:
temperature, voltage or switches. Ethernet is older than WiFi but more reliable and is widely used in
industry. To make such a weberver parts cost ca 10 EUR and it takes one day to build. Commercial Arduino
Ethernet thermometers are available on Ebay starting at 50 EUR.
Arduino webserver is powered via 5V USB connector or with more efforts Power Over Ethernet
(POE) capability is added. Arduino Nano can be reprogrammed any time via the USB connector.
Free-of-charge ZABBIX IOT platform for plotting and monitoring data
ZABBIX is a platform for IOT signal monitoring developed for server room monitoring and for sending out
alarms. It is similar to Xively, but ZABBIX provides installation download free of charge and can be installed
also on Raspberry Pi. The companys business model is to send a service person to install Zabbix in industrial
client server rooms. ZABBIX home is Riga the capital city of Latvia, EU. Zabbix has been actively developed
during the last decade:
http://www.zabbix.com
ZABBIX can be installed on a Linux PC or on a virtual machine. It works with a SQL database. A virtual
machine image can also be downloaded. Configuration is done via a webpage.
Large flexibility is achieved that computers to be monitored just need to generate a webpage and
ZABBIX just fetches data from a webpage of other servers. This allows to monitor web traffic, server load
and if server is alive.
In recent years has opened a possibility to make low-cost Arduino Ethernet webservers for electric
sensor monitoring: temperature, voltage or switches. Here is the vision by ZABBIX:
Envisioning picture made by Zabbix for DevTernity conference 12.2016. In Riga, Latvia.
ZABBIX stand at a developer conference
Inside the box was packed with this. Version on the right had a DS18B20 temperature sensor.
Power over Ethernet to supply the webserver
Power over Ethernet was a tricky thing to achieve. Ethernet connector of ENC28J60 shield has a
transformer inside that galvanically separates inputs from outputs. To get POE the metal shield of the
connector was cut off with a diamond disk allowing to access connections before the transformer. The
connector pins had to be cut off from the circuit board with a transformer because there was a low-
resistance connection. Thin flexible wires were soldered to POE pins.
A correct solution would be to use Ethernet connector without the built-in transformer, found in
routers or a-10pin Ethernet connector, giving access to POE pins, Farnell ca 8EUR.
As a source of POE Mikrotik routerboard 951Ui 2HnD was used. It has 5 Ethernet ports. Nr 1 is marked POE
input. There is no voltage across it. Nr 5 is marked POE output and to activate the POE output voltage one
needs to change Configuration/Interfaces/POE /ON. Routerboard is supplied from 24 V 2A power supply.
This 24V voltage appears as POE output voltage. There are other routers providing more POE outputs.
Tweaking a standard Ethernet connector for POE use
3) Identify the contacts and cut off using a 1 mm or 1.5 mm diameter mill (Dremel). This is necessary
because pins are soldered internal resistors that block POE activation from router side.
4) Using a thin soldering iron tip solder two wires to the two contacts.
5) Put some insulation tape and close the metal cover of the connector. Fix the new POE wires with some
glue.
6) To ensure correct POE polarity add a rectifier diode bridge before the step-down regulator.
7) Step-down module is LM2596HV module can be used. Industrial POE modules use a galvanic isolation
transformer. It might be possible to use a phone charger from 110V to 5V as it might work at lower voltage.
http://www.tuxgraphics.org/electronics/200903/hobby-poe.shtml
`
Photo on the right shows the Arduino server box running on POE with USB cable unplugged.
LCD and box with transparent lid
LCD indicator is a very handy thing to see the obtained IP address on startup and allows easy to
check that the device is working correctly. The two-line LCD indicator has an adapter board with I2C-
expander PCF8574 that only needs 2 wires (data and clock). One needs to identify the I2C address of this
chip first as it might differ from different suppliers. Two-line indicator is bulky and next version will be with
a tiny OLED graphical indicator, but OLEDs might not survive years of continuous operation.
I2C LCD screen 2-line PCF8574T connects to Arduino A4=SCL A5= SDA and uses the library:
https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
Aduino IDE
Program initially was written in
Arduino IDE 1.0.0. Later it was decided
to switch to one of the latest Arduino
IDE 1.6.13. Differences were in OneWire
library use. I use D8 for the one-wire bus
as D9 can be useful for PWM output.
Quick sensor fidelity test can be done
measuring human body temperature.
To make 3.3V out of 5V for the ENC board is not enough current from Arduino CH340 chip.
Another ENC28J60 board modificationis more expensive with plug in socket for Arduino Nano v3. It has a 3.3V
regulator on the board and also TTL level shifter.
If you decide to go for POE then you need a step-down POE voltage regulator that can handlle up to 57 Volts, for
example LM2576 HV version
Some routers and switches can supply POE, if you dont have such model then can inject POE.
Hermetically sealed sensors with cable are convenient to use. There are some with audio plug on the end.
Arduino IDE 1.0.1 code for version with a temperature sensor and analog input, no LCD:
#include <EtherCard.h>
// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x33 };
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 8
OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire);
float t1; // temperature
int button=3; long state=0; long clicks=0; // for the digital input button
long AIN;
bfill = ether.tcpOffset();
bfill.emit_p(PSTR(
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nPragma: no-cache\r\n\r\n<meta http-equiv='refresh'
content='1'/>"
"<body><html><u>Arduino Ethernet ENC28J60 webserver #3</u><BR><B>Temperat $L.$L </B><BR>A0 inp % $L
<br>"
"D3 state: $L <br>D3 clicks $L <br>Seconds $L </body></html>"),
T1, T1A, AIN, state, clicks, t);
return bfill.position();
}
void loop () {
if (millis()%100>70){if (digitalRead(button)==LOW) {if (state==0) {clicks=clicks+1; state=1;}}
delay(50); if (digitalRead(button)==HIGH){if (state==1) {state=0;}}}
if (millis()%1000>900){sensors.requestTemperatures(); t1 = sensors.getTempCByIndex(0);}
// Serial.print ("t1= "); Serial.println (t1);} // t2 = sensors.getTempCByIndex(1);
# bash script to read the Arduino webserver webpage, extract temperature and upload to Xively.
# webpage: <meta http-equiv='refresh' content='1'/><body><html><h1>Arduino webserver</h1>
# <h1>T= 19.5 </h1> <h1>A0= 25 </h1> <h1>t= 750669</h1>
# a file is prepared in RAM /tmp directory that is uploaded to server.
cd /tmp
rm index*
wget 192.168.1.101
a=$(cat index.html)
# convert scaling
round(){
echo $(printf %.$2f $(echo "scale=$2;(((10^$2)*$1)+0.5)/(10^$2)" | bc))
};
tt=$(round $t/1 0)
echo $tt
echo $t >/tmp/asi
a='{"version":"1.0.0","datastreams":[{"id":"2", "current_value":"'
b='"}]}'
echo $a$t$b
echo $a$t$b > /tmp/update.json
// Code adopted by Janis Alnis. v5. 2017.01.09. Compiled with Arduino IDE version 1.6.13.
#include <EtherCard.h>
// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x35 };
#include <OneWire.h>
OneWire ds(8); // on pin 8 (a 4.7K resistor is necessary)
float t1; // temperature
int button=3; long state=0; long clicks=0; // for the digital input button
long AIN;
return bfill.position();
}
void loop () {
if (millis()%100>70){if (digitalRead(button)==LOW) {if (state==0) {clicks=clicks+1; state=1;}}
delay(50); if (digitalRead(button)==HIGH){if (state==1) {state=0;}}}
if (millis()%1000>900){t1 = getTemp();
lcd.setCursor (0,0); lcd.print(t1);
lcd.setCursor (7,0); lcd.print(AIN);
lcd.setCursor (0,1); lcd.print(state);
lcd.setCursor (3,1); lcd.print(clicks);
lcd.setCursor (7,1); lcd.print(millis()/1000);
float getTemp(void) {
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius;
if ( !ds.search(addr)) {
// Serial.println("No more addresses.");
// Serial.println();
// ds.reset_search();
// delay(250);
// return;
}
// Serial.print("ROM =");
// for( i = 0; i < 8; i++) {Serial.write(' ');Serial.print(addr[i], HEX);}
ds.reset();
ds.select(addr);
ds.write(0x44, 1); // start conversion, with parasite power on at the end
present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad