Things used in this project

Hardware components:
Photon new
Particle Photon
×1
LCD Display 1602 - 5V
×1
LCD Display 2004 - 5V
optional
×1
I2C Adapter
×1
11026 02
Jumper wires (generic)
4 pices
×1
Mfr 25fbf52 4k75 sml
Resistor 4.75k ohm
in case you will better sleep to save your LCD - my project works without resistors on top
×2
12002 04
Breadboard (generic)
×1

Schematics

I2C Scanner

Code

The clockC/C++
#include <LiquidCrystal_I2C_Spark.h>

LiquidCrystal_I2C *lcd;

void setup()
{
    Serial.begin(9600);
    
    // The address is typically 0x27. I2C Address: 0x3F
    // https://www.sainsmart.com/new-sainsmart-iic-i2c-twi-1602-serial-lcd-module-display-for-arduino-uno-mega-r3.html
    lcd = new LiquidCrystal_I2C(0x3F /*address*/, 16 /*columns*/, 2/*rows*/);
    lcd->init();
    lcd->backlight();
    lcd->clear();
    Time.zone(+2.00); // setup a time zone, which is part of the ISO6801 format 
}
    

 
void loop()
{
 // sonst friert die Änderung des Wochentages im Display ein und überlappt sich mit dem Neuen
 if (Time.now(), "%H:%M:%S" == "00:00:00") 
 {
    lcd->clear();
 }  
  
  lcd->setCursor(0 /*columns*/,0 /*rows*/);
 // lcd->print(Time.timeStr());
  lcd->print(Time.format(Time.now(), "%d.%m. %A"));
  
  
 // Serial.println(Time.format(Time.now(), "%H:%M:%S"));
  lcd->setCursor(4,1);
  lcd->print(Time.format(Time.now(), "%H:%M:%S"));

}
I2C ScannerC/C++
    // --------------------------------------
    // i2c_scanner
    //
    // Version 1
    //    This program (or code that looks like it)
    //    can be found in many places.
    //    For example on the Arduino.cc forum.
    //    The original author is not know.
    // Version 2, Juni 2012, Using Arduino 1.0.1
    //     Adapted to be as simple as possible by Arduino.cc user Krodal
    // Version 3, Feb 26  2013
    //    V3 by louarnold
    // Version 4, March 3, 2013, Using Arduino 1.0.3
    //    by Arduino.cc user Krodal.
    //    Changes by louarnold removed.
    //    Scanning addresses changed from 0...127 to 1...119,
    //    according to the i2c scanner by Nick Gammon
    //    http://www.gammon.com.au/forum/?id=10896
    // Version 5, March 28, 2013
    //    As version 4, but address scans now to 127.
    //    A sensor seems to use address 120.
    // Version 6, November 27, 2015.
    //    Added waiting for the Leonardo serial communication.
    //
    //
    // This sketch tests the standard 7-bit addresses
    // Devices with higher bit address might not be seen properly.
    //
    // Source: http://playground.arduino.cc/Main/I2cScanner
    // 2 Changes for Particle user
     
    //#include <Wire.h> = Change 1/2
    #include "application.h"
     
     
    void setup()
    {
      Wire.begin();
     
      Serial.begin(9600);
      //while (!Serial);                    // Leonardo: wait for serial monitor = Change 2/2
      while (!Serial) Particle.process();    // <-- to keep Particle cloud connection alive
      Serial.println("\nI2C Scanner");
    }
     
     
    void loop()
    {
      byte error, address;
      int nDevices;
     
      Serial.println("Scanning...");
     
      nDevices = 0;
      for(address = 1; address < 127; address++ )
      {
        // The i2c_scanner uses the return value of
        // the Write.endTransmisstion to see if
        // a device did acknowledge to the address.
        Wire.beginTransmission(address);
        error = Wire.endTransmission();
     
        if (error == 0)
        {
          Serial.print("I2C device found at address 0x");
          if (address<16)
            Serial.print("0");
          Serial.print(address,HEX);
          Serial.println("  !");
     
          nDevices++;
        }
        else if (error==4)
        {
          Serial.print("Unknown error at address 0x");
          if (address<16)
            Serial.print("0");
          Serial.println(address,HEX);
        }    
      }
      if (nDevices == 0)
        Serial.println("No I2C devices found\n");
      else
        Serial.println("done\n");
     
      delay(5000);           // wait 5 seconds for next scan
    }

Credits

Img 6554 3ywwumwxbh
Ingo Lohs
25 projects • 42 followers
I am well over 40 years and come from the middle of Germany. You can contact me also in German. Donation for projects: paypal.me/ingolohs
Contact
Thanks to clyde, Hitchhikers, spydrop, peekay123, ScruffR.

Comments