Hexabitz-Raspberry pi Interface

Raspberry pi interface with Hexabitz modules which make them useful for new brand projects

This tutorial will walk through how to setup a small demo project involving a Raspberry Pi 4, HF1R0x and H01R0x, H08R6x and H0BR4x. By the end of this article, you will be able to hook up your Hexabitz project to any raspberry pi in minutes and explore the numerous possibilities of projects that were not possible before.

introduction:

Before we can proceed further, make sure we have everything that will be needed today. I have listed all the items that might be required:

  • Type C USB Cable for powering up the Pi 4
  • Raspberry Pi 4
  • Micro SD Card
  • Micro SD Card Adapter
  • A Wi-Fi Router
  • HF1R0 Module
  • Power Supply (5V 3A)
  • Soldering Iron, Flux and Soldering Wire
  • A Laptop

we use HF1R0x module to connect Hexabitz module to Raspberry pi, it interfaces seamlessly to Raspberry Pi (single-board computers) and enables you to connect and control your favorite Hexabitz modules from the Raspberry Pi operating system and build your own Raspberry Pi Hat. This is the world’s first build-your-own-Pi-Hat system!

for more information about this module, you can visit its page.

Hardware Setup:

Take your Hexabitz array and HF1R0 module then solder them together.

after soldering you need to place the array on Raspberry pi as shown below

You have Jumper JP1 and JP2 at position 1 & 2 when your Hexabitz array is soldered at the right-side of HF1R0or at position 2 & 3 when your Hexabitz array is soldered at the left-side of HF1R0 as shown in the picture below:

