Compare commits

...

6 Commits

Author SHA1 Message Date
Joachim Hummel
2d66f7730a Edit dsp310.ino added wire1 port for qwiic connector 2024-02-26 17:31:03 +00:00
Joachim Hummel
38e42cb323 Edit all INO-File, added Header infos 2024-02-08 22:13:19 +00:00
Joachim Hummel
a4b95097ba Added DSP310 Sensor with MQTT and Wifi 2024-02-08 18:46:35 +00:00
Joachim Hummel
9b0e84f001 Added MQTT with DHT11 Sensor 2024-02-07 14:03:36 +00:00
Joachim Hummel
98c54799f5 Merge branch 'main' of https://git.unixweb.net/joachim/arduino-uno-r4-wifi into main 2024-02-07 13:18:01 +00:00
Joachim Hummel
5dbc778440 Edit Readme 2024-02-07 13:17:32 +00:00
7 changed files with 371 additions and 0 deletions

View File

@@ -6,3 +6,8 @@ Repo für den Arduino UNO R4 Wifi
<img src="https://git.unixweb.net/joachim/arduino-uno-r4-wifi/raw/branch/main/images/Arduino-UNO-R4-Wifi-Uhr.jpg">
</a>
## Arduino Animation
<img src="https://git.unixweb.net/joachim/arduino-uno-r4-wifi/raw/branch/main/images/Arduino-UNO-R4-Wifi-Pfeil.jpg">
</a>

56
animation/animation.h Normal file
View File

@@ -0,0 +1,56 @@
const uint32_t animation[][4] = {
{
0x800c0060,
0xf00f006,
0xc00800,
66
},
{
0xc0060030,
0xf80f803,
0x600c00,
66
},
{
0x60030018,
0xfc0fc01,
0x80300600,
66
},
{
0x3001800c,
0xfe0fe00,
0xc0180300,
66
},
{
0x1800c006,
0xff0ff00,
0x600c0180,
66
},
{
0xc006003,
0xff8ff80,
0x300600c0,
66
},
{
0x6003001,
0x8ffcffc0,
0x18030060,
66
},
{
0x3001800,
0xcffeffe0,
0xc018030,
66
},
{
0x1800c00,
0x6ffffff0,
0x600c018,
66
}
};

45
animation/animation.ino Normal file
View File

@@ -0,0 +1,45 @@
/*
Projekt: Animation f<>r 12x8 Neopixel Display
Beschreibung: Dieses Sketch kann zur Nutzung auf einem Arduino UNO R4 Wifi mit dem Display genutzt werden
Autor: Joachim Hummel
Datum: 08.02.2024 Erstellung
Arduino-Board: Arduino Uno R4 WiFi
Lizenz: Apache 2.0
Hinweise:
- Die Nutzung des Code beinhaltet keinerlei Garantie oder Gew<65>hrliestung.
Die Nutzung erfolgt auf eigenes Risiko ohne Rechtsanspruch
Credits:
- Danke f<>r die Bereitstellung von Codeteilen aus der Arduino IDE
Weitere Informationen findest du in der README.md-Datei oder auf GitHub.
*/
#include "animation.h" //Include animation.h header file
// Create an instance of the ArduinoLEDMatrix class
ArduinoLEDMatrix matrix;
void setup() {
Serial.begin(115200);
// you can also load frames at runtime, without stopping the refresh
matrix.loadSequence(animation);
matrix.begin();
// turn on autoscroll to avoid calling next() to show the next frame; the paramenter is in milliseconds
// matrix.autoscroll(300);
matrix.play(true);
}
void loop() {
delay(2500);
Serial.println(millis());
}

View File

@@ -0,0 +1,3 @@
//arduino_secrets.h header file
#define SECRET_SSID "xxxx"
#define SECRET_PASS "xxxx"

118
mqtt-dht11-sensor/mqtt.ino Normal file
View File

