Talking to the network with an Arduino: Unterschied zwischen den Versionen
Aus DL8RDS Wiki
Dl8rds (Diskussion | Beiträge) (New page: Well, even this is most certainly no longer related to my SWR meter project, I just find that it's sooooo cool, so I will simply present some code here: #include <Server.h> #include <E...) |
Dl8rds (Diskussion | Beiträge) (→The Sketch) |
||
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
+ | Well, even this is most certainly no longer related to my SWR meter project, I just find that it's sooooo cool, so I will simply present some code here. | ||
− | + | == Hardware == | |
+ | * Arduino Duemillanove | ||
+ | * Ethernet Shield, purchased from Watterott: http://www.watterott.com/Arduino-Shield-Ethernet | ||
+ | * LM75 temperature sensoe board from Horter & Kalb: http://www.horter.de/i2c/i2c-temperatur/temperatur_1.html | ||
+ | |||
+ | == Related == | ||
+ | * http://shop.ulrichradig.de/Projekte/ETH-M32-EX/ETH-M32-EX-Leiterplatte.html | ||
+ | |||
+ | == The Sketch == | ||
#include <Server.h> | #include <Server.h> | ||
Zeile 54: | Zeile 63: | ||
It will show the room temperature of my lab. I used the above mentioned LM75 sensor from [http://www.horter.de Horter] and the Ethernet shield with the WIZnet Ethernet module that you can purchase from Watterott. Also have a look there: | It will show the room temperature of my lab. I used the above mentioned LM75 sensor from [http://www.horter.de Horter] and the Ethernet shield with the WIZnet Ethernet module that you can purchase from Watterott. Also have a look there: | ||
− | http://www.mats-vanselow.de | + | http://www.mats-vanselow.de/arduino-ins-netz-bringen |
Given that my controller grabs the temperature from the source via I2C, it would be no problem to connect several sensors over this bus. It would be possible to read out a huge number of data sources... | Given that my controller grabs the temperature from the source via I2C, it would be no problem to connect several sensors over this bus. It would be possible to read out a huge number of data sources... |
Aktuelle Version vom 27. September 2017, 17:00 Uhr
Well, even this is most certainly no longer related to my SWR meter project, I just find that it's sooooo cool, so I will simply present some code here.
1 Hardware
- Arduino Duemillanove
- Ethernet Shield, purchased from Watterott: http://www.watterott.com/Arduino-Shield-Ethernet
- LM75 temperature sensoe board from Horter & Kalb: http://www.horter.de/i2c/i2c-temperatur/temperatur_1.html
2 Related
3 The Sketch
#include <Server.h> #include <Ethernet.h> #include <Client.h> #include <Wire.h> #define address 0x48 byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; byte ip[] = {192, 168, 178, 190}; byte gateway[] ={192,168,178,1}; byte subnet[] = {255,255,255,0}; Server server = Server(80); void setup() { Wire.begin(); Serial.begin(9600); Ethernet.begin(mac, ip, gateway, subnet); server.begin(); } void loop() { Client client = server.available(); if (client) { Wire.beginTransmission(address); Wire.send(0x00); Wire.requestFrom(address, 1); int temperature; if (Wire.available()) { temperature = Wire.receive(); } Wire.endTransmission(); server.print("HTTP/1.0 200 OK\r\nServer: arduino\r\n"); server.print("Content Type: text/html\r\n\r\n"); server.print("Zimmertemperatur </head>\r\n"); server.print("<body>Zimmertemperatur:<p>\r\n"); server.print(temperature-4); server.print("<p>Uptime:"); server.print(millis()); server.print("ms."); delay(10); client.stop(); Serial.println("-----------"); Serial.println(temperature); } }
It will show the room temperature of my lab. I used the above mentioned LM75 sensor from Horter and the Ethernet shield with the WIZnet Ethernet module that you can purchase from Watterott. Also have a look there:
http://www.mats-vanselow.de/arduino-ins-netz-bringen
Given that my controller grabs the temperature from the source via I2C, it would be no problem to connect several sensors over this bus. It would be possible to read out a huge number of data sources...