From 98ec91b7a353a755396fc3fa13a299baa2ebf56b Mon Sep 17 00:00:00 2001 From: Glyn Hudson Date: Sat, 24 Sep 2016 19:26:30 +0100 Subject: [PATCH] update --- .gitignore | 12 +++--------- lib/readme.txt | 36 ++++++++++++++++++++++++++++++++++++ platformio.ini | 48 ++++++++++++++++++++++++++++++++++++++++++------ src/src.ino | 28 ++++++++++++++-------------- 4 files changed, 95 insertions(+), 29 deletions(-) create mode 100644 lib/readme.txt diff --git a/.gitignore b/.gitignore index 688b630..625b431 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1,19 @@ .pioenvs +.clang_complete +.gcc-flags.json .piolibdeps *~ - # Ignore list for Eagle, a PCB layout tool - # Backup files *.s#? *.b#? *.l#? - - # file locks introduced since 7.x *.lck - - # OS generated files # ###################### .DS_Store ehthumbs.db Icon? Thumbs.db -*/overlays -*~ - +*/overlays \ No newline at end of file diff --git a/lib/readme.txt b/lib/readme.txt new file mode 100644 index 0000000..3f9e008 --- /dev/null +++ b/lib/readme.txt @@ -0,0 +1,36 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organized `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +More information about PlatformIO Library Dependency Finder +- http://docs.platformio.org/en/stable/librarymanager/ldf.html diff --git a/platformio.ini b/platformio.ini index 7fae856..9fe4e81 100644 --- a/platformio.ini +++ b/platformio.ini @@ -18,15 +18,51 @@ # targets = upload [platformio] -src_dir = src +env_default = emonth2 + +[common] +lib_deps_external = + DHT sensor library @1.2.3 + DallasTemperature @3.7.7 + JeeLib @c057b5f4c0 + SI7021 @c5ce0922ef [env:emonth2] platform = atmelavr framework = arduino board = uno -lib_install = 19, 54, 252, 536 +lib_deps = ${common.lib_deps_external} -# [ 19 ] Adafruit-DHT -# [ 54 ] DallasTemperature -# [ 252 ] JeeLib -# [ 536 ] https://github.com/LowPowerLab/SI7021 \ No newline at end of file +[env:isp] +# upload using isp +# $ pio run -t program -e isp +platform = atmelavr +framework = arduino +board = uno +lib_deps = ${common.lib_deps_external} +upload_protocol = stk500v2 +upload_flags = -Pusb + + + +[common] +build_flags = -D BUILD_TAG=2.5.0 + +# http://docs.platformio.org/en/stable/projectconf.html#lib-deps +lib_deps_external = + DallasTemperature @3.7.7 + EmonLib + JeeLib@c057b5f4c0 + +[env:emontx] +platform = atmelavr +framework = arduino +board = uno +build_flags = ${common.build_flags} + +[env:emontx_deploy] +platform = atmelavr +framework = arduino +board = uno +lib_deps = ${common.lib_deps_external} +build_flags = !echo '-DBUILD_TAG='$TRAVIS_TAG diff --git a/src/src.ino b/src/src.ino index 067620b..860ab4a 100644 --- a/src/src.ino +++ b/src/src.ino @@ -46,7 +46,7 @@ ------------------------------------------------------------------------------------------------------------- emonhub.conf node decoder: See: https://github.com/openenergymonitor/emonhub/blob/emon-pi/configuration.md - + [[23]] nodename = emonTH_5 firmware = V2.x_emonTH_DHT22_DS18B20_RFM69CW_Pulse @@ -175,7 +175,7 @@ void setup() { rf12_sleep(RF12_SLEEP); if (debug==1) { - Serial.begin(9600); + Serial.begin(115200); Serial.print(DIP1); Serial.println(DIP2); Serial.println("OpenEnergyMonitor.org"); Serial.print("emonTH - Firmware V"); Serial.println(version*0.1); @@ -275,8 +275,8 @@ void setup() { } } if (debug==1) delay(200); - - + + //################################################################################################################################ // Interrupt pulse counting setup //################################################################################################################################ @@ -291,7 +291,7 @@ void setup() { p = 0; attachInterrupt(pulse_countINT, onPulse, RISING); - + //################################################################################################################################ // Power Save - turn off what we don't need - http://www.nongnu.org/avr-libc/user-manual/group__avr__power.html //################################################################################################################################ @@ -301,7 +301,7 @@ void setup() { // power_timer0_disable(); //don't disable necessary for the DS18B20 library power_timer1_disable(); power_spi_disable(); - + } // end of setup @@ -369,7 +369,7 @@ void loop() power_spi_enable(); - + // Read from SI7021 SPI temp & humidity sensor if (SI7021_status==1){ si7021_env data = SI7021_sensor.getHumidityAndTemperature(); @@ -377,8 +377,8 @@ void loop() emonth.humidity = data.humidityBasisPoints; // might nee dome delay here } - - + + // Send data via RF rf12_sleep(RF12_WAKEUP); dodelay(100); @@ -392,11 +392,11 @@ void loop() //digitalWrite(LED,HIGH); //dodelay(100); //digitalWrite(LED,LOW); - + if (debug==1) { Serial.print("temp:");Serial.print(emonth.temp); Serial.print(","); - + if (((DHT22_status) || (SI7021_status)) && (DS18B20)){ // DS18b230 + other sensor = assume ds18b20 is external Serial.print("temp_ex:");Serial.print(emonth.temp_external); Serial.print(","); } @@ -411,8 +411,8 @@ void loop() } delay(50); } // end serial print debug - - + + unsigned long last = now; now = millis(); WDT_number=0; @@ -441,4 +441,4 @@ void onPulse() } #endif // IMPORTANT LINE! end unit test -//http://docs.platformio.org/en/stable/plus/unit-testing.html \ No newline at end of file +//http://docs.platformio.org/en/stable/plus/unit-testing.html