Over a million developers have joined DZone.

Happy (Raspberry) Pi Day 2017!

DZone's Guide to

Happy (Raspberry) Pi Day 2017!

Raspberry Pi Zero W is out and it's Pi Day — 3.14! Let's get to hacking.

· IoT Zone
Free Resource

Address your IoT software testing needs – improve quality, security, safety, and compliance across the development lifecycle.

Once a year, we get 3.14—it's a big deal here outside of Princeton. See, here we were privileged to have Mr. Einstein who was born 3/14. And well, Pi is just a cool number.

The weather this year is a bit rough with a late season Winter storm, but it won't stop my new Raspberry Pi Zero W! In what could only be credited to numerical magic, my brand new Rasberry Pi Zero W has arrived from Canada just before the storm. I highly recommend everyone get one of these cool little devices, it's only $10 US.

Let's run this cool little device in honor of the brilliant mathematician, cool number, and awesome device. I got two accessories which I think are critical. One is a miniHDMI to HDMI adapter, so I can configure things on the first boot. Another is a microUSB hub that I connected so I could add keyboard and mouse as needed. I have a lot of Raspberry Pi compatible power supplies, so getting plugged in is no problem.  

Killer Features for $10!?

  • 802.11 b/g/n wireless LAN (WIFI on board)
  • Bluetooth 4.1
  • Bluetooth Low Energy (BLE) - I will be doing some IoT stuff with this
  • 1GHz, single-core CPU and 512 MB RAM

There is an awesome new tool called Pi Bakery which is free for OSX, Linux, and Windows. It lets you easily configure and burn a MicroSD card for the Pi. This was fast and flawless.

Once I had it first set up, I switched over to SSH, which is my preferred mechanism. Just run an ifconfig to get your IP address.

Once I was logged in, I started to do some cleanup.

Next step was to make sure Java JDK was up to snuff and then I installed MiniFi to send data to my NiFi server.

I downloaded MiFi from Hortonworks and SCP'd it to Linux.

unzip minifi-
rm *.zip
cd minifi-
bin/minifi.sh install
sudo /etc/init.d/minifi start

Example Log

