FEZ Spider E-Block Temperature Module

I am experimenting with the Fez Spider E-Block Temperature Module using the eBlockExpansion. I am able to get a voltage but i am not sure how to convert the voltage to a temperature. I cannot find the e-block temperature schematics. Also, Visual C# Studio allows you to plug the GHIElectornics Block Expansion anywhere on the FEZ board. I found out it works on port number 9 (not 11 as I tried).

Here is the code I have so far.


using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;

using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

namespace GadgeteerApp1
{
    public partial class Program
    {
        void ProgramStarted()
        {

            Debug.Print("Program Started");

            GT.Interfaces.AnalogInput TemperatureVoltage = eBlockExpansion.SetupAnalogInput(GT.Socket.Pin.Three);
            double temp = 0;

            while (true)
            {
                Debug.Print("The Voltage is: " + TemperatureVoltage.ReadVoltage());
                temp = TemperatureVoltage.ReadVoltage();
                display.SimpleGraphics.ClearNoRedraw();
                display.SimpleGraphics.DisplayText("The Voltage is: " + temp, Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Blue, 5, 5);
                Thread.Sleep(500);
            }
        }


    }
}

Welcome to the forum.
Check the driver code for that module it shows how convert the reading to the temperature value.

http://www.ghielectronics.com/downloads/FEZ/Component/FEZ_Components_Thermometer.cs

I saw that but the


 GT.Interfaces.AnalogInput TemperatureVoltage = eBlockExpansion.SetupAnalogInput(GT.Socket.Pin.Three);

does not give me a option to SettheLinearScale.

It only gives my the ReadVoltage(). I am assuming the driver when it does the adc.Read() automatically converts it to Celsius from the voltage.

Look at it this way:

-22C when analog reading is 0V
56C when analog reading is 3V3

It is linear. With a simple math and values provided you can get the temperature for any reading.

Cool thanks. Also, for anyone else the equation comes out to be Celsius = (78/3) * inputVoltage - 22

Thanks for your help :slight_smile:

Wouldn’t that be…

Celsius = (78/3.3) * inputVoltage - 22

Actually, I’d probably get the voltage from testing boiling water. Maybe that’s where you came up with the 3…

Your absolutely right…my bad lol :smiley:

Just curious why 78? The official driver uses 56.

I was trying to find a linear equation.
-22C when analog reading is 0V
56C when analog reading is 3.3V

Point 1 = (0, -22)
Point 2 = (3.3, 56)

y = mx + b

m = (y2 - y1) / (x2 - x1) = (56 + 22) / (3.3 - 0) = (78 / 3.3)

-22 = (78/3) * 0 + b therefore b = -22

so the equation comes out to be:
Celsius = (78/3.3) * inputVoltage - 22

If there are problems with them math, please let me know. :slight_smile:

Doh! :-[

Of course, 78 is the difference between max and min. Well, the detailed explanation you have provided might help somebody else who will be reading this thread. Thank you!

Again, I wouldn’t trust that either. Take a reading of ice and a reading of boiling water. Those are your real min & max values. I doubt it’ll be exactly 0V and 3.3V. If you’re really concerned then also factor in altitude.

I have no idea where these numbers came from!

Did Weston start us on a wild goose chase? Enlighten us Obiwan? I’ve never actually used that sensor.

Ha ha, wild goose chase. ;D I measured the temp of the air using this sensor and I got 50 Fahrenheit (so I will need to put a correction factor in the equation). I am going to use this sensor to measure the temp of the water in a fish tank for my project.

The math jumbo I did is what this command would of done (in the driver code):


adc.SetLinearScale(-22, 56);

Basically, the equation assumes that when the analog output is 0V the temperature is -22 Celsius (plug 0 for x) and when the analog output is 3.3V the temperature is 56 Celsius. Most likely the voltages are not exactly like those so there will need to be a correction factor. If you wanted an exact equation, you would do what ianlee74 said.

  1. Measure the output voltage in freezing water
  2. Measure the output voltage in boiling water

Use these two points to derive the equation just like I did. I hope that makes better sense?

Also, be careful when you plug the eblock Expansion Module. Visual Studio Designer allows you to plug this module in any socket on the FEZ spider board. It is only supposed to be plugged into a socket that supports “A” (which are ports 9 and 10 on the FEZ spider) Just thought I would let you guys know :slight_smile:

Actually, the eBlock can be plugged into any port since it’s basically the same as an Extender module. It requires a little more knowledge of the eBlock used and the type of pins it requires. If your eBlock needs digital I/O then an X or Y socket would suffice. If your eBlock needs analog then you need an A socket. Make sense?

To make matters even more confusing (not too confusing, given that you’re interfacing with a different “module” technology in the eblocks), while the eblock expansion module can plug into any socket, and as Ian notes there are specific sockets you’ll need to choose for specific eblocks, depending on whether they need digital I/O, analog I/O, PWM, etc., the eblock expansion module itself has restrictions on which pins can be used for what.

Generally (Ian or others, please correct me if I miss anything here), pins 3-5 are used for analog inputs or outputs, and pins 6-9 are used for digital or PWM. So to use a given eblock, you need to know if it’s digital or analog, and choose both the correct pin on the eblock expansion module, and plug the module into a socket that is compatible with the pin or pins you’re using.

Note also that you can use more than one eblock simultaneously with a single eblock expansion module, as long as all of the eblocks you’re using are of a type supported by the socket you’re plugged into, and you have enough of those inputs on the module.

@ devhammer I don’t think what you’re experiencing is a limitation of the eBlock but rather a limitation of the Gadgeteer socket. I haven’t used my eBlock module much yet but I believe it is just a straight through design. What you are experiencing is the layout of pins in the socket. This is where you’re going to have to pull out the Spider or Hydra schematics and see what types of pins each socket has and relate that to the eBlock socket.

Pin types and layout on any socket is the same on any Gadgeteer main board - you don’t need schematics for that. You just need socket table from mainboard or module design doc from the gadgeteer site.

Yes, of course, that would be easier. I still have the Hydra schematics in front of me from pre-Gadgeteer days and just keep going with it… :frowning:

D’oh!

Yeah, @ Ian and @ Architect, you’re right…I was oversimplifying things, based on a few projects, and too long since I looked at:

[url]GHI Electronics – Where Hardware Meets Software

which is one place you can find the skinny one which pins to what based on which socket type.

I love the fact that eblocks are supported, particularly since there are a number of sensors that are not available as separate modules yet, but eblocks do (IMO) add to the complexity factor a bit, at least for embedded newbs like myself. :slight_smile:

Sorry for any confusion caused by my earlier reply!