<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[forum.rcl-radio.ru &mdash; ENC28J60 - терморегулятор]]></title>
		<link>http://forum.rcl-radio.ru/viewtopic.php?id=130</link>
		<atom:link href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;tid=130&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «ENC28J60 - терморегулятор».]]></description>
		<lastBuildDate>Sat, 15 Feb 2020 18:05:22 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: ENC28J60 - терморегулятор]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=970#p970</link>
			<description><![CDATA[<p>Отлично, всё работает.</p>]]></description>
			<author><![CDATA[null@example.com (andrys)]]></author>
			<pubDate>Sat, 15 Feb 2020 18:05:22 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=970#p970</guid>
		</item>
		<item>
			<title><![CDATA[Re: ENC28J60 - терморегулятор]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=969#p969</link>
			<description><![CDATA[<p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2020/02/9e14cf254b05a87fdb88fed279562f53.png" alt="http://forum.rcl-radio.ru/uploads/images/2020/02/9e14cf254b05a87fdb88fed279562f53.png" /></span> </p><div class="codebox"><pre><code>#include &lt;EtherCard.h&gt;         // EtherCard-master.zip 
#include &lt;OneWire.h&gt;           //https://github.com/PaulStoffregen/OneWire/archive/master.zip 
#include &lt;DallasTemperature.h&gt; // http://rcl-radio.ru/wp-content/uploads/2018/07/DallasTemperature.zip
#include &lt;EEPROM.h&gt;
OneWire oneWire(A0);
DallasTemperature t(&amp;oneWire);
 
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 10,42,0,100 };
 
byte Ethernet::buffer[975];
float temp;
int reg,temp0,temp1,a;
byte times,w;
const byte gis = 1; // гистерезис 1 градус
BufferFiller bfill;
String line;
 
void setup () {
 // Serial.begin(9600);
  pinMode(2, OUTPUT); // D2 управление реле нагревательного элемента
  ether.begin(sizeof Ethernet::buffer, mymac, 10);
  ether.staticSetup(myip);
  reg = EEPROM.read(0);times = EEPROM.read(1);
  t.begin(); 
  t.setResolution(9);
}
 
void loop () {
  t.requestTemperatures();
  temp = t.getTempCByIndex(0);
  temp0 = int(temp);
  temp1 = (temp-temp0)*100;
  if(reg &gt;= temp + gis){digitalWrite(2,HIGH);}
  if(reg &lt;= temp - gis){digitalWrite(2,LOW);}
 
  word pos = ether.packetLoop(ether.packetReceive()); 
  if (pos){ char *data = (char *) Ethernet::buffer + pos;
  
  line = data;
  a = line.indexOf(&quot;?reg=&quot;);if(a&gt;0){reg = line.substring(a+5, a+8).toInt();w=1; if(reg&lt;0){reg=0;}if(reg&gt;125){reg=125;}}
  a = line.indexOf(&quot;?p=&quot;);if(a&gt;0){times = line.substring(a+3, a+6).toInt();w=1;}
 
  ether.httpServerReply(html());
  
  if(w==1){w=0;EEPROM.update(0,reg);EEPROM.update(1,times);}
}}

static word html(){
  bfill = ether.tcpOffset();
  bfill.emit_p(PSTR(
 &quot;&lt;html&gt;&lt;head&gt;&lt;meta charset=&#039;UTF-8&#039;&gt;&quot;
 &quot;&lt;meta http-equiv=&#039;refresh&#039; content=&#039;$D&#039;/&gt;&lt;/head&gt;&quot;
 &quot;&lt;style&gt;.tab1 {background-color:#F5F5F5;border-radius: 5px;margin: auto;}a{color:#333;&lt;/style&gt;&lt;/head&gt;&quot;
 &quot;&lt;br&gt;&lt;TABLE class=&#039;tab1&#039; align=&#039;center&#039; width=&#039;470&#039; BORDER=&#039;1&#039; cellspacing=&#039;0&#039; cellpadding=&#039;10&#039;&gt;&quot;
 &quot;&lt;td&gt;&lt;center&gt;&lt;big&gt;&lt;b&gt;Терморегулятор DS18B20&lt;/b&gt;&lt;/big&gt;&lt;/td&gt;&lt;tr&gt;&lt;td&gt;&lt;center&gt;&quot;
 &quot;Температура: &lt;b&gt;$D.$D &lt;/b&gt;&amp;#176;C&quot;
 &quot;&lt;/td&gt;&lt;tr&gt;&lt;td align=&#039;center&#039;&gt;Установка температуры регулирования (0...125&amp;#176;C)&quot;
 &quot;&lt;form action=&#039;&#039; method=&#039;GET&#039;&gt;&quot;
 &quot;&lt;br&gt;&lt;input type=&#039;text&#039; name=&#039;reg&#039; autocomplete=&#039;off&#039; size=&#039;1&#039;&gt;&lt;/input&gt;  &quot;
 &quot;&lt;button type=&#039;submit&#039;&gt;Подтвердить&lt;/button&gt;&lt;/form&gt;&lt;/td&gt;&lt;tr&gt;&quot;
 &quot;&lt;td&gt;&lt;center&gt;Температура регулировки: &lt;b&gt;$D &amp;#176;C&lt;/b&gt;&lt;/td&gt;&quot;
 &quot;&lt;tr&gt;&lt;td&gt;&lt;center&gt;&lt;small&gt;Время обновления страницы каждые $D сек | &lt;b&gt;&lt;a href=&#039;/?p=5&#039;&gt;5 сек&lt;/a&gt; &lt;a href=&#039;/?p=10&#039;&gt;10 сек&lt;/a&gt; &lt;a href=&#039;/?p=30&#039;&gt;30 сек&lt;/a&gt; &lt;a href=&#039;/?p=60&#039;&gt;1 мин&lt;/a&gt;&lt;/b&gt;&quot;
 &quot;&lt;/td&gt;&lt;/table&gt;&lt;/center&gt;&lt;/html&gt;&quot;
  ),times,temp0,temp1,reg,times);
  return bfill.position();
  }</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Sat, 15 Feb 2020 16:43:38 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=969#p969</guid>
		</item>
		<item>
			<title><![CDATA[ENC28J60 - терморегулятор]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=949#p949</link>
			<description><![CDATA[<p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2020/02/fb5d89631650690b9e001160e2b7db85.png" alt="http://forum.rcl-radio.ru/uploads/images/2020/02/fb5d89631650690b9e001160e2b7db85.png" /></span> </p><div class="codebox"><pre><code>#include &lt;EtherCard.h&gt;
#include &lt;OneWire.h&gt;//https://github.com/PaulStoffregen/OneWire/archive/master.zip
#include &lt;DallasTemperature.h&gt;
#include &lt;EEPROM.h&gt;
OneWire oneWire(A0);
DallasTemperature t(&amp;oneWire);

static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
static byte myip[] = { 10,42,0,100 };

byte Ethernet::buffer[1000];
float temp;
int reg,temp0,temp1,a;
const byte gis = 1; // гистерезис 1 градус
BufferFiller bfill;
String line;

static word homePage() {
  bfill = ether.tcpOffset();
  bfill.emit_p(PSTR(
&quot;&lt;html&gt;&lt;head&gt;&lt;meta charset=&#039;UTF-8&#039;&gt;&quot;
&quot;&lt;meta http-equiv=&#039;refresh&#039; content=&#039;10&#039;/&gt;&quot;
&quot;&lt;style&gt;.tab1 {background-color:#F5F5F5;border-radius: 5px;margin: auto;}&lt;/style&gt;&lt;/head&gt;&quot;

&quot;&lt;br&gt;&lt;TABLE class=&#039;tab1&#039; align=&#039;center&#039; width=&#039;470&#039; BORDER=&#039;1&#039; cellspacing=&#039;0&#039; cellpadding=&#039;10&#039;&gt;&quot;
&quot;&lt;td&gt;&lt;center&gt;&lt;big&gt;&lt;b&gt;Терморегулятор DS18B20&lt;/b&gt;&lt;/big&gt;&lt;/td&gt;&lt;tr&gt;&lt;td&gt;&lt;center&gt;&quot;
&quot;Температура: &lt;b&gt;$D.$D &lt;/b&gt;&amp;#176;C&quot;
&quot;&lt;/td&gt;&lt;tr&gt;&lt;td align=&#039;center&#039;&gt;Установка температуры регулирования (0...125&amp;#176;C)&quot;
&quot;&lt;form action=&#039;&#039; method=&#039;GET&#039;&gt;&quot;
&quot;&lt;br&gt;&lt;input type=&#039;text&#039; name=&#039;reg&#039; autocomplete=&#039;off&#039; size=&#039;1&#039;&gt;&lt;/input&gt;  &quot;
&quot;&lt;button&gt;Подтвердить&lt;/button&gt;&lt;/form&gt;&lt;/td&gt;&lt;tr&gt;&quot;
&quot;&lt;td&gt;&lt;center&gt;Температура регулировки: &lt;b&gt;$D &amp;#176;C&lt;/b&gt;&lt;/td&gt;&quot;
&quot;&lt;/table&gt;&quot;
&quot;&lt;/center&gt;&lt;/body&gt;&lt;/html&gt; &quot;
  ),temp0,temp1,reg);
  return bfill.position();
}

void setup () {
  Serial.begin(9600);
  pinMode(2, OUTPUT); // D2 управление реле нагревательного элемента
  ether.begin(sizeof Ethernet::buffer, mymac, 10);
  ether.staticSetup(myip);
  reg = EEPROM.read(0);
  t.begin(); 
  t.setResolution(9);
}

void loop () {
  t.requestTemperatures();
  temp = t.getTempCByIndex(0);
  temp0 = int(temp);
  temp1 = (temp-temp0)*100;

  word pos = ether.packetLoop(ether.packetReceive());
  if (pos){  // check if valid tcp data is received
    char *data = (char *) Ethernet::buffer + pos;
  
  line = data;a = line.indexOf(&quot;?reg=&quot;);if(a&gt;0){reg = line.substring(a+5, a+8).toInt();
  if(reg&lt;0){reg=0;}if(reg&gt;125){reg=125;}EEPROM.update(0,reg);}

  if(reg &gt;= temp + gis){digitalWrite(2,HIGH);}
  if(reg &lt;= temp - gis){digitalWrite(2,LOW);} 
  
  ether.httpServerReply(homePage());   
}}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Sat, 15 Feb 2020 07:25:45 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=949#p949</guid>
		</item>
	</channel>
</rss>
