Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
yellowknife
Published © TAPR-OHL

Portable personal DIY dosimeter

RadSensor v1.0: Let’s assemble a portable personal dosimeter from ready-made components

IntermediateFull instructions provided5 hours795
Portable personal DIY dosimeter

Things used in this project

Hardware components

Wemos D1 development board
×1
RadSens
×1
OLED-screen 1.3
×1
Passive piezo emitter
×1
Charge board TP4056
×1
Batttery 18650
×1
Box for 18650 battery
×1
Protoboard 7*3 sm
×1
Switch KCD-01
×1
XH-2.54 connector
×1
Resistors 220 kohm
×1
Resistors 100 kohm
×1
Screws / self-tapping screws with a thread diameter of 3 and 2.5 mm
×1
Case made on 3d-prinder
×1

Story

Read more

Custom parts and enclosures

RadSensor case models

Schematics

RadSensor scheme

Code

RadSensor code

Arduino
// Initializing libraries
#include <Wire.h>
#include <CG_RadSens.h>
#include <GyverOLED.h>

#define ADC_pin A0 // Set the value of the ADC pin
#define buz_pin 14 // Set pin values for the buzzer

GyverOLED<SSH1106_128x64> oled; // Initializing 1.3" OLED-screen
CG_RadSens radSens(RS_DEFAULT_I2C_ADDRESS); // Initializing RadSens

uint16_t ADC; // Variable for ADC values
uint32_t timer_cnt; // Timer for dosimeter measurements
uint32_t timer_bat; // Timer for battery charge measurements
uint32_t timer_imp; // Pulse polling timer for a piezo emitter
uint32_t pulsesPrev; // Number of pulses for the previous iteration

//Audio greeting function
void hello() {
  for (int i = 1; i < 5; i++) {
    tone(buz_pin, i * 1000);
    delay(100);
  }
  tone(buz_pin, 0);
  delay(100);
  oled.setScale(2);
  oled.setCursor(10, 3);
  oled.print("Radsensor");
  oled.update();  
  delay(3000);
  oled.clear(); 
}

//A function that creates sound of the piezo emitter when pulses appear
void beep() {     // A function that describes the time and frequency of the piezo emitter beeping
  tone(buz_pin, 3500);
  delay(13);
  tone(buz_pin, 0);
  delay(40);
}

//Warning function when the radiation threshold is exceeded
void warning() {
  for (int i = 0; i < 3; i++) {
    tone(buz_pin, 1500);
    delay(250);
    tone(buz_pin, 0);
    delay(250);
  }
}

void setup() {
  Wire.begin();
  oled.init(); // Initializing OLED
  oled.clear(); 
  oled.update();  
  pinMode(ADC_pin, OUTPUT); // Initializing ADC as data receiver
  hello();  // Greeting sound  
  oled.update();  // Screen update
  pulsesPrev = radSens.getNumberOfPulses(); // Write a value to prevent a series of cracks at the start
}

void loop() {
  // Once every 250 ms, the pulse counter is polled to create clicking sounds, if the number of pulses in 250 ms exceeds 5, a warning will sound
  if (millis() - timer_imp > 250) {  
    timer_imp = millis();
    int pulses = radSens.getNumberOfPulses();
    if (pulses - pulsesPrev > 5 ) {
      pulsesPrev = pulses;
      warning();
    }
    if (pulses > pulsesPrev) {
      for (int i = 0; i < (pulses - pulsesPrev); i++) {
        beep();
      }
      pulsesPrev = pulses;
    }
  }
  // Read from the dosimeter and display
  if (millis() - timer_cnt > 1000) { 
    timer_cnt = millis();
    char buf1[50];
    char buf2[50];
    char buf3[50];
    sprintf(buf1, "%.1f мкр/ч", radSens.getRadIntensyDynamic()); // Read a line with dynamic intensity data
    sprintf(buf2, "Стат: %.1f мкр/ч ", radSens.getRadIntensyStatic()); // Read a line with average intensity data

    oled.setCursor(0, 2);
    oled.setScale(2);
    oled.print(buf1);
    oled.setCursor(0, 6);
    oled.setScale(1);
    oled.print(buf2);
  }
  // Read from the ADC pin, create a charge indication
  if (millis() - timer_bat > 5000) { 
    timer_bat = millis();
    ADC = analogRead(ADC_pin); 
    oled.rect(110, 0, 124, 8, OLED_STROKE); 
    oled.rect(125, 3, 126, 5, OLED_FILL);
    if (ADC >= 350) {
      oled.rect(112, 2, 114, 6, OLED_FILL);
      oled.rect(116, 2, 118, 6, OLED_FILL);
      oled.rect(120, 2, 122, 6, OLED_FILL);
    }
    if (ADC < 350 && ADC >= 335) {
      oled.rect(112, 2, 114, 6, OLED_FILL);
      oled.rect(116, 2, 118, 6, OLED_FILL);
    }
    if (ADC < 335 && ADC >= 320) {
      oled.rect(112, 2, 114, 6, OLED_FILL);
    }
    if (ADC < 320){
      oled.rect(110, 0, 124, 8, OLED_STROKE);
      oled.rect(125, 3, 126, 5, OLED_FILL);
    }
  }
  oled.update(); // Screen update
}

Credits

yellowknife

yellowknife

3 projects • 3 followers

Comments