Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

phantomtypist

Member Since 10 Aug 2010
Offline Last Active Jun 11 2015 03:57 AM
-----

#60074 NYC Code Camp (13-SEP-2014) and IoT session

Posted by phantomtypist on 11 September 2014 - 03:19 PM

In case anybody is planning on going to the code camp and sitting in on my session.... some sponsors have been very generous.  There is some nice swag that will be given away ;)




#59767 NYC Code Camp (13-SEP-2014) and IoT session

Posted by phantomtypist on 18 August 2014 - 07:13 PM

Olaf, I'm actually bringing both Netduino and GHI devices!




#59494 NYC Code Camp (13-SEP-2014) and IoT session

Posted by phantomtypist on 01 August 2014 - 03:46 AM

For those of you planning on going to the NYC Code Camp I'll be presenting a session called "Azure, .NET and the Internet of Things", provided I get enough votes ;)

 

Here is the abstract:

 

 

The Internet of Things (IoT) movement is picking up steam. It's estimated that by 2020, the IoT will be an $8.9 trillion market with over 200 billion connected devices. In this session you'll learn how to leverage your existing .NET skills to build the next big (or tiny) thing!

This session will explore:

  • What is the Internet of Things?
  • An introduction to basic micro electronics.
  • What is the .NET Micro Framework (NETMF)?
  • Exploring the NETMF and Arduino.
  • Running C# on a Raspberry Pi.
  • Connecting your devices to Azure.
  • Using the Windows on Devices SDK with an Intel Galileo.

There will be no time for boring slides here. Instead we'll be covering lots of code and fun interactive demos with the audience.

 

For more information about the NYC Code Camp > http://www.codecampnyc.org/

 

You can view all the potential sessions and abstracts over at > http://bit.ly/ccnyc-...ns-listing-2014




#14585 Debug issues with multiple projects

Posted by phantomtypist on 22 June 2011 - 12:05 PM

Go to the solution properties (right click on the solution). A window will appear. There is a tree structure of sorts on the left hand side. Click on "Configuration Properties". The right hand side of the window will change. This shows you all of the projects in your solution and their build/deploy properties. My guess is that all of your projects are set to "Deploy". Only check the boxes of the projects you wish to deploy. That should do it. Let us know how you make out and good luck on your presentation!


#6091 I2C Devices using the I2CBus class

Posted by phantomtypist on 14 December 2010 - 10:41 PM

I've already touched on this. It can be used by pretty much any I2C device on probably any .NET Micro Framework device.

My work -> A derivative of Pavel Bansky's I2CBus class, but implements the singleton pattern (because it should be implementing the singleton pattern since you are supposed to only have one instance of the I2CDevice class.) You really might want to explore using the singleton pattern so that you guarantee that there is only one instance of the I2CDevice being used by your I2C devices.

I used this in the Bosch BMP085 Digital Pressure and Temperature Sensor

FYI my singleton implementation of the I2CBus class is being used in several projects with as many as four I2C devices on operating on the same bus.


#5000 How to interface LCD with netduino board

Posted by phantomtypist on 17 November 2010 - 01:08 PM

You could always use Bavel Bansky's I2C LCD display implmentation and it will only use two wires.

I used this I2C GPIO port expander -> NXP PCA9554N

If you need something bigger than an 8 port extender, try the 16 port I2C extender -> NXP PCA9555N

Just makes sure the LCD display is 3.3V. No need to buy the serial edition IMHO as it wastes pins and is more expensive than the I2C option.

You're also going to need a trimpot of sorts -> 10K trimpot


#4273 Bosch BMP085 Digital Pressure and Temperature Sensor

Posted by phantomtypist on 27 October 2010 - 04:39 AM

This managed driver is for the Bosch BMP085 Digital Pressure and Temperature Sensor. This sensor allows you to retrieve the temperature and barometric pressure in both Pascals and Inches of Mercury (InHg). While not coded, you could hypothetically use the data from this sensor alone to calculate your altitude.

This code uses my I2CBus managed driver. You will need the I2CBus.cs file attached in that posting.

I completed this a few weeks ago and I've been testing it to make sure it works.

FYI there is a timer in this driver that takes the readings / measurements every 30 seconds. You can change that as you please. Furthermore, you can remove the timer and make the TakeMeasurements method public so that you can take readings / measurements only when you want or need to. Last, but not least, if you intend to use this sensor and code please read the datasheet. It will definitely help you understand what is going on in the code.

Here is an example of using the code:

    BMP085 pressureSensor = new BMP085(0x77, BMP085.DeviceMode.UltraLowPower);
    Debug.Print("BMP085 Pascal: " + pressureSensor.Pascal);
    Debug.Print("BMP085 InchesMercury: " + pressureSensor.InchesMercury.ToString("F2"));
    Debug.Print("BMP085 Temp*C: " + pressureSensor.Celsius.ToString("F2"));

