Moira TuckerJasmine Ramirez
Published

CloudCompanion

Introducing the Cloud Companion, the ultimate weather device that keeps you up-to-date on the weather conditions wherever you are!

IntermediateFull instructions provided8 hours20
CloudCompanion

Things used in this project

Hardware components

Argon
Particle Argon
×2
Jumper wires (generic)
Jumper wires (generic)
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
Adafruit SHT 40
×1
Adafruit LTR 390
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Google Sheets
Google Sheets
ThingSpeak API
ThingSpeak API

Story

Read more

Schematics

Argon 1 Schematic

Argon 2 Schematic

Code

Argon 2 Code

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

int digitalvalue = 0;
int light;
TCPClient client;

unsigned long myChannelNumber = 2114533;
const char * myWriteAPIKey = "2WK76U1AMJHMTE7M";

// I2C address of the LTR 390 sensor
const int LTR390_I2C_ADDR = 0x53;

// Register addresses of LTR 390 sensor
const int LTR390_DATA_LSB_REG = 0x8C;
const int LTR390_DATA_MSB_REG = 0x8D;
const int LTR390_MEAS_RATE_REG = 0x85;
const int LTR390_CMD_REG = 0x80;

void setup() {
  Serial.begin(9600);

  // Initialize I2C communication
  Wire.begin();

  // Configure measurement rate
  Wire.beginTransmission(LTR390_I2C_ADDR);
  Wire.write(LTR390_MEAS_RATE_REG);
  Wire.write(0x03); // Set measurement rate to 100ms
  Wire.endTransmission();
 
  // Start measurement
  Wire.beginTransmission(LTR390_I2C_ADDR);
  Wire.write(LTR390_CMD_REG);
  Wire.write(0x03); // Start continuous measurement
  Wire.endTransmission();
 
  ThingSpeak.begin(client);
 
  Particle.variable("digitalvalue", digitalvalue);
  Particle.variable("light", light);
 
Serial.begin(9600);

  pinMode(D4, INPUT);
}

void loop() {
  // Read data from the LTR 390 sensor
  uint16_t ltrData;
  Wire.beginTransmission(LTR390_I2C_ADDR);
  Wire.write(LTR390_DATA_LSB_REG);
  Wire.endTransmission(false);
  Wire.requestFrom(LTR390_I2C_ADDR, 2);
  if (Wire.available() == 2) {
    uint8_t lsb = Wire.read();
    uint8_t msb = Wire.read();
    ltrData = ((uint16_t)msb << 8) | lsb;
  }
 
  // Convert raw data to light value
  float light = ltrData * 0.56;

  // Print light value to serial monitor
  Serial.print("Light: ");
  Serial.print(light);
  Serial.println(" lux");
 
   delay(1000);
    // Read the digital value of the sensor (LTR390)
    digitalvalue=digitalRead(D4);
 
 
  Particle.publish("light",String (light), MY_DEVICES);
  ThingSpeak.setField(1,light);
  Serial.print(light);
  Serial.println("light");
  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
 
  delay(1000);
}

Argon 1 Code

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

int analogvalue = 0;
int temp;;
int humidity;
TCPClient client;

unsigned long myChannelNumber = 2115601;
const char * myWriteAPIKey = "P65KV1ZLUE14I30S";

void setup(){

  ThingSpeak.begin(client);
 
  Particle.variable("analogvalue", analogvalue);
  Particle.variable("temp", temp);
  Particle.variable("analogvalue", analogvalue);
  Particle.variable("humidity", humidity);
 
Serial.begin(9600);

  pinMode(D4, INPUT);
}

void loop()
{
    delay(1000);
  // Read the analog value of the sensor (TMP36)
  analogvalue = analogRead(A0);
  //Convert the reading into degree
  temp = (analogvalue*-.081+151);
  //temp = 69;
 
 
  Particle.publish("temperature",String (temp), ALL_DEVICES);
  ThingSpeak.setField(1,temp);
  Serial.print(temp);
  Serial.println("temp");
 
  Particle.publish("humidity",String (humidity), ALL_DEVICES);
  ThingSpeak.setField(2,humidity);
  Serial.print(humidity);
  Serial.println("humidity");
  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
  delay(1000);

}

Credits

Moira Tucker

Moira Tucker

0 projects • 0 followers
Jasmine Ramirez

Jasmine Ramirez

0 projects • 0 followers

Comments

Add projectSign up / Login