Skip to content

Commit

Permalink
Merge pull request #27 from acremonezi/19-2005869-add-display-capabil…
Browse files Browse the repository at this point in the history
…ity-2

display capability + some stuff
  • Loading branch information
ioFormigoni authored Sep 28, 2022
2 parents 4307234 + 2ef005f commit 6fe1463
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 2 deletions.
126 changes: 126 additions & 0 deletions hardware/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,129 @@
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch


# Created by https://www.toptal.com/developers/gitignore/api/c,c++,visualstudiocode,platformio,git
# Edit at https://www.toptal.com/developers/gitignore?templates=c,c++,visualstudiocode,platformio,git

### C ###
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

### C++ ###
# Prerequisites

# Compiled Object files
*.slo

# Precompiled Headers

# Compiled Dynamic libraries

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai

# Executables

### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig

# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt

### PlatformIO ###
.pioenvs
.piolibdeps
.clang_complete
.gcc-flags.json
.pio

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

# Support for Project snippet scope
.vscode/*.code-snippets

# Ignore code-workspaces
*.code-workspace

# End of https://www.toptal.com/developers/gitignore/api/c,c++,visualstudiocode,platformio,git
16 changes: 16 additions & 0 deletions hardware/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ lib_deps =
knolleary/PubSubClient@^2.8
ESP8266WiFi@^1.0
bblanchon/ArduinoJson@^6.19.4
thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@^4.3.0

[env:nodemcu-32s]
platform = espressif32
Expand All @@ -33,3 +34,18 @@ lib_deps =
knolleary/PubSubClient@^2.8
ESP8266WiFi@^1.0
bblanchon/ArduinoJson@^6.19.4
thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@^4.3.0

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
upload_port = /dev/ttyUSB0
monitor_port = /dev/ttyUSB0
lib_deps =
adafruit/DHT sensor library@^1.4.4
adafruit/Adafruit Unified Sensor@^1.1.6
knolleary/PubSubClient@^2.8
ESP8266WiFi@^1.0
bblanchon/ArduinoJson@^6.19.4
thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@^4.3.0
75 changes: 75 additions & 0 deletions hardware/src/display/display.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include <Arduino.h> // Main Arduino Library
#include "pinSettings.h" // Pin Settings Setup

// Features
#include "sensors/DHTxx.h" // DHTxx Sensor Code


//Display
#include <Wire.h>
#include "SSD1306Wire.h"
#include <stdio.h>
#include <iostream>
#include <string.h>


// vars to use with display
String textTemperatureComplete;
String textHumidityComplete;
String textMACComplete;


SSD1306Wire display(0x3c, D6, D5, GEOMETRY_128_64);


void startDisplay()
{
display.init();
display.flipScreenVertically();
}


void refreshDisplay()
{
// display lines
delay(2000);
display.clear(); // only first time in loop
display.setTextAlignment(TEXT_ALIGN_LEFT);

// MACADRESS
display.setFont(ArialMT_Plain_10);
textMACComplete += espClientMAC;
if (textMACComplete == "")
{
textMACComplete += "Not Conected";
}
display.drawString(10, 0, textMACComplete);
Serial.print("MACADRESS: ");
Serial.println(textMACComplete);
display.display();
textMACComplete = "";

// Temperature
display.setFont(ArialMT_Plain_16);



textTemperatureComplete += DHTxxTemperature;
textTemperatureComplete += " ºC";
display.drawString(20, 20, textTemperatureComplete);
display.display();
textTemperatureComplete = "";

// Humidity
display.setFont(ArialMT_Plain_16);

textHumidityComplete += DHTxxHumidity;
textHumidityComplete += " %";
display.drawString(70, 40, textHumidityComplete);
display.display();
textHumidityComplete = "";

Serial.println(textTemperatureComplete);
Serial.println(textHumidityComplete);

}
5 changes: 4 additions & 1 deletion hardware/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "sensors/DHTxx.h" // DHTxx Sensor Code
#include "wifi/wifi.h" // Wifi Connection
#include "mqtt/mqtt.h" // MQTT Code
#include "display/display.h" //Display Code


void setup() {
Expand All @@ -15,6 +16,7 @@ void setup() {
DHTxxSetup(); // DHTxx Sensor Setup
wifiConnect(); // Wifi Connection
mqttConnect(); // MQTT Setup
startDisplay(); // Start and configure display

}

Expand All @@ -23,5 +25,6 @@ void loop() {
DHTxxRead(); // DHTxx Sensor Readings
DHTxxSerialPrint(); // DHTxx Sensor Serial Print
mqttPublish(); // MQTT Publish

refreshDisplay(); // Show MAC, temperature and humidity in display

}
5 changes: 4 additions & 1 deletion hardware/src/pinSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
// For ESP8266 use pins 3, 4, 5, 12, 13 or 14 --
// ----------------------------------------------

#define DHTPIN D3
#define DHTPIN D3 // Pin for DHT Sensor
#define SDLPIN D5 // Pin for display
#define SDAPIN D6 // Pin for display



// Pin Settings Setup
Expand Down

0 comments on commit 6fe1463

Please sign in to comment.