Skip to content

Commit

Permalink
Merge pull request #9 from tkoeberl/master
Browse files Browse the repository at this point in the history
init the si1145 & changed the mqtt config
  • Loading branch information
jhughes1010 authored Apr 4, 2022
2 parents d96e213 + 81d1ab2 commit b7a9da3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
secrets.h
.vscode/
3 changes: 3 additions & 0 deletions iot_data.ino
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,7 @@ void sendData(struct sensorData *environment)
delay(5000);
}
}
else if (App == "MQTT") {
SendDataMQTT(environment);
}
}
14 changes: 10 additions & 4 deletions sensors.ino
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,14 @@ void readBME(struct sensorData *environment)
//=======================================================
void readUV(struct sensorData *environment)
{
environment->UVIndex = uv.readUV() / 100;
MonPrintf("UV Index: %f\n", environment->UVIndex);
MonPrintf("Vis: %i\n", uv.readVisible());
MonPrintf("IR: %i\n", uv.readIR());
if (! uv.begin()) {
Serial.println("Didn't find Si1145");
environment->UVIndex = -1;
}
else{
environment->UVIndex = uv.readUV() / 100;
MonPrintf("UV Index: %f\n", environment->UVIndex);
MonPrintf("Vis: %i\n", uv.readVisible());
MonPrintf("IR: %i\n", uv.readIR());
}
}
6 changes: 0 additions & 6 deletions weather.ino
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,6 @@ void processSensorUpdates(void)
#endif
//send sensor data to IOT destination
sendData(&environment);

//send sensor data to MQTT
#ifdef MQTT
SendDataMQTT(&environment);
#endif

WiFi.disconnect();
}

Expand Down
11 changes: 11 additions & 0 deletions wifi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ void wifi_connect()
}
MonPrintf("WiFi connected\n");
}
else if (App == "MQTT") // for posting datas to Thingspeak website
{
MonPrintf("Connecting to WiFi\n");
WiFi.begin(ssid, pass);

while (WiFi.status() != WL_CONNECTED)
{
delay(500);
}
MonPrintf("WiFi connected\n");
}
else
{
//WiFi.begin(ssid, pass);
Expand Down

0 comments on commit b7a9da3

Please sign in to comment.