Skip to content

General Sensor Actor Block for Arduino

Patrick Werner edited this page Mar 16, 2020 · 2 revisions

preconditions: embedded systems;Java; Javascript

context: OpenRoberta is a learning platform using a graphical programming language (based on blockly) and has code generators/loader for many robots and embedded systems used in education.

problem: Arduino is the first embedded system connected to the lab, that has a great flexibility attaching sensors and actors to the hardware. At the moment we support the sensors/actors from the funduino system. So we support the ultrasonic sensor HC-SR04, for instance. But there are many more. To write new blocks for every new piece of hardware requires changes throughout the software stack. In addition, a lot of the code that is needed to handle a new block on the server and on the web-frontend is quite similar though.

task: A first step would be to add infrastructure to reduce code duplication in the project. For that one needs to analyse at least some sensors/actors available for arduino. Based on that, extract a concept for a new set of blocks, that are configurable to support (almost) all of these devices. This includes:

  • A configuration (in JSON or YAML, e.g.) for declaring which pins are used (D/A), an optional reference to the library with a driver for the device.
  • A generator which takes the configuration and generates 2 different inputs for blockly (this will be javascript): one to allow blockly to generate the configuration block for this sensor/actor, one to allow Blockly to generate a programming block to retrieve data from and send data to the sensor/actor. Sensor/actor usually accept specific data (uint16, e.g.), thus a data conversion facility must be available.
  • A way to include custom library code (e.g. on the Arduino side).

note: the project is more demanding than one expects.

contact: Reinhard Budde <reinhard.budde AT iais.fraunhofer.de> @rbudde, Stefan Sauer <ensonic AT google.com>

Clone this wiki locally