Added HX711 support
This commit is contained in:
@@ -9,6 +9,10 @@
|
|||||||
#include "DHT.h"
|
#include "DHT.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MBED_CONF_APP_HX711_ENABLED
|
||||||
|
#include "HX711.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace events;
|
using namespace events;
|
||||||
|
|
||||||
uint8_t rx_buffer[LORAMAC_PHY_MAXPAYLOAD];
|
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);
|
DHT dht(MBED_CONF_APP_DHT_DATA, MBED_CONF_APP_DHT_TYPE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MBED_CONF_APP_HX711_ENABLED
|
||||||
|
HX711 loadcell(MBED_CONF_APP_HX711_CLK, MBED_CONF_APP_HX711_DATA);
|
||||||
|
#endif
|
||||||
|
|
||||||
//DigitalOut led(LED1, 1);
|
//DigitalOut led(LED1, 1);
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|
||||||
lorawan_status_t retcode;
|
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
|
// Initialize LoRaWAN stack
|
||||||
if(lorawan.initialize(&ev_queue) != LORAWAN_STATUS_OK) {
|
if(lorawan.initialize(&ev_queue) != LORAWAN_STATUS_OK) {
|
||||||
printf("\r\n LoRa initialization failed! \r\n");
|
printf("\r\n LoRa initialization failed! \r\n");
|
||||||
@@ -117,6 +132,12 @@ static void send_message() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MBED_CONF_APP_HX711_ENABLED
|
||||||
|
loadcell.powerUp();
|
||||||
|
cayenne.addAnalogInput(2, loadcell.getUnits(5));
|
||||||
|
loadcell.powerDown();
|
||||||
|
#endif
|
||||||
|
|
||||||
// No data to send
|
// No data to send
|
||||||
if(cayenne.getSize() == 0) {
|
if(cayenne.getSize() == 0) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
+11
-2
@@ -27,7 +27,11 @@
|
|||||||
"battery-adc": { "value": "NC" },
|
"battery-adc": { "value": "NC" },
|
||||||
"dht-enabled": { "value": "false" },
|
"dht-enabled": { "value": "false" },
|
||||||
"dht-type": { "value": "DHT::DHT22" },
|
"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": {
|
"target_overrides": {
|
||||||
"*": {
|
"*": {
|
||||||
@@ -276,7 +280,12 @@
|
|||||||
"battery-adc": "PA_2",
|
"battery-adc": "PA_2",
|
||||||
"dht-enabled": true,
|
"dht-enabled": true,
|
||||||
"dht-data": "D8",
|
"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\""]
|
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_lora_config.h\""]
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
https://github.com/atoy40/mbed-hx711/#92640d4fcfc8f2128c3f3f54031cfafed5733bc8
|
||||||
Reference in New Issue
Block a user