0815Creeper
Posts: 1
Joined: Sat Apr 16, 2016 6:03 am

Sense Hat + Java

Sat Apr 16, 2016 6:07 am

Hi there,
is it currently possible to use the sense hat with java? (pi2)
And: are there diffrent sense hats? (I have seen one by adafruit)

Thanks

Simon

User avatar
DougieLawson
Posts: 34762
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Sense Hat + Java

Sat Apr 16, 2016 12:25 pm

All Sense HATs are the same (including the two carried on the International Space Station). The library routines for it are all written in python. If you want to spend some time picking those things apart it should be possible to re-write all the code in Java.

Someone, somewhere must have a technical spec for the Sense HAT and which SPI & I2C sensors are used on it, but I've never found that document.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

DirkS
Posts: 9732
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Sense Hat + Java

Sat Apr 16, 2016 1:07 pm

DougieLawson wrote:Someone, somewhere must have a technical spec for the Sense HAT and which SPI & I2C sensors are used on it, but I've never found that document.
https://www.raspberrypi.org/blog/buy-th ... -in-space/ has info on sensors and links to datasheets.

mattlewis
Posts: 112
Joined: Sat Jan 12, 2013 3:05 pm
Location: UK
Contact: Website

Re: Sense Hat + Java

Mon Apr 18, 2016 11:33 am

Addding support for the SenseHat I2C peripherals is on my todo-list for diozero.
Annoyingly I seem to have broken the LCD display on mine somehow, however all of the I2C devices show up when I do i2cdetect (I think).
Controlling the LCD matrix should be interesting - you could use JNI to create a memory mapped DirectByteBuffer interface over the framebuffer device.

Regards,
Matt
http://www.diozero.com/

mattlewis
Posts: 112
Joined: Sat Jan 12, 2013 3:05 pm
Location: UK
Contact: Website

Re: Sense Hat + Java

Mon Apr 25, 2016 7:02 pm

FYI I've just committed to GitHub Java support for the LPS25H & HTS221 I2C devices into the latest diozero snapshot build (0.7). Next up - Sense HAT IMU support...

Matt
http://www.diozero.com/

Pierantonio
Posts: 3
Joined: Wed May 04, 2016 8:05 am

Re: Sense Hat + Java

Mon May 09, 2016 1:44 pm

Hi,
I was searching for information on SenseHat and Java and I found this post.

FYI, I developed the support for the SenseHat for the Eclipse Kura project (http://www.eclipse.org/kura/).
Since it is written in Java, maybe this can help you.

In the examples folder (https://github.com/eclipse/kura/tree/de ... a/examples) there are the service and example bundles for the SenseHat.

Best,
Pierantonio

mattlewis
Posts: 112
Joined: Sat Jan 12, 2013 3:05 pm
Location: UK
Contact: Website

Re: Sense Hat + Java

Thu May 12, 2016 8:28 pm

Thanks for pointing that out, really useful. I wonder if I could help you guys out at all.
Matt
http://www.diozero.com/

tonystark87
Posts: 1
Joined: Tue Jan 31, 2017 12:00 pm

Re: Sense Hat + Java

Tue Jan 31, 2017 12:23 pm

Hello Pierantonio,
I have read your post about sense Hat and Java. I have to develop an application running on raspberry + sense hat. I want to use your code to interface with sense hat sensors. I am new to kura and eclipse and I just run the hello word from the quick star guide.
How I can use your code? Can I import it as a library?

Pierantonio
Posts: 3
Joined: Wed May 04, 2016 8:05 am

Re: Sense Hat + Java

Fri Jan 26, 2018 11:52 am

Hi tonystark87,

I'm sorry for the very very very late reply. Probably you've already found a solution, however...

Kura comes with two components for the SenseHat: an example and an OSGI service that provides the methods to interact with the SenseHat.
If you want to use the service out of Kura, you should develop a java library based on the SenseHat service.

The code is available here: https://github.com/eclipse/kura/tree/de ... i.sensehat and here for the example: https://github.com/eclipse/kura/tree/de ... at.example

psksvp
Posts: 2
Joined: Sun Sep 11, 2016 9:39 pm

Re: Sense Hat + Java

Tue Dec 18, 2018 10:52 pm

I have written code in Scala to interface with the SenseHAT. It should not be too hard recode it in Java. The LED and joystick can be accessed using the device File System. However, the IMU is best accessed using RTIMULib which required using JNI. IMU can also be accessed using i2c.

https://github.com/psksvp/ScratchPad/bl ... eHAT.scala
https://github.com/psksvp/ScratchPad/tr ... psksvp/RPi

hope this helps

psksvp

Return to “Java”