Software Setup:

  • We need to setup the Raspberry Pi. Follow the instructions in the link below step-by-step. Here is an introduction to the latest Pi 4: https://projects.raspberrypi.org/en/projects/raspberry-pi-setting-up
  • Download Raspbian Buster Lite.For every computer hardware, we need it’s software (Firmware). For Raspberry pi 4, we call this firmware “Raspbian”. Raspbian is the Foundation’s official supported operating system. You can download “Raspbian Buster Lite” for this demo ohttps://www.raspberrypi.org/downloads/raspbian/.https://www.raspberrypi.org/downloads/raspbian/ . The Raspbian Buster Lite image contained in the ZIP archive is over 0.5 GB in size. If you find that the download appears to be corrupt or the file is not unzipping correctly, please try using 7Zip (Windows) or The Unarchiver (Macintosh). Both are free of charge and have been tested to unzip the image correctly.
  • Download Balena Etcher to flash your SD Card You will need to use an image writing tool to install the image you have downloaded on your SD card. Balena Etcher is a graphical SD card writing tool that works on Mac OS, Linux and Windows, and is the easiest option for most users. balenaEtcher also supports writing images directly from the zip file, without any unzipping required. To write your image with balenaEtcher:
  • Download the latest version of balenaEtcher (https://www.balena.io/etcher/) and install it.
  • Connect an SD card reader with the SD card inside.
  • Open balenaEtcher and select from your hard drive the Raspberry Pi.img or.zip file you wish to write to the SD card.
  • Select the SD card you wish to write your image to.
  • Review your selections and click ‘Flash!’ to begin writing data to the SD card.
  • Configure the WiFi and ssh for your Pi 4To configure the WiFi and ssh for your Pi 4, you need to insert the SD card into your laptop. You’ll have to locate the boot directory, on my Mac it’s in /Volumes/boot. Create a file in this directory called wpa_supplicant.conf. The file should contain the following details:network={ssid=”YOUR_NETWORK_NAME”psk=”YOUR_PASSWORD”key_mgmt=WPA-PSK}
  • For SSH, you need to create an empty file called ssh. In Linux, you can create it using “touch ssh”. In Windows, you can create an empty file using notepad and save it under the /Volumes/boot directory
  • Insert the microSD card to Raspberry Pi 4 Now it’s time to physically set up your Raspberry Pi. Flip over Raspberry Pi 4 and locate the microSD card socket underneath. Carefully insert the microSD card. It will only fit in one way around, so if it’s struggling to go in flip the microSD card over. Once it’s inserted all the way in, it’s time to start up your Raspberry Pi.
  • Power upPlug in your Raspberry Pi power supply by inserting a power Type C USB cable into the Raspberry Pi 4 Type C Connector. You will see Red LED and a Green LED blinking. For troubleshooting follow this link: https://elinux.org/R-Pi_Troubleshooting
  • Connecting to PiWe don’t need a Keyboard or a Monitor to access the Pi. We can use ssh to login to Raspberry Pi. You will be needing putty for Windows 10. Follow the link below:https://www.raspberrypi.org/documentation/remote-access/ssh/windows.md Raspberry pi 4 has following default credentials for ssh:username: pipassword: raspberryType (for Linux or Mac):
ssh [email protected]

Setting up the build environmentFollow these commands to prepare the pi 4 for building your hexabitz libraries and future development

sudo apt-get updatesudo apt-get install autoconf cmake build-essential git
  • Setting up the Hexabitz Module After you are done, take your Hexabitz array and unpack HF1R0 module and solder them together. Make sure to connect your hexabitz array at the right spot as explained in Hardware Setup section. In this demo, I have Jumper JP1 and JP2 at position 1 & 2 and my Hexabitz array is soldered between port 2 and port 3 of HF1R0.
  • Downloading and Installing Pi 4 Hexabitz Package If you just want to head jump to test your modules and doesn’t want to build latest hexabitz binaries, then you can install the dpkg package for your pi module. Follow the steps below:
cd ~mkdir hexabitzgit clone https://github.com/HexabitzPlatform/HF1R0x-Firmware.gitcd HF1R0x-Firmware/output/pi4sudo dpkg -i hexabitz-1.5-Linux.deb

After this, you will have a binary “hexabitz-demo”, “libhexabitz.so.1.5” shared library and Hexabitz header files copied to your /usr/bin, /usr/lib/ and /usr/include folder, respectively. You can run the binary using:

./hexabitz-demo

Building the Hexabitz Latest Binaries If you have followed the above steps and want to move further by building the latest binaries and shared libraries, then follow the steps below:

cd Desktop/HF1R0x-Firmware/buildcmake..make

After “make”, you will have a binary “hexabitz-demo” and “libhexabitz.so.1.5” shared library to play around. You can run the binary using: ./hexabitz-demo

Note:

The executable demo file can be run by typing ./Hexabitz-demo in terminal. The name of executable output file depends on what it was called in the git branch, and it will appear after you write (make) for compilation process.

Building your own Code using Hexabitz development libraries:

If you have your own example code (demo.cpp) and want to build using hexabitz, then you must have followed the step “Downloading and Installing Pi 4 Hexabitz Package”. To compile your source code:

g++ --std=c++17 test.cpp -I/usr/include/hexabitz

Coding Your Own Projects Using our C++ Library!

Hexabitz has been developed keeping in mind the needs of the Coder, Hobbyist, Geeks and even those who don’t want to Code and just want to download and run some projects.

The HF1R0 is an open-source project which enables the community to use the projects that are available off-the shelf, make your own projects using the library core or modify the library for your own custom needs and requirements.

NOTE: this code is based on Hexabitz Firmware for more information about messaging between module you can visit the website below:
https://hexabitz.com/docs/code-overview/array-messaging/

this code is for H08R6x:

int main(int argc, char *argv[]){       // set measurement unit to CM     messageParams[0] = 0;     SendMessageToModule(2, CODE_H08R6_SET_UNIT, 1);     // transfer data     uint32_t period = 100;     uint32_t timeout = 5000;     memcpy(&messageParams[0], &period, 4);     memcpy(&messageParams[4], &timeout, 4);     SendMessageToModule(2,CODE_H08R6_STREAM_MEM, 8);      init();		std::cout<<"Press any Key and enter to exit"<<std::endl;	while(1){	  	  	  if(getchar()!=0) break;	  	  delay_s(1);	      }	std::cout<<"exiting ..."<<std::endl;  	return 0;}

the video below shows how to build and shows data in stream mode.

Source: Hexabitz-Raspberry pi Interface

Scroll to Top
Read previous post:
ULTRASOC ANNOUNCES NEXT-GENERATION HARDWARE-BASED CYBERSECURITY PRODUCTS
ULTRASOC ANNOUNCES NEXT-GENERATION HARDWARE-BASED CYBERSECURITY PRODUCTS

UltraSoC today announced next-generation hardware-based cybersecurity products that can be used to detect, block and record cyber-attacks in a broad...

Close