Added HX711 support

This commit is contained in:
2019-03-08 17:19:50 +01:00
parent 81ff742abe
commit ff26a7aeb8
3 changed files with 33 additions and 2 deletions
+21
View File
@@ -9,6 +9,10 @@
#include "DHT.h"
#endif
#if MBED_CONF_APP_HX711_ENABLED
#include "HX711.h"
#endif
using namespace events;
uint8_t rx_buffer[LORAMAC_PHY_MAXPAYLOAD];
@@ -45,11 +49,22 @@ AnalogIn bat(MBED_CONF_APP_BATTERY_ADC);
DHT dht(MBED_CONF_APP_DHT_DATA, MBED_CONF_APP_DHT_TYPE);
#endif
#if MBED_CONF_APP_HX711_ENABLED
HX711 loadcell(MBED_CONF_APP_HX711_CLK, MBED_CONF_APP_HX711_DATA);
#endif
//DigitalOut led(LED1, 1);
int main(void) {
lorawan_status_t retcode;
#if MBED_CONF_APP_HX711_ENABLED
loadcell.setScale(MBED_CONF_APP_HX711_SCALE);
loadcell.setOffset(MBED_CONF_APP_HX711_OFFSET);
loadcell.powerDown();
#endif
// Initialize LoRaWAN stack
if(lorawan.initialize(&ev_queue) != LORAWAN_STATUS_OK) {
printf("\r\n LoRa initialization failed! \r\n");
@@ -117,6 +132,12 @@ static void send_message() {
}
#endif
#if MBED_CONF_APP_HX711_ENABLED
loadcell.powerUp();
cayenne.addAnalogInput(2, loadcell.getUnits(5));
loadcell.powerDown();
#endif
// No data to send
if(cayenne.getSize() == 0) {
return;
+11 -2
View File
@@ -27,7 +27,11 @@
"battery-adc": { "value": "NC" },
"dht-enabled": { "value": "false" },
"dht-type": { "value": "DHT::DHT22" },
"dht-data": { "value": "NC" }
"dht-data": { "value": "NC" },
"hx711-clk": { "value": "NC" },
"hx711-data": { "value": "NC" },
"hx711-scale": { "value": "1.0f" },
"hx711-offset": { "value": 0 }
},
"target_overrides": {
"*": {
@@ -276,7 +280,12 @@
"battery-adc": "PA_2",
"dht-enabled": true,
"dht-data": "D8",
"dht-type": "DHT::DHT22"
"dht-type": "DHT::DHT22",
"hx711-enabled": true,
"hx711-clk": "D7",
"hx711-data": "D6",
"hx711-scale": "21000.0f",
"hx711-offset": -2000
}
},
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_lora_config.h\""]
+1
View File
@@ -0,0 +1 @@
https://github.com/atoy40/mbed-hx711/#92640d4fcfc8f2128c3f3f54031cfafed5733bc8