A group of 40 UK-based tech firms has developed a way to help apps and machines communicate in a bid to spur on smart cities and smart homes.
Claire Keane

❣ Chile in a Photography ❣
"I'm Dorothy Gale from Kansas"
RMH
occasionally subtle
ojovivo

#extradirty

izzy's playlists!
Sade Olutola
Misplaced Lens Cap
trying on a metaphor
NASA
h

JBB: An Artblog!

Andulka
hello vonnie
Show & Tell



seen from Malaysia
seen from France
seen from United States

seen from United States

seen from United States
seen from Denmark

seen from Indonesia

seen from Vietnam

seen from Israel

seen from United States
seen from TĂĽrkiye

seen from Israel
seen from Portugal

seen from France

seen from Japan
seen from United States

seen from United States
seen from China

seen from T1
seen from United States
@tp-embedded
A group of 40 UK-based tech firms has developed a way to help apps and machines communicate in a bid to spur on smart cities and smart homes.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
The likes of Union Pacific, GE Power & Water, and ConocoPhillips are turning IoT hype into reality, but they want to do more. Here's what's still getting in the way.
Sleep Monitor: Data Logger
This is the fourth part in a series of posts describing how to build a DIY sleep monitor. In the third part I explored the relative merits of using cloud storage versus using local storage for the sleep data and decide that the best approach would be to store the data on a SD card.
With that decided, it's time to add a suitable data logger to the Arduino/sensor combination we built in a previous post.
An SD card interface is a common peripheral for the Arduino. There are dozen of shields and breakout boards and a standard library. Many of these shields are designed for data logging and include some form of real time clock (RTC) device. The DS1307 is probably the most popular and well supported RTC chip including a popular and well supported library, which makes life easier. So, since we need a RTC for the sleep monitor, it makes sense to look for a shield with an SD card interface and a DS1307 RTC.
I have a Snootlab Mémoire shield which combines an SD card interface with a DS1307 RTC, so that's the shield we'll be using. More information on the Mémoire shield can be found on my hardware page.
We'll start by doing a quick test to make sure that the SD card interface is working. To do this, we'll use the CardInfo example that comes with the Arduino IDE: File → Examples → SD → CardInfo.
The Mémoire shield uses pin D10 as the SPI chip select pin for the SD card interface. So, before running the example, we need to change the value of chipSelect from 4 to 10.
const int chipSelect = 10;
Insert a formatted SD card (FAT16 or FAT32 only) and upload the modified CardInfo sketch and if everything is OK you should see output similar to the one below.
Initializing SD card...Wiring is correct and a card is present. Card type: SDHC Volume type is FAT32 Volume size (bytes): 3899719680 Volume size (Kbytes): 3808320 Volume size (Mbytes): 3719 Files found on the card (name, date and size in bytes): ~1.TRA 2014-04-20 21:59:44 4096 20140421.CS 2000-01-01 01:00:00 186 TRASHE~1/ 2014-04-20 21:59:44 SPOTLI~1/ 2014-04-20 21:59:44 STORE-V2/ 2014-04-20 21:59:44 0AF162~1/ 2014-04-20 21:59:44 PSID.DB 2014-05-13 11:21:58 8192 TM~1.SNO 2014-04-21 10:22:24 0 TM~1.LIO 2014-04-21 10:22:24 0 LIO~1.CRE 2014-04-21 10:22:24 0 TMP.CAB 2014-04-21 10:22:24 0 CA~1.CRE 2014-04-21 10:22:24 0
Now we're happy the SD card interface is working, let's do a quick test to make sure that the RTC is also working. To do this, we'll use the RTCLib library and the ds1307 example sketch that comes with the library.
First, comment out the following line in the sketch. This is used to set the RTC to the date and time the sketch was uploaded.
//rtc.adjust(DateTime(__DATE__, __TIME__));
Upload the modified sketch and it should produce an output similar to the one below, starting with the current date and time.
2014/5/2 14:23:42 since midnight 1/1/1970 = 1399040622s = 16192d now + 7d + 30s: 2014/5/9 14:24:12
If the output shows the wrong date and time, then try the following:
Run the original sketch unchanged to set the date and time
Disconnect the power from the Arduino and wait a few minutes. This is to check that the backup battery is working
Comment out the line described above and upload the modified sketch
The sketch should now output the current date and time.
The following sketch writes a line to a CSV file on the SD card every 60 seconds. The line starts with the current date and time, followed by the light level, temperature and sound level. The CSV filename is the current date in YYYYMMDD format, using the data as the filename ensures that a new file is automatically created at the start of each day.
#include <SD.h> #include <Wire.h> #include <RTClib.h> #include <PString.h> #include <Streaming.h> // If it's not used as the CS pin, the hardware CS pin // (10 on most Arduino boards, 53 on the Mega) must be left // as an output or the SD library functions will not work. const int chipSelect = 10; RTC_DS1307 rtc; void writeDate(PString& pstr, DateTime& dt) { pstr << ((dt.day() < 10) ? "0" : "") << dt.day() << '/'; pstr << ((dt.month() < 10) ? "0" : "") << dt.month() << '/'; pstr << dt.year(); } void writeTime(PString& pstr, DateTime& dt) { pstr << ((dt.hour() < 10) ? "0" : "") << dt.hour() << ':'; pstr << ((dt.minute() < 10) ? "0" : "") << dt.minute() << ':'; pstr << ((dt.second() < 10) ? "0" : "") << dt.second(); } void writeDateTime(PString& pstr, DateTime& dt) { writeDate(pstr, dt); pstr << ' '; writeTime(pstr, dt); } void writeFilename(PString& pstr, DateTime& dt) { pstr << dt.year(); pstr << ((dt.month() < 10) ? "0" : "") << dt.month(); pstr << ((dt.day() < 10) ? "0" : "") << dt.day(); pstr << ".CSV"; } // Analog sensor pins const int lightSensorPin = 0; const int tempSensorPin = 1; const int soundSensorPin = 2; // B value of the thermistor const int B = 3975; void writeTemperature(PString& pstr, int sensorValue) { float resistance = (float) (1023 - sensorValue) * 10000; resistance = resistance / sensorValue; float temperature = 1 / (log(resistance / 10000) / B + 1 / 298.15); temperature = temperature - 273.15; pstr << temperature; } char filename[13]; PString filenamePStr(filename, sizeof(filename)); char line[40]; PString linePStr(line, sizeof(line)); DateTime now; // Pin 9 has an LED connected on Snootlab Memoire shield. const int led = 9; // The delay between samples in ms, e.g. 60000 = 60s const unsigned long sampleRate = 60000; void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT); // Open serial communications and wait for port to open: Serial.begin(57600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } // set date time callback function SdFile::dateTimeCallback(dateTime); Serial.print("Initializing SD card..."); // make sure that the default chip select pin is set to // output, even if you don't use it: pinMode(chipSelect, OUTPUT); // see if the card is present and can be initialized: if (!SD.begin(chipSelect)) { Serial.println("Card failed, or not present"); // don't do anything more: return; } Serial.println("card initialized."); #ifdef AVR Wire.begin(); #else // Shield I2C pins connect to alt I2C bus on Arduino Due Wire1.begin(); #endif rtc.begin(); if (!rtc.isrunning()) { Serial.println("RTC is NOT running!"); } } void loop() { // turn the LED on digitalWrite(led, HIGH); now = rtc.now(); linePStr.begin(); writeDateTime(linePStr, now); linePStr << ','; // read the light sensor int sensorValue = analogRead(lightSensorPin); linePStr << sensorValue << ','; // read the temperature sensor and convert deg C sensorValue = analogRead(tempSensorPin); writeTemperature(linePStr, sensorValue); linePStr << ','; // read the sound sensor sensorValue = analogRead(soundSensorPin); linePStr << sensorValue; Serial << line << endl; filenamePStr.begin(); writeFilename(filenamePStr, now); // open the file. note that only one file can be open at a time, // so you have to close this one before opening another. File dataFile = SD.open(filename, FILE_WRITE); if (dataFile) { // if the file is available, write to it: dataFile << line << endl; dataFile.close(); // print to the serial port too: Serial << line << endl; } else { // otherwise, report an error: Serial << "error opening: " << filename << endl; } // turn the LED off digitalWrite(led, LOW); delay(sampleRate); }
The full version of the sketch including the code to correctly set the created date on the files can be found here. To keep size of the sketch down, I'm using Mikal Hart's PString library which saves about 2000 bytes compared with using String objects. The sketch also his Streaming library which provides the C++-style << operator. It's a matter of personal preference but I think it makes the code look less clumsy and improves readability.
Date Time,Light,Temp,Sound 02/05/2014 01:15:48,0,24.35,126 02/05/2014 01:16:48,0,24.35,140 02/05/2014 01:17:48,0,24.35,114 02/05/2014 01:18:48,0,24.35,123 02/05/2014 01:19:48,20,24.35,148 02/05/2014 01:20:48,23,24.35,124 02/05/2014 01:21:48,240,24.35,123 02/05/2014 01:22:48,0,24.26,123 02/05/2014 01:23:48,0,24.26,125 02/05/2014 01:24:48,0,24.26,147 02/05/2014 01:25:48,0,24.26,117 02/05/2014 01:26:48,0,24.26,132 02/05/2014 01:27:48,0,24.26,137 02/05/2014 01:28:48,0,24.26,137 02/05/2014 01:29:48,0,24.35,122 02/05/2014 01:30:48,0,24.26,113
The CSV excerpt above shows a 15 minute period between 01:15 and 01:30 with stable temperature and sound levels. The three minute spike in light levels is me checking the time on my phone and then getting up to use the bathroom. Note that the actual temperature is 4-5°C lower than reported by the sensor.
Sleep Monitor: Cloud Storage Versus Local Storage
This is the third part in a series of posts describing how to build a DIY sleep monitor. In the second part I briefly tested three potential room sensors.
Before continuing further the architecture needs to be fleshed out. The sleep monitor needs to be able to store sensor readings for analysis and comparison. It also needs to be able store simple settings such as wake-up time. The Arduino only has a small amount of memory. There should be sufficient flash memory to store a small number of settings but not nearly enough to store the sensor readings, this will require external storage.
There is a huge movement towards the Internet of Things (IoT) and devices like the Arduino are a big part of this. So the obvious choice would be to connect the sleep monitor to the Internet and store the data in the "cloud". It's the obvious choice but is it the best choice?
The alternative to storing the sensor data in the "cloud" is to store it locally using some form of non-volatile memory. Both approaches have their merits, so let's compare them by assessing of the costs over a nominal three year lifespan; and by making qualitative assessment of the convenience, complexity, reliability and privacy of each approach. Privacy may not be an important consideration for a DIY project such as this but in the current political and social climate it is worth considering, nevertheless.
I'm deliberately avoiding including networking as part of this comparison. The mobile app requires that the sleep monitor possess either Bluetooth or WiFi connectivity, so it would be wrong to consider it as a factor here.
Cloud Storage
The cloud storage approach relies on using third party services such as Amazon Web Services (AWS) to store the sleep data.
Advantages:
Convenience: a user can access her/his sleep data from anywhere, for example they can analyse how well you slept last night whilst your on your way to work.
Disadvantages:
Cost: without the economies of scale associated with a large user base, the ongoing costs associated with storing data in the cloud are expensive. For example, taking advantage of the AWS free usage tier to zero out the cost for the first year, the storage cost for three years would be approximately €30. Unfortunately, boards such as the Arduino Uno don't have sufficient computing power to manipulate this storage directly. So it would be necessary to purchase computing power in the cloud order to make the storage accessible. Doing so pushes the cost for three years to approximately €300.
Complexity: calling a web service to store data does not significantly add to the complexity of the code running on the Arduino, compared to writing the same data to an SD card, for example. However, including web service does significantly increase the complexity of the solution, overall.
Reliability: cloud services such as those provided by AWS are extremely reliable. However, the services provided by ISPs are not. The level of intermittent failure associated with broadband connection are orders of magnitude higher than those associated with a non-volatile memory device, such as an SD card.
Privacy: the reliance on third party services to store the sleep data means that the user is only able to exercise control "after the fact", e.g. after their data has already been shared with these third party services.
Local Storage
The local storage approach relies on using a non-volatile memory device such as an <a href="http://en.wikipedia.org/wiki/Secure_Digital" target=_blank">SD card to store the sleep data.
Advantages:
Cost: using a branded SDHC card as an example, the cost of a 4GB card and the electronics required to interface it to an Arduino cost approximately €30.
Reliability: all non-volatile flash memory cells have a limit on the number of times they can be written to or erased before they are no longer usable. New, professional quality SDHC and SDXC cards employ wear levelling technology to reduce the chance of such failures during normal use. As a result the reliability of such cards significantly exceeds that of an Arduino board and most other components in the sleep monitor.
Complexity: the complexity of the code required to read and write to a SD card is not significantly different from the required to call a web service. However, the local storage solution is far less complex overall, than the cloud solution.
Privacy: the user is able to exercise full control of her/his sleep data, with that data only being shared if the user chooses to share it.
Disadvantages:
Convenience: a user can only access the sleep data stored on the sleep monitor whilst he/she is at home.
Conclusion
Local storage is the better of the two approaches for our purposes. It is cheap, reliable and simple to implement. The extra convenience associated with storing the sleep data in the cloud just aren't enough to offset the drawbacks. Nevertheless, convenient access to sleep data is important factor for and we will look at it again when we are designing the mobile app.
Note: my personal preference would be a hybrid approach that uses a low power radio link and an IoT gateway to store the sleep data within the user's home network but outside of the sleep sensor. However, I want to keep this project as accessible as possible, so this approach will have to wait for Sleep Monitor 2.0.
MĂ©moire SD Log Shield with RTCÂ
Name Mémoire Description SD log shield with RTC and prototyping area Manufacturer Snootlab Family Arduino Category Shield DIY Level Part assembled - some soldering required I2C Yes - use 7-bit address 0x68 (not configurable) SPI D10-D13 (Chip Select, MOSI, MISO, SCK, respectively)
Snootlab describe their Mémoire shield as a SD log shield with RTC (real time clock) and a small prototyping area.
Features:
SD card interface works with FAT16 or FAT32 formatted cards
Onboard 3.3v regulator for improved reliability
Compatible with the standard SD library
DS1307 real time clock (RTC) with lithium battery so it keeps the time even when unplugged
Battery backup lasts for approx. 10 years
Compatible with the popular RTCLib library
Small prototyping area with 5V and GND strips and easy access to A0-A5 and D0-D8, D10-D13
Programmable square wave (SQW) output
LED connected to D9
Reset switch on top
The shield comes as a kit of 25 components in a resealable ESD bag. The high quality PCB arrives with the SD card socket and 3.3V regulator pre-soldered. The positions of the components is clearly printed on the top of the PCB. The header pins are clearly labelled on both sides of the PCB, as are the 5V and GND strips.
The assembly guide provides clear, step-by-step instructions in the form of annotated images. The kit was generally very easy to assemble, with just a couple of minor issues. The optional instruction to solder the body of the crystal to the GND plane can take a number of attempts and is best done before fitting R8, R9 and R10. It is also quite easy to mistakenly fit R5, R6 and R7 into the holes meant for R2, R3 and R4, as they are in series with one another .
I have the original version of the shield. The newer v2.0 shield has a slightly revised layout in order to accommodate the Arduino 1.0 pinout which adds SDA and SCL pins near to the AREF pin, an IOREF pin next to the RESET pin and an addition unused pin next to the IOREF pin.
There are other similar shields on the market, especially from Adafruit who make a data logging shield with a nearly identical spec. The only real difference being the level shifter circuitry used to achieve the 3.3v levels for the SD card. In this respect, the design of the Adafruit shield is slightly more robust than that of the Snootlab shield. However, this wasn't significant enough for me to choose the Adafruit shield.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Sleep Monitor: Room Sensors
This is the second part in a series of posts describing how to build a DIY sleep monitor. In the first part I identified the need for three room sensors: an ambient sound sensor; an ambient temperature sensor; and an ambient light sensor. I also decided to use an Arduino for this project.
To begin with I'm going to use three Grove sensors, Grove shield and a Seeeduino because I have them laying around. Seeed Studio's Grove system consists of a base shield and various I/O modules with standardized connectors. The Seeeduino V3 is an Arduino Duemilanove compatible board. More details on the Grove system and the Seeeduino can be found on my hardware page.
Using the Grove base shield, the three sensors were connected to the Seeeduino as follows:
a light sensor connected to analog input A0;
a temperature sensor connected to analog input A1; and
a sound sensor connected to analog input A2.
As a quick test, the following sketch prints out the light level, temperature and sound level once a second. The temperature equation is a variation of the Steinhart-Hart equation, taken from the Grove wiki.
int lightSensorPin = 0; int tempSensorPin = 1; int soundSensorPin = 2; // B value of the thermistor int B = 3975; float resistance; float temperature; // duration between temperature readings int del=1000; void setup() { Serial.begin(9600); } void loop() { int sensorValue = analogRead(lightSensorPin); Serial.print("Light Level: "); Serial.println(sensorValue); sensorValue = analogRead(tempSensorPin); resistance = (float) (1023 - sensorValue) * 10000 / sensorValue; temperature = 1 / (log(resistance / 10000) / B + 1 / 298.15); temperature = temperature - 273.15; Serial.print("Temperature: "); Serial.println(temperature); sensorValue = analogRead(soundSensorPin); Serial.print("Sound Level: "); Serial.println(sensorValue); delay(del); }
You can download the sketch here.
Light Level: 777 Temperature: 23.65 Sound Level: 0 Light Level: 777 Temperature: 23.74 Sound Level: 0 Light Level: 777 Temperature: 24.17 Sound Level: 467 Light Level: 777 Temperature: 24.26 Sound Level: 0 Light Level: 777 Temperature: 24.26 Sound Level: 0
Sample output from the Arduino IDE: Tools → Serial Monitor
Sleep Monitor: The Inspiration
Inspired by this BBC News article on Withings bedroom sensors from CES 2014, I decided it would be interesting to have a go at building my own sleep monitor. We have a Philips Wake-up Light in our bedroom but it is little more than an alarm clock with a 100W lamp and I've often thought I could do better.Â
The Withings Aura™ Smart Sleep System consists of three main parts: a bedside device; a sleep sensor; and a mobile application. According to Withings' website:
The bedside device "records your sleep environment (noise pollution, room temperature, and light level), and provides with [sic] scientifically-validated light, and sound programs."
The sleep sensor is a "discreet sensor that slips under your mattress to monitor your personal sleep patterns, and cycles (body movements, breathing cycles, heart rate)."
The mobile application "lets you visualize your sleep cycles, understand what wakes you up, and compare nights." Using it "you can control your personalized wake-up, and fall-asleep programs."
Unpacking the marketing hype, the sleep system appears to have the following features:
Ambient sound sensor
Ambient temperature sensor
Ambient light sensor
Multi-colour LED light
Audio player
Clock display (a display showing 8:30 is visible in the images of the bedside device)
Pressure sensor (at the time of writing, the Aura is yet to go on sale and I'm skeptical about the claims that a sensor placed "under your mattress" can monitor breathing cycles and heart rate)
Data logger (the mobile app's visualisation and comparison functions imply the need for some form of data logging)
Real Time Clock (necessary for accurate data logging and for the clock display)
Bluetooth or WiFi connectivity (required for the mobile app)
Mobile app
With the exception of the mobile app itself, these features are all within the capabilities of an Arduino based project, so that's where we'll start.Â
Grove Starter Kit Plus
Name Grove Starter Kit Plus Description Grove is a modular electronic platform for quick prototyping Manufacturer Seeed Studio Family Arduino Category Development Kit DIY Level Fully assembled - no soldering required I2C -
Seeed Studio describe Grove as a modular electronic platform for quick prototyping. The Grove system consists of a base shield and various I/O modules with standardized connectors. Every module has one function, such as touch sensing, creating audio effect and so on. Just plug the modules you need to the base shield and you are ready to test your idea.
The stackable base shield is very well constructed and has 16 Grove sockets:
7 digital I/O sockets (D2-D8)
4 analog input sockets (A0-A3)
4 I2C sockets
1 UART socket
Each 4-pin Grove socket includes VCC, GND and two I/O pins, on the analog and digital sockets one of these I/O is left unused.
The Starter Kit Plus comes in a green box and contains a base shield, 15 Grove cables of various lengths, a 9v battery clip, a Grove guide booklet and 15 Grove modules.
The modules included in the kit are:
Buzzer
Sound sensor
Rotary angle sensor (potentiometer)
Touch sensor
Light sensor
Vibrator
Temperature
Relay
Magnetic switch (SPST dry reed switch)
Switch (SPDT slide switch)
3 LEDs (5mm red, 3mm green and 3mm blue)
Servo
Button
The build quality of modules is generally very good and the starter kit offers a good starting place for someone new to electronics and the Arduino. However, the sensors included in the kit are very limited and quickly outgrown. The Grove system includes dozens of other prebuilt modules but for me the big plus of a modular system like Grove is that I can use it to create my own modules.
Don't get me wrong, using a modular system like Grove hasn't made my workbench any less messy. It is still covered in jumper wires and resistors with bent leads. But when it's time to deploy a robust prototype, it gives me an alternative to soldering and means I can keep my breadboards where they should be - on my workbench.Â
Similar modular systems are available from other vendors and I wouldn't claim that Grove is better than any of these competing products. However, Grove is simple, it's open and it uses cheap, readily available components which makes it good enough to meet my needs.
Seeeduino v3.0 (ATmega328P)
Name Seeeduino v3.0 Description Arduino Duemilanove compatible board based on the ATmega328P Manufacturer Seeed Studio Family Arduino Category Microcontroller Board DIY Level Fully assembled - no soldering required I2C -
The Seeed Studio Seeeduino v3.0 is an Arduino Duemilanove compatible board based on the ATmega328P.
The main differences between the Seeeduino and the Arduino Duemilanove are:
The addition of two Grove connectors: one I2C and one serial
The addition of a VCC selector switch
The addition of a reset selector switch to control whether the DTR signal from the host is allowed to reset the micro-controller
I bought the Seeeduino bundled with a Grove starter kit and whilst it's not my favourite board, so far I have no complaints. I've used it for prototyping a couple of projects. It is very well constructed and has clocked up 200-300 hours continuous use without any issues.