Windows 10 IoT Support

Anytime Karen. Cool to contribute to the GrovePi community.

  1. I maybe looking at the wrong library. I don’t see a command address for : 0x0C. The line I was basing that bit of code off of was here.

  2. I was going to ask about the sleep times in all the code. Most/all of the sensor code seem to have a delay between reading and writing. The times seem to differ and I am wondering if there is any formula to the specific time?

  3. and 4) In our code we create an object that represents a device on the i2c bus. In this case that device is ‘TextDirectAccess’. This is being passed into the constructor https://github.com/DexterInd/GrovePi/blob/master/Software/C%23/GrovePi/I2CDevices/RgbLcdDisplay.cs#L24.

That object is being created by our Device-factory here. using these addresses

Sorry this reply is becoming so lengthy! At any-rate…to circle back to textcommand… our C# method called ‘SetText’ uses the TextDirectAccess object (with the DisplayTextI2CAddress of 0x3e) to write to the bus.

So this :

TextDirectAccess.Write(new[] {TextCommandAddress, ClearDisplayCommandAddress});

would translate to

bus.write_byte_data(0x3e,0x80,0x01)

TextDirectAccess object has the 0x3e address,
TextCommandAddress = 0x80, and
ClearDisplayCommandAddress = 0x01.

Something to note: the RGB part works great. I can change the background color to any RGB value.

I will definitely try out number 1 and 2 when I am off work.Thanks again.

-Paul

Ignore all that.

the python library sends a single byte 0x0C

That was the trick. When I was looking here at a quick glance…I was reading it as 0x08 , 0x04. But clearly it is 0x08 | 0x04 (logicalOR == 0x0C).

I updated my code to the following :

TextDirectAccess.Write(new[] {TextCommandAddress, (byte)(DisplayOnCommandAddress | NoCursorCommandAddress)});

and now it works. Thanks Karan.

Great work guys! Thanks!

FYI. I created a nuget package…

https://www.nuget.org/packages/GrovePi/

I’m not sure its all available for download via visual studio yet as I just published it.

Exadon, if you have a nuget username I can add you as an owner.

Cheers
Jonathan

Jonathan, good to hear from you. My username on nuget is “Exadon”

Do you happen to have a GoPiGo? We created a Windows 10 library for it as well based off the GrovePi work.

also I submitted the repository to deters GitHub

I don’t have a GoPiGo. Will have to look at that. I am planning to look at adding Windows IoT support for BrickPi next, then hopefully use BrickPi and GrovePi together.

Sounds good. I ended up using the GrovePi and GoPiGo together with no problems.

Ill keep a look out for your BrickPi Win10 library.

Also do you mind updating Dexters repository as well with your latest changes?

Thanks.

Hi,

I was able to clone your repository into visual studio, thank you. Unfortunately I am completely new to this and I was wondering if you or anyone interested could do a quick tutorial detailing exactly how to get one of the sensors up and running.

Thanks again

Hello proconrpi.

First robsonj wrote a create readme.md file which can be found on his git hub here.That said I don’t mind walking you through a simple tutorial. I am assuming you know how to deploy a Universal Windows Application on your PI and just need help with using the GrovePi Win10 library. If that’s not the case let me know.

In your “Driver” project you should see a project called “Simple Driver.cs”. In this file you can see several quick samples of sensors.

Go ahead and clear out the “Run” method for now so it looks like this (paste bin for readability): http://pastebin.com/dP5iSKsn

        private readonly IBuildGroveDevices _deviceFactory = DeviceFactory.Build;

        public void Run(IBackgroundTaskInstance taskInstance)
        {
        }

the “_deviceFactory” is what we will use to build all of our Grove Sensors. Currently only the sensors in the starter kit are supported (and a few extras)

Alright, lets start with something easy. Lets build an led, grab its state, and turn it on. Plug in your Grove LED into pin D2 then add the following code : http://pastebin.com/t93Bmnu6

        public void Run(IBackgroundTaskInstance taskInstance)
        {
            //Build the LED sensor that is 
            //plugged into the GrovePi at port D2:
            var led = _deviceFactory.Led(Pin.DigitalPin2);
            
            //Grab the sensors current state. At this point 
            //it should = SensorStatus.Off
            var currentState = led.CurrentState;
            
            //Turn LED on
            led.ChangeState(SensorStatus.On););
        } 

In the code above we build an LED sensor, grab its current state, and turn it on. Note that many sensors function the same way as the LED including the Buzzer, Relay, SoundSensor, and ButtonSensor.

