Skip to content

Commit

Permalink
Make scale-adjust-hx711.ino compile against Espressif/ESP8266
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Mar 31, 2017
1 parent 716798c commit c3a42a5
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -9,6 +9,7 @@ CHANGES

in-progress
===========
- :ref:`scale-adjust-firmware`: Make `scale-adjust-hx711.ino`_ compile against Espressif/ESP8266


2017-03-31 0.14.0
Expand Down
2 changes: 2 additions & 0 deletions doc/source/resources.rst
Expand Up @@ -39,6 +39,8 @@
.. _Terrine: https://github.com/hiveeyes/arduino/tree/master/libraries/Terrine
.. _Terkin: https://github.com/hiveeyes/arduino/tree/master/libraries/Terkin
.. _Hiveeyes-Lib: https://github.com/hiveeyes/arduino/tree/master/libraries/Hiveeyes
.. _scale-adjust-ads1231.ino: https://github.com/hiveeyes/arduino/blob/master/scale-adjust/ADS1231/scale-adjust-ads1231.ino
.. _scale-adjust-hx711.ino: https://github.com/hiveeyes/arduino/blob/master/scale-adjust/HX711/scale-adjust-hx711.ino

.. BERadio
.. _BERadio C++: https://github.com/hiveeyes/arduino/tree/master/libraries/BERadio
Expand Down
26 changes: 26 additions & 0 deletions scale-adjust/HX711/Makefile-ESP8266.mk
@@ -0,0 +1,26 @@
# makeEspArduino: A makefile for ESP8266/Arduino projects.
# https://github.com/plerup/makeEspArduino

# Announce path to your "ESP8266 Arduino Core" installation
# Can also be announced via environment variable: export ESP_ROOT=...
# ESP_ROOT=~/dev/hiveeyes/sdk/esp8266-arduino-core-2.3.0/Arduino-2.3.0

# Attempt to autodetect libraries: Does not work because it would try to compile LowPower libs and more.
#LIBS = $(shell perl -e 'use File::Find;$$d = shift;while (<>) {$$f{"$$1"} = 1 if /^\s*\#include\s+[<"]([^>"]+)/;}find(sub {print $$File::Find::dir," " if $$f{$$_}}, $$d);' $(ESP_ROOT)/libraries $(SKETCH))
#LIBS += $(shell perl -e 'use File::Find;$$d = shift;while (<>) {$$f{"$$1"} = 1 if /^\s*\#include\s+[<"]([^>"]+)/;}find(sub {print $$File::Find::dir," " if $$f{$$_}}, $$d);' ../libraries $(SKETCH))
#LIBS -= ../libraries/LowPower

# Manually enumerate libraries, this is currently the only deterministic way.
LIBS = \
$(ESP_LIBS)/esp8266 \
$(ESP_LIBS)/GDBStub \
$(ESP_LIBS)/SPI \
$(ESP_LIBS)/Wire \
../../libraries/HX711 \
../../libraries/RobTillaart-Arduino/libraries/RunningMedian

# For ESP8266 (makeEspArduino)
BUILD_EXTRA_FLAGS += -DARDUINO_ARCH_ESP8266=true

# Run makeEspArduino
include ../../tools/makeEspArduino/makeEspArduino.mk
8 changes: 7 additions & 1 deletion scale-adjust/HX711/scale-adjust-hx711.ino
Expand Up @@ -83,8 +83,9 @@ float weightKg;
RunningMedian weightSamples = RunningMedian(weightSamplesNumber); // create RunningMedian object

// power saving
#ifndef ARDUINO_ARCH_ESP8266
#include <LowPower.h> // https://github.com/rocketscream/Low-Power

#endif

// Forward declarations
void getWeight();
Expand Down Expand Up @@ -220,10 +221,15 @@ void getWeight() {
do {
// wait between samples
Serial.flush();

#ifndef ARDUINO_ARCH_ESP8266
for (int i=0; i<waitTimeLoadSamples; i++) {
// sleep for one second
LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF); // delay 60 ms
}
#else
delay(60);
#endif

// power HX711 / load cell
loadCell.power_up();
Expand Down
3 changes: 0 additions & 3 deletions scale-adjust/README.rst
Expand Up @@ -17,9 +17,6 @@ commonly used in industrial `load cell`_ components:
- `scale-adjust-ads1231.ino`_ for ADS1231_ from Texas Instruments
- `scale-adjust-hx711.ino`_ for HX711_ from Avia Semiconductor

.. _scale-adjust-ads1231.ino: https://github.com/hiveeyes/arduino/blob/master/scale-adjust/ADS1231/scale-adjust-ads1231.ino
.. _scale-adjust-hx711.ino: https://github.com/hiveeyes/arduino/blob/master/scale-adjust/HX711/scale-adjust-hx711.ino


************
Instructions
Expand Down

0 comments on commit c3a42a5

Please sign in to comment.