Here is the code for the driver:

    /// <summary>
    /// Bosch BMP085 digital pressure and temperature sensor.
    /// </summary>
    public class BMP085
    {
        private I2CDevice.Configuration _slaveConfig; // BMP085 I2CDevice configuration
        private const byte ClockRateKHz = 40; // BMP085 clock rate

        // Oversampling for measurements.  Please see the datasheet for this sensor for more information.
        private byte _oversamplingSetting;

        // These wait times correspond to the oversampling settings.  
        // Please see the datasheet for this sensor for more information.
        private readonly byte[] _pressureWaitTime = new byte[] {5, 8, 14, 26};

        private const int TransactionTimeout = 1000; //ms
        private Timer _sensorTimer;
        public enum DeviceMode
        {
            UltraLowPower = 0,
            Standard = 1,
            HighResolution = 2,
            UltraHighResolution = 3
        }

        // Calibration data backing stores
        private short _ac1;
        private short _ac2;
        private short _ac3;
        private ushort _ac4;
        private ushort _ac5;
        private ushort _ac6;
        private short _b1;
        private short _b2;
        private short _mb;
        private short _mc;
        private short _md;

        public BMP085(byte address, DeviceMode deviceMode)
        {
            Address = address;
            _slaveConfig = new I2CDevice.Configuration(address, ClockRateKHz);
            _oversamplingSetting = (byte) deviceMode;

            // Get calibration data that will be used for future measurement taking.
            GetCalibrationData();

            // Take initial measurements.
            TakeMeasurements();

            // Take new measurements every 30 seconds.
            _sensorTimer = new Timer(TakeMeasurements, null, 200, 30000);
        }

        /// <summary>
        /// Calculates the compensated pressure and temperature.
        /// </summary>
        private void TakeMeasurements()
        {
            TakeMeasurements(null);
        }

        /// <summary>
        /// Calculates the compensated pressure and temperature.
        /// </summary>
        /// <param name="state"></param>
        private void TakeMeasurements(object state)
        {
            long x1, x2, x3, b3, b4, b5, b6, b7, p;

            long ut = ReadUncompensatedTemperature();

            long up = ReadUncompensatedPressure();

            // calculate the compensated temperature
            x1 = (ut - _ac6) * _ac5 >> 15;
            x2 = (_mc << 11) / (x1 + _md);
            b5 = x1 + x2;
            _celsius = (float)((b5 + 8) >> 4) / 10;

            // calculate the compensated pressure
            b6 = b5 - 4000;
            x1 = (_b2 * (b6 * b6 >> 12)) >> 11;
            x2 = _ac2 * b6 >> 11;
            x3 = x1 + x2;
            switch (_oversamplingSetting)
            {
                case 0:
                    b3 = ((_ac1 * 4 + x3) + 2) >> 2;
                    break;
                case 1:
                    b3 = ((_ac1 * 4 + x3) + 2) >> 1;
                    break;
                case 2:
                    b3 = ((_ac1 * 4 + x3) + 2);
                    break;
                case 3:
                    b3 = ((_ac1 * 4 + x3) + 2) << 1;
                    break;
                default:
                    throw new Exception("Oversampling setting must be 0-3");
            }
            x1 = _ac3 * b6 >> 13;
            x2 = (_b1 * (b6 * b6 >> 12)) >> 16;
            x3 = ((x1 + x2) + 2) >> 2;
            b4 = (_ac4 * (x3 + 32768)) >> 15;
            b7 = (up - b3) * (50000 >> _oversamplingSetting);
            p = (b7 < 0x80000000 ? (b7 * 2) / b4 : (b7 / b4) * 2);
            x1 = (p >> 8) * (p >> 8);
            x1 = (x1 * 3038) >> 16;
            x2 = (-7357 * p) >> 16;
            _pascal = (int) (p + ((x1 + x2 + 3791) >> 4));
        }

        private long ReadUncompensatedTemperature()
        {
            // write register address
            I2CBus.GetInstance().Write(_slaveConfig, new byte[2] { 0xF4, 0x2E }, TransactionTimeout);

            // Required as per datasheet.
            Thread.Sleep(5);

            // write register address
            I2CBus.GetInstance().Write(_slaveConfig, new byte[] { 0xF6 }, TransactionTimeout);

            // get MSB and LSB result
            byte[] inputData = new byte[2];
            I2CBus.GetInstance().Read(_slaveConfig, inputData, TransactionTimeout);

            return ((inputData[0] << 8) | inputData[1]);
        }

        private long ReadUncompensatedPressure()
        {
            // write register address
            I2CBus.GetInstance().Write(_slaveConfig, new byte[2] { 0xF4, (byte) (0x34+(_oversamplingSetting<<6)) }, TransactionTimeout);

            // insert pressure waittime using oversampling setting as index.
            Thread.Sleep(_pressureWaitTime[_oversamplingSetting]);

            // get MSB and LSB result
            byte[] inputData = new byte[3];
            I2CBus.GetInstance().ReadRegister(_slaveConfig, 0xF6, inputData, TransactionTimeout);

            return ((inputData[0] << 16) | (inputData[1] << 8) | (inputData[2])) >> (8 - _oversamplingSetting);
        }

        /// <summary>
        /// Retrieves the factory calibration data stored in the sensor.
        /// </summary>
        private void GetCalibrationData()
        {
            _ac1 = ReadShort(0xAA);
            _ac2 = ReadShort(0xAC);
            _ac3 = ReadShort(0xAE);
            _ac4 = (ushort)ReadShort(0xB0);
            _ac5 = (ushort)ReadShort(0xB2);
            _ac6 = (ushort)ReadShort(0xB4);
            _b1 = ReadShort(0xB6);
            _b2 = ReadShort(0xB8);
            _mb = ReadShort(0xBA);
            _mc = ReadShort(0xBC);
            _md = ReadShort(0xBE);
        }

        private short ReadShort(byte registerAddress)
        {
            // write register address
            I2CBus.GetInstance().Write(_slaveConfig, new byte[] { registerAddress }, TransactionTimeout);

            // get MSB and LSB result
            byte[] inputData = new byte[2];
            I2CBus.GetInstance().Read(_slaveConfig, inputData, TransactionTimeout);

            return (short)((inputData[0] << 8) | inputData[1]);
        }

        private byte _address;
        public byte Address
        {
            get { return _address; }
            private set { _address = value; }
        }

        private int _pascal;
        public int Pascal
        {
            get { return _pascal; }
        }

        public float InchesMercury
        {
            get
            {
                return (float) (_pascal / 3386.389);
            }
        }

        private float _celsius;
        public float Celsius
        {
            get { return _celsius; }
        }

        public void Dispose()
        {
            _sensorTimer.Dispose();
        }

    }

