Trying my first Cream Project, hitting issues

Hi All, trying to get the following working, I have a moisture module on socket 4:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

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

// The Blank Page item template is documented at

namespace SparkPlant
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
        private GTM.FEZCream mainboard;
        private GTM.Moisture moisture;
        private DispatcherTimer timer;

        public MainPage()


        private async void Setup()
            this.mainboard = await GT.Module.CreateAsync<GTM.FEZCream>();
            this.moisture = await GT.Module.CreateAsync<GTM.Moisture>(this.mainboard.GetProvidedSocket(4));


        private void ProgramStarted()
            this.timer = new DispatcherTimer();
            this.timer.Interval = TimeSpan.FromMinutes(1);
            this.timer.Tick += Timer_Tick;

        private void Timer_Tick(object sender, object e)
            double reading = moisture.GetReading();

I’m running into issues with these:

            this.mainboard = await GT.Module.CreateAsync<GTM.FEZCream>();
            this.moisture = await GT.Module.CreateAsync<GTM.Moisture>(this.mainboard.GetProvidedSocket(4));

For the first line the error is saying I didn’t specify parentSockets for the mainboard. For the second line it says there is not GetProvidedSocket method for the FEZCream.

I borrowed both from the Fez Cream example project.

Also, how do I debug.print?

I am using pretty much identical startup code, and it’s working, but I have a source snapshot from a month ago. Maybe they changed something. If I get a chance, I’ll do another pull and see if anything changed.

From CortanaAllJoynDemo/HardwareManager.cs at master · martincalsyn/CortanaAllJoynDemo · GitHub

_mainboard = await GT.Module.CreateAsync<GTM.FEZCream>();
_button = await GT.Module.CreateAsync<GTM.Button>(this._mainboard.GetProvidedSocket(3));
_button.Released += _button_Released;
_relays[0] = await GT.Module.CreateAsync<PGTM.RelayX1>(_mainboard.GetProvidedSocket(4));
_relays[1] = await GT.Module.CreateAsync<PGTM.RelayX1>(_mainboard.GetProvidedSocket( 8 ));

As for Debug.Print, the equivalent is System.Diagnostics.Debug.WriteLine(…)

1 Like

@ mcalsyn - It may go deeper than I thought, the attached screenshot is from Module.cs in the Gadgeteer.Core project, seems like there’s some kind of core reference missing, I’m getting things like System.Object and System.Void being undefined. What’s missing that even System can’t be referenced?

Exit and restart VS - the system.void indication can be a false indication from VS (I just saw this myself). If you do a build and don’t see those messages in the build output (not the errors window - the actual compiler output), then it’s VS that is confused.

Also, make sure you have added a reference to the IOT extension assembly (under Extensions in Add References window)

1 Like

… and if that fails, grab a copy of the CortanaAllJoyn project or a working GHI project; make sure that builds; and then compare the References items to make sure your project matches.

1 Like

Well I’ll be, never knew it was confusable like that, thanks!

Ok, one more question:

It appears the highest reading for the Moisture sensor is a double at roughly 0.37, Should I just calibrate for that being full moisture, or should I have expected to get similar return values as to when I was using the sensor with a Cerberus Gadgeteer project?

@ Squeebee - We will take a look and let you know what we find.

@ Squeebee - The value should be between 0 and 1. It was incorrectly scaled down instead of up. In the module driver for Moisture, in GetReading(), change the “/ 1.6” to “* 1.6”.

@ John - Found my first bug! Now I feel like a contributor! :wink:

Thanks for the fix!

1 Like

@ John - And that worked like a charm! I’m going to do a blow about this one, I assume it’ll be fixed in the bitbucket soon enough that I don’t have to mention it in the blog entry?

Make sure to post a link to the blog please. ;D

@ Squeebee - It is fixed in Bitbucket as well.

If the code was in Github, rather than Bitbucket, you could have done a pull request. Amirite, @ ianlee74? :wink:

cc/ @ Gary

1 Like

Will do! Now that it’s working as planned I just need to write it up.