Sketch: -, Version 2020-12-10
Deutsche Version
This repository contains a lot of helper classes for the Wemos D1 mini.
Application examples for these classes can be found in the repository D1mini_oop, among others.
How to use the classes
- Make a directory
srcinside the (Arduino) working directory. - Copy directory (or directories) that contain the source code into directory
src. - Add
#includeline in ino file like
#include "src/dout/D1_class_Dout.h"
This classes often are used for the D1 mini data logger shield (microSD + DS1307RTC Shield).
| class | purpose |
|---|---|
| DS1307 | get/set date and time from/to real time clock DS1307 |
| SDfile | file management on micro SD card |
| TimeHttp | get date and time from a server by http request |
Every directory contains some classes for controlling a EPD by SPI or over a IS602-I2C-SPI-bridge:
- SPI connection class
EpdConnection, - paint classes
EpdPaintandEpdPainter, - class for painting a bar (
EpdPainterBar) and - class to adjust a certain display
Epd_(names see table below)
| directory | purpose |
|---|---|
| epd_0154bw | class Epd_ for 2-color 1.54 inch EPD (200x200 black-white) |
| epd_0154red | class Epd_ for 3-color 1.54 inch EPD (200x200 black-white-red) |
| epd_0290bw | class Epd_ for 2-color 2.90 inch EPD (296x128 black-white) |
| epd_i2c_0154bw | class Epd_ for 2-color 1.54 inch EPD (200x200 black-white) and IS602 bridge |
| epd_i2c_ 0290bw | class Epd_ for 2-color 2.90 inch EPD (296x128 black-white) and IS602 bridge |
The directory epd_fonteditor contains ods-files to generate your own characters for a e-paper display.
Character sizes: 16x8, 20x11 and 24x11.
The directory epd_fonts contains the file fonts.hand c files with fonts for electronic paper displays (EPD) with different char sizes:
ASCII values 32..127: font8.c (8x5), font12.c (12x7), font16.c (16x11), font20.c (20x14), font24.c (24x17); font_20x11.c (20x11), font_24x11.c (24x11)
ASCII values 32..255: font16x8_255.c (16x8), font20x11_255.c (20x11), font_24x11_255.c (24x11)
ASCII values 32..255, characters in program memory: pmfont_24x11_255.c (24x11)
The directory contains some picures.
| class | purpose |
|---|---|
| Ain | analog input (Default: Pin A0) |
| Din | digital input (Default: Button at D3) |
| Dout | digital output (Default: blue LED on D1mini) |
| relay2 | switch a relay on |
| class | purpose |
|---|---|
| PubSubClient | class to send and receive MQTT messages by WLAN |
| MqttClientKH | Extension of class PubSubClient for easy data transmission |
| MqttClientKH2 | Various improvements of the class MqttClientKH (e.g. separation of WiFi and MQTT methods) |
| SimpleMqtt | Extension of the class PubSubClient for easy creation of MQTT applications for D1mini and ESPD1mini. A base topic is defined, actions are performed via /get, and /set messages and responses are sent back via /ret-topics. |
OLED classes are used to display text on a 0.66" D1 mini OLED shield (SSD1306, 64x48, I2C, 7bit-address 0x3C or 0x3D). Only 6 lines with 10 chars can be displayed.
Special: char(158) = Euro sign instead of Pt (Pesetas) (158=9E)
The code is strongly based on Adafruit libs
- Adafruit_SSD1306-esp8266-64x48.zip and
- Adafruit-GFX-Library-1.1.5.zip
To avoid problems with installed classes, Adafruit names in this class have a leading underline.
Use this class, if you have problems with the Adafruit classes especially after an update of the libraries.
| class | purpose |
|---|---|
| Screen1 | class to display text on a 0.66" OLED shield. |
| Screen1a | Extended class Screen1 for scrolling. |
| Screen_64x48 | Basic functions for OLED shield 0.66" 64x48 pixel. |
| Screen096 | class to display text on a 0.96" OLED shield. |
Examples
screen6(3,"Demo",'l');..... Write the text "Demo" with align left in line 3 of a screen with 6 lines.screen6i(4,"XXX",'r');..... Write the text "XXX" inverted with align right in line 4 of a screen with 6 lines.screen6iClear(1,"Demo",'c');..... Clear display, then write the text "Demo" inverted and centered in line 1 of a screen with 6 lines.
The screens screen6, screen5, screen4 and screen4B located in the files D1_class_Screen1a.h and D1_class_Screen1a.cpp allow scrolling a text. Write the text in the next, invisible line. (Eg for screen6: line 7 and so on.)
Directory oled_fonteditor contains ods-files to create your own characters for a OLED.
Character size(s): 5x8.
| class | purpose |
|---|---|
| AM2322 | Class for temperature and humidity i2c sensor AM2322. Temperature -40°..+80°C, +-0,5°C/+-0,2°C, 16bit; Humidity 0%..99,0%, +-3%/+-0,1%, 16bit. Default i2c address is 0x5C. |
| BH1750 | Class for i2c digital light sensor BH1750. Default i2c address is 0x23 (other option 0x5C). |
| BME280 | Class for temperature, humidity and pressure/altitude i2c sensor BME280. Temperature -40°C...85°C +-1°, 0,01°C resolution, humidity 0%...100% +-3%RH absolut, 0,008%RH resolution, pressure 300...1100hPa +-1,0hPa. Default i2c address is 0x76 (other 0x77). |
| SHT30 | Class for temperature and humidity i2c sensor SHT30. Temperature -40°C...125°C +-0,7% (0°..+65°C, +-0,3°C), Humidity +-3%RH. Default i2c address is 0x45 (other 0x44). |
| class | purpose |
|---|---|
| GSMmodule | D1 mini class for sending and receiving SMS with a SIM800C GSM GPRS module STM32. Select software or hardware serial by constructor: No value or true selects software serial (D5=Tx, D6=RX), false selects hardware serial |
| GSMmodule0 | D1 mini class for sending and receiving SMS with a SIM800C GSM GPRS module STM32. Select software or hardware serial by #define-command in file D1_class_GSMmodule0.h: #define GSMMOD_SWS true //software serialAdvantage: hardware serial needs less memory after compiling. Disadvantage: You have to edit file D1_class_GSMmodule0.h |
| GSMmodule | D1 mini class for sending and receiving SMS with a SIM800C GSM GPRS module STM32. Select software or hardware serial by constructor: No value or true selects software serial (D5=Tx, D6=RX), false selects hardware serial. Class directory also contains source code for software serial. |
| class | purpose |
|---|---|
| statemachine | class to create a statemachine. Examples for methodes: Statemachine statemachine(STATE_MAX, STATE_DELAY);, int state=loopBegin();, switch(state), unsigned long duration=loopEnd(); |