Wednesday Oct 30, 2013

Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 5)

So, here's the finished product. I have 8 networked Raspberry Pi devices strategically placed around our Oracle Santa Clara Building 21 office. I attached a JFET transistor based EMF sensor on each device to capture any strange fluctuations in the electromagnetic field (which supposedly, paranormal spirits can change as they pass by).

And, I have have a Web app (embedded in this page) which can take the readings and show a graphical display in real-time. As you can see, all the Raspberry Pi devices are blinking away green, indicating they are all operational and all sensors are working correctly. But, I don't see anything... Darn...

Maybe, I have to stare at the Web app for a while. I don't know when the "alleged" ghosts in our Oracle Santa Clara office are supposed to be active, but let me know if you see anything...

Oh, and by the way, Happy Halloween from the Internet of Spooky Things!

See the previous posts for the full series on the steps to this cool demo:
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 1)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 2)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 3)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 4)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 5)

Monday Oct 28, 2013

ARM TechCON 2013 presentation: Java SE 8 Compact Profiles

I'll be giving a technical session presentation at ARM TechCON 2013 this Wed. 10/30 @ 11:30am. So if you are in Santa Clara, Calif. come over to the conference and hear me present on this fun-filled topic!

See:

Java SE 8 Compact Profiles

Here's a quote:

 Java SE 8 has a new Compact Profiles 
 feature that allows for three new
 specification–compliant subsets of 
 Java SE 8 APIs. Compact Profiles will 
 enable the creation of Java SE 8 
 runtimes that support configurations 
 that previously were possible only 
 with the CDC version of J2ME...
It's an important topic in today's mad, mad world of Embedded Development. You never want to develop in Java for small devices with your Compact Profiles. It's just not what you'd want! ;-)

Friday Oct 25, 2013

Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 4)

And now here's the Java code that you'll need to read your ghost sensor on your Raspberry Pi

The general idea is that you are using Java code to access the GPIO pin on your Raspberry Pi where the ghost sensor (JFET trasistor) detects minute changes in the electromagnetic field near the Raspberry Pi and will change the GPIO pin to high (+3 volts) when something is detected, otherwise there is no value (ground).

Here's that Java code:

try {
            
    /*** Init GPIO port(s) for input ***/
    
    // Open file handles to GPIO port unexport and export controls
    FileWriter unexportFile = 
            new FileWriter("/sys/class/gpio/unexport");
    FileWriter exportFile = 
            new FileWriter("/sys/class/gpio/export");
    for (String gpioChannel : GpioChannels) {
        System.out.println(gpioChannel);
             // Reset the port
        File exportFileCheck = new 
	    File("/sys/class/gpio/gpio"+gpioChannel);
        if (exportFileCheck.exists()) {
            unexportFile.write(gpioChannel);
            unexportFile.flush();
        }
    
        // Set the port for use
        exportFile.write(gpioChannel);   
        exportFile.flush();
         // Open file handle to input/output direction control of port
        FileWriter directionFile =
            new FileWriter("/sys/class/gpio/gpio" + gpioChannel + 
                "/direction");
    
        // Set port for input
        directionFile.write(GPIO_IN);
    }
    
    /*** Read data from each GPIO port ***/
    RandomAccessFile[] raf = new RandomAccessFile[GpioChannels.length];
    
    int sleepPeriod = 10;
    final int MAXBUF = 256;
    
    byte[] inBytes = new byte[MAXBUF]; 
    String inLine;
    
    int zeroCounter = 0;
    
    // Get current timestamp with Calendar()
    Calendar cal;
    DateFormat dateFormat = 
            new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
    String dateStr;
    
    // Open RandomAccessFile handle to each GPIO port
    for (int channum=0; channum < raf.length; channum++) {
        raf[channum] = new RandomAccessFile("/sys/class/gpio/gpio"
                + GpioChannels[channum] + "/value", "r");
    }
    
    // Loop forever
    while (true) {
        
        // Get current timestamp for latest event
        cal = Calendar.getInstance();
        dateStr = dateFormat.format(cal.getTime());

        // Use RandomAccessFile handle to read in GPIO port value
        for (int channum=0; channum < raf.length; channum++) {
            
            // Reset file seek pointer to read latest value of GPIO port
            raf[channum].seek(0);
            raf[channum].read(inBytes);
            inLine = new String(inBytes);
            
            // Check if any value was read
            if (inLine != null) {
                
                // Compress 0 values so we don't see too many 
                //   unimportant lines
                if (inLine.startsWith("0")) {
                    if (zeroCounter < 1000) {
                        zeroCounter++;
                    } else {
                        System.out.print(dateStr + ": " + inLine);
                        zeroCounter = 0;
                    }
                } else {
                    // Else, specially mark value non-zero value
                    System.out.print("***" + dateStr + ": " + inLine);
                    zeroCounter = 0;
                }
            }
             // Wait for a while
            java.lang.Thread.sleep(sleepPeriod);

        }
    }
} catch (Exception exception) {
   exception.printStackTrace();
}


