# SunFounder Basic Sensor Kit for Raspberry Pi



## balanga (Jun 16, 2017)

A couple of years ago, I bought the SunFounder Basic Sensor Kit for Raspberry Pi which includes sample source code for various projects. It is obviously geared towards Linux, but should I expect to be able to compile some of the examples on FreeBSD?


----------



## SirDice (Jun 16, 2017)

As far as I can tell it's all Python, assuming the GPIO Python library is available it should work as-is.

https://github.com/sunfounder/Sunfounder_SensorKit_Python_code_for_RaspberryPi


----------



## balanga (Jun 16, 2017)

Thanks, that's good to know... But which version of Python should I use?


----------



## aragats (Jun 16, 2017)

If you look in the source code, you can see that _*print*_ is a statement, e.g. `print 'relay off...'`, that means it's Python 2.7, since in Python 3 _*print*_ is a function, would be: `print ("relay off...")`.


----------



## Phishfry (Jun 16, 2017)

Gonzo has wrappers for GPIO that might help porting.
https://github.com/gonzoua/freebsd-gpio


----------



## balanga (Jun 17, 2017)

SirDice said:


> As far as I can tell it's all Python, assuming the GPIO Python library is available it should work as-is.



That could be the problem... I just tried the first program and get:-

```
ImportError: No module named RPi.GPIO
```

Not knowing anything about Python, I don't whether this is simply unresolvable because the paths or environment isn't set up, or maybe I need to download/build it... Chances that it will only work on Raspian.

Just found it here:-

https://learn.adafruit.com/playing-...spberry-pi/install-python-module-rpi-dot-gpio

and here:-

https://sourceforge.net/projects/raspberry-gpio-python/

But this looks more promising:-

https://github.com/evadot/fbsd_gpio_py


----------



## balanga (Oct 28, 2017)

balanga said:


> That could be the problem... I just tried the first program and get:-
> 
> ```
> ImportError: No module named RPi.GPIO
> ...



Just wondered if anyone has tried this....


----------



## balanga (Nov 6, 2017)

Further to my quest for a FreeBSD RPi.GPIO module, I asked on the RPi forum about how to build such a module and got this response:-


> If you have built Python 3.6 from source then it is as simple as :
> 
> 
> Code: Select all
> ...



I see that I do have a /dev/mem. Is it worth trying this?


----------



## aragats (Nov 6, 2017)

A while ago I experimented with /dev/mem for similar purpose for BeagleBone Black. It works, but you have to read/write all registers manually, kind of writing your own driver.


----------

