@@ -23,9 +23,9 @@ | |||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/core/variant}""/> | <listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/core/variant}""/> | ||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/BME280/src}""/> | <listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/BME280/src}""/> | ||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/Ethernet/src}""/> | <listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/Ethernet/src}""/> | ||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/SPI/src}""/> | |||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/Wire/src}""/> | |||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/PubSubClient/src}""/> | <listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/PubSubClient/src}""/> | ||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/Wire/src}""/> | |||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/SPI/src}""/> | |||||
</option> | </option> | ||||
<inputType id="io.sloeber.compiler.cpp.sketch.input.2111848896" name="CPP source files" superClass="io.sloeber.compiler.cpp.sketch.input"/> | <inputType id="io.sloeber.compiler.cpp.sketch.input.2111848896" name="CPP source files" superClass="io.sloeber.compiler.cpp.sketch.input"/> | ||||
</tool> | </tool> | ||||
@@ -35,9 +35,9 @@ | |||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/core/variant}""/> | <listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/core/variant}""/> | ||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/BME280/src}""/> | <listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/BME280/src}""/> | ||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/Ethernet/src}""/> | <listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/Ethernet/src}""/> | ||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/SPI/src}""/> | |||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/Wire/src}""/> | |||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/PubSubClient/src}""/> | <listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/PubSubClient/src}""/> | ||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/Wire/src}""/> | |||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/SPI/src}""/> | |||||
</option> | </option> | ||||
<inputType id="io.sloeber.compiler.c.sketch.input.1286716504" name="C Source Files" superClass="io.sloeber.compiler.c.sketch.input"/> | <inputType id="io.sloeber.compiler.c.sketch.input.1286716504" name="C Source Files" superClass="io.sloeber.compiler.c.sketch.input"/> | ||||
</tool> | </tool> | ||||
@@ -47,9 +47,9 @@ | |||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/core/variant}""/> | <listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/core/variant}""/> | ||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/BME280/src}""/> | <listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/BME280/src}""/> | ||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/Ethernet/src}""/> | <listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/Ethernet/src}""/> | ||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/SPI/src}""/> | |||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/Wire/src}""/> | |||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/PubSubClient/src}""/> | <listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/PubSubClient/src}""/> | ||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/Wire/src}""/> | |||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BME280MTTQ/libraries/SPI/src}""/> | |||||
</option> | </option> | ||||
<inputType id="io.sloeber.compiler.S.sketch.input.1129911259" name="Assembly source files" superClass="io.sloeber.compiler.S.sketch.input"/> | <inputType id="io.sloeber.compiler.S.sketch.input.1129911259" name="Assembly source files" superClass="io.sloeber.compiler.S.sketch.input"/> | ||||
</tool> | </tool> | ||||
@@ -74,6 +74,10 @@ | |||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> | <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> | ||||
</storageModule> | </storageModule> | ||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> | <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> | ||||
<storageModule moduleId="refreshScope"/> | |||||
<storageModule moduleId="refreshScope" versionNumber="2"> | |||||
<configuration configurationName="Release"> | |||||
<resource resourceType="PROJECT" workspacePath="/BME280MTTQ"/> | |||||
</configuration> | |||||
</storageModule> | |||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/> | <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/> | ||||
</cproject> | </cproject> |
@@ -44,7 +44,7 @@ | |||||
<link> | <link> | ||||
<name>libraries/BME280</name> | <name>libraries/BME280</name> | ||||
<type>2</type> | <type>2</type> | ||||
<location>C:/Users/Andy.I4A/Documents/Arduino/libraries/BME280</location> | |||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/libraries/BME280/2.3.0</locationURI> | |||||
</link> | </link> | ||||
<link> | <link> | ||||
<name>libraries/Ethernet</name> | <name>libraries/Ethernet</name> | ||||
@@ -4,11 +4,7 @@ | |||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> | <extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> | ||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> | <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> | ||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> | <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> | ||||
<<<<<<< Upstream, based on origin/master | |||||
<provider class="io.sloeber.core.toolchain.ArduinoLanguageProvider" console="false" env-hash="959438751749300006" id="io.sloeber.languageSettingsProvider" keep-relative-paths="false" name="Arduino Compiler Settings" parameter="${COMMAND} -E -P -v -dD -D__IN_ECLIPSE__ "${INPUTS}"" prefer-non-shared="true"> | |||||
======= | |||||
<provider class="io.sloeber.core.toolchain.ArduinoLanguageProvider" console="false" env-hash="924733868962110222" id="io.sloeber.languageSettingsProvider" keep-relative-paths="false" name="Arduino Compiler Settings" parameter="${COMMAND} -E -P -v -dD -D__IN_ECLIPSE__ "${INPUTS}"" prefer-non-shared="true"> | <provider class="io.sloeber.core.toolchain.ArduinoLanguageProvider" console="false" env-hash="924733868962110222" id="io.sloeber.languageSettingsProvider" keep-relative-paths="false" name="Arduino Compiler Settings" parameter="${COMMAND} -E -P -v -dD -D__IN_ECLIPSE__ "${INPUTS}"" prefer-non-shared="true"> | ||||
>>>>>>> 092ee8e log changes | |||||
<language-scope id="org.eclipse.cdt.core.gcc"/> | <language-scope id="org.eclipse.cdt.core.gcc"/> | ||||
<language-scope id="org.eclipse.cdt.core.g++"/> | <language-scope id="org.eclipse.cdt.core.g++"/> | ||||
</provider> | </provider> | ||||
@@ -475,7 +475,7 @@ environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.BOARD_NA | |||||
environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.BOARD_NAME/value=Arduino Mega or Mega 2560 | environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.BOARD_NAME/value=Arduino Mega or Mega 2560 | ||||
environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.COM_PORT/delimiter=; | environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.COM_PORT/delimiter=; | ||||
environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.COM_PORT/operation=replace | environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.COM_PORT/operation=replace | ||||
environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.COM_PORT/value=COM5 | |||||
environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.COM_PORT/value=COM4 | |||||
environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.ECLIPSE_LOCATION/delimiter=; | environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.ECLIPSE_LOCATION/delimiter=; | ||||
environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.ECLIPSE_LOCATION/operation=replace | environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.ECLIPSE_LOCATION/operation=replace | ||||
environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.ECLIPSE_LOCATION/value=C\:\\Sloeber\\ | environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.ECLIPSE_LOCATION/value=C\:\\Sloeber\\ | ||||
@@ -5,10 +5,10 @@ | |||||
#include <PubSubClient.h> | #include <PubSubClient.h> | ||||
#include <Dns.h> | #include <Dns.h> | ||||
BME280I2C bme; | BME280I2C bme; | ||||
uint16_t airQuality; | |||||
int val = 0; | |||||
float Temperatur; | float Temperatur; | ||||
float Humidity; | float Humidity; | ||||
float Pressure; | float Pressure; | ||||
@@ -21,7 +21,7 @@ byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x1A }; | |||||
// Port fur Daten-Empfang | // Port fur Daten-Empfang | ||||
unsigned int localPort = 5010; | unsigned int localPort = 5010; | ||||
char msg[50]; | |||||
char msg[20]; | |||||
// IP Adresse Loxone-MiniServer | // IP Adresse Loxone-MiniServer | ||||
IPAddress RecipientIP; | IPAddress RecipientIP; | ||||
@@ -49,9 +49,9 @@ void MQTTcallback(char*, byte*, unsigned int); | |||||
//MQTT | //MQTT | ||||
const char *MQTT_BROKER = "loxberry"; | const char *MQTT_BROKER = "loxberry"; | ||||
IPAddress mqttbroker; | |||||
IPAddress mqttbroker(192,168,1,104); | |||||
EthernetClient ethClient; | EthernetClient ethClient; | ||||
PubSubClient MQTTclient(mqttbroker, 1883, MQTTcallback, ethClient); | |||||
PubSubClient MQTTclient(ethClient); | |||||
void setup() { | void setup() { | ||||
Wire.begin(); | Wire.begin(); | ||||
@@ -70,28 +70,34 @@ void setup() { | |||||
// start the Ethernet connection and the server: | // start the Ethernet connection and the server: | ||||
server.begin(); | server.begin(); | ||||
Serial.print("server is at "); | |||||
Serial.println(Ethernet.localIP()); | |||||
if (!bme.begin()) { | |||||
Serial.println("Could not find a valid BME280 sensor, check wiring!"); | |||||
while (1) | |||||
; | |||||
} | |||||
while (!bme.begin()) { | |||||
delay(1000); | |||||
Serial.println("No valid BME280 sensor, check wiring! retray"); | |||||
} | |||||
Serial.println("1"); | |||||
//DNS Client starten | //DNS Client starten | ||||
dnClient.begin(Ethernet.dnsServerIP()); | dnClient.begin(Ethernet.dnsServerIP()); | ||||
Serial.print("server is at "); | |||||
Serial.print("dns server is at "); | |||||
Serial.println(Ethernet.dnsServerIP()); | Serial.println(Ethernet.dnsServerIP()); | ||||
if (dnClient.getHostByName(MQTT_BROKER, mqttbroker) == 1) { | |||||
if (dnClient.getHostByName(MQTT_BROKER, mqttbroker,10) == 1) { | |||||
Serial.print(F("loxberry = ")); | Serial.print(F("loxberry = ")); | ||||
Serial.println(mqttbroker); | Serial.println(mqttbroker); | ||||
} else { | } else { | ||||
Serial.print("dns failed"); | |||||
mqttbroker.fromString("192.168.1.131"); | |||||
Serial.println("dns failed "); | |||||
Serial.println( (MQTT_BROKER, mqttbroker,10)); | |||||
mqttbroker.fromString("192.168.1.127"); | |||||
Serial.println(mqttbroker); | |||||
} | } | ||||
// MQTT | |||||
MQTTclient.setServer(mqttbroker, 11884); | |||||
MQTTclient.setCallback(MQTTcallback); | |||||
//Serial leeren | //Serial leeren | ||||
clearAll(); | clearAll(); | ||||
@@ -100,20 +106,21 @@ void setup() { | |||||
} | } | ||||
void loop() { | void loop() { | ||||
String aq = String(airQuality); | |||||
String temp = String(Temperatur, 2); | String temp = String(Temperatur, 2); | ||||
String hum = String(Humidity, 2); | String hum = String(Humidity, 2); | ||||
String press = String(Pressure / 100, 2); | String press = String(Pressure / 100, 2); | ||||
char buff[50]; | |||||
char buff[10]; | |||||
bme.read(Pressure, Temperatur, Humidity); | bme.read(Pressure, Temperatur, Humidity); | ||||
//MQTT | //MQTT | ||||
if (!MQTTclient.connected()) { | if (!MQTTclient.connected()) { | ||||
MQTTclient.connect("Stall", "loxberry", "OSVL0AMqISFXgr5g"); | |||||
MQTTclient.connect("Arduino1"); | |||||
Serial.print("MQTT Client state:"); | |||||
Serial.println(MQTTclient.state()); | |||||
// Abonieren von Nachrichten mit dem angegebenen Topic | // Abonieren von Nachrichten mit dem angegebenen Topic | ||||
MQTTclient.subscribe("/Stall/arduino1/#"); | |||||
//MQTTclient.subscribe("/Stall/arduino1/#"); | |||||
Serial.println("connected to MQTT"); | |||||
} | } | ||||
temp.toCharArray(buff,temp.length()); | temp.toCharArray(buff,temp.length()); | ||||
MQTTclient.publish("/Stall/Temperatur", buff); | MQTTclient.publish("/Stall/Temperatur", buff); | ||||
press.toCharArray(buff,press.length()); | press.toCharArray(buff,press.length()); | ||||
@@ -121,26 +128,11 @@ void loop() { | |||||
hum.toCharArray(buff,hum.length()); | hum.toCharArray(buff,hum.length()); | ||||
MQTTclient.publish("/Stall/Humidity", buff); | MQTTclient.publish("/Stall/Humidity", buff); | ||||
MQTTclient.loop(); // Schleife für MQTT | |||||
// MQTTclient.loop(); // Schleife für MQTT | |||||
// schaut on ein UDP Befehl empfangen wurde | // schaut on ein UDP Befehl empfangen wurde | ||||
checkUDP(); | checkUDP(); | ||||
if (!strcmp(packetBuffer, "000")) { | |||||
Serial.print("CO2 = "); | |||||
Serial.print(airQuality); | |||||
Serial.print(" "); | |||||
Serial.println("[ppm]"); | |||||
// Wert wird auf 3000ppm begrnezt | |||||
if (airQuality > 3000) { | |||||
aq = "3000"; | |||||
} else { | |||||
aq = airQuality; | |||||
} | |||||
sendUDP(aq); | |||||
} | |||||
if (!strcmp(packetBuffer, "001")) { | if (!strcmp(packetBuffer, "001")) { | ||||
sendUDP(temp); | sendUDP(temp); | ||||
} | } | ||||
@@ -154,9 +146,9 @@ void loop() { | |||||
clearAll(); | clearAll(); | ||||
snprintf(msg, 50, "Alive since %ld milliseconds", millis()); | snprintf(msg, 50, "Alive since %ld milliseconds", millis()); | ||||
Serial.print("Publish message: "); | |||||
Serial.println("Publish message: "); | |||||
Serial.println(msg); | Serial.println(msg); | ||||
MQTTclient.publish("/home/data", "Hello World"); | |||||
MQTTclient.publish("/home/data", msg); | |||||
// listen for incoming clients | // listen for incoming clients | ||||
EthernetClient client = server.available(); | EthernetClient client = server.available(); | ||||
@@ -173,29 +165,18 @@ void loop() { | |||||
// so you can send a reply | // so you can send a reply | ||||
if (c == '\n' && currentLineIsBlank) { | if (c == '\n' && currentLineIsBlank) { | ||||
// send a standard http response header | // send a standard http response header | ||||
client.println("HTTP/1.1 200 OK"); | |||||
client.println("Content-Type: text/html"); | |||||
client.println("Connection: close"); | |||||
client.println(); | |||||
client.println("<!DOCTYPE HTML>"); | |||||
client.println("<html>"); | |||||
// add a meta refresh tag, so the browser pulls again every 5 seconds: | |||||
client.println( | |||||
"<meta http-equiv=\"refresh\" content=\"10\">"); | |||||
// output the value of each analog input pin | |||||
client.println("Current Humidity = "); //Prints information within qoutation | |||||
client.println(hum); //Prints the Humidity read from the DHT11 on PIN 5 | |||||
client.print("Feuchtigkeit = "); //Prints information within qoutation | |||||
client.print(hum); //Prints the Humidity read from the DHT11 on PIN 5 | |||||
client.println("% "); | client.println("% "); | ||||
client.println("Temperature = "); | |||||
client.println(temp); //Prints the temperature read from the DHT11 on PIN 5 | |||||
client.print("Temperature = "); | |||||
client.print(temp); //Prints the temperature read from the DHT11 on PIN 5 | |||||
client.println("C "); | client.println("C "); | ||||
client.println("Luftdruck = "); | |||||
client.println(press); | |||||
client.println(" "); | |||||
client.println("[hPa]"); | |||||
client.print("Luftdruck = "); | |||||
client.print(press); | |||||
client.println(" [hPa]"); | |||||
client.println("</html>"); | |||||
break; | break; | ||||
} | } | ||||
if (c == '\n') { | if (c == '\n') { | ||||
@@ -253,11 +234,11 @@ void MQTTcallback(char *topic, byte *payload, unsigned int length) { | |||||
Serial.print(topic); | Serial.print(topic); | ||||
Serial.print("] "); | Serial.print("] "); | ||||
char msg[length + 1]; | char msg[length + 1]; | ||||
for (int i = 0; i < length; i++) { | |||||
for (unsigned int i = 0; i < length; i++) { | |||||
Serial.print((char) payload[i]); | Serial.print((char) payload[i]); | ||||
msg[i] = (char) payload[i]; | msg[i] = (char) payload[i]; | ||||
} | } | ||||
Serial.println(); | |||||
Serial.println("keine Ahnung"); | |||||
msg[length] = '\0'; | msg[length] = '\0'; | ||||
Serial.println(msg); | Serial.println(msg); | ||||