Ahmet Karagöz
Published © CC BY-ND

Insulin Temperature Control with LoRaWAN IoT Applications

Insulin is a life-critical medication that loses potency if exposed to extreme temperatures (below 2°C or above 8°C).

AdvancedProtip3 hours19
Insulin Temperature Control with LoRaWAN IoT Applications

Things used in this project

Hardware components

RAKwireless RAK4631
×1
RAKwireless RAK12059
×1

Software apps and online services

Arduino IDE
Arduino IDE
The Things Network (TTN)
Datacake
Datacake
Telegram Bot (Optional)

Hand tools and fabrication machines

Flat Ribbon Cable
Small Vial/Bottle
Magnetic Case

Story

Read more

Code

Untitled file

Arduino
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LoRaWan-RAK4630.h>

#define ONE_WIRE_BUS 2 // Pin where the probe is connected

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(115200);
  sensors.begin();
  // LoRa init code here...
}

void loop() {
  // 1. Request Temperature
  sensors.requestTemperatures(); 
  float tempC = sensors.getTempCByIndex(0);
  
  Serial.print("Insulin Temp: ");
  Serial.println(tempC);

  // 2. Error Check (Sensor disconnected usually returns -127)
  if(tempC == -127.00) {
     Serial.println("Error: Check Probe Connection!");
     return;
  }

  // 3. Prepare Payload (Multiply by 100 to send as integer)
  int16_t payloadTemp = (int16_t)(tempC * 100);
  
  uint8_t payload[2];
  payload[0] = payloadTemp >> 8;
  payload[1] = payloadTemp & 0xFF;

  // 4. Send Packet
  send_lora_packet(payload, 2);
  
  // 5. Sleep for 15 minutes
  delay(900000); 
}

Credits

Ahmet Karagöz
1 project • 0 followers
Information Technology Teacher

Comments