Main Site Documentation

FEZ Cobra II (wifi) with Temperature & Humidity Module problem


#1

Hi

I am trying to use temperature module with no luck, do you know if this is possible ?

which port should I use ? note will use TE35 display module too

I am getting this error:

Module TemperatureHumidity cannot be used with invalid socket number

temperatureHumidity = new TemperatureHumidity(5or 6);
temperatureHumidity.MeasurementComplete += new TemperatureHumidity.MeasurementCompleteEventHandler(temperatureHumidity_MeasurementComplete);
temperatureHumidity.StartContinuousMeasurements();

Thanks!


#2

Cobra2 will use this module on sockets 1,3,4,5, or 6. Seems like you’re not using a Gadgeteer app and defining it correctly, or you’re duplicating something. The code you mention above, is that in your ProgramStarted()? Did you include the module in the designer and drag the connection to 5 or 6?


#3

@ Brett - Thanks Brett, you are right it is not a Gadgeteer app, I don’t use a designer.

I hope I don’t need to transport all my code to Gadgeteer app

Thank


#4

So step 1 is… get it working in a simple app in Gadgeteer land, and prove it works :slight_smile:

Step 2 is how to integrate it with your app - and yes, it should be simple, but lets prove you don’t have some other issue at play !


#5

… and thinking about it, Gadgeteer framework doesn’t know what sockets you have until the mainboard is instantiated and initialised, that’s possibly what your error is telling you.

Do the “step 1” test and then look at the main() in Program.Generated, to use the Gadgeteer “driver” as-is you need to “replicate” that. But you can equally create a new “driver” that leverages the Gadgeteer driver code and uses the pins you need - you’ll see typically the driver allocates the socket, and then allocates the pins it needs from the socket; you’d simply allocate the pins you need and that’s it.


#6

@ Brett - Thanks Brett, your comments give me the idea

basically I have changed the driver on the method


  protected virtual void OnMeasurementCompleteEvent(TemperatureHumidity sender, double temperature, double relativeHumidity)
        {
            if (_OnMeasurementComplete == null) _OnMeasurementComplete = new MeasurementCompleteEventHandler(OnMeasurementCompleteEvent);
            
             MeasurementComplete(sender, temperature, relativeHumidity) 
        }

so I can initialize with the class without inherence from Gadgeteer.Program

  GHIElectronics.Gadgeteer.FEZCobra_II c = new GHIElectronics.Gadgeteer.FEZCobra_II();           
            temperatureHumidity = new TemperatureHumidity(5);
             temperatureHumidity.MeasurementComplete += new TemperatureHumidity.MeasurementCompleteEventHandler(temperatureHumidity_MeasurementComplete);
             temperatureHumidity.StartContinuousMeasurements();