From 301ccbb72dd23f35c31be0f1fecef96f059d740e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Fri, 20 Jan 2017 14:12:44 +0100 Subject: [PATCH] submit DDM100TC measurements --- main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/main.c b/main.c index a46aac6..70bc722 100644 --- a/main.c +++ b/main.c @@ -566,7 +566,12 @@ void main(void) "energy,meter=SDM120,phase=%u,type=active,direction=total value=%.3f\n", "energy,meter=SDM120,phase=%u,type=reactive,direction=total value=%.3f\n" }; + uint32_t ddm100tc_value_energy = (uint32_t)((ddm100tc_pulses*(uint64_t)1000)/1600); // the meter has 1600 impulses/kWh (use 64-bit calculation to not overflow after 2684354 Wh) + const char* ddm100tc_string_energy = "energy,meter=DDM100TC value=%lu\n"; + uint32_t ddm100tc_value_power = (uint32_t)(((rcc_ahb_frequency*(double)1.0)/((uint32_t)TIM_PSC(TIM(DDM100TC_TIMER))+1))*(3600*1000/1600)/ddm100tc_interval); // calculate with floating point for precision + const char* ddm100tc_string_power = "power,meter=DDM100TC value=%lu\n"; + // calculate length for text to POST char line[256] = {0}; // measurement line to send size_t data_length = 0; /**< length of the data string to send */ for (pzem_meter = 0; pzem_meter0) { + http_send((uint8_t*)line, 0); // don't care about the result + } + if (snprintf(line, LENGTH(line), ddm100tc_string_power, ddm100tc_value_power)>0) { + http_send((uint8_t*)line, 0); // don't care about the result + } http_end(); // end HTTP request (don't care about the result) gpio_set(GPIO(LED_SUBMIT_PORT), GPIO(LED_SUBMIT_PIN)); // switch off submit LED printf("OK\n");