Using an electron w/tinker to monitor temperature in a second home

There might be an easier way to do this.
I wanted to use the Tinker app because I can pull it up on my phone and its already programmed. I didn’t want to publish the data, since I didn’t how much data that would end up using.

What I did was use an Arduino with a DHT11 sensor PWM Pin6.
The Arduino outputPin 6 PWM (0-255) changing with temp feeds into the Electron Analog input A1(0-4059).
Now this raw Arduino PWM is not readable by the AnalogRead becasue your reading at 5volts or zero.
So I stuck a big cap (100uf) across the PWM and it makes a flat dc signal that moves up and down with temp viewed by an oscilloscope.

Using a Photon in temporary place of the Electron for the purpose of setting things up.
I was able to open the Arduino’s serial monitor and watch the actual temp while scaling the code to make Tinker’s numbers match within one degree.
example: 33F would show up on Tinker 336, just drop the last number.
I would have to change the scaling about every 7 degrees. Not too bad since I only have to watch from 50F down to 32F.

Like I said, there is better ways, so post your thoughts here.

Why not just push the temp data to then you can set up Email or SMS alerts if the temp goes out of your programmed ranges. This way you don’t have to rely on the Tinker app running always to receive the temp data.

I would go with a better i2c temp sensor with temp and humidity, something like the SHT-31. You can get more accurate data this way.

It may be a little more work upfront but in the end, you will end up with a dashboard that can look something like this along with the ability to send yourself email or SMS message alerts for warnings.

A simple single line of Particle Publish code will get the temp data out to Losant which is a small amount of data.

The whole sketch for the VOC sensor and Temp / Humidity sensor sending data to Losant looks like this:

Voc Readings - powered by Losant

  This is a library for the CCS811 air

  This sketch reads the sensor

  Designed specifically to work with the Adafruit CCS811 breakout

  These sensors use I2C to communicate. The device's I2C address is 0x5A

  Adafruit invests time and resources providing this open source code,
  please support Adafruit andopen-source hardware by purchasing products
  from Adafruit!

  Written by Dean Miller for Adafruit Industries.
  BSD license, all text above must be included in any redistribution

#include "Adafruit_CCS811.h"
#include "math.h"
#include "Adafruit_SHT31.h"

Adafruit_CCS811 ccs;

Adafruit_SHT31 sht31 = Adafruit_SHT31();

char publishStateString[256];

void setup() {
  Serial.println("CCS811 test");

    Serial.println("Failed to start sensor! Please check your wiring.");

  Serial.println("SHT31 test");
  if (! sht31.begin(0x44)) {   // Set to 0x45 for alternate i2c addr
    Serial.println("Couldn't find SHT31");


void loop() {
  float t = sht31.readTemperature();
  float h = sht31.readHumidity();
  float tF = (t* 9) /5 + 32;

  //This sends the temperature data to the CCS811
  //ccs.setEnvironmentalData(h, t); //commented out because VOC seemed to follow humidity levels.



      Serial.print("Temp F = "); Serial.println(tF);

      Serial.print("Hum. % = "); Serial.println(h);

      Serial.print("CO2: ");
      Serial.println(" ppm");
      Serial.print("TVOC ");

      snprintf(publishStateString, sizeof(publishStateString), "%u:%u:%f:%f:",
                                                          ccs.getTVOC(), ccs.geteCO2(), tF, h );
          Particle.publish("Voc", publishStateString);



@knightTyme, you can also use the very cool Blynk library and phone App. It is super easy to work with.

I agree with @RWB regarding the quality of the sensor. I find the DHT11 is both unreliable and often just plain bad. :wink:

UPDATE: I missed the “electron part”! As such, Blynk may not be the best choice :pensive:

Regardless of what you choose to use on the receiving end…

I’d cut out the Arduino middle man. Not only does that reduce a failure point, but it also minimizes the inaccuracies. The electron is very much capable of reading that sensor directly, so why not use that?

As far as using Tinker goes, you could still do that, even with custom code. In the data tab, you can querie your custom functions/variables, without having to adhere to the Tinker scheme. That makes it a whole lot cleaner, and you can have it display the actual temperature, without having to drop values :wink:

This was the direction I started to go in at first.
I am not experienced enough with code to make those changes at this point in time. Can you get me started in the right direction with altering the Tinker sketch?
I am have no idea in the tinker code that deals with the cell initiation.

I agree that unsolicited email is the way to go, but my code experience is limiting me at this point in time.

If you followed this tutorial you would be up and running. You can do it :slight_smile:

Not a good idea.
The PWM output will still go to 5V but on the Photon the ADCs are only save for 3.3V any higher you risk damaging the ADC.

There are lots of options to do this better - some mentioned already by others.