Scratch Sensor 2.0

Scratch Sensor 2.0 is an Android smartphone app that enables the Scratch user to read the Android smartphone sensors data in ScratchX. ScratchX has Experimental Extensions which allows Scratch to connect to external hardware or web services. This note is intended for users familiar with Scratch.

If you have updated from Scratch Sensor 1.0, note that Scratch Sensor 2.0 does not work with Scratch 1.4.

Scratch Sensor 2.0 does not work with Scratch 3. ScratchX and Scratch 3 extensions are incompatible.

What are the requirements of Scratch Sensor 2.0?

Getting Started

Scratch Sensor

  1. Install Scratch Sensor 2.0 from the Google Play Store onto your Android phone.
  2. Press Start. When the server is running, a notification appears in the notification area of your Android phone. Note the IP address. In our example it is 192.168.1.6
  3. Click start.sbx to load the Getting Started Project in ScratchX. .
  4. Set the addr variable in the project to the IP address you noted in step 2.
  5. Run the ScratchX project.
    • When you tilt your phone, the tilt variable value is the same as shown on your phone.
    • The time the data is accessed from the phone server is also displayed.
    • The status of the phone web server is also available.
  6. You have sucessfully accessed the tilt sensor data from your Android phone. The tilt sensor is a composite sensor derived from the accelerometer sensor.
  7. Stop the ScratchX project.
  8. Click Stop on the Scratch Sensor app to stop the server. The notification will disappear.

Sample ScratchX Projects

ScratchX Extension

Scratch Sensor 2.0

ScratchX URL

https://emantpl.github.io/scratch-sensor-2.0/scratch_sensor.js

Scratch Sensor App

Scratch Sensor App

To turn on/off the server

  1. Click Start to start the server
  2. Notification will appear. Tapping on the notification will bring the app to the foreground.
  3. IP address of the phone will be displayed.
  4. Click Stop to stop the server. The notification will disappear.

Available Sensors

The app will display the following sensors if they are available in your phone.

Important Note

Although the app need not be in the foreground, the screen should be left on. The doze mode to extend battery life introduced in Android versions from Marshmallow onwards may turn off the sensors and server.

Support or Contact

Support is via comments below. You may also email us.

Generate sensor data for Human Activity Recognition (HAR)

Human Activity Recognition (HAR) based on wearable sensor data aims to identify a person’s actions, such as standing, sitting, jumping, and going up stairs, by using data from body-worn sensors. Now you can use the Chrome browser on your Android phone to save the sensor data to Google sheets at sensor-cloud.com.