Grove Expansion Module

Anyone have any sample code of this running a Grove Sensor? I thought I’d try to make a Sound Meter using a Spider (4.1 still), Grove Expansion Module http://www.seeedstudio.com/depot/grove-expansion-net-gadgeteer-compatible-p-1084.html?cPath=203 and Grove - Sound Sensor http://www.seeedstudio.com/depot/grove-sound-sensor-p-752.html?cPath=144_148 but currently it can’t decide if it wants an A or K socket (ie keeps telling me it wants the other socket type).

I do have a number of Grove Sensors so samples of any sensor would be greatly appreciated.

Thanks

looking at the Arduino code below it looks like it’s an A socket…


const int ledPin =  12;      // the number of the LED pin
const int thresholdvalue=400;//The threshold to turn the led on
void setup() {
     pinMode(ledPin, OUTPUT); 
}
 
void loop() {
  int sensorValue = analogRead(A0);//use A0 to read the electrical signal
  if(sensorValue>thresholdvalue)
  digitalWrite(ledPin,HIGH);//if the value read from A0 is larger than 400,then light the LED
  delay(200);
  digitalWrite(ledPin,LOW);
 }

and BTW you can adapt this code to read the input… and don’t forget to checkout the light sense Driver to adapt it to your own…

cheers.

The problem I’m having is when I plug it into port 10 which is a A port I get:

An unhandled exception of type ‘Gadgeteer.Socket.InvalidSocketException’ occurred in Gadgeteer.dll

Additional information: Module GroveExpansion cannot use socket 10 because it requires a socket supporting type ‘K’

But when I plug it into say port 4 which is a K port I get:

An unhandled exception of type ‘Gadgeteer.Socket.InvalidSocketException’ occurred in Gadgeteer.dll

Additional information: Socket 4 does not support type ‘A’ required by GroveExpansion module, so you can see its rather messed up.

Here is the code I’m trying to get running.


using Microsoft.SPOT;
using GT = Gadgeteer;
using GTI = Gadgeteer.Interfaces;

namespace GroveTest1
{
    public partial class Program
    {
        private GTI.AnalogInput _input;
  
        void ProgramStarted()
        {
            _input = groveExpansion.SetupAnlogInput(GT.Socket.Pin.Three);

            GT.Timer _timer = new GT.Timer(500);

            _timer.Tick += new GT.Timer.TickEventHandler(_timer_Tick);

            _timer.Start();
        }

        void _timer_Tick(GT.Timer timer)
        {

            Debug.Print("tick");
            
            double volts = _input.ReadVoltage();
            double proportion = _input.ReadProportion();

            Debug.Print("volts: " + volts.ToString());
            Debug.Print("proportion: " + proportion.ToString());

        }
    }
}

What socket are you plugged into on the GroveExpansion board? Try making sure you’re plugged into one of the pure “GPIO” sockets and not a “GPIO/UART”. It may be that they are looking for something plugged into one of the UART sockets and have a bug that is forcing a “K” (UART) socket on the mainboard in that case. I don’t have any Grove equipment, so this is just a guess.

I tried this with nothing plugged in, and with the Grove Sound Sensor plugged into a pure GPIO socket, same problem.

Thanks

I’d start looking for the Seeed source code. Sounds like they may have a bug.

edit: how about trying just the groove module by itself … does it compile and run …?

i would also try to run the test application they have here:

http://www.seeedstudio.com/document/GroveExpansion.zip

and i think you will need to assign it a socket first before you can access pins like this:
which is missing from your code above.


GTM.Seeed.GroveExpansion groveExpansion = new GTM.Seeed.GroveExpansion(4);

Had to switch over to a Hydra Board as all my Spiders are busy running projects right now.

So with nothing plugged into the grove board and no code setting anything up (ie just the generated code), if I plug into socket 6 (K Socket), no problems, however if I plug into socket 14 (A Socket):

An unhandled exception of type ‘Gadgeteer.Socket.InvalidSocketException’ occurred in Gadgeteer.dll

Additional information: Module GroveExpansion cannot use socket 14 because it requires a socket supporting type ‘K’

Makes sense. They apparently can’t tell which sockets on the GroveExpansion module you’re using, so they’re requiring that you use a “K” socket because it covers all the bases :frowning:

OK I’ve had some success with a new driver as apparently the old one was pretty much junk (I’m starting to think the hardware geeks equivalent of ‘if it compiles, ship it’, is ‘if the led lights up, ship it’ or perhaps that is just Seeed’s rule) Now I’m not going to claim that the readings make any sense as sometimes they don’t, but at least I have something running which is a start.

The new driver looks pretty much exactly like the eblock expansion module driver, strangely enough :slight_smile:

Once I test this out some more I’ll post a sample project in Codeshare.

I’ve now have this working with a Cerberus board (running 4.2 of course), and I’ll try to build an installer etc for the grove extension module.

I’m loving that little Cerberus mainboard. I’m will definitely be picking up some more of those.

I’ve got a:

Error 1 The “Candle” task could not be loaded from the assembly C:\Program Files (x86)\MSBuild\Microsoft\WiX\v3.x\WixTasks.dll. Could not load file or assembly ‘file:///C:\Program Files (x86)\MSBuild\Microsoft\WiX\v3.x\WixTasks.dll’ or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. C:\Users\Blake\documents\visual studio 2010\Projects\CerberusAirSensor\GroveExpansion\GroveExpansion\GroveExpansion.csproj 93 5 GroveExpansion

problem which is messing up my release build, so guess what I’m looking at tonight.

@ Duke Nukem - I get the same error when I want to build in release mode. Did you find a solution for that error?

Install Wix 3.5

http://wix.codeplex.com/releases/view/60102

more info: http://www.ghielectronics.com/community/forum/topic?id=9924

That @ Justin guy is fast, and even has the correct answer.

@ Duke Nukem - ::slight_smile:

I would say: Not fast, JustIn time :wink:

Hell yeah! Thank you :smiley: