Azure IOT for the GrovePi

Hi,

I’m trying to access the LED on the D4 port but without using the GrovePi libraries. (The GrovePi LED blink code sample works fine).

FYI - I am trying to follow an Azure IOT tutorial (which internally uses wiringPi) which is using the following line of code:

const int GREEN_LED_PIN = 5;
writeToPin(GREEN_LED_PIN, HIGH);

Any ideas please as to what I’m doing wrong - am a newbie and slightly lost at the moment.

Thanks!

Hey @tejanb,
Couple of followup questions for you:

  1. How are you programming the GrovePi? We’re a little confused about using wiringPi, can you be a little more specific?
  2. Do you have a link to the tutorial you’re referencing?
  3. Why do you think you’re doing something wrong?

Thanks! We can’t wait to help!

Hi John - Thanks so much for the quick response.

  1. The tutorial is based on connecting LEDs to the Raspi using a breadboard and the code uses wiringPi to blink the LEDs. This is working without any issues and the code used (main.c and wiring.h) is attached for reference.
    Now, I am trying to use the GrovePi LED and other sensors instead of connecting to the regular LED via breadboards, etc. However, I’m unsure what changes I need to make to the code to get this to work. Henvce, my original question about how we can access GrovePi sensors directly (i.e. without using the GrovePi api).

  2. The course is an open course offered by Microsoft on the edX platform. The link is at the url below:
    https://www.edx.org/course/developing-iot-solutions-azure-iot-microsoft-dev225x

  3. Everyhting works fine and LED blinks when connected via breadboard and using the attached code files. But not working if I plug in the GrovePi LED instead.

wiring.txt (3.7 KB)
main.txt (5.9 KB)
Thanks!

Ok, I think this clears it up a little bit. Let me know if I have understood correctly:

  1. Your code was used to connect an LED directly to the GPIO pins of the Raspberry Pi, using a breadboard and jumpers.
  2. You are looking to turn a Grove LED on and off with the GrovePi.
  3. You are using C.

Is this right?

The short answer is: If you want to use C/C++ with the GrovePi, you can see our library for the GrovePi and C++ here. To control an LED on and off, we have a blink example in C++ here.

The longer answer is that moving from GPIO control of sensors and inputs is going to be a little different than copying over the code directly. The GrovePi sits between the Raspberry Pi and sensors/LEDs and takes commands from the Pi using I2C.