diff --git a/check_custom_build_flags_esp32.sh b/check_custom_build_flags_esp32.sh old mode 100755 new mode 100644 index 08f4c46..3d4d6b6 --- a/check_custom_build_flags_esp32.sh +++ b/check_custom_build_flags_esp32.sh @@ -1,10 +1,11 @@ #! /bin/bash export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short) -#export FLAGS="$FLAGS -DDMX_DISABLE" +export FLAGS="$FLAGS -DDMX_DISABLE" export FLAGS="$FLAGS -DMODBUS_DISABLE" -#export FLAGS="$FLAGS -DOWIRE_DISABLE" -#export FLAGS="$FLAGS -DDHT_DISABLE" +export FLAGS="$FLAGS -DOWIRE_DISABLE" +export FLAGS="$FLAGS -DDHT_DISABLE" export FLAGS="$FLAGS -DCOUNTER_DISABLE" +#export FLAGS="$FLAGS -DM5STACK" #export FLAGS="$FLAGS -std=gnu++11" CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_esp32.sh if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then diff --git a/check_custom_build_flags_nrf52840.sh b/check_custom_build_flags_nrf52840.sh old mode 100755 new mode 100644 index c8fe8d2..9b02f8f --- a/check_custom_build_flags_nrf52840.sh +++ b/check_custom_build_flags_nrf52840.sh @@ -1,5 +1,6 @@ #! /bin/bash export FLAGS="$FLAGS -DWiz5500" +#export FLAGS="$FLAGS -DW5500_CS_PIN=10" export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short) export FLAGS="$FLAGS -DDMX_DISABLE" export FLAGS="$FLAGS -DMODBUS_DISABLE" diff --git a/lighthub/dmx.cpp b/lighthub/dmx.cpp index 29ef073..0bcc0f9 100644 --- a/lighthub/dmx.cpp +++ b/lighthub/dmx.cpp @@ -28,7 +28,7 @@ e-mail anklimov@gmail.com #endif #endif -#if defined(ESP8266) +#if defined(ESP8266) || defined(ARDUINO_ARCH_ESP32) #ifndef DMX_DISABLE DMXESPSerial dmxout; #endif diff --git a/lighthub/dmx.h b/lighthub/dmx.h index 874eae9..ca239bf 100644 --- a/lighthub/dmx.h +++ b/lighthub/dmx.h @@ -43,6 +43,12 @@ extern DMXESPSerial dmxout; #define DmxWrite dmxout.write #endif +#if defined(ARDUINO_ARCH_ESP32) +#include +extern DMXESPSerial dmxout; +#define DmxWrite dmxout.write +#endif + #if defined(__SAM3X8E__) #include #define DmxWrite dmxout.write diff --git a/lighthub/inputs.cpp b/lighthub/inputs.cpp index de552f6..318395c 100644 --- a/lighthub/inputs.cpp +++ b/lighthub/inputs.cpp @@ -134,8 +134,8 @@ int Input::poll(short cause) { if (!isValid()) return -1; #ifndef CSSHDC_DISABLE - in_ccs811 ccs811(this); - in_hdc1080 hdc1080(this); + in_ccs811 _ccs811(this); + in_hdc1080 _hdc1080(this); #endif switch (cause) { @@ -167,10 +167,10 @@ switch (cause) { { #ifndef CSSHDC_DISABLE case IN_CCS811: - ccs811.Poll(); + _ccs811.Poll(); break; case IN_HDC1080: - hdc1080.Poll(); + _hdc1080.Poll(); break; #endif #ifndef DHT_DISABLE diff --git a/lighthub/main.cpp b/lighthub/main.cpp index dc6b028..7eddd99 100644 --- a/lighthub/main.cpp +++ b/lighthub/main.cpp @@ -691,7 +691,7 @@ wifiManager.setTimeout(30); #ifdef W5500_CS_PIN Ethernet.w5500_cspin = W5500_CS_PIN; debugSerial< HAVE_IP_ADDRESS) { diff --git a/lighthub/main.h b/lighthub/main.h index 541d4a4..d14d9f0 100644 --- a/lighthub/main.h +++ b/lighthub/main.h @@ -1,6 +1,11 @@ #pragma once #include "options.h" + +#if defined(M5STACK) +#include +#endif + #if defined(__SAM3X8E__) #include #include diff --git a/lighthub/modules/in_ccs811_hdc1080.cpp b/lighthub/modules/in_ccs811_hdc1080.cpp index 00965ca..4385c55 100644 --- a/lighthub/modules/in_ccs811_hdc1080.cpp +++ b/lighthub/modules/in_ccs811_hdc1080.cpp @@ -3,10 +3,14 @@ #include "options.h" #include "Streaming.h" -#ifndef CSSHDC_DISABLE +#if defined(M5STACK) +#include +#endif + +#ifndef CSSHDC_DISABLE +static ClosedCube_HDC1080 hdc1080; +static CCS811 ccs811(CCS811_ADDR); -CCS811 ccs811(CCS811_ADDR); -ClosedCube_HDC1080 hdc1080; long ccs811Baseline; static bool HDC1080ready = false; @@ -35,8 +39,16 @@ Wire.begin(); //Inialize I2C Harware printDriverError(returnCode); return 0; } -ccs811.setBaseline(62000); +//ccs811.setBaseline(62000); CCS811ready = true; + +//returnCode = ccs811.setDriveMode(1); +//printDriverError(returnCode); + +delay(2000);Poll(); +delay(2000);Poll(); +delay(2000);Poll(); +delay(2000); return 1; } @@ -81,6 +93,19 @@ if (reg!=0xff) Serial.print("C, RH="); Serial.print(h=hdc1080.readHumidity()); Serial.println("%"); + + + #ifdef M5STACK + M5.Lcd.print(" T="); + //Returns calculated CO2 reading + M5.Lcd.print(t=hdc1080.readTemperature()); + M5.Lcd.print("C, RH="); + //Returns calculated TVOC reading + + M5.Lcd.print(h=hdc1080.readHumidity()); + M5.Lcd.print("%\n"); + #endif + publish(t,"/T"); publish(h,"/H"); if (CCS811ready) ccs811.setEnvironmentalData(h,t); @@ -99,8 +124,10 @@ int in_ccs811::Poll() #ifdef WAK_PIN digitalWrite(WAK_PIN,LOW); #endif + delay(1); //Check to see if data is ready with .dataAvailable() if (ccs811.dataAvailable()) +//if (1) { //If so, have the sensor read and calculate the results. //Get them later @@ -117,6 +144,19 @@ int in_ccs811::Poll() Serial.print("] baseline["); Serial.print(ccs811Baseline = ccs811.getBaseline()); + #ifdef M5STACK + M5.Lcd.print(" CO2["); + //Returns calculated CO2 reading + M5.Lcd.print(co2 = ccs811.getCO2()); + M5.Lcd.print("] tVOC["); + //Returns calculated TVOC reading + + M5.Lcd.print(tvoc = ccs811.getTVOC()); + M5.Lcd.print("]\n"); + #endif + + + publish(co2,"/CO2"); publish(tvoc,"/TVOC"); publish(ccs811Baseline,"/base"); diff --git a/lighthub/modules/in_ccs811_hdc1080.h b/lighthub/modules/in_ccs811_hdc1080.h index c9ab805..0b2787f 100644 --- a/lighthub/modules/in_ccs811_hdc1080.h +++ b/lighthub/modules/in_ccs811_hdc1080.h @@ -21,9 +21,10 @@ #endif #if defined (ARDUINO_ARCH_ESP32) -#ifndef WAK_PIN -#define WAK_PIN 17 -#endif +#undef WAK_PIN +//#ifndef WAK_PIN +//#define WAK_PIN 17 +//#endif #endif #if defined(ARDUINO_ARCH_AVR) diff --git a/lighthub/options.h b/lighthub/options.h index 54a8d94..ab076ce 100644 --- a/lighthub/options.h +++ b/lighthub/options.h @@ -164,7 +164,11 @@ #if defined(ARDUINO_ARCH_ESP32) #undef _dmxin #undef _modbus -#undef _dmxout + +#ifndef DMX_DISABLE +#define _espdmx +#endif +//#undef _dmxout #undef modbusSerial #endif @@ -189,6 +193,10 @@ #define strncpy_P strncpy #endif +//#ifdef M5STACK +//#define debugSerial M5.Lcd +//#endif + #ifndef debugSerial #define debugSerial Serial #endif diff --git a/platformio.ini b/platformio.ini index ae3bdc4..ebdf85f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -17,11 +17,12 @@ env_default = ; due ; esp8266 ; esp32 + m5stack ; megaatmega2560-5500 ; due-5500 ; controllino ; stm32 - nrf52840 +; nrf52840 ;build_dir = /tmp/pioenvs ;libdeps_dir = /tmp/piolibdeps @@ -78,6 +79,53 @@ lib_deps = +[env:m5stack] +platform = espressif32 +board = m5stack-core-esp32 +framework = arduino +upload_speed = 921600 +targets = upload +build_flags = !bash check_custom_build_flags_esp32.sh +lib_ignore = + DmxSimple + DMXSerial + DmxDue + DueFlashStorage + SD + SdFat + Ethernet + Ethernet2 + Ethernet3 + EEPROM + Artnet + UIPEthernet + ESP_EEPROM + httpClient + HttpClient_ID66 + HttpClient + ArduinoHttpClient +lib_deps = + https://github.com/ebenolson/WIFIMANAGER-ESP32.git + https://github.com/zhouhan0126/WebServer-esp32.git + https://github.com/anklimov/aJson + https://github.com/anklimov/CmdArduino + https://github.com/knolleary/pubsubclient.git + Streaming + ;ESP_EEPROM + https://github.com/anklimov/NRFFlashStorage + Adafruit Unified Sensor + DHT sensor library for ESPx + https://github.com/anklimov/Artnet.git + https://github.com/anklimov/ModbusMaster + https://github.com/anklimov/Arduino-Temperature-Control-Library.git + https://github.com/anklimov/DS2482_OneWire + https://github.com/anklimov/ESP-Dmx + FastLED + ClosedCube HDC1080 + ;SparkFun CCS811 Arduino Library + https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library.git + M5Stack + [env:esp32] platform = espressif32 framework = arduino @@ -121,7 +169,8 @@ lib_deps = https://github.com/anklimov/ESP-Dmx FastLED ClosedCube HDC1080 - SparkFun CCS811 Arduino Library + ;SparkFun CCS811 Arduino Library + https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library.git [env:due] platform = atmelsam framework = arduino