What is Vitrobian Crystal?
The Internet of Things needs powerful gateways to perform sophisticated operations. To ensure the security of a network and improve cryptographic operations we need True Random Number Generator and secure storage module on the platform. These features are a domain of Vitrobian Crystal, which you may purchase at our shop. It supports many communication protocols including Ethernet, Wi-Fi, CSMA, GSM and more. As an IoT gateway, it has many interfaces to interact with the environment and monitor the state of systems as CAN bus, MOD bus, PM bus, and SCADA. Another feature of the device is an ability to operate as a stand-alone media server with hardware accelerated H.264 video display 1080p@24FPS on HDMI. For development, you can use Raspberry Pi compatible GPIO header.
Vitrobian Crystal is most frequently used as athe Internet of Things gateway. It can also operate as a stand-alone media center or monitor station. Also its rich set of interfaces allows using this platform as a powerful actuator.
As an example of application Vitrobian Crystal, I will use SenseHAT, rich in sensors Raspberry Pi board. As a sample program, I will use HTS221 temperature sensor and grid of LEDs to display actual temperature.
To run a sample program you will need:
- Vitrobian Crystal board
- power supply
- at least 8GB micro SD card
- Ethernet cable
At first, you have to flash operating system at your device. You can use dedicated Vitrobian – custom OS based on Debian. Plug in SD card to your PC (you may need micro SD card adapter).
The latest, pre-build image of Vitrobian can be downloaded from the following link
After that flash SD card using
dd command. Be careful, because if you select the wrong device you can damage your hard drive. Typically SD card adapters are mounted in Linux OS’s in
X is the number of an adapter. So in my case, I have run the command below:
bash gzip -cdk vitrobian_0.2.0.img.gz | sudo dd of=/dev/mmcblk0 bs=16M status=progress
When you finish insert micro SD card in a card pocket on the board. Next, supply power, mount SenseHAT and connect Ethernet cable. After a while device will boot and you will be able to log in.
After the correct connection, you should see the colors of the rainbow on the LED matrix, like below:
You can log in to the Vitrobian Crystal in two ways:
- by connection using a serial port
- by connection using SSH
The second way is easier, so we’ll try this solution. Firstly we have to check local IP of a device. For this purpose, execute:
bash ping crystal.local
The output should be similar to below:
bash PING crystal.local (192.168.4.178) 56(84) bytes of data. 64 bytes from 192.168.4.178 (192.168.4.178): icmp_seq=1 ttl=64 time=0.184 ms 64 bytes from 192.168.4.178 (192.168.4.178): icmp_seq=2 ttl=64 time=0.243 ms 64 bytes from 192.168.4.178 (192.168.4.178): icmp_seq=3 ttl=64 time=0.204 ms 64 bytes from 192.168.4.178
For instance, if you are using Linux open terminal and execute the following command:
Login: user Password: user
You can access SenseHAT sensors by the I2C bus. Therefore the first thing we need to do is loading the necessary kernel module.
sudo modprobe i2c-dev
Next task is to download python installer and module for accessing I2C bus.
sudo apt-get install -y python pip sudo pip install smbus2
After reaching this point your device is ready to run a sample python program.
To utilize I2C bus we have to import a python module and create an instance of SMBusWrapper class. As a constructor parameter it accept a number of I2C bus.
from smbus2 import SMBusWrapper ... with SMBusWrapper(1) as Bus: ...
To make use of SenseHAT we have to know correct devices’ addresses. By default temperature sensor HTS221 address is
smbus2 module we can read temperature and corresponding calibration registers to obtain an accurate value.
T0_OUT_LSB = bus.read_byte_data(0x5F, 0x3C) T0_OUT_MSB = bus.read_byte_data(0x5F, 0x3D)
When we have measurement data we can display them on the LED matrix, which have default address
0x46. Its registers contain 3 values representing red, green and blue color. By mixing them we can display different colors. Setting one LED is a little bit messy:
pixels = [[0, 1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21, 22, 23]] def setRGB(bus, number, r, g, b): r %= 48 g %= 48 b %= 48 if number == 0: number = 1 index = (number - 1) % 8 row = int((number - 1) / 8) bus.write_byte_data(0x46, pixels[index]+(row*24), r) bus.write_byte_data(0x46, pixels[index]+(row*24), g) bus.write_byte_data(0x46, pixels[index]+(row*24), b)
To run a sample program you have to enter
sample directory and run
sample.py with administrator privileges:
cd sample sudo python sample.py
After running a demo you should see the displayed temperature at the LED matrix.
In conclusion, in this simple example, I have shown that it’s easy to get started with Vitrobian Crystal. Linux-based OS gives you all necessary tools to build your own sophisticated IoT applications without any problems.
In LPN Plant we connect consulting, technical expertise and financial effectiveness to design and implement low power wireless solutions for industry. If you looking for LoRaWAN product developers or just need support in a small piece of your system feel free to set up call with us using calendly. If you enjoying this type of content feel free to sing up to our newsletter and share content on social media.