And, then we just load up our Java SE Embedded app, place each Raspberry Pi with a ghost sensor attached in strategic locations around our Santa Clara office (which apparently is very haunted by ghosts from the Agnews Insane Asylum 1906 earthquake), and watch our analytics for any ghosts.

Easy peazy.

See the posts for the full series on the steps to this cool demo:
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 1)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 2)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 3)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 4)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 5)

Tuesday Oct 22, 2013

Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 3)

So, let's now connect the parts together to make a Java Embedded ghost sensor using a Raspberry Pi. Grab your JFET transistor, LED light, wires, and breadboard and follow the connections on this diagram.

The JFET transistor plugs into the breadboard with the flat part facing left. Then, plug in a wire to the same breadboard hole row as the top JFET lead (green in the diagram) and keep it unconnected to act as an antenna. Then, connect a wire (red) from the middle lead of the JFET transistor to Pin 1 on your RPi GPIO header. And, connect another wire (blue) from the lower lead of the JFET transistor to Pin 25 on your RPi GPIO header, then connect another (blue) wire from the lower lead of the JFET transistor to the long end of a common cathode LED, and finally connect the short end of the LED with a wire (black) to Pin 6 (ground) of the RPi GPIO header.

That's it. Easy.

Now test it. See:

Ghost Sensor Testing

Here's a video of me testing the Ghost Sensor circuit on my Raspberry Pi. We'll cover the Java SE app needed to record the ghost analytics in the next post.

See the posts for the full series on the steps to this cool demo:
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 1)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 2)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 3)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 4)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 5)

Monday Oct 21, 2013

Freescale One Box Unboxing (then installing Java SE Embedded technology)

So, I get a FedEx delivery the other day... "What cool device could be inside this FedEx Overnight Express Large Box?" I was wondering...


Could it be a new Linux/ARM target device board, faster than a Raspberry Pi and better than a BeagleBone Black???


Why, yes! Yes, it was a Linux/ARM target device board, faster than anything around!


It was a Freescale i.MX6 Sabre Smart Device Board (SDB)! Cool... Quad Core ARM Cortex A9 1GHz with 1GB of RAM. So, cool... I installed the Freescale One Box OpenWRT Linux image onto its SD card and booted it up into Linux.


But, wait! One thing was missing... What was it? What could be missing? Why, it had no Java SE Embedded installed on it yet, of course! So, I went to the JDK 7u45 download link. Clicked on "Accept License Agreement", and clicked on "jdk-7u45-linux-arm-vfp-sflt.tar.gz", installed the bad boy, and all was good. Java SE Embedded 7u45 on a Freescale One Box. Nice...

Wednesday Oct 16, 2013

Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 2)

To start out our ghost hunting here at the Oracle Santa Clara campus office, we first need a ghost sensor. It's pretty easy to build one, since all we need to do is to create a circuit that can detect small fluctuations in the electromagnetic field, just like the fluctuations that ghosts cause when they pass by... Naturally, right?

So, we build a static charge sensor and will use a Java Embedded app to monitor for changes in the sensor value, running analytics using Java technology on a Raspberry Pi. Bob's your uncle, and there you have it: a ghost sensor.

See:

Ghost Detector

So, go out to Radio Shack and buy up these items:

shopping list:

  1 - NTE312 JFET N-channel 
      transistor 
      (this is in place of 
       the MPF-102)
  1 - Set of Jumper Wires
  1 - LED
  1 - 300 ohm resistor
  1 - set of header pins
Then, grab a flashlight, your Raspberry Pi, and come back here for more instructions... Don't be afraid... Yet.

See the posts for the full series on the steps to this cool demo:
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 1)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 2)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 3)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 4)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 5)

Friday Oct 11, 2013