2017-03-14 12:35:55,176 INFO [main] org.apache.nifi.minifi.MiNiFiServer Loading Flow...
2017-03-14 12:36:01,977 INFO [main] o.a.nifi.util.FileBasedVariableRegistry Loaded 84 properties from system properties and environment variables
2017-03-14 12:36:01,979 INFO [main] o.a.nifi.util.FileBasedVariableRegistry Loaded a total of 84 properties.  Including precedence overrides effective accessible registry key size is 84
2017-03-14 12:36:02,954 INFO [main] o.a.n.p.MiNiFiPersistentProvenanceRepository Recovered records
2017-03-14 12:36:03,222 INFO [main] o.a.n.p.MiNiFiPersistentProvenanceRepository Created new Provenance Event Writers for events starting with ID 0
2017-03-14 12:36:03,272 INFO [main] o.a.n.c.repository.FileSystemRepository Initializing FileSystemRepository with 'Always Sync' set to false
2017-03-14 12:36:05,109 INFO [main] org.wali.MinimalLockingWriteAheadLog org.wali.MinimalLockingWriteAheadLog@127b497 finished recovering records. Performing Checkpoint to ensure proper state of Partitions before updates
2017-03-14 12:36:05,111 INFO [main] org.wali.MinimalLockingWriteAheadLog Successfully recovered 0 records in 29 milliseconds
2017-03-14 12:36:05,699 INFO [main] org.wali.MinimalLockingWriteAheadLog org.wali.MinimalLockingWriteAheadLog@127b497 checkpointed with 0 Records and 0 Swap Files in 586 milliseconds (Stop-the-world time = 47 milliseconds, Clear Edit Logs time = 59 millis), max Transaction ID -1
2017-03-14 12:36:06,063 INFO [main] o.apache.nifi.controller.FlowController Not enabling RAW Socket Site-to-Site functionality because nifi.remote.input.socket.port is not set
2017-03-14 12:36:06,064 INFO [main] o.apache.nifi.controller.FlowController Not enabling HTTP(S) Site-to-Site functionality because the 'nifi.remote.input.http.enabled' property is not true
2017-03-14 12:36:08,318 INFO [main] o.apache.nifi.controller.FlowController Successfully synchronized controller with proposed flow
2017-03-14 12:36:10,054 INFO [main] org.wali.MinimalLockingWriteAheadLog org.wali.MinimalLockingWriteAheadLog@1cb70be finished recovering records. Performing Checkpoint to ensure proper state of Partitions before updates
2017-03-14 12:36:10,055 INFO [main] org.wali.MinimalLockingWriteAheadLog Successfully recovered 0 records in 724 milliseconds
2017-03-14 12:36:11,975 INFO [main] org.wali.MinimalLockingWriteAheadLog org.wali.MinimalLockingWriteAheadLog@1cb70be checkpointed with 0 Records and 0 Swap Files in 1918 milliseconds (Stop-the-world time = 1071 milliseconds, Clear Edit Logs time = 735 millis), max Transaction ID -1
2017-03-14 12:36:11,977 INFO [main] o.a.n.c.r.WriteAheadFlowFileRepository Successfully restored 0 FlowFiles
2017-03-14 12:36:12,530 INFO [main] o.apache.nifi.controller.FlowController Starting 0 processors/ports/funnels
2017-03-14 12:36:12,532 INFO [main] o.apache.nifi.controller.FlowController Started 0 Remote Group Ports transmitting
2017-03-14 12:36:12,580 INFO [main] org.apache.nifi.minifi.MiNiFiServer Flow loaded successfully.
2017-03-14 12:36:12,590 INFO [main] org.apache.nifi.BootstrapListener Successfully initiated communication with Bootstrap
2017-03-14 12:36:12,592 INFO [main] org.apache.nifi.minifi.MiNiFi Controller initialization took 17416427687 nanoseconds.

I also wanted MQTT (GitHub) because when I IoT, I like me some MQTT. So, I install a few Python libraries because Python is already installed on RPIWZ and is a great language for tiny devices. For some more details on this, see this article I wrote.

 pip install paho-mqtt 

 pip install flask 

Quick Example Code on RPIWZ

import paho.mqtt.client as paho
import os
import time
import datetime
import subprocess
import sys
import os
import datetime
import traceback
import math
import random, string

def tail():
  stdin,stdout = os.popen2("tail -5000 minifi-app.log")
  lines = stdout.readlines(); stdout.close()
  return lines[:]

datastr = tail()
datastr = "{ \"log\": \"" + '\n'.join(datastr) + "\"}";
client = paho.Client()
client.connect("mqttserver", 14162, 60)
client.publish("RPIWZ", payload=datastr, qos=1, retain=False)

I have been thinking for a followup I will try to run MXNet, PyTorch, or TensorFlow on this little guy. There's a good GitHub for tensorflow cross-compile.

Image title

Yes, even in a fancy wood and laser cut plexiglass case, it's barely bigger than 2 US quarters.   This little Raspberry Pi is the latest edition to my collection of Raspberry Pis, Microbits, and other assorted small computing factory devices.

I was going to run an infinite calculation of Pi on it, but I am already running a pointlessly long-running TensorFlow training (18,530 of 1,000,000) complete.

INFO:tensorflow:global step 18528: loss = 0.0726 (18.16 sec/step)
INFO:tensorflow:global step 18529: loss = 0.0580 (16.01 sec/step)
INFO:tensorflow:global step 18530: loss = 0.1164 (16.44 sec/step)

Image title


Accelerate the delivery of high-quality software in the connected IoT era through an integrated analysis, testing, security, and analytics platform. Parasoft's comprehensive portfolio of testing toolsautomates time-consuming testing tasks and provides management with intelligent analytics and reporting so they can focus on what matters.

raspberry pi zero w ,raspberry pi ,iot ,minifi ,nifi

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}