<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=47&amp;t=13662&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2015-11-24T00:27:50+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=47&amp;t=13662&amp;mode</id>
<entry>
<author><name><![CDATA[Jaglarz]]></name></author>
<updated>2015-11-24T00:27:50+01:00</updated>
<published>2015-11-24T00:27:50+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=13662&amp;p=146215#p146215</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=13662&amp;p=146215#p146215"/>
<title type="html"><![CDATA[Re: Niestabilny WebSerwer na Arduino]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=13662&amp;p=146215#p146215"><![CDATA[
<!-- l --><a class="postlink-local" href="http://forum.atnel.pl/topic7402.html" >topic7402.html</a><!-- l --><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=471">Jaglarz</a> — 24 lis 2015, o 00:27</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mglowinski93]]></name></author>
<updated>2015-11-23T21:48:55+01:00</updated>
<published>2015-11-23T21:48:55+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=13662&amp;p=146199#p146199</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=13662&amp;p=146199#p146199"/>
<title type="html"><![CDATA[Niestabilny WebSerwer na Arduino]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=13662&amp;p=146199#p146199"><![CDATA[
Witam, <br />chciałem zrobić sterowanie przekaźnikami oraz odczyt z kilku czujników przez internet. <br />Użyłem do tego Arduino Leonardo oraz rutera Huawei B683. <br /><br />Problem polega na tym, że serwer jest niestabilny, czasem się wyłączony, czasem przytnie itp. <br /><br />Z czego może wynikać problem? Użyłem składni przestarzałego HTML-a? <br />Dodam, że WebSerwer z przykładu Arduino działa bez zarzutu. <br /><br />Mam jeszcze problem ze sterowaniem z przekaźnikiem. <br />Mianowicie gdy przerzucam z Off na On wszystko jest ok. Problem pojawia się, gdy przełączam z On na Off. Pierwszy raz gdy klikam On na Off nic się nie dzieje, dopiero za drugim razie przeskakuje na Off. Gdzie może być przyczyna? <br /><br /><br />mój kod : <br /><div class="codetitle"><b>Code:</b></div><div class="codecontent">#include &lt;SPI.h&gt;<br />#include &lt;Ethernet.h&gt;<br /><br />void Processcheckbox(EthernetClient cl);<br /><br />String HTTP_req;          // stores the HTTP request<br />volatile boolean LED_status = 0;   // state of LED, off by default<br />volatile boolean LED_status2 = 0;<br /><br /><br />byte mac&#91;&#93; = {<br />  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED<br />};<br />IPAddress ip(192, 168, 1, 110);<br /><br />// Initialize the Ethernet server library<br />// with the IP address and port you want to use<br />// (port 80 is default for HTTP):<br />EthernetServer server(80);<br /><br />void setup() {<br />  // Open serial communications and wait for port to open:<br />  //pinMode(2,OUTPUT);<br />  //pinMode(3,OUTPUT);<br />  Serial.begin(9600);<br />  while (!Serial) {<br />    ; // wait for serial port to connect. Needed for Leonardo only<br />  }<br /><br /><br />  // start the Ethernet connection and the server:<br />  Ethernet.begin(mac, ip);<br />  server.begin();<br />  Serial.print(&quot;server is at &quot;);<br />  Serial.println(Ethernet.localIP());<br />  pinMode(2, OUTPUT); <br />  pinMode(3, OUTPUT); <br />}<br /><br /><br />void loop() {<br />  // listen for incoming clients<br />  EthernetClient client = server.available();<br />  if (client) {<br />    Serial.println(&quot;new client&quot;);<br />    // an http request ends with a blank line<br />    boolean currentLineIsBlank = true;<br />    while (client.connected()) {<br />      if (client.available()) {<br />        char c = client.read();<br />        HTTP_req += c;<br />        Serial.write(c);<br />        // if you've gotten to the end of the line (received a newline<br />        // character) and the line is blank, the http request has ended,<br />        // so you can send a reply<br />        if (c == '\n' &amp;&amp; currentLineIsBlank) {<br />          // send a standard http response header<br />          client.println(&quot;HTTP/1.1 200 OK&quot;);<br />          client.println(&quot;Content-Type: text/html&quot;);<br />          client.println(&quot;Connection: close&quot;);  // the connection will be closed after completion of the response<br />          client.println(&quot;Refresh: 5&quot;);  // refresh the page automatically every 5 sec<br />          client.println();<br />          client.println(&quot;&lt;!DOCTYPE HTML&gt;&quot;);<br />          client.println(&quot;&lt;html&gt;&quot;);<br />          client.println(&quot;&lt;title&gt;&quot;);<br />          client.println(&quot;Moj projekt&quot;);<br />          client.println(&quot;&lt;/title&gt;&quot;);<br />          client.println(&quot;&lt;head&gt;&lt;h1&gt;&quot;);<br />          client.println(&quot;Czujniki&quot;);<br />          client.println(&quot;&lt;/h1&gt;&lt;/head&gt;&quot;);<br />          client.println(&quot;&lt;br /&gt;&quot;);<br />          // output the value of each analog input pin<br />          for (int analogChannel = 0; analogChannel &lt; 6; analogChannel++) {<br />            int sensorReading = analogRead(analogChannel);<br />            client.print(&quot;analog input &quot;);<br />            client.print(analogChannel);<br />            client.print(&quot; is &quot;);<br />            client.print(sensorReading);<br />            client.println(&quot;&lt;br /&gt;&quot;);<br />          }<br />          <br />          <br />          client.println(&quot;&lt;h1&gt;&quot;);<br />          client.println(&quot;Przekazniki&quot;);<br />          client.println(&quot;&lt;/h1&gt;&quot;);<br />          client.println(&quot;&lt;p&gt;Przekaznik nr.1&lt;/p&gt;&quot;);<br />                    client.println(&quot;&lt;form method=\&quot;get\&quot;&gt;&quot;);<br />                    ProcessCheckbox(client);<br />                    client.println(&quot;&lt;/form&gt;&quot;);<br />                    <br />          client.println(&quot;&lt;p&gt;Przekaznik nr.2&lt;/p&gt;&quot;);<br />                    client.println(&quot;&lt;form method=\&quot;get\&quot;&gt;&quot;);<br />                    ProcessCheckbox2(client);<br />                    client.println(&quot;&lt;/form&gt;&quot;);<br />          <br />          client.println(&quot;&lt;/html&gt;&quot;);<br />          Serial.print(HTTP_req);<br />                    HTTP_req = &quot;&quot;;<br />          break;<br />        }<br />       <br />        if (c == '\n') {<br />          // you're starting a new line<br />          currentLineIsBlank = true;<br />        }<br />        else if (c != '\r') {<br />          // you've gotten a character on the current line<br />          currentLineIsBlank = false;<br />        }<br />      }<br />    }<br />    // give the web browser time to receive the data<br />    delay(1);<br />    // close the connection:<br />    client.stop();<br />    Serial.println(&quot;client disconnected&quot;);<br />  }<br />}<br /><br /><br />void ProcessCheckbox(EthernetClient cl)<br />{<br />    if (HTTP_req.indexOf(&quot;LED2=2&quot;) &gt; -1) {  // see if checkbox was clicked<br />        // the checkbox was clicked, toggle the LED<br />        //if (LED_status) {<br />            LED_status = 1;<br />        }<br />        else {<br />            LED_status = 0;<br />        }<br />    //}<br />    <br />    if (LED_status) {    // switch LED on<br />        digitalWrite(2, HIGH);<br />        // checkbox is checked<br />        cl.println(&quot;&lt;input type=\&quot;checkbox\&quot; name=\&quot;LED2\&quot; value=\&quot;2\&quot; \<br />        onclick=\&quot;submit();\&quot; checked&gt;On&quot;);<br />    }<br />    else {              // switch LED off<br />        digitalWrite(2, LOW);<br />        // checkbox is unchecked<br />        cl.println(&quot;&lt;input type=\&quot;checkbox\&quot; name=\&quot;LED2\&quot; value=\&quot;2\&quot; \<br />        onclick=\&quot;submit();\&quot;&gt;Off&quot;);<br />    }<br />}<br /><br />void ProcessCheckbox2(EthernetClient cl)<br />{<br />    if (HTTP_req.indexOf(&quot;LED2=3&quot;) &gt; -1) {  // see if checkbox was clicked<br />        // the checkbox was clicked, toggle the LED<br />        //if (LED_status) {<br />            LED_status2 = 1;<br />        }<br />        else {<br />            LED_status2 = 0;<br />        }<br />    //}<br />    <br />    if (LED_status2) {    // switch LED on<br />        digitalWrite(3, HIGH);<br />        // checkbox is checked<br />        cl.println(&quot;&lt;input type=\&quot;checkbox\&quot; name=\&quot;LED2\&quot; value=\&quot;3\&quot; \<br />        onclick=\&quot;submit();\&quot; checked&gt;On&quot;);<br />    }<br />    else {              // switch LED off<br />        digitalWrite(3, LOW);<br />        // checkbox is unchecked<br />        cl.println(&quot;&lt;input type=\&quot;checkbox\&quot; name=\&quot;LED2\&quot; value=\&quot;3\&quot; \<br />        onclick=\&quot;submit();\&quot;&gt;Off&quot;);<br />    }<br />}<br /></div><br /><br />Z góry dziękuje za pomoc<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=5183">mglowinski93</a> — 23 lis 2015, o 21:48</p><hr />
]]></content>
</entry>
</feed>