Cranfield University we are interested in the ‘Internet of Things’ for environmental sensing. In this blog, we use one off SeedStudio’s Wio Node devices, with a home-made connection to a one wire temperature sensor, and finally an IOS shortcut on an iPhone to read and speak the value using Siri. In part, this blog follows this project.
Hardware
[caption id="attachment_1662" align="alignright" width="300"]
Construction
The Grove standard is a modular, standardized connector prototyping system, permitting Plug-n-Play connectivity with scores of sensor devices for measuring a wide range of phenomena. The advantage of Seeed Studio’s Wio range is that these simply plug into the sockets on the board. However, if one has a sensor without a Grove plug, there is a Protoshield prototyping board available. This can be used to wire up a sensor such as the DS18B20 to allow it to be connected. Unfortunately we didn’t have a Protoshield, however, we did have a pre-wired grove compatible plug that fitted the socket on the Wio Node – so a visit to the trusty soldering iron and heat-shrink cable was required. To make the DS18B20 work, a 4.7k pull-up resistor is required between the VCC and signal lines. The wiring diagram is as follows: [caption id="attachment_1666" align="aligncenter" width="300"]
Software controller
[caption id="attachment_1668" align="alignright" width="138"]

https://us.wio.seeed.io/v1/node/GroveTemp1WireD1/temp?access_token=TOKEN_GOES_HEREThe temperature values are returned as a JSON string, appearing thus:
{"temperature":19.1800000000001}To access the actual value from the JSON, we will need to extract the number from the data pair (see step 3 below). Once we were happy the approach was all working, we copied the URL off for use in the next stage of the project.
Voice control
The project at this point is all working well – the temperature sensor reports to the Wio Node, and an API REST URL can be used to access the value. However, we can go further. We next used an Apple iPhone X, and its newly introduced ‘Shortcuts’ capability. This involves firstly installing the Shortcuts app from the iTunes App Store. Shortcuts allow one to build a relatively sophisticated programme very simply. We therefore set out to develop a ‘Shortcut’ that accessed the new sensor – for this we needed the URL (REST endpoint) from before. The shortcut settings are shown below, namely: (1) URL – enter in the URL from above; (2) Get Contents of URL [use Advanced options – method: GET, Header: temperature; (3) Get Dictionary Value [Key – temperature]; (4) Set Variable [Temperature] (saves value off to a new variable called Temperature); (5) Text [degrees Celsius] (creates a block of text to append); (6) Add to Variable [Temperature] (appends text to variable); (7) Combine Text [Separator – New Lines]; (8) Speak Text [Wait Until Finished]. A further elaboration is to use the ‘If‘ statement to check there was a valid reading (e.g. temperature > -20) ‘Else‘ advise of a problem.



