Initial Program for MultiTech Dragonfly to communicate to PTC ThingWorx. Sensors are from Rohm version1
Dependencies: MbedJSONValue mbed mtsas
Fork of UUU_MultiTech_Dragonfly_Sprint by
Revision 3:f6bceb9e5e1a, committed 2015-09-24
- Comitter:
- mfiore
- Date:
- Thu Sep 24 19:35:46 2015 +0000
- Parent:
- 2:955a63247721
- Child:
- 4:730b61258422
- Commit message:
- forgot to read moisture sensor & fix moisture reading & add note about analog reference voltage
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Sep 24 19:19:11 2015 +0000 +++ b/main.cpp Thu Sep 24 19:35:46 2015 +0000 @@ -31,6 +31,8 @@ * - Connect the Grove button to the D8 socket on the Base Shield * - Connect the Grove moisture sensor to the A0 socket on the Base * Shield + * - Make sure the reference voltage selector switch (next to the A0 + * socket) is switched to 5V so you get accurate analog readings * - Stack the MEMs board on top of the Base Shield * - Plug in the power cable * - Plug a micro USB cable into the port below and slightly to the @@ -84,7 +86,7 @@ // misc variables static char wall_of_dash[] = "--------------------------------------------------"; bool radio_ok = false; -static int thp_interval_ms = 2000; +static int thpm_interval_ms = 2000; static int motion_interval_ms = 250; static int print_interval_ms = 5000; int debug_baud = 115200; @@ -114,11 +116,11 @@ button.fall(&button_irq); - Timer thp_timer; + Timer thpm_timer; Timer motion_timer; Timer print_timer; - thp_timer.start(); + thpm_timer.start(); motion_timer.start(); print_timer.start(); @@ -130,11 +132,12 @@ motion_timer.reset(); } - if (thp_timer.read_ms() > thp_interval_ms) { + if (thpm_timer.read_ms() > thpm_interval_ms) { read_temperature(); read_humidity(); read_pressure(); - thp_timer.reset(); + read_moisture(); + thpm_timer.reset(); } if (print_timer.read_ms() > print_interval_ms) { @@ -235,7 +238,7 @@ } void read_moisture() { - moisture_percent = moisture_sensor; + moisture_percent = moisture_sensor * 100.0; } void read_magnetometer() {