Industriële fabricage
Industrieel internet der dingen | Industriële materialen | Onderhoud en reparatie van apparatuur | Industriële programmering |
home  MfgRobots >> Industriële fabricage >  >> Manufacturing Technology >> Productieproces

Directe e-mail & SMS-waarschuwingen bij abnormale hartslag

Onderdelen en benodigdheden

Hartslagsensor-module (bijv. KY-039 of Pulse Sensor) 1
Arduino Mega 2560 1
Bolt IoT WiFi-module 1
Draadjes (jumper wires) 7

Apps en online diensten

  • Bolt IoT Bolt Cloud – IoT-platform
  • DigitalOcean VPS (of eigen Linux-server/VM) – draait Python-monitoringcode
  • Mailgun – e-mail automatisering
  • Twilio SMS API – SMS-versturen

Over dit project

24/7 hartslagmonitoring (zoals fitnessbands) is gangbaar. Maar wat als je ook een SMS of e-mail krijgt bij een abnormale hartslag? Dit project laat zien hoe je dat eenvoudig realiseert.

Stap 1: Hartslagsensor aan Arduino

  • Sensor OUT → Arduino pin 2
  • Sensor VCC → 5V
  • Sensor GND → GND

Stap 2: Arduino-code

Meet pulsen op pin 2, berekent hartslag per minuut (bpm), stuurt waarde via Serial naar Bolt-module.

unsigned long highCounter = 0;
int pulse = 0, val = 0, lastPulse = LOW;
unsigned long oldMillis = 0;

void setup() {
  pinMode(2, INPUT);
  Serial.begin(9600);
}

void loop() {
  pulse = digitalRead(2);
  if (pulse != lastPulse) {
    lastPulse = pulse;
    if (pulse == HIGH) highCounter++;
  }
  if (millis() - oldMillis >= 10000) { // elke 10 sec
    oldMillis = millis();
    val = highCounter * 6; // bpm
    if (highCounter > 1) Serial.println(val);
    highCounter = 0;
  }
}

Stap 3: Bolt WiFi-module aan Arduino

  • Bolt 3V3 → Arduino 3.3V
  • Bolt TX → Arduino RX
  • Bolt RX → Arduino TX

Hierdoor ontvangt Bolt de seriële hartslagdata.

Stap 4: Mailgun instellen (e-mail)

  1. Account aanmaken, telefoon verifiëren
  2. Domains → Add Recipient → Invite New Recipient → je e-mailadres
  3. Nieuwe sandbox aanmaken → credentials kopiëren (API key, sandbox URL, sender/recipient e-mail)

Stap 5: Twilio instellen (SMS)

  1. Registreren op twilio.com → gratis API key
  2. Telefoonnummer verifiëren
  3. Products → Programmable SMS + Phone Numbers inschakelen
  4. Project Info → Account SID & Auth Token noteren
  5. Programmable SMS → Get Started → Get a number → kies nummer → noteren

Stap 6: DigitalOcean VPS voor monitoring-code

(Of eigen Linux-machine/VM)

  1. Droplet aanmaken (Ubuntu), via PuTTY inloggen
  2. sudo apt-get -y update
  3. sudo apt install python3-pip
  4. sudo pip3 install boltiot
  5. Bestand conf.py aanmaken met alle credentials (Twilio SID/Token, nummers, Mailgun key/URL, Bolt API/Device ID)
  6. Bestand heart_rate.py aanmaken (zie code-sectie)
  7. sudo python3 heart_rate.py draaien

Bij afwijkende hartslag (<57 of >100 bpm) worden SMS én e-mail verstuurd.

Code

Arduino-code

(Zie stap 2 – identiek)

conf.py (Python-configuratie)

# Twilio
SID = 'jouw_twilio_sid'
AUTH_TOKEN = 'jouw_twilio_auth_token'
FROM_NUMBER = 'twilio_nummer'
TO_NUMBER = 'jouw_nummer_met_landcode'

# Mailgun
MAILGUN_API_KEY = 'jouw_mailgun_api_key'
SANDBOX_URL = 'jouw_sandbox_url'
SENDER_EMAIL = 'test@jouw_sandbox_url'
RECIPIENT_EMAIL = 'jouw_email'

# Bolt
API_KEY = 'jouw_bolt_api_key'
DEVICE_ID = 'jouw_bolt_device_id'

heart_rate.py (Python-monitoring)

import conf, json, time
from boltiot import Email, Bolt, Sms

minimum_limit = 57
maximum_limit = 100

mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
mailer = Email(conf.MAILGUN_API_KEY, conf.SANDBOX_URL, conf.SENDER_EMAIL, conf.RECIPIENT_EMAIL)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)

while True:
    response = mybolt.serialRead(2)
    data = json.loads(response)
    sensor_value = data['value']
    try:
        if sensor_value > maximum_limit or sensor_value < minimum_limit:
            mailer.send_email("Alert", "The Current Heart Rate is " + str(sensor_value))
            sms.send_sms("Alert! The Current Heart Rate is " + str(sensor_value))
    except Exception as e:
        print(e)
    time.sleep(10)

Schema

Zie schematische tekening: sensor → pin 2, Bolt ↔ Serial (RX/TX gekruist), gemeenschappelijke GND.

Productieproces

  1. Hoe data en storytelling te gebruiken om goedkeuring te krijgen voor uw onderhoudsprojecten
  2. Negen Bewezen Strategieën om Je Baam Te Beveiligen en Carrièregroei Te Versnellen
  3. 5 Manieren Waar Anti-Seize Smeermiddelen Tijd, Geld Besparen en Hoofdpijn Voorkomen in MRO
  4. Snelle Reactie: Hoe We Een Plotse Stop Op Een Komori 28" Offset Pers Oplosden
  5. 4 Sleutelfactoren bij het Kopen van Industriële Snijmessers
  6. De Juiste Automatische Boosterpomp voor Uw Huis Kiezen: Een Praktische Gids
  7. Schroeven en Bouten: Typen, Toepassingen en Optimale Montage
  8. Schroef vs. Bout: Belangrijkste Verschillen, Typen en Toepassingen
  9. Sales e-mails onder de knie krijgen: Aandacht grijpen & leads converteren
  10. Expert Gids: Uw Oplosmiddel Terugwinning Distilleerketel Onderhouden Voor Topprestaties
  11. Optimaliseren Van Graafmachine En Vrachtwagen Pairings Voor Maximale Efficiëntie En Winst In Mijnbouw