CodeClub Internet of Things Boxes sponsored by Microsoft NZ

A few months ago Microsoft NZ donated NZ6K to CodeClub NZ for the purchase of kits for our basic electronics and programming classes.

Over the last couple of months I have been assembling these so we now have 15 kits ready to go. Each one has enough gear for 2-6 students, fits into a 7L Sistema plastic box and contains the following items

2 x Netduino 2 Plus devices
2 x Seeedstudio Grove Starter kits for Arduino which contain

  • 1xBase Shield
  • 1xGrove – LCD RGB Backlight
  • 1xGrove – Smart Relay
  • 1xGrove – Buzzer
  • 1xGrove – Sound Sensor
  • 1xGrove – Touch Sensor
  • 1xGrove – Rotary Angle Sensor
  • 1xGrove – Temperature Sensor
  • 1xGrove – Light Sensor
  • 1xGrove – Button
  • 1xGrove LED Blue-Blue
  • 1xGrove LED Green-Green
  • 1xGrove  LED Red-Red
  • 1xMini Servo
  • 10xGrove Cables
  • 1x9V to Barrel Jack Adapter
  • 1xGrove starter kit Manual
  • 1xGreen Plastic Box
  • 1 x ultrasonic ranger

In addition to the Netduino devices and the Grove starter kits, we also include

Thanks to Embedded coolness, Secret Labs, and Seeedstudio which discounted their products so our funding went further.

CodeClub Programming and electronics kits

CodeClub Programming and electronics kits

Silicon Labs Si7005 Device Driver oddness

I have been working on a Netduino I2C driver for the Silicon Labs Si7005 Digital I2C Humidity & Temperature Sensor for weather station and building monitoring applications as it looks like a reasonably priced device which is not to complex to interface with.I’m using a SeeedStudio Grove – Temperature&Humidity Sensor (High-Accuracy & Mini) for development.

The first time I try and read anything from the device it fails. Otherwise my driver works as expected.

Netduino 2 Plus & Silicon Labs Si7005

Bill of materials (prices as at April 2015)

  • Netduino Plus 2 USD60 NZD108
  • Grove – Temperature&Humidity Sensor (High-Accuracy & Mini) USD11.50
  • Grove – Base Shield USD8.90

This code just shows the flow, I’ll package into a driver shortly

I strobe the I2C line which seems to help

using (OutputPort i2cPort = new OutputPort(Pins.GPIO_PIN_SDA, true))
{
   i2cPort.Write(false);
   Thread.Sleep(1000);
}

I then try and read the Device ID (0x50) from register 0X11 but this (and any other read fails)

byte[] writeBuffer = { RegisterIdDeviceId };
byte[] readBuffer = new byte[1];

I2CDevice.I2CTransaction[] action = new I2CDevice.I2CTransaction[] 
{ 
   I2CDevice.CreateWriteTransaction(writeBuffer),
   I2CDevice.CreateReadTransaction(readBuffer)
};

int length = device.Execute(action, TransactionTimeoutMilliseconds);
Debug.Print("Byte count " + length.ToString());
foreach (byte Byte in readBuffer)
{
   Debug.Print(Byte.ToString("X2"));
}

I can read the temperature and humidity by writing to the command register

byte[] writeBuffer = { RegisterIdConiguration, CMD_MEASURE_TEMP };

I2CDevice.I2CTransaction[] action = new I2CDevice.I2CTransaction[] 
{ 
   I2CDevice.CreateWriteTransaction(writeBuffer),
};

int length = device.Execute(action, TransactionTimeoutMilliseconds);
Debug.Print("Byte count" + length.ToString());

Then poll for measurement process to finish

conversionInProgress = true
do
{
   byte[] writeBuffer = { RegisterIdStatus };
   byte[] readBuffer = new byte[1];

   I2CDevice.I2CTransaction[] action = new I2CDevice.I2CTransaction[] 
   { 
      I2CDevice.CreateWriteTransaction(writeBuffer4),
      I2CDevice.CreateReadTransaction(readBuffer4)
   };

   int length = device.Execute(action, TransactionTimeoutMilliseconds);
   Debug.Print("Byte count " + length.ToString());
   foreach (byte Byte in readBuffer)
   {
      Debug.Print(Byte.ToString());
   }

   if ((readBuffer[RegisterIdStatus] && STATUS_RDY_MASK) != STATUS_RDY_MASK)
   {
      conversionInProgress = false;
   }
} while (conversionInProgress);

Then finally read and convert the value

byte[] writeBuffer = { REG_DATA_H };
byte[] readBuffer = new byte[2];

I2CDevice.I2CTransaction[] action = new I2CDevice.I2CTransaction[] 
{ 
   I2CDevice.CreateWriteTransaction(writeBuffer),
   I2CDevice.CreateReadTransaction(readBuffer)
};

int length = device.Execute(action, TransactionTimeoutMilliseconds);
Debug.Print("Byte count " + length.ToString());
foreach (byte Byte in readBuffer)
{
   Debug.Print(Byte.ToString());
}

int temp = readBuffer[0];

temp = temp << 8;
temp = temp + readBuffer[1];
temp = temp >> 2;

double temperature = (temp / 32.0) - 50.0;

Debug.Print(" Temp " + temperature.ToString("F1"));