When using the DS3231 module with for example Arduino-based project there is no easy way to properly set the actual time on that device. There is a way using Linux. Since we'll be using the I2C to hook up the clock module you are going to need either the i2c-tiny-usb interface or for example Raspberry Pi which has the bus with gold pins ready to use.
The solution
Connect the module to the I2C bus, load the appropriate kernel module, initialize the device letting the system know there is a hardware clock attached, synchronize the system clock and finally store that system clock value
Grafana is a great data visualization application. I use it all the time for all kinds of purposes, most notably to chart information from my weather station. Recently there have been some serious changes in Telegraf that will make it play nicely with InfluxDB 0.9+
Since we're at the awesome I have recently bought a Raspberry Pi 2 Model B. It's a great little machine with 4 cores and 1GB of RAM. That got me thinking: how about installing influxDB, Telegraf and Grafana on it?
Unfortunately it is not so simple. There are no official packages of the latest version for Raspbian, not to mention the 0.3.0-beta2 version of Telegraf. So to use it I have had to compile it myself. Compiling Go programs is actually quite easy with GVM and RVM but one needs to learn how to use it first. There are someresources on the Internet to help out with the process but the biggest problem of all is high CPU usage over long period of time during compilation which leads to high CPU temperatures (up to 70°C). There are 3 methods to overcome that problem
Buy radiators (already on the way)
Cool it down with a fan
Find pre-compiled packages
I went with the second option which kept the CPU at a steady 34°C but let me tell you with the Go compiler compilation it took forever (5h+) on the little machine. To not have to do it again I have prepared all 3 packages so that I, and everyone else willing to try it out can grab them and skip the boring part.
Now all that is left is to download those packages and to install them using dpkg -i <package-name>.
There are 2 things to note: one, there will be no telegraf database by default (need to create one yourself using the WUI - web user interface - CREATE DATABASE "telegraf") and there is no defaults file for telegraf which will make it impossible for it to start right out of the box. To fix it create one like so:
sudo touch /etc/default/telegraf
Also grafana-server service isn't enabled by default. This is mentioned at the end of the installation but for convenience here are the enchantments to make it work
Edit on January 11th 2016
As oriste pointed out the grafana package is a lot smaller than the one for Linux x64 found on grafana site. I have looked at it and the reason for it is that my package does not include the phantomjs binary in /usr/share/grafana/vendor/phantomjs/ folder that is used to prepare snapshots for sharing. If you'd like to use it you can always get the binary from https://github.com/piksel/phantomjs-raspberrypi/raw/master/bin/phantomjs
Edit on January 11th 2016
I have verified the packages and added some installation procedures that will help out put a monitoring solution using the three tools.
Edit on October 6th, 2016
There are ready-made packages for the armhf for Telegraf and InfluxDB now. Use those instead!. You might be puzzled as to how to download the deb packages for armhf. What you do is you take the URL of the amd64 package, change the architecture in the URL to armhf and presto - you get a link to the RPi package, for example:
The project I was working on recently was to get the Digispark module to act as a Linux I2C-to-USB driver. It wasn't all so straight forward so I decided to put a little put a little tutorial on how to do it.
That's how the breadboard version of it looks like
Let's get to hacking!
Requirements
You will obviously need a Digispark or a clone of it. I used one I bought from aliexpress.com and it does the trick quite nicely
Let's assume you don't have the micronucleus bootloader installed and let's build one from scratch. You'll need a AVR programmer like USBasp (cheap and does the job very well)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You'll also need an LCD with PCF8547A or PCF8547T extender. I used one with T which required me to apply a patch to the LCDProc sources. More on that soon
The project
First we need the littlewire version of the firmware for our Digispark. You can get it form github
Buinding it and installing onto your Digispark is very straight-forward and described in details here.
Let's get to the hacky part of it!
Patching LittleWire firmware
As it turns out the original driver for i2c-tiny-usb was reluctant to recognize the hardware as proper I2C adapter. I needed to update the vendor and device IDs to make it work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
After building it and installing again on the Digispark and loading the i2c-tiny-usb and i2c-dev modules using modprobe the command i2cdetect -l finally started spitting out some good news :)
After hooking up the LCD to pins 0 (SDA) and 2 (SCL) and adding 2 4.7k pull-up resistors the LCD has been properly recognized as well :)
padcom@aphrodite:~$ sudo i2cdetect 8
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-8.
I will probe address range 0x03-0x77.
Continue? [Y/n]
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Success! Well, actually to get to this point took me over 2 days to figure out all the moving parts but the joy of having it actually working was just great :)
Now it's time to do some serious work with that new piece of hardware we have. Let's use LCDProc to display some system statistics!. Download, extract... and if you're using the PCF8547T version of the extender apply the following patch before building:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
And under the section [hd44780] make sure you have the following values
ConnectionType=i2c
Device=/dev/i2c-8 # that is the I2C bus id you have from i2cdetect -l
Port=0x27 # that is the I2C device id you have from i2cdetect 8
Check out also other options - they are all properly commented so it should be easy to figure out what they mean
Starting it all up
First start the LCDd daemon. You might want to start it initially with the -f (foreground) parameter to check if it works ok.
LCDd -f
Next you need to run the client. Yes! It is a client-server architecture! Use lcdproc --help for the list of all available options. I use the SMP-CPU version the most
lcdproc -f P
That's it! I admit this is more hassle that I generally like but getting it working is worth every late night minute I spent on it :)
I have been fighting the HC-06 module for a bit longer than I am usually comfortable with and decided to put it all together here.
The instructions should be the same on all Linux distributions with the bluez package installed. I have verified it on Ubuntu 15.10 with all the updates and it doesn't work. It does however work on Linux Mint 17.2...
I have received an entry-level STM32F103C8T6 board and was eager to take it for a spin. After some digging it occurred to me that the board isn't quite as easy to get started with as Arduino is (even though it was advertised as such). But let's take it one step at a time.
For the sake of clarity I am using Linux Mint but the instructions should be fine for whatever Debian-based Linux distro out there.
Install Arduino
This step is fairly easy. You go to the Arduino website and download the package. I'm using the one for Linux 64 bits.
After downloading extract it somewhere (I like having a programs folder somewhere but you can use /opt for all I care.
Install Arduino STM32 Hardware support
That step we can actually automate quite nicely (not that we can't do the same with installing the Arduino IDE :))
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Done. Now the problem is that once you start uploading your sketches you'll bump into all sort of compilation and linkage errors. To overcome them execute the following:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Now I know it ain't the nicest way of putting it all together but unfortunately I didn't find a nicer way of installing the needed stdc++ library.
Start using Arduino
My chosen way of working with the board was to use a USB-to-TTL board. To hook it up properly one uses the +3.3V and GND first then the RX and TX to A9 and A10 (if it isn't working right away swap RX and TX).
Start Arduino IDE. From Tools select Board: STM32F103C series, Variant: 20k RAM, 64K Flash, Upload method: serial. That should set you up nicely.
Hardware setup
Now don't you be forgetting the jumper settings!
Test drive
Now we need an app to run. We're not going to be very sophisticated here and do a blink on PC13.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters