Daan van der WerfErwin van Ginkel
Published © GPL3+

Understanding night sweating during the menopause

Recording nocturnal perspiration patterns while sleeping

IntermediateShowcase (no instructions)1 hour254
Understanding night sweating during the menopause

Things used in this project

Hardware components

Seeeduino LoRaWAN
Seeeduino LoRaWAN
×1
SparkFun Soil Moisture Sensor (with Screw Terminals)
SparkFun Soil Moisture Sensor (with Screw Terminals)
×1
Temperature Sensor
Temperature Sensor
×2
Carbon Wire
×1
Absorbent paper
×1

Story

Read more

Code

Q-Strip Source Node

Arduino
Getting 3 values from 2 analog TMP36 temp sensors and 1 groove moisture sensor and send them over LoRaWAN to store at TTN
#include <Wire.h>
#include <LoRaWan.h>
#include <math.h>

int tempPin   = A1; //temp sensor
int RtempPin  = A5; //temp room sensor
int sensorPin = A4; //input pin for the bed tempsensor
int sensorvalue;

char buffer[256];


void setup(void)
{
    //SerialUSB.begin(115200);
    //while(!SerialUSB);
    
    lora.init();
    
    memset(buffer, 0, 256);
    lora.getVersion(buffer, 256, 1);
    //SerialUSB.print(buffer); 
    
    memset(buffer, 0, 256);
    lora.getId(buffer, 256, 1);
    //SerialUSB.print(buffer);

  //lora.setId("Device Address", "Device EUI", "Application EUI");
  lora.setId("XXXXXXXXXXXX", "XXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXX");

    //lora.setKey("Network Session Key", "App Session Key", NULL);
    lora.setKey("XXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXX");
    
    lora.setDeciveMode(LWABP);
    lora.setDataRate(DR0, EU868);
    lora.setAdaptiveDataRate(1);
    
    lora.setChannel(0, 868.1);
    lora.setChannel(1, 868.3);
    lora.setChannel(2, 868.5);
    
    lora.setReceiceWindowFirst(0, 868.3);
    lora.setReceiceWindowSecond(869.5, DR3);
    
    lora.setDutyCycle(false);
    lora.setJoinDutyCycle(false);
    
    lora.setPower(20);
    lora.setPort(1);
}

void loop(void)
{   
   bool result = false;

  delay (2000);
  int sensorvalue = analogRead(sensorPin);
  int moisture = sensorvalue * 100; 
  delay (2000);
  
  int reading = analogRead(tempPin); 
  float voltage = reading * 3.3;
  voltage /= 1024.0;
  int temperatureC = ((voltage - 0.5) * 100)* 100 ;
  delay (2000);
  int reading2 = analogRead(RtempPin); 
  float voltage2 = reading2 * 3.3;
  voltage2 /= 1024.0;
  int temperatureR = ((voltage2 - 0.5) * 100)* 100 ;

 
  byte data[6];
    data[0] = temperatureC >> 8;
    data[1] = temperatureC & 0xFF;
    data[2] = moisture >> 8;
    data[3] = moisture & 0xFF; 
    data[4] = temperatureR >> 8;
    data[5] = temperatureR & 0xFF;
   
   result = lora.transferPacket(data, 6);
   
    //TTN DOWNLINK
    if(result)
    {
        short length;
        short rssi;
        
        memset(buffer, 0, 256);
        length = lora.receivePacket(buffer, 256, &rssi);
        
        if(length)
        {
            //SerialUSB.print("Length is: ");
            //SerialUSB.println(length);
            //SerialUSB.print("RSSI is: ");
            //SerialUSB.println(rssi);
            //SerialUSB.print("Data is: ");
            for(unsigned char i = 0; i < length; i ++)
            {
                //SerialUSB.print("0x");
                //SerialUSB.print(buffer[i], HEX);
                //SerialUSB.print(" ");
            }
            //SerialUSB.println();
        }
    }
    delay(60000);
}

Example dataset in CSV

Plain text
Gender: female, age : 40, BMI : 34.1
No preview (download only).

Credits

Daan van der Werf

Daan van der Werf

2 projects • 1 follower
I am a Delphi developer for over 15 years. Since 2016 I am combining IoT into applications with the focus on innovating sensor techniques.
Erwin van Ginkel

Erwin van Ginkel

1 project • 1 follower
Supporting inventor Daan van der Werf to tell the world about the potential of nocturnal perspiration data.

Comments