Programming grove pi board in C


Actually I am trying to write C program for reading temp,humidity and light sensor. Is there any sample program to read dht and light sensor using C. Which header files I need to mention in the program.

Thanks in advance.

Right now the GrovePi does not support C but it should not be too hard to make a C/C++ port for it. The firmware is written in C/C++ but the software that interacts with the GrovePi is written in Python/NodeJS and Go. The interaction on the hardware takes place using I2C. There are I2C libraries available for C which can be used for using the GrovePi . There has not been a lot of demand for the C library hence we have not built. Do let us know if you are interested in writing it.

Another thing that we can do is to make a TCP socket server in Python which could take the commands from a socket client and do the necessary actions on the GrovePi . This should be easier to do since you wouldn’t have to write and code for I2C. Do let us know what works for you and we would be happy to help you in any way we can.


Hi Karan,
it seems the Software/C directory disappeared from the GrovePi(+) librairies on GitHub… (several posts on the forum send to a Software/C link that is now a 404 error).

At which step did you stop support this language?
Do these programs went into the SoftwareC++ folder?
Is there a way we could have access to what existed previously in C?

Thanks for letting us know.


Hi @vberry,

We’ve changed the name of the resource/folder since the library is no longer written in C, but in C++.

Here’s the new link to our C++ library for the GrovePi platform:

And what we had in C back then is no longer available.
This new library is better than the old one, which wasn’t complete.

Does this solve your request?

Thank you!

Hi Robert,
thanks for your answer.
Unfortunately, we used the library last fall term with students that learn C programming (not C++, which contains more concepts, to be learnt later in the teaching program), and planned to do so this year again, hence my surprise :wink:

If, exceptionally, we could have access somewhere (e.g., a temporary link) to the latest version of the C library that existed before it was made unavailable, this would help us.

Thanks :cold_sweat:

Hi @vberry,

We are slowly moving away from C language because C++ is way more powerful.
Even though C++ is primarily object-oriented, we haven’t used classes in this library, so you’ll still be able to write procedural code. Within your source code, you’re still going call functions in order to interface with the GrovePi.

If you really have to use the old library, then sure, no problem, here’s a link to it:

This points to the latest commit where the C library was still intact.
As long as the API doesn’t change, yes, you can still use this library.

Part of the benefit of working with version control systems (such as git) is that you can revert the repository to any point in time after its creation.

Thank you!

We’ll start moving to the Cpp library if it’s not using classes and simply providing functions that will compile in C (or that can be easily adapted).

Thanks for all.

Hi @vberry,

Please, take a look at the C++ example programs and see if it suits you.

Do you think we should add something else to this library or does this look fine for you?

Bottom line is:

  1. What do you think of it?

  2. How can we improve it?

  3. What would be the best approach for you?

We appreciate a lot the feedback from our customers.

Thank you!

Hello @RobertLucian,
I think this C++ is designed for Debian/Raspbian OS on raspberry, but I implemented a Windows 10 IoT on it. Now when I try to compile these code on VS 2017, there is always some files which can not be found. I guess the are just something in the toolchain. So which toolchain do I need to compile the code? Or these c++ code is not suitable for Windows 10 IoT and I need to use the windows library? Now problems mainly exist in I2C.

Thanks in advance

Hi @johnzuo,

All you need for it is the g++ compiler and the said libraries for Linux. The libraries that need to be included are listed here - I highlighted those that are needed:

As it looks like, some of them are specific to Linux, so you won’t be able to compile programs in Windows 10 IoT.

So, yeah, we had Linux in mind when we created this library. Hope this makes it clear.

Thank you!