Skip to content

Commit

Permalink
Added North Optic's J306β as a new GM tube model and exposed interrup…
Browse files Browse the repository at this point in the history
…t trigger mode
  • Loading branch information
Shigeru Kobayashi authored and Shigeru Kobayashi committed May 9, 2011
1 parent 8b49372 commit bc4b0b9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 30 deletions.
57 changes: 31 additions & 26 deletions arduino/GeigerCounterToPachube/GeigerCounterToPachube.pde
Expand Up @@ -56,20 +56,25 @@ void setup() {
Serial.println("Tube model: LND 712");
break;
case SMB_20:
// Reference:
// http://www.libelium.com/wireless_sensor_networks_to_control_radiation_levels_geiger_counters
conversionCoefficient = 0.00277;
Serial.println("Tube model: SMB-20");
break;
case J408GAMMA:
// Reference:
// http://garden.seeedstudio.com/index.php?title=Geiger_Counter
//
// 300CPS = 0.0084µGy/s
// 18,000CPM = 30.24µGy/h
// 1CPM = 0.00168µGy/h
conversionCoefficient = 0.00168;
Serial.println("Tube model: SMB-20");
Serial.println("Tube model: J408gamma");
break;
case J408GAMMA:
// Reference:
// http://www.libelium.com/wireless_sensor_networks_to_control_radiation_levels_geiger_counters
conversionCoefficient = 0.00277;
Serial.println("Tube model: J408Gamma");
case J306BETA:
// NOTE: THIS IS DUMMY
conversionCoefficient = 0.00168;
Serial.println("Tube model: J306beta");
break;
default:
Serial.println("Tube model: UNKNOWN!");
Expand All @@ -96,9 +101,11 @@ void setup() {
// Note:
// Most Arduino boards have two external interrupts:
// numbers 0 (on digital pin 2) and 1 (on digital pin 3)
attachInterrupt(1, onPulse, FALLING);
updateIntervalInMillis = (updateIntervalInMinutes * 60000) - 1;
nextExecuteMillis = millis() + updateIntervalInMillis;
attachInterrupt(1, onPulse, interruptMode);
updateIntervalInMillis = updateIntervalInMinutes * 60000;

unsigned long now = millis();
nextExecuteMillis = now + updateIntervalInMillis;
}

void loop() {
Expand All @@ -111,23 +118,25 @@ void loop() {
Serial.print(c);
}

if ((millis() - lastConnectionTime) > 5000) {
if (client.connected()) {
Serial.println("Disconnecting.");
client.stop();
}
unsigned long now = millis();
if (client.connected() && ((now - lastConnectionTime) > 30000)) {
Serial.println();
Serial.println("Disconnecting.");
client.stop();
}

if (millis() > nextExecuteMillis) {
Serial.println();
Serial.println("Updating...");
if (now < nextExecuteMillis) {
return;
}
nextExecuteMillis = now + updateIntervalInMillis;

float countsPerMinute = (float)count / (float)updateIntervalInMinutes;
count = 0;
Serial.println();
Serial.println("Updating...");

updateDataStream(countsPerMinute);
nextExecuteMillis = millis() + updateIntervalInMillis;
}
float countsPerMinute = (float)count / (float)updateIntervalInMinutes;
count = 0;

updateDataStream(countsPerMinute);
}

// On each falling edge of the Geiger counter's output,
Expand Down Expand Up @@ -202,7 +211,3 @@ void appendFloatValueAsString(String& outString,float value) {
outString += fractionalPortion;
}





16 changes: 12 additions & 4 deletions arduino/GeigerCounterToPachube/PrivateSettings.h
Expand Up @@ -3,22 +3,30 @@
// please replace with your own settings

// The environment ID for your datastreams
const int environmentId = 12345;
const int environmentId = ********;

// Your API key (a public secure key is recommended)
const char *apiKey = "*******************************************";

// REPLACE WITH A PROPER MAC ADDRESS
byte macAddress[] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xAB };
0x**, 0x**, 0x**, 0x**, 0x**, 0x** };

// Update interval in minutes
const int updateIntervalInMinutes = 5;

enum TubeModel {
LND_712, // LND
SMB_20, // GSTube
J408GAMMA // North Optic
J408GAMMA, // North Optic
J306BETA // North Optic
};

const TubeModel tubeModel = LND_712;
// Tube model
const TubeModel tubeModel = ********;

// Interrupt mode:
// * For most geiger counter modules: FALLING
// * Geiger Counter Twig by Seeed Studio: RISING
const int interruptMode = ********;

0 comments on commit bc4b0b9

Please sign in to comment.