Simple clock powered by RaspberryPi & I2C driven 4x20 LCD panel
$ sbt assembly
This generates the fat jar in target/scala-2.13/pi-clock-assembly-2.0.0.jar
$ java -jar pi-clock-assembly-2.0.0.jar
You can use environment variables to configure the application:
PI_CLOCK_CHECK_INTEGRITY
: Exit with0
status code (simple check for corruption; default:false
)PI_CLOCK_I2C_BUS_FOR_DISPLAY
: The I2C bus of the display (decimal / hex; default:0
)PI_CLOCK_I2C_DEVICE_FOR_DISPLAY
: The I2C device address of the display (decimal / hex; default0
)PI_CLOCK_LOG_DISPLAY_UPDATES
: Should the device log detailed display updates to stdout (toggle text; default:off
)PI_CLOCK_LOG_TIMING_INFO
: Should the device log details on how long delays and updates take (toggle text; default:off
)PI_CLOCK_DISPLAY_ENABLED
: This can be switched off to test on a non-pi system (toggle text; default:off
)PI_CLOCK_DISPLAY_DIMENSIONS
: The dimensions of the display (20x4
or16x2
)PI_CLOCK_HUMAN_FRIENDLY
: Should the display be human friendly; standard is ISO-8601 timestamps (default:false
)PI_CLOCK_BUTTON_ENABLED
: Should the control button be enabled (default:false
)PI_CLOCK_BUTTON_PIN
: The pin associated with the control button (cycles display mode)PI_CLOCK_BUTTON_NC
: Is the button normally-closed (default:false
)PI_CLOCK_CUSTOM_DISPLAY_FILE_PATH
: Load custom display lines from this file.PI_CLOCK_INTERNET_HEALTH_CHECK
: Should the device perform regular Internet health checks (default:false
)PI_CLOCK_INTERNET_POWER_PIN
: The GPIO pin to which the power relay is connectedPI_CLOCK_INTERNET_POWER_HIGH
: Power is on when the power pin is pulled high (default:false
)PI_CLOCK_INTERNET_CHECK_INTERVAL
: Frequency at which to perform Internet health checks (default:1m
)PI_CLOCK_INTERNET_CHECK_TIMEOUT
: Health check HTTP request timeout (default:5s
)PI_CLOCK_INTERNET_OUTAGE_DURATION
: Outage duration required for an Internet connection reset (default:5m
)PI_CLOCK_INTERNET_RESET_DELAY
: Minimum delay between Internet connection resets (default:15m
)PI_CLOCK_HEALTH_SLACK_WEBHOOK
: Slack webhook for health checks.PI_CLOCK_SENSE_HAT_INSTALLED
: Sense-hat system is installed (default:false
)PI_CLOCK_NOTIFICATION_SLACK_WEBHOOK
: Slack webhook for notifications.
The control logic is ported from the C++ Arduino library LiquidCrystal_I2C
- Add custom Internet/network URLs for health checks
- Add option to disable network checks
| Display |
|=======================|
| GND-------------- |
| VCC------------ | |
| SDA----- | | |
| SCL--- | | | |
. | | | | .
| | | |
| | | |
. | | | | .
| 3.3V | | o o | | 5V |
| SDA | -- o o-- | 5V |
| SCL ---- o o---- GND |
|=======================|
| Raspberry Pi |
- Install the tools
sudo apt install i2c-tools
-
Make sure that the I2C interface is enabled (raspberry pi settings, may require a reboot).
-
List I2C devices
i2cdetect -y 1