Sensor

The sensor thing is a TOO-ready device. This means that you can use it out of the box without writing a single line of code (see the interface below). Simply connect the sensor to the power and the local WIFI network, and it will start generating events with sensed values immediately.

There are many types of physical sensors, but since they all share the same interface, they will look the same in the program – sensor. For example, a temperature sensor and a humidity sensor are similar except for the value they report. In case a program contains different types of sensors, they can be distinguished by alias names. For example, temperature:sensor and humidity:sensor.

The sensors are built from two parts: (1) a generic module that contains the SoC (System On Chip) and optionally additional electronics, and (2) one or more probes. Each probe is identified as a separate sensor thing.

This image shows the generic module of the sensor (70x52x35mm). The red LED indicates power, while the blue LED indicates a WIFI connection (normally blinking). The green terminal-block connects the generic module to the probe. The white mini-USB below the terminal-block connects the generic module to a power source (5V DC). The grill contains a sieve for heat dissipation. The three circular green “ears” (two on the sides and one on top) are for wall mounting.

 

When purchasing the sensor thing at the marketplace, you should specify the type of sensor required, and optionally set a name for it. This will be the instance name. The sensor arrives by courier with the SoC preconfigured to the specified type and the instance name. The sensor stub (the associated TOO code) is downloaded immediately, allowing you to deploy the sensor into your program(s). The following types are currently available:

TypePriceAvailabilityDescription
humidity-DHT22$93immediatecomes bundled with temperature-DHT22
temperature-DHT22$93immediatecomes bundled with humidity-DHT22
temperature-Thermistor$69immediateAir temperature sensor. Range -50 to 150 Celsius. Accuracy 0.1 degrees
temperature-PT100$892 weeksWater (liquid) temperature sensor
temperature-DS18B20$756 weeksWaterproof temperature sensor
co2-MH-Z14$123immediateMH-Z14 NDIR infrared CO2 sensor
ec-Gravity$1496 weeksAnalog electrical conductivity meter
photometer-LDR$69immediateLight Dependent Resistor
photometer-Apogee$3246 weeksApogee Quantum PAR sensor
loadcell-HX711$756 weeksuser should specify weight range
ph-4502C$796 weekspH range 0-14
sonar-JSN-SR04T$796 weeksJSN-SR04T Waterproof Ultrasonic Distance Sensor
liquidLevel-Resistor$856 weeksTank water level indicator

Other types could be manufactured upon request:

smoke detector, motion detector, gas detector, distance, flow meter, volume, time of flight, dissolved oxygen, pollution, alcohol, noise, obstacle, doppler, wind speed, ultrasonic, voltage, current, resistance, transducer pressure, barometric pressure, soil humidity, force tension, UV sensor, dust, water turbidity, heartbeat rate, microwave sensor, non contact liquid level, piezo vibration, position sensor, wind direction, and more. 

 

Generic module properties

  • Supports logging of hundreds of messages while offline
  • Flushes the logged messages gradually when back online
  • Enables updates of new software versions over the air (OTA)
  • Supports a secondary WIFI connection to backup primary connection
  • Actuators buffer future commands to facilitate smooth operation when offline
  • Support “back to factory defaults”, software reset, and a physical reset button
  • Sends periodic heartbeat messages to enable hi-level monitoring
  • Enables upload/download of firmware configuration files
  • Contains power LED and WIFI LED indicators
  • Supports extensive get/set commands
  • Can hose multiple probes

Sensor interface

A sensor generates the following events:

notifies·periodic·update(value:number)

An event is generated periodically with the current probe value. The period is configurable and can be set using the set function.

notifies·low(value:number)

An event is generated when the probe senses a value below the “low” threshold. The event implements hysteresis, meaning that once the event is generated, a flag is set to prevent further notifications. The flag is reset when the probe returns to normal values (crosses another threshold).

notifies·high(value:number)

An event is generated when the probe senses a value above the “high” threshold. The event implements hysteresis, meaning that once the event is generated, a flag is set to prevent further notifications. The flag is reset when the probe returns to normal values (crosses another threshold).

notifies·up

Event is generated when sensor is up and running.

A sensor supports the following functions:

read (value:number)

Returns the current probe value.

set(json:string)

Sets the parameters in the JSON string.

get (value:number)

Returns a JSON string with all the sensor parameters.

as·number (value:number)

Returns the current probe value.

as·location (longitude:number,latitude:number)

Returns the probe geo-location.

.