To show this lets build a simple button. plug in your Grove button into D2 and replace your code with the following: http://pastebin.com/W8bPCHgM

 public void Run(IBackgroundTaskInstance taskInstance)
        {
            //Build the button sensor that is 
            //plugged into the GrovePi at pin D2:
            var button = _deviceFactory.ButtonSensor(Pin.DigitalPin2);

            //Break out of while loop on button press
            while (true)
            {
                //Try catch to prevent error from reading
                //too quickly
                try
                {
                    if (button.CurrentState == SensorStatus.On)
                        break;
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }

Many of our methods can be chained together. For example you can build a sensor and read its value from the same line. Here on example : http://pastebin.com/EwehYWnG

        public void Run(IBackgroundTaskInstance taskInstance)
        {
            //This is the same as...
            var ultraSonicSensor = _deviceFactory.UltraSonicSensor(Pin.DigitalPin2);
            var measurementInCentimeters = ultraSonicSensor.MeasureInCentimeters();

            //This
            var measurementInCentimetersChain = _deviceFactory.UltraSonicSensor(Pin.DigitalPin2).MeasureInCentimeters();
        }

This is great if you simply need to get/set a value once and never use it again. Or if you want to build a sensor and act on said sensor all in one line.

You can use intellisense on _deviceFactory to get a full list of supported sensors so far. Let us know if there is a sensor you are looking for that’s not on the list!

Hope this helps some.

Hi there,

Thee is also a pre compiled nuget package available for this… NuGet Gallery | GrovePi 1.0.10

Also some examples on the master github repository…

Hopefully that helps. Let us know how it goes.

Cheers
Jonathan

Hi Guys,

I Just got everything ready to start playing with windows 10 on Rpi and GrovePi with a large variety of sensors.

I spent a lot of time setting everything Up and I finally found out that the only supported sensor that I have is Light Sensor! The project that you have made in so little time is great. Thank you very much for sharing everything.
Now lets go to the question(s)!
Are you planning to support more sensors in the future ?
As far as i am not familiar with Git , can i get the project, try to implement the extra sensors on my own and then share the code ?
The sensors that i have right now and i would like to use are :

  1. Temperature and Humidity Sensor Pro (Is not working Correctly with the Existing Code–For Sure not 13° in Greece right now!)
  2. Collision Sensor
  3. PiezoVibration Sensor
  4. 3-Axis Accelerometer (±16g)

Thanks

Hi There,

Glad its of help. I also put together a nuget package…

http://www.nuget.org/packages/GrovePi/

and the official github project is hosted at…

I will take a look at the temperature sensor. I noticed the temp was off on mine also, but seemed fine on another users, so I’m wondering if its the sensors themselves.

I would be happy to support more sensors, but I don’t own them. Maybe Dexter Industries would send some to code against and then return?

Let me know if you have any further issues, I’ll take a look at the temperature sensor when I get a chance. Feel free to raise an issue on the github repository for things you find.

Cheers
Jonathan

Hello Jonathan,

Thanks for the help.
I don’t know if it makes any Difference , but my Temperature Sensor Is The PRO edition . I don’t see a method to get the Humidity. Is there any way to get the Humidity ?

It would be great if Dexter Industries were willing to provide you with the sensors.
But if not , another possibility may be to share my sensors ,with you, over the internet. I could possibly provide you with a vpn connection to my LAN and connect the sensors to the GrovePi. Then , I think, you can code just like having the sensors next to you .
If it makes sense to try something like that , let me know .

Thanks

Hey Jonathan, we’d love to support further development of the sensors in Win10. Can you contact us through this link:

http://dexterindustries.com/contact.html

I’ll be happy to pickup the conversation over e-mail and see how we can get you a few of the sensors or a Starter kit for the GrovePi.

Playing around with the Lib and my sensors everything workes just fine right now.
What I have left from my Grove Starter Kit is the Servo Motor.
From the Thread http://www.dexterindustries.com/forum/?topic=how-many-motors it seems like Servos are not working with the GrovePI at all. When i attach a Servo it makes a short move when powering on, but it does nothing when it is accessed by Code.
Can you shed some light on this Topic? Why did you not get it working? It moves during powering up so whatever happens then it makes the Motor move.

Hello Guys,
Do you have any news on that ?
Are there any plans to update the drivers and include more sensors?
Do you have an idea on when will the drivers be available ?
Do you know which sensors are you going to support for now?

Thanks

@PatGet Currently the GrovePi does not support servo motors.

@d.emiliou You can download the library
Here. I have. It’s also on Dexter’s GitHub.

What sensors do you want us to support? We are happy to add anything you need :slight_smile:

Hello Exaxdon .

I got this library. The sensors that i need are missing.

The Sensors that i have are :

  1. Temperature and Humidity Sensor Pro
  2. Collision Sensor
  3. PiezoVibration Sensor
  4. 3-Axis Accelerometer (±16g)
  5. Light Sensor (Already supported)

Any plans for them ?

Thanks

@d.emiliou let me look into getting those sensors and then adding them to the library.