Zoran Roncevic
Published © LGPL

Particle Photon & Thermo3 Click

Connect Thermo3 click board to Particle Photon and send temperature data to cloud. Simple I2C tutorial for Particle Photon.

BeginnerProtip30 minutes1,119
Particle Photon & Thermo3 Click

Things used in this project

Story

Read more

Code

Thermo3.ino

Arduino
Copy & paste code into you app in build.particle.io developer enviroment.
// 
// Mikroelektronika Thermo 3 click - DEMO
// Particle Photon
// 


void setup()
{
  Serial.begin(9600); // do not use other bitrate for Particle Photon
  Wire.begin(); 

}

int reading = 0;
float temp;
int state = LOW;

void loop()
{

  Wire.beginTransmission(0x48);  // transmit to device (0x48)
  Wire.write(byte(0x00));       // sends instruction byte  
  Wire.endTransmission();      // stop transmitting

  delay(100);
  
  Wire.requestFrom(0x48,2);
  if(2 <= Wire.available())    // if two bytes were received
  {
    reading = Wire.read();     // receive high byte (overwrites previous reading)
    reading = reading << 8;    // shift high byte to be high 8 bits
    reading |= Wire.read();    // receive low byte as lower 8 bits
    reading = reading >> 4;    // shift right 4 bits
    temp = reading * 0.0625;
    Serial.println(temp);   // print the reading
    Particle.publish("temperature", String(temp)); // send data to dashboard
  }  

  delay(5000);
}

Credits

Zoran Roncevic

Zoran Roncevic

19 projects • 128 followers
Hackster Live ambassador in Serbia. Organizer of Maker NS community.

Comments