Ingo Lohs
Published © GPL3+

Hover Labs Beam - Temperature, Humidity & Time

A first introduction to using Hover Labs Beam.

BeginnerProtip2 hours1,296
Hover Labs Beam - Temperature, Humidity & Time

Things used in this project

Hardware components

Beam
×1
Photon
Particle Photon
×1

Software apps and online services

Blynk
Blynk

Story

Read more

Code

full code from MyWeatherstation-project inclusive beam example

C/C++
#include "application.h"
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h>
// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>
#define BLYNK_DEBUG       // Uncomment this to see debug prints
#define BLYNK_PRINT Serial
// This #include statement was automatically added by the Particle IDE.
#include "beam.h"
/* pin definitions for Beam */
#define RSTPIN 2        //use any digital pin
#define IRQPIN 9        //currently not used - leave unconnected
#define BEAMCOUNT 1     //number of beams daisy chained together

/* Iniitialize an instance of Beam */
Beam b = Beam(RSTPIN, IRQPIN, BEAMCOUNT);

//Put your blynk token here
//DANGER - DO NOT SHARE!!!!
char auth[] = "<< your auth token here >>"; // photon1
//char auth[] = "<< your auth token here >>"; // photon3 - Auth token of bridged device
//DANGER - DO NOT SHARE!!!!

int led = D7;  // The on-board LED


// DHT parameters
    #define DHTPIN 5 // what pin we´re connected to
    #define DHTTYPE DHT22 // DHT 22 (AM2302)
    // Variables
    float temperature;
    int humidity;
    int light;
    // Pins
    int light_sensor_pin = A0;
    // DHT sensor
    DHT dht(DHTPIN, DHTTYPE);
    unsigned long lastmillis = 0;
    
    // Configure bridge on LOCAL_BRIDGE virtual pin
//    WidgetBridge bridge(BRIDGE);
    
    
    void setup() {
        Serial.begin(115200);
        delay(5000); // Allow board to settle
        // Start Blynk
        Blynk.begin(auth);

        Wire.begin();
        Serial.println("Starting Beam to show temp & hum");
        b.begin();

        // Start DHT sensor
        dht.begin();
        // Start LED
        pinMode(led, OUTPUT);
        // Start Webhooks
        Particle.subscribe("hook-response/temp", myHandler, MY_DEVICES);
        Particle.subscribe("hook-response/humidity", myHandler, MY_DEVICES);
        Particle.subscribe("hook-response/light", myHandler, MY_DEVICES);
    }
    
    void myHandler(const char *event, const char *data) {
      // Handle the integration response
    }
    
    void readData()
        {
        digitalWrite(led, HIGH);   // Turn ON the LED
        // Humidity measurement
        temperature = dht.getTempCelcius();
        // Humidity measurement
        humidity = dht.getHumidity();
        // Light level measurement
        float light_measurement = analogRead(light_sensor_pin);
        light = (int)(light_measurement/4096*100);
        
        // Publish data to Webhook -> thingspeak.com
        Particle.publish("temp", String(temperature), PRIVATE);
        Particle.publish("humidity", String(humidity), PRIVATE);
        Particle.publish("light", String(light), PRIVATE);
        
        // Publish data to Blynk
        // virtual pin 1 will be the temperature
        Blynk.virtualWrite(V1, String(temperature)); // photon1 gauge
        
        // virtual pin 2 will be the temperature
//        Blynk.virtualWrite(V2, String(temperature)); // photon3 gauge
        
        // virtual pin 3 will be the humidity
        Blynk.virtualWrite(V3, String(humidity)); // photon1 gauge
        
        // virtual pin 4 will be the humidity
//        Blynk.virtualWrite(V4, String(humidity)); // photon3 gauge
        
        // virtual pin 5 will be the humidity
        Blynk.virtualWrite(V5, String(humidity)); // photon1 history graph
        
        // virtual pin 6 will be the light
        Blynk.virtualWrite(V6, String(light)); // photon1 history graph
        
        // virtual pin 7 will be the light
        Blynk.virtualWrite(V7, String(temperature)); // photon1 history graph
        
        // virtual pin 8 will be the humidity
//        Blynk.virtualWrite(V8, String(humidity)); // photon3 history graph
        
        // virtual pin 9 will be the light
//        Blynk.virtualWrite(V9, String(light)); // photon3 history graph
        
        // virtual pin 10 will be the light
//        Blynk.virtualWrite(V10, String(temperature)); // photon3 history graph

        //  Beam can begin scrolling text with just print() and play()
        b.print(String(temperature).substring(0, 5) + " C");
        //b.play();
        b.display();
        delay(3000);  
        
        //  Beam can begin scrolling text with just print() and play()
        b.print(String(humidity).substring(0, 5) + " %");
        //b.play();
        b.display();
        delay(3000);  
      
        //Time.format(time, TIME_FORMAT_DEFAULT); // Sat Jan 10 08:22:04 2004 , same as Time.timeStr()
        //b.print(Time.format(time, TIME_FORMAT_DEFAULT));
        Time.zone(+2.00);  // setup a time zone, which is part of the ISO6801 format 
        //b.print(Time.format(Time.now(), "%I:%M%p.")); // = 12h = hh:mmPM. check here for a good format list: http://php.net/manual/en/function.strftime.php
        b.print(Time.format(Time.now(), "%H:%M h")); // = 24h = hh:mm
        b.display();
        delay(3000);   
        
        digitalWrite(led, LOW);    // Turn OFF the LED
        //delay(15000);              // Wait for 15 seconds - thingspeak.com refresh time
        }
    
    void loop() {
        
        Blynk.run(); // all the Blynk magic happens here
        
            if ((millis() - lastmillis) > 20000) {
                lastmillis = millis();
                readData();
                
            }
    }

Original Libary from Hoverlabs

Credits

Ingo Lohs

Ingo Lohs

182 projects • 194 followers
I am well over 50 years and come from the middle of Germany.

Comments