@@ -0,0 +1,118 @@
/*
Projekt: MQTT Wifi DHT11 Sensor
Beschreibung: Dieses Sketch kann zur Nutzung auf einem Arduino UNO R4 Wifi mit dem Sensor DHT11 genutzt werden
Autor: Joachim Hummel
Datum: 08.02.2024 Erstellung
Arduino-Board: Arduino Uno R4 WiFi
Lizenz: Apache 2.0
Hinweise:
- Die Nutzung des Code beinhaltet keinerlei Garantie oder Gew<65>hrliestung.
Die Nutzung erfolgt auf eigenes Risiko ohne Rechtsanspruch
Credits:
- Danke f<>r die Bereitstellung von Codeteilen aus der Arduino IDE
Weitere Informationen findest du in der README.md-Datei oder auf GitHub.
*/
#include <ArduinoJson.h>
#include <ArduinoJson.hpp>
#include <WiFiS3.h>
#include <PubSubClient.h>
#include <Wire.h>
#include <DHT.h> // Replace "Adafruit_BME680.h" with "DHT.h"
#include "arduino_secrets.h"
#define DHTPIN 8
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
// please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
const char* mqtt_server = "192.168.10.7"; //IP of your MQTT Broker
WiFiClient espClient;
PubSubClient client(espClient);
unsigned long lastMsg = 0;
#define MSG_BUFFER_SIZE (50)
char msg[MSG_BUFFER_SIZE];
int value = 0;
void setup_wifi() {
delay(100);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void callback(char* topic, byte* payload, unsigned int length) {
// Handle incoming MQTT messages if needed
}
void reconnect() {
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
String clientId = "ESP8266Client-";
clientId += String(random(0xffff), HEX);
if (client.connect(clientId.c_str())) {
Serial.println("connected");
client.publish("outTopic", "hello world");
client.subscribe("inTopic");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
delay(5000);
}
}
}
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println(F("DHT11 test"));
dht.begin();
setup_wifi();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
}
void loop() {
if (!client.connected()) {
reconnect();
}
client.loop();
StaticJsonDocument<32> doc;
char output[55];
long now = millis();
if (now - lastMsg > 5000) {
lastMsg = now;
float temp = dht.readTemperature();
float humidity = dht.readHumidity();
doc["t"] = temp;
doc["h"] = humidity;
serializeJson(doc, output);
client.publish("/home/sensors", output);
}
}

View File

@@ -0,0 +1,3 @@
//arduino_secrets.h header file
#define SECRET_SSID "xxxx"
#define SECRET_PASS "xxxx"

View File

@@ -0,0 +1,141 @@
/*
Projekt: MQTT Wifi DSP310 Sensor
Beschreibung: Dieses Sketch kann zur Nutzung auf einem Arduino UNO R4 Wifi mit dem Sensor DSP310 genutzt werden
Autor: Joachim Hummel
Datum: 08.02.2024 Erstellung
Arduino-Board: Arduino Uno R4 WiFi
Bibliotheken:
- [Liste der verwendeten Bibliotheken, inklusive Versionen wenn möglich]
Lizenz: Apache 2.0
Hinweise:
- Die Nutzung des Code beinhaltet keinerlei Garantie oder Gew<65>hrliestung.
Die Nutzung erfolgt auf eigenes Risiko ohne Rechtsanspruch
Credits:
- Danke f<>r die Bereitstellung von Codeteilen aus der Arduino IDE
Weitere Informationen findest du in der README.md-Datei oder auf GitHub.
*/
#include <ArduinoJson.h>
#include <WiFiS3.h>
#include <PubSubClient.h>
#include <Adafruit_DPS310.h>
#include "arduino_secrets.h"
Adafruit_DPS310 dps;
Adafruit_Sensor *dps_temp = dps.getTemperatureSensor();
Adafruit_Sensor *dps_pressure = dps.getPressureSensor();
// Please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID; // Your network SSID (name)
char pass[] = SECRET_PASS; // Your network password (use for WPA, or use as key for WEP)
const char* mqtt_server = "192.168.10.7"; // IP of your MQTT Broker
WiFiClient espClient;
PubSubClient client(espClient);
unsigned long lastMsg = 0;
#define MSG_BUFFER_SIZE (50)
char msg[MSG_BUFFER_SIZE];
int value = 0;
void setup_wifi() {
delay(100);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void callback(char* topic, byte* payload, unsigned int length) {
// Handle incoming MQTT messages if needed
}
void reconnect() {
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
String clientId = "ESP8266Client-";
clientId += String(random(0xffff), HEX);
if (client.connect(clientId.c_str())) {
Serial.println("connected");
client.publish("outTopic", "Sensor Online!");
client.subscribe("inTopic");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
delay(5000);
}
}
}
void setup() {
Serial.begin(115200);
while (!Serial) delay(10);
Serial.println("DPS310");
if (! dps.begin_I2C(0x77,&Wire1)) {
Serial.println("Failed to find DPS");
while (1) yield();
}
Serial.println("DPS OK!");
// Setup highest precision
dps.configurePressure(DPS310_64HZ, DPS310_64SAMPLES);
dps.configureTemperature(DPS310_64HZ, DPS310_64SAMPLES);
setup_wifi();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
}
void loop() {
if (!client.connected()) {
reconnect();
}
client.loop();
StaticJsonDocument<32> doc;
char output[55];
sensors_event_t temp_event, pressure_event;
if (dps.temperatureAvailable() && dps.pressureAvailable()) {
dps_temp->getEvent(&temp_event);
dps_pressure->getEvent(&pressure_event);
Serial.print(F("Temperature = "));
Serial.print(temp_event.temperature);
Serial.println(" *C");
Serial.print(F("Pressure = "));
Serial.print(pressure_event.pressure);
Serial.println(" hPa");
Serial.println();
doc["temperature"] = temp_event.temperature;
doc["pressure"] = pressure_event.pressure;
serializeJson(doc, output);
client.publish("/home/sensors", output);
delay(5000);
}
}