Attached Files




#3440 Honeywell HIH-4030 Humidity Sensor

Posted by phantomtypist on 04 October 2010 - 04:34 AM

This is code for the Honeywell HIH-4030 humidity sensor (SparkFun SKU: SEN-09569).

Please note that the sensor is supposed to be used with 5v input, but it works just fine with 3.3v input because the output is linear.

The code below is tailored to 3.3v input.

    /// <summary>
    /// Honeywell HIH-4030 humidity sensor (SEN-09569). 
    /// Please note that the sensor is supposed to be used with 5v input, 
    /// but it works just fine with 3.3v input because the output is linear.
    /// The code below is tailored to 3.3v input.
    /// </summary>
    public class HIH4030 : IDisposable
    {
        private AnalogInput _sensor;
        private bool _disposed;

        protected virtual void Dispose(bool disposing)
        {
            // Check if Dipose has already been called.
            if (!_disposed)
            {
                if (disposing)
                {
                    _sensor.Dispose();
                    _disposed = true;
                }
            }
        }

        ~HIH4030()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this); // tell the GC not to finalize.
        }

        public HIH4030(Cpu.Pin analogPin)
        {
            _sensor = new AnalogInput(analogPin);
            _sensor.SetRange(0, 3300);
        }

        /// <summary>
        /// Calculates the relative humidity with temperature compensation.
        /// </summary>
        /// <param name="temp">Current temperature in Celsius.</param>
        /// <returns>Returns the relative humidity as a percentage.</returns>
        public double RelativeHumidity(float temp)
        {
            // Get the humidity sensor reading.
            int sensorReading = _sensor.Read();

            // Calculate the humidity sensor voltage.
            double sensorVoltage = (((double)sensorReading / 3300) * 3.3);

            // Define the voltage the sensor returns at 0% humidity.
            double zeroVoltage = 0.528;

            /* It has been observed that some sensors are consistently 
             * inaccurate and off by a certain voltage than what they 
             * should be.  Use this variable to compensate for what the 
             * voltage should be if needed. */
            double calibrationVoltage = 0.00;

            /* Determine the maxium voltage of the sensor with 
                temperature compensation. */
            double maxVoltage = (2.1582 - (0.004426 * temp));

            /* Determine the temperature compensated relative humidity 
                as a percentage. */
            double rh = ((sensorVoltage + calibrationVoltage - zeroVoltage) / maxVoltage) * 100;
            
            return rh;
        }
        
    }

Attached Files




#2667 An interesting talk with Colin Miller about .NET Micro Framework

Posted by phantomtypist on 23 September 2010 - 12:11 PM

This was a great episode. Colin mentions that the .NET Micro Framework team will be announcing something really big at Maker Faire in New York this weekend!


home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.