Halloween: Season for Internet of Spooky Things (IoST) and Java Embedded (Part 1)

It's Halloween time! And, you know what that means. Ghost stories... WooooOOOoooo... Not many people know this, but the Oracle office in Santa Clara, Calif. (formerly the Sun Microsystems, Santa Clara campus) where I happen to work, was built on the same site as the Agnews Insane Asylum which was orginally built in 1885.

Unfortunately, in 1906 the original Agnews Asylum suffered a fire during the San Francisco earthquake and became the site of Santa Clara Valley's "greatest loss of life" resulting from the quake. 117 patients and staff were killed and buried in mass graves on the site (same place as where I work now). The main building (seen in the photo) and some others were irreparably damaged. Ever since then, there have been strange reports of workers witnessing apparitions, hearing strange laughter and screaming, sensing cold spots and seeing freezer doors fly open violently and eject their contents (which is pretty darn scary, if you ever saw what's been left and forgotten in our breakroom refrigerators over time by co-workers).

Quite frankly, late some evenings, after a long day at work, I've smelled something strange burning in the air. Usually, it's someone who microwaved their popcorn too long in the breakroom. But, it could be ghosts...

See:

Agnews Insane Asylum

Here's a quote:

 Following this disaster, Agnews was 
 reconstructed in the so-called 
 Mediterranean Revival style, 
 resembling a college campus of 
 two-story buildings; it re-opened 
 circa 1911 as Agnews State Mental 
 Hospital.

That second mental hospital mentioned in the above quote lasted until Sun Microsystems demolished it and built an office complex on top of that, then Oracle acquired Sun Microsystems including the Santa Clara campus and here we are today.

So, what better way to celebrate Halloween than by building an Internet of Spooky Things (IoST) ghost sensor connected to a Raspberry Pi running Java Embedded to track ghosts in our office building. I'm going to show you how you can build this too for your Raspberry Pi then run a Java Embedded app to collect ghost analytics.

We'll see how many ghosts we can detect with our IoST gateway device here at the Oracle Santa Clara campus office by placing my embedded device and sensor in different locations throughout our office building in the next few weeks... WoooOOOooooo... Stay tuned...

See the series of posts for the steps to this cool demo:
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 1)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 2)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 3)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 4)
Halloween: Season for Java Embedded Internet of Spooky Things (IoST) (Part 5)

Saturday Oct 05, 2013

Silicon Valley Code Camp Presentation on Raspberry Pi and Java SE Embedded

I gave a technical session presentation as part of the Silicon Valley Code Camp (SVCC) this morning at Foothill College on "How to Develop on the Raspberry Pi with Java SE Embedded". If you were one of the 50+ developers attending my session, thanks for sitting in! Hopefully, I was able to give some good information on how to use Java SE Embedded to program a Linux/ARM development device, like the Raspberry Pi. If you want a copy of my slides, make sure to click on the SVCC link and look for the purple "Session Materials" link to the PDF of the slides.

See:

SVCC: How to Develop RPi

I saw Arun Gupta and Doris Chen there today, too. Nice to see developers presenting technical sessions to other local developers, especially where Java SE Embedded is concerned. Good luck to Stephen Chin tomorrow on his Raspberry Pi Gaming for Kids hands-on lab! That's sounds like fun too.

Tuesday Oct 01, 2013

Even Quicker Guide to Install Java Embedded on a Raspberry Pi

Here's an even Quicker Guide to install Java Embedded on a Raspberry Pi:
 sudo apt-get update && \
   sudo apt-get install oracle-java7-jdk

That's it! It's fast, simple, and easy to remember... It's easy to remember if you find that everything you do after the "sudo" is easy to remember, that is... :-)

See:

Even Quicker RPi Java Embedded

Here's a quote:

 All future Raspbian images will ship 
 with Oracle Java by default; existing 
 users can install it by typing:

 sudo apt-get update && sudo \
   apt-get install oracle-java7-jdk

 We’d like to thank our friends at 
 Oracle for their hard work in making 
 this possible.
You are most welcome! Raspberry Pi and Oracle Java rule!

About

Hinkmond Wong's blog on making Machine to Machine (M2M) and the Incredible Internet of Things (IoT) smarter with Java Embedded Technologies

Search

Archives
« October 2013 »
SunMonTueWedThuFriSat
  
2
3
4
6
7
8
9
10
12
13
14
15
17
18
19
20
23
24
26
27
29
31
  
       
Today