Last active
September 12, 2019 20:11
-
-
Save tlrobinson/f911f206e777e1af0e76a220f9c77bec to your computer and use it in GitHub Desktop.
Revisions
-
tlrobinson revised this gist
Sep 12, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ // get config.h from Adafruit IO example sketch and fill in your details #include "config.h" #include <Pins_Arduino.h> -
tlrobinson revised this gist
Sep 12, 2019 . No changes.There are no files selected for viewing
-
tlrobinson created this gist
Sep 12, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ #include "config.h" #include <Pins_Arduino.h> #include <SoftwareSerial.h> #include <Regexp.h> AdafruitIO_Feed *cpm_feed = io.feed("Geiger CPM"); AdafruitIO_Feed *cps_feed = io.feed("Geiger CPS"); AdafruitIO_Feed *usv_feed = io.feed("Geiger uSv/hr"); SoftwareSerial geiger(D2, D3); void setup() { Serial.begin(115200); while (! Serial); Serial.print("Connecting to Adafruit IO"); io.connect(); while (io.status() < AIO_CONNECTED) { Serial.print("."); delay(500); } Serial.println(); Serial.println(io.statusText()); geiger.begin(9600); geiger.setTimeout(10); } void loop() { io.run(); String line = geiger.readStringUntil('\n'); char buf[line.length()]; line.toCharArray(buf, line.length()); MatchState ms; ms.Target(buf); char result = ms.Match ("CPS, (%d+), CPM, (%d+), uSv/hr, (%d+.%d+)"); if (result == REGEXP_MATCHED) { Serial.println(line); int cps = atoi(ms.GetCapture(buf, 0)); int cpm = atoi(ms.GetCapture(buf, 1)); float usv = atof(ms.GetCapture(buf, 2)); cps_feed->save(cps); cpm_feed->save(cpm); usv_feed->save(usv); } }