Переглянути джерело

# WARNING: head commit changed in the meantime

changes
log changes
master
agr 4 роки тому
джерело
коміт
95ae467d94
5 змінених файлів з 56 додано та 75 видалено
  1. +11
    -7
      .cproject
  2. +1
    -1
      .project
  3. +0
    -4
      .settings/language.settings.xml
  4. +1
    -1
      .settings/org.eclipse.cdt.core.prefs
  5. +43
    -62
      BME280MTTQ.ino

+ 11
- 7
.cproject Переглянути файл

@@ -23,9 +23,9 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/core/variant}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/BME280/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/Ethernet/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/SPI/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/Wire/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/PubSubClient/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/Wire/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/SPI/src}&quot;"/>
</option>
<inputType id="io.sloeber.compiler.cpp.sketch.input.2111848896" name="CPP source files" superClass="io.sloeber.compiler.cpp.sketch.input"/>
</tool>
@@ -35,9 +35,9 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/core/variant}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/BME280/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/Ethernet/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/SPI/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/Wire/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/PubSubClient/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/Wire/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/SPI/src}&quot;"/>
</option>
<inputType id="io.sloeber.compiler.c.sketch.input.1286716504" name="C Source Files" superClass="io.sloeber.compiler.c.sketch.input"/>
</tool>
@@ -47,9 +47,9 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/core/variant}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/BME280/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/Ethernet/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/SPI/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/Wire/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/PubSubClient/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/Wire/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/BME280MTTQ/libraries/SPI/src}&quot;"/>
</option>
<inputType id="io.sloeber.compiler.S.sketch.input.1129911259" name="Assembly source files" superClass="io.sloeber.compiler.S.sketch.input"/>
</tool>
@@ -74,6 +74,10 @@
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</storageModule>
<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"/>
</cproject>

+ 1
- 1
.project Переглянути файл

@@ -44,7 +44,7 @@
<link>
<name>libraries/BME280</name>
<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>
<name>libraries/Ethernet</name>


+ 0
- 4
.settings/language.settings.xml Переглянути файл

@@ -4,11 +4,7 @@
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<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__ &quot;${INPUTS}&quot;" 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__ &quot;${INPUTS}&quot;" prefer-non-shared="true">
>>>>>>> 092ee8e log changes
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>


+ 1
- 1
.settings/org.eclipse.cdt.core.prefs Переглянути файл

@@ -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.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/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/operation=replace
environment/project/io.sloeber.core.toolChain.release.1051055115/JANTJE.ECLIPSE_LOCATION/value=C\:\\Sloeber\\


+ 43
- 62
BME280MTTQ.ino Переглянути файл

@@ -5,10 +5,10 @@
#include <PubSubClient.h>
#include <Dns.h>



BME280I2C bme;

uint16_t airQuality;
int val = 0;
float Temperatur;
float Humidity;
float Pressure;
@@ -21,7 +21,7 @@ byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x1A };
// Port fur Daten-Empfang
unsigned int localPort = 5010;

char msg[50];
char msg[20];
// IP Adresse Loxone-MiniServer
IPAddress RecipientIP;

@@ -49,9 +49,9 @@ void MQTTcallback(char*, byte*, unsigned int);

//MQTT
const char *MQTT_BROKER = "loxberry";
IPAddress mqttbroker;
IPAddress mqttbroker(192,168,1,104);
EthernetClient ethClient;
PubSubClient MQTTclient(mqttbroker, 1883, MQTTcallback, ethClient);
PubSubClient MQTTclient(ethClient);

void setup() {
Wire.begin();
@@ -70,28 +70,34 @@ void setup() {

// start the Ethernet connection and the server:
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
dnClient.begin(Ethernet.dnsServerIP());
Serial.print("server is at ");
Serial.print("dns server is at ");
Serial.println(Ethernet.dnsServerIP());

if (dnClient.getHostByName(MQTT_BROKER, mqttbroker) == 1) {
if (dnClient.getHostByName(MQTT_BROKER, mqttbroker,10) == 1) {
Serial.print(F("loxberry = "));
Serial.println(mqttbroker);
} 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
clearAll();

@@ -100,20 +106,21 @@ void setup() {
}

void loop() {
String aq = String(airQuality);
String temp = String(Temperatur, 2);
String hum = String(Humidity, 2);
String press = String(Pressure / 100, 2);
char buff[50];
char buff[10];
bme.read(Pressure, Temperatur, Humidity);

//MQTT
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
MQTTclient.subscribe("/Stall/arduino1/#");
//MQTTclient.subscribe("/Stall/arduino1/#");
Serial.println("connected to MQTT");
}

temp.toCharArray(buff,temp.length());
MQTTclient.publish("/Stall/Temperatur", buff);
press.toCharArray(buff,press.length());
@@ -121,26 +128,11 @@ void loop() {
hum.toCharArray(buff,hum.length());
MQTTclient.publish("/Stall/Humidity", buff);

MQTTclient.loop(); // Schleife für MQTT
// MQTTclient.loop(); // Schleife für MQTT

// schaut on ein UDP Befehl empfangen wurde
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")) {
sendUDP(temp);
}
@@ -154,9 +146,9 @@ void loop() {
clearAll();

snprintf(msg, 50, "Alive since %ld milliseconds", millis());
Serial.print("Publish message: ");
Serial.println("Publish message: ");
Serial.println(msg);
MQTTclient.publish("/home/data", "Hello World");
MQTTclient.publish("/home/data", msg);

// listen for incoming clients
EthernetClient client = server.available();
@@ -173,29 +165,18 @@ void loop() {
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// 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("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("Luftdruck = ");
client.println(press);
client.println(" ");
client.println("[hPa]");
client.print("Luftdruck = ");
client.print(press);
client.println(" [hPa]");

client.println("</html>");
break;
}
if (c == '\n') {
@@ -253,11 +234,11 @@ void MQTTcallback(char *topic, byte *payload, unsigned int length) {
Serial.print(topic);
Serial.print("] ");
char msg[length + 1];
for (int i = 0; i < length; i++) {
for (unsigned int i = 0; i < length; i++) {
Serial.print((char) payload[i]);
msg[i] = (char) payload[i];
}
Serial.println();
Serial.println("keine Ahnung");

msg[length] = '\0';
Serial.println(msg);


Завантаження…
Відмінити
Зберегти