<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>Your Phone as a Sensor: Making IoT Accessible for Novice Programmers</title></titleStmt>
			<publicationStmt>
				<publisher></publisher>
				<date>10/13/2021</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10322192</idno>
					<idno type="doi">10.1109/FIE49875.2021.9637272</idno>
					<title level='j'>IEEE Frontiers in Education Conference (FIE)</title>
<idno></idno>
<biblScope unit="volume"></biblScope>
<biblScope unit="issue"></biblScope>					

					<author>Devin Jean</author><author>Brian Broll</author><author>Gordon Stein</author><author>Akos Ledeczi</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[Distributed computing, computer networking, and the Internet of Things are all around us, yet only computer science and engineering majors learn the technologies that enable our modern lives. This paper introduces PhoneIoT, a mobile app that makes it possible to teach some of the basic concepts of distributed computation and networked sensing to novices. PhoneIoT turns mobile phones and tablets into IoT devices and makes it possible to create highly engaging projects through NetsBlox, an open-source block-based programming environment focused on teaching distributed computing at the high school level. PhoneIoT lets NetsBlox programs-running in the browser on the student's computer-access available sensors. Since phones have touchscreens, PhoneIoT also allows building a GUI remotely from NetsBlox, which can be set to trigger custom code written by the student via NetsBlox's message system. The approach enables students to create quite advanced distributed projects, such as turning their phone into a game controller or tracking their exercise on top of an interactive Google Maps background with just a few blocks of code.]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head>I. INTRODUCTION</head><p>Most of the applications we use on our computers and mobile devices every day are distributed and use the Internet to provide their functionality. Networked sensors and actuatorsthe Internet of Things (IoT)-are also becoming ubiquitous, with smart homes and health monitoring leading the way. Yet hardly any of the enabling technologies are taught in introductory computer science classes in K-12. There do exist classes and makerspaces where some students are exposed to embedded computers, providing opportunities to program Raspberry Pis or micro:bits with simple sensors and actuators, such as LEDs, using connectivity based on either a USB cable or Bluetooth. While these experiences are fun, they are fairly disconnected from the IoT that otherwise surrounds us. In addition, not many schools offer these types of classes due to cost, logistics, and a lack of teachers.</p><p>84% of teenagers in the United States, however, already own a device <ref type="bibr">[1]</ref> that comes with a rich set of powerful sensors, including accelerometers, gyroscopes, microphones, cameras, GPS, and many more, and is Internet-enabled out of the box. Smartphones offer an excellent opportunity to expose students to networked sensing and make computing Supported by the National Science Foundation (#1835874) and the National Security Agency (H98230-18-D-0010). more engaging by enabling them to be creators and not just users of compelling applications. But how can we make these powerful technologies accessible to novice programmers?</p><p>We introduce a mobile app, PhoneIoT, to programmatically access smartphones and tablets as IoT devices through Nets-Blox <ref type="bibr">[2]</ref>, a block-based programming environment based on Snap! <ref type="bibr">[3]</ref>. NetsBlox introduced two powerful networking and distributed computing abstractions to block-based languages. Remote Procedure Calls (RPCs) make a rich set of online services and data sources accessible to student programs, such as Google Maps, gnuplot, earthquake data from USGS, climate change datasets from NOAA, the Open Movie database, and many more <ref type="bibr">[4]</ref>. Message passing lets NetsBlox projects running anywhere in the world communicate with one another, making it possible to create multi-player games and other distributed programs. RPCs and messages are also used to control WiFi-enabled devices such as educational robot vehicles <ref type="bibr">[5]</ref>. PhoneIoT utilizes these very same abstractions, so any user familiar with NetsBlox will already have the necessary knowledge to create projects using PhoneIoT.</p><p>PhoneIoT provides two main features: the ability to read and/or stream live sensor data, and the ability to create an interactive, configurable user interface on a mobile device. Both of these features are accessible through RPCs and messages, allowing for the creation of fun and engaging projects that integrate sensor data and custom user input and provide feedback on the device's display. By using a simple, yet powerful, block-based interface, we abstract away much of the complexity of networking and distributed computing while allowing students to explore and learn the most important concepts in a convenient framework.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>II. PREVIOUS WORK</head><p>There are several approaches, including Thunkable, App Inventor, and Kodular (formerly known as AppyBuilder), that allow for the creation of standalone mobile apps that can be constructed online with a block-based programming interface <ref type="bibr">[6]</ref>- <ref type="bibr">[8]</ref>. Pocket Code (part of the Catrobat project) is similar to these, although its app designer is built into the app itself and is more focused on creating games or simulations <ref type="bibr">[9]</ref>. Thunkable is perhaps the most similar to PhoneIoT, as it allows access to Internet resources (e.g., speech recognition and translation services), as well as several device sensors, such as the accelerometer and gyroscope. However, PhoneIoT is fundamentally different from these projects in that it does not aim to be an app creation tool; rather, the custom controls in PhoneIoT are merely a means of interacting with NetsBlox code running in the browser on the student's computer. That is, Thunkable and similar projects are not tools for teaching distributed computing or IoT, as all user interaction and sensor data is kept internal to the device running the app. Additionally, because PhoneIoT is tailored to a distributed computing environment, it offers more possibilities for creating engaging educational projects. For instance, PhoneIoT could be used to turn a phone into a custom game controller, with accelerometer input and soft buttons on the phone's screen making sprites move or shoot on the computer's screen. The phone could also be used to control real robots in the same way, using a single NetsBlox program to control multiple computers: one or more mobile devices, one or more robots, and the laptop, creating an engaging distributed application.</p><p>Another project similar to PhoneIoT in terms of intent and network architecture is Sensor Fusion, an education-focused project which collects sensor data from a mobile device and streams it to a computer for analysis <ref type="bibr">[10]</ref>. This is similar to the core sensor-based functionality of PhoneIoT but is more heavily focused on a scientific perspective, namely sensor fusion, or the combination of data from multiple sensors to achieve greater accuracy or precision than would otherwise be possible. In contrast, PhoneIoT is part of a distributed computing environment, empowering students to utilize incoming live data streams, as well as content from other NetsBlox services, and reconfigure the phone's display in real time based on the desired application (e.g., a game controller, data viewer, or fitness tracker). This is not possible with Sensor Fusion, as its display and interactive components are not configurable. PhoneIoT's programmability is a key factor in creating engaging educational projects for young learners.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>III. PHONEIOT</head><p>Mobile devices come with a wide variety of hardware sensors, from simple accelerometers and gyroscopes to more specialized sensors like step counters and relative humidity detectors. Although a typical device does not contain all potential sensors, there are several sensors that are reliably present even on older devices, simply due to basic system requirements. These include an accelerometer (used for landscape-portrait rotation) and, for smartphones, a microphone and proximity sensor (to disable the touchscreen when held to a user's ear). While not essential for core device functionality, virtually all modern smartphones and tablets also have a camera, although access to this sensor through PhoneIoT is handled differently due to privacy concerns (see below). Additionally, through services such as Google's Fused Location Provider API, any mobile device connected to the Internet can retrieve live location data, if not by GPS, then by estimating it from network connectivity. PhoneIoT continuously collects and streams data from all available sensors to the NetsBlox server, in addition to handling other specialized requests, such as GUI configuration and interactions. Figure <ref type="figure">1</ref> visualizes this system architecture. PhoneIoT raises some potential privacy issues due to accessing live sensor data, including microphone, camera, and location information. To address these concerns, PhoneIoT</p><p>&#8226; Exposes only volume levels and not actual audio samples,</p><p>&#8226; Allows camera access only through direct user approval (the user must actively take the image), and &#8226; Secures location (and other) data by requiring a randomly generated password that expires after one day. Additionally, unless the "run in background" setting is explicitly opted into, no communication is permitted unless the app is open and active in the foreground.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>A. Network Exchanges</head><p>When the PhoneIoT app is started, it connects to the Nets-Blox server, announces its presence, provides the server with its unique identifier for further communications, and begins streaming sensor data and accepting network requests via UDP. This protocol was selected because our data exchange model is already packet-based, making UDP a better model than streaming protocols such as TCP. Although UDP has the potential issue of dropping packets, for our purposes, this is actually desirable due to providing real-world lessons on error-handling in fallible network transactions. For instance, an early project for students could be to make robust wrappers for some PhoneIoT functions by repeating the operation until it succeeds. The networking primitives used by the NetsBlox side of PhoneIoT are composed of "messages," the same concept used throughout NetsBlox. In essence, a "message" is a structured block of data that is identified by name and has a set of fields associated with it. Messages can be sent with the "send msg" block and received (typically on a different computer) with a "when I receive" block. As an example, there is a default message type called "message" which has a single field called "msg." Figure <ref type="figure">2</ref> shows a simple example of how to send and receive a message of this type. PhoneIoT provides two primary ways of accessing sensor data: either through explicit requests, or by registering a sensor update event. Explicit requests are done with normal RPC return values, while sensor update events are received by a custom message type. If an explicit request does not receive a response from the phone (e.g, due to a dropped packet), an error is returned to the user, which would have to be checked. Because of this, the streaming method is simpler for users as sensor data are sent asynchronously from the phone, and a dropped packet simply results in a skipped message. Figure <ref type="figure">3</ref> shows example code which registers for and receives sensor updates from the accelerometer every 100ms.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>B. Custom GUI Controls</head><p>An important feature of PhoneIoT is its customizable interactive display. The static GUI for the main screen of the PhoneIoT app is rather barren, showing only a button to access the app main menu and a canvas for rendering custom controls. This canvas is initially empty, but it can be populated with content via various RPCs from the user's program. PhoneIoT supports many standard GUI control types, such as labels, buttons, text fields, image displays, and toggle switches, as well as some controls tailored for designing game controllers, such as virtual joysticks. Each of these controls is fully customizable as to text content, location, size, color, and many other options depending on the specific control. A nonexhaustive example of custom controls is given in Figure <ref type="figure">4 (a)</ref> and<ref type="figure">(b)</ref>.</p><p>Most custom controls have some form of event associated with them, which is sent to the server each time it is raised in the form of a message. For instance, buttons send a message when they are pressed, text fields and image displays send a message when a user updates the content (e.g., via the camera), and joystick controls send a message each time the stick is moved. Additionally, there are other RPC requests which access state information about the controls, such as their text or toggle state. As an example, a student could perform some action every second while a button is held down. This interactive component is important for teaching IoT to younger K-12 audiences because it immediately gives the students a useful tool related to things they already know, such as game controllers or content sharing with text/image displays. Due to how important phones are to today's youth, introducing them to new ways of engaging with and controlling their devices can be especially motivating for continued interest in CS topics. The networking and IoT components are added to this to provide even more functionality and to teach the concepts to an already eager audience as a "side effect."</p><p>IV. EXAMPLE PROJECTS This section will cover several example projects to demonstrate how phone-based IoT through the NetsBlox platform enables powerful applications with very little code or specialized knowledge.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>A. GPS Tracker</head><p>The NetsBlox platform already supports many online services, one of which is Google Maps. With this service, a program can get and display a map of the current location, specified by latitude and longitude, or get the screen position of a latitude and longitude point on the map and vice versa. By reading live GPS data from a mobile device running PhoneIoT, it is possible to track the location of the device on a map and use NetsBlox's built-in drawing utilities (inherited from Snap!) to plot the course. Thus far, this has all been performed on the NetsBlox client (for user logic and drawing) and the NetsBlox server (for performing API requests), with the device running PhoneIoT only being used as a sensor. However, by using PhoneIoT's custom GUI elements, we can add an image display and send periodic updates to the mobile device. Essentially, this creates a stripped-down form of the Google Maps front-end that can be built in under ten blocks. See Figure <ref type="figure">5</ref> for the blocks that set up the display, Figure <ref type="figure">6</ref> for the update logic running on NetsBlox, and Figure <ref type="figure">4</ref> (b) for the custom GUI shown on the mobile app.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>B. Accelerometer Plotter</head><p>A common topic in introductory IoT is analyzing a live data stream coming from a device. We have already seen that receiving a data stream from PhoneIoT is as simple as one RPC call and listening for a NetsBlox message. Once we have this data, the student can perform whatever analysis is needed and output results to their NetsBlox client display. A simple project that could be conducted on a student's first day of working with PhoneIoT is to receive live accelerometer data and plot its x, y, and z components.</p><p>This can be done with the Chart service, a pre-existing Nets-Blox service for generating graphs from data points. Figure <ref type="figure">7</ref> shows the code required to do this, and Figure <ref type="figure">4 (c)</ref> shows the NetsBlox display (running on the student's computer) after the phone was picked up from rest, rotated slowly around one axis, then another, and finally dropped onto a pillow.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>V. CONCLUSION</head><p>In this brief overview, we have shown that PhoneIoT is a low-cost method for allowing K-12 students to access device sensors for learning the concepts of networked sensing. These concepts include API requests in fallible conditions, methods for handling failures, sensor data processing, event based   programming via message passing, and potentially many other topics depending on usage. Additionally, the custom display on the phone allows students to come up with novel ways to interact with their code running on NetsBlox. We believe students will find PhoneIoT an enjoyable educational tool that will allow them to envision and create innovative distributed applications. Along the way, they will learn important cutting edge computing concepts rarely taught in K-12 today. The PhoneIoT app is already available on both Android and iOS. Our future work includes creating curricular units around it, with some of the relevant educational topics having been mentioned in this paper. As a test of learning efficacy and student engagement, we intend to introduce PhoneIoT into our K-12 summer camps and collect data from real users. The current curriculum is project-based and focuses on having students learn the basic concepts and features, then apply them in creative individual or group projects. We will also be covering several other NetsBlox services and advanced CS topics during the camp, giving the students plenty of interesting possibilities for integration with PhoneIoT's sensor data and input controls.</p></div></body>
		</text>
</TEI>
