Joseph BurgessBrian Sullivan
Published © GPL3+

MEGR 3171 Portable Temperature and UV index

This IOT Project provides more accurate temperature and UV index values based on your location vs. what the weather channel could provide.

BeginnerFull instructions provided4 hours114
MEGR 3171 Portable Temperature and UV index

Things used in this project

Hardware components

Argon
Particle Argon
×2
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
Adafruit veml6070
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×2
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×2
Pocket Solder- 60/40 Rosin Core 0.031" diameter
Pocket Solder- 60/40 Rosin Core 0.031" diameter
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
ThingSpeak API
ThingSpeak API

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Temperature

UV

Code

Temperature

C/C++
This records the temperature value and sends it to the second argon. It is subscribed to the second argon, so it can receive the UV value and post it to thingspeak.
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>

// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h>

// This example assumes the sensor to be plugged into CONN2
#define DHTPIN 2     // what pin we're connected to

// Here we define the type of sensor used
#define DHTTYPE DHT11         
int UVint;
DHT dht(DHTPIN, DHTTYPE);

bool humid = false;

TCPClient client;


unsigned long myChannelNumber = 1358252; //Replace with your own channel number
const char * myWriteAPIKey = "1ETUJPTN9B1ZSOYL"; //Replace with your own API key 


void setup() {
    
    ThingSpeak.begin(client);
    
 pinMode(D2, OUTPUT);
 Serial.begin(9600); 
 dht.begin();


}

void loop() {
    // Wait a few seconds between measurements.
    delay(1000);
   
    // Read temperature as Farenheit
    float f = dht.getTempFarenheit();

  String f_string = String(f);
  String UV_string;
  Particle.publish("Temp", f_string , ALL_DEVICES);
  Particle.subscribe("UV",UVdata);
    
    ThingSpeak.setField(2,UVint); // Takes the UV value from argon 2 and it is then posted to thingspeak  
    Serial.print(dht.getTempFarenheit());
    Serial.println("f");
    ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);  
    delay(3000); // ThingSpeak will only accept updates every 15 seconds. 
    
}
 void UVdata(const char *event, String UV_string){

    UVint = String(UV_string).toInt();
}
    

UV Index

C/C++
This utilizes the VEML 6070 sensor to take in the light intensity and divide it by a factor to calculate the UV index. The index is then sent to the first argon, and it is subscribed to the first argon so it is able to post the temperature to thingspeak.
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>

// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_VEML6070.h>

#include <Wire.h>
int fint;
float UV;
Adafruit_VEML6070 uv = Adafruit_VEML6070();

TCPClient client;
unsigned long myChannelNumber = 1358252; //Replace with your own channel number
const char * myWriteAPIKey = "1ETUJPTN9B1ZSOYL"; //Replace with your own API key 

void setup() {
    
     String UV_string = String(UV);
     String f_string;
     Particle.publish("UV_Value",UV_string, ALL_DEVICES);
     Particle.subscribe("Temp",fdata);
     ThingSpeak.begin(client);
     
  Serial.begin(9600);
  Serial.println("VEML6070 Test");
  uv.begin(VEML6070_1_T);  // pass in the integration time constant
}


void loop() {
  Serial.print("UV light level: "); Serial.println(uv.readUV());
  
  delay(1000);
  
    float UV = uv.readUV()/(210);
  
   ThingSpeak.setField(1,fint); //Takes the Temperature value from argon1 and it is then posted to thingspeak 
    Serial.print(uv.readUV());
    Serial.println("uv.readUV");
    ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);  
    delay(3000); // ThingSpeak will only accept updates every 15 seconds. 
    
    
  
}
void fdata(const char *event, String f_string){
    fint = String(f_string).toInt();
}

Credits

Joseph Burgess

Joseph Burgess

1 project • 1 follower
Brian Sullivan

Brian Sullivan

1 project • 1 follower

Comments

Add projectSign up / Login