summaryrefslogtreecommitdiff
path: root/arduino/arduinoAnalogHTTP/analogethernet.ino
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2013-04-20 22:26:55 +0200
committerYves Fischer <yvesf-git@xapek.org>2013-04-20 22:27:00 +0200
commit0fab00a2ff4fbe7c3c56b7bd2dc523eb974aba61 (patch)
tree3d8222d4e3de49172b410c3d1136dfaaa18294d0 /arduino/arduinoAnalogHTTP/analogethernet.ino
parentb5c71cfd18eb145acb72d0a9b58c5b10fbeac74d (diff)
downloadebus-alt-0fab00a2ff4fbe7c3c56b7bd2dc523eb974aba61.tar.gz
ebus-alt-0fab00a2ff4fbe7c3c56b7bd2dc523eb974aba61.zip
sachen rumgeschoben, leveldb: 32bit fix
Diffstat (limited to 'arduino/arduinoAnalogHTTP/analogethernet.ino')
-rwxr-xr-xarduino/arduinoAnalogHTTP/analogethernet.ino99
1 files changed, 0 insertions, 99 deletions
diff --git a/arduino/arduinoAnalogHTTP/analogethernet.ino b/arduino/arduinoAnalogHTTP/analogethernet.ino
deleted file mode 100755
index 63c53e7..0000000
--- a/arduino/arduinoAnalogHTTP/analogethernet.ino
+++ /dev/null
@@ -1,99 +0,0 @@
-// vim: filetype=cpp
-#include <SPI.h>
-#include <Ethernet.h>
-
-byte mac[] = { 0xAD, 0xEE, 0x00, 0xEF, 0xFE, 0xED };
-const int ledPin = 13; // select the pin for the LED
-
-const long ADC_REF_MV = 3300;
-const long ADC_MAX_STEP = 1024;
-const long OV_FACTOR = 4; // Op. Verstärker Faktor = 4; 10mV = 1dB
-
-EthernetClient client;
-
-void sendKeyValue(const char *key, const char *value) {
- char hdrbuf[512];
- snprintf(hdrbuf, 512, "Content-Length: %d\r\n", strlen(value));
-
- if ( ! client.connect("10.1.0.1", 8080)) {
- Serial.println("Failed to connect");
- delay(500);
- return;
- }
- Serial.print("Send ");
- Serial.print(key);
- Serial.print("=");
- Serial.println(value);
-
- client.write("PUT /api/value/");
- client.write(key);
- client.write(" HTTP/1.1\r\n");
- client.write(hdrbuf);
- client.write("\r\n");
- client.write(value);
-
- client.stop();
-}
-
-void sendPinValue() {
- long sensorValue,
- sensorValueMV,
- sensorValueDBA,
- pinnr;
- char buf[12];
- char *sensorKey = "arduino.aX",
- *sensorKeyMV = "arduino.aX.mv",
- *sensorKeyDBA = "arduino.aX.dba";
- for (int i = A0; i <= A5; i++) {
- pinnr = i - A0;
-
- sensorValue = analogRead(i);
- sensorKey[9] = '0' + pinnr;
- snprintf(buf, 8, "%u", sensorValue);
- sendKeyValue(sensorKey, buf);
-
- sensorValueMV = sensorValue * (ADC_REF_MV*100/ADC_MAX_STEP);
- sensorKeyMV[9] = '0' + pinnr;
- snprintf(buf, 8, "%ld.%03ld", sensorValueMV/100, sensorValue%100);
- sendKeyValue(sensorKeyMV, buf);
-
- sensorValueDBA = sensorValueMV / OV_FACTOR;
- sensorKeyDBA[9] = '0' + pinnr;
- snprintf(buf, 12, "%ld.%04ld", sensorValueDBA/1000, sensorValueDBA%1000);
- sendKeyValue(sensorKeyDBA, buf);
- }
-}
-
-
-void setup() {
- Serial.begin(9600);
- Serial.println("Begin init");
-
- // declare the ledPin as an OUTPUT:
- pinMode(ledPin, OUTPUT);
-
- // start the Ethernet and UDP: Use DHCP for IP-Configuration
- Ethernet.begin(mac);
- Serial.println("Ethernet init done");
-
- analogReference(EXTERNAL);
- delay(1000);
- Serial.println("Start loop()");
-}
-
-
-
-char buf[512];
-
-void loop() {
- unsigned long dt = millis();
- digitalWrite(ledPin, HIGH);
-
- sendPinValue();
-
- digitalWrite(ledPin, LOW);
-
- dt = (millis() - dt);
- if (dt < 1000) delay(1000 - dt);
-}
-