gadgetoid
Posts: 152
Joined: Wed Mar 07, 2012 9:58 pm

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 2:57 pm

At the moment PUD_UP, and all other constants are not defined in wiringpi. I was having problems with some other libraries trying to define them too ( although this was in Ruby ) and had made a mental note to see if there's a more graceful way to do it.

I'm in two minds about the constants, they hide the details of magic numbers which I think people should know, but on the flip side our goal is to reach Arduino levels of comfort and simplicity; so I'm going to add them back in!

It could also be that the wrapping code is not correctly passing the value of a pin from C to Python when reading, I will have to conduct some tests of my own.


Edit: A quick readback test seems to suggest that digitalRead is simply broken by my wrapper. Looking into it further.

Edit: Actually, I was being dense. My test was flawed. I need to hook up some buttons and try again.


Aha, for reference:

HIGH = 1
LOW = 0
MSBFIRST = 1
LSBFIRST = 0
WPI_MODE_PINS = 0
WPI_MODE_GPIO = 1
WPI_MODE_SYS = 2
MODE_PINS = 0
MODE_GPIO = 1
MODE_SYS = 2
INPUT = 0
OUTPUT = 1
PWM_OUTPUT = 2
PUD_OFF = 0
PUD_DOWN = 1
PUD_UP = 2

This is what I mean about hiding things like the value of PUD_UP in a constant. I had a feeling it was 2, but I had to double check.

Try using 2 instead of 1, and declare the above constants in your Python file for ease. I'm going to put them into the wrapper and push up a new version soon.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 3:34 pm

That'll be good :)

I'm perfectly happy with numbers just as long as there's a way of finding out what the heck they were.

It was months before I found out how to use the pullups in wiringpi 1 because there was no documentation for it (in the python version).



Yes - buttons-wp.py AND butled-wp.py now working :) I'm going to test the motor-wp.py now. Is there anything I need to know about PWM? :lol:
Alex Eames RasPi.TV, RasP.iO

gadgetoid
Posts: 152
Joined: Wed Mar 07, 2012 9:58 pm

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 3:56 pm

alexeames wrote:That'll be good :)

I'm perfectly happy with numbers just as long as there's a way of finding out what the heck they were.

It was months before I found out how to use the pullups in wiringpi 1 because there was no documentation for it (in the python version).



Yes - buttons-wp.py AND butled-wp.py now working :) I'm going to test the motor-wp.py now. Is there anything I need to know about PWM? :lol:
Good point about lack of documentation!

The only reason I knew what those values were is because I used an Arduino, I probably even lifted them right out of one of its library files.

PWM is a bit alien to me, although I have successfully tested softPWM with great and easy to achieve results.

I've no idea about hardware PWM though! That was on my to-do list to try.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri Mar 29, 2013 4:03 pm

Don't worry - it works. Lovely motor control with hardware PWM. Not only will your wrappers be done by WP2 launch day, but I've been systematically going through my Gertboard Python test suite. Just two programs to go, but all the functionality I need for those has already been tested. :D

motor-wp.py works nicely :)

so does open collector ocol-wp.py (just potmot-wp.py to go). :D

Now we are complete. potmot-wp.py works too.

OK. That's the basics out of the way. More advanced stuff next, after the break. :lol:
Alex Eames RasPi.TV, RasP.iO

gadgetoid
Posts: 152
Joined: Wed Mar 07, 2012 9:58 pm

Re: Don your testing hats, it's WiringPi2-Python

Thu Apr 04, 2013 11:19 am

Managed to compile onto Arch. Found a couple of build issues that had snuck into the PiPy package and fixed them. Eeek! If anyone has had an error about a missing README.rst, it's now fixed.

Compiling for arch needs: pacman -S base-devel, along with the usual requirements. Except Python-dev headers should just come bundled with Python, so no need to source them separately.

ACPI
Posts: 1
Joined: Fri Apr 12, 2013 1:17 am

Re: Don your testing hats, it's WiringPi2-Python

Fri Apr 12, 2013 1:29 am

Thanks to you and Gordon for this great stuff. The kids were having lots of fun with Gordon's tuxx example, and decided to convert to python so we can also roll in some pygame features to go with the physical lights. So I was very happy to come across wiringPi2. Anyway, am posting our tuxx.py here in case it could be useful for others. I am not a python programmer, so don't laugh too hard at this.

Code: Select all

#-------------------------------------------------------------------------------
# tuxx.py: (from tuxx.c)
#
#	Python version of Gordon Henderson's tuxx.c
# 
#   Tux Crossing. A variant on the UK "Pelican" crossing for
#	pedestrians going over roads.
#
# 	There is a set of Red, Yellow (sometimes called amber) and
# 	Green traffic lights to control the traffic, and a "Red Man"
# 	and "Green Man" indicators for pedestrians, and a button for
# 	them to push.
# 	Push the button and the lights cycle to Red, then the Green Man
# 	comes on (often with a beeping sound), then after a short while
# 	the Green man starts to flash, meaning to not start crossing,
# 	and the Yellow traffic light flashes too - meaning that if the
# 	crossing is clear, traffic can pass... Then after a few more seconds
# 	the flashing stops and it reverse to Go for traffic and Stop for
# 	pedestrians.
#
#-------------------------------------------------------------------------------

import os
import wiringpi2 as wp

# Our lamps:
#	(These are wiringPi pin numbers)

RED	      = 0
YELLOW    = 1
GREEN     = 2
RED_MAN	  = 3
GREEN_MAN = 4

# The input button

BUTTON    = 8

# Pin modes

INPUT = 0
OUTPUT = 1

# Button

LOW = 0
HIGH = 1

#
# setup:
#	Program the GPIO correctly and initialise the lamps
#-------------------------------------------------------------------------------
#

def setup():

    if (os.geteuid () != 0):
        print "tuxx: Need to be root to run (sudo?)\n"
        exit (0)

    if (wp.wiringPiSetup () == -1):
        exit (1)

    print "Setup ... "
    for i in range(0,5):
        wp.pinMode (i, OUTPUT)
        wp.digitalWrite (i, 0)
        print i

    wp.digitalWrite (GREEN, 1)
    wp.digitalWrite (RED_MAN, 1)
    wp.pinMode (BUTTON, INPUT)

    print "OK\n"

#
#  waitButton:
# 	Wait for the button to be pressed. Because we have the GPIO
# 	pin pulled high, we wait for it to go low to indicate a push.
#-------------------------------------------------------------------------------
#

def waitButton():

    print "Waiting for button ... "
    while (wp.digitalRead (BUTTON) == HIGH):
        wp.delay (100) 
    print "Got it\n"

#
# stopTraffic:
#	Cycle the traffic lights from Green to Red
#-------------------------------------------------------------------------------
#

def stopTraffic():

    print "Stopping traffic ... "
    wp.digitalWrite (GREEN,  0)
    wp.digitalWrite (YELLOW, 1)
    wp.delay  (2000)
    wp.digitalWrite (YELLOW, 0)
    wp.digitalWrite (RED,    1)
    wp.delay  (2000)
    print "Stopped\n"

#
# walk:
#	Signal the red/green man to walk and when time is up,
#	start the traffic light sequence to let the traffic move again
#-------------------------------------------------------------------------------
#

def walk():

    print "Walk now ... "

    wp.digitalWrite (RED_MAN,   0)
    wp.digitalWrite (GREEN_MAN, 1)
    wp.delay  (10000)
    wp.digitalWrite (RED,    0)
    wp.digitalWrite (YELLOW, 1)

    print "Walked\n"


#
# graceTime:
# 	This is the time when the green man is flashing, and the yellow
# 	traffic light is also flashing - to signal to pedestrians to not
# 	start to cross and to drivers that they can move on if the
# 	crossing is clear.
#-------------------------------------------------------------------------------
#

def graceTime():

    print "Grace time ... "

    for i in range(0,8):

        wp.delay (500)
        wp.digitalWrite (GREEN_MAN, 0)
        wp.digitalWrite (YELLOW,    0)
        wp.delay (500)
        wp.digitalWrite (GREEN_MAN, 1)
        wp.digitalWrite (YELLOW,    1)

    print "time up!\n"


#
# startTraffic:
#	Back to the Red Man and Green traffic light
#-------------------------------------------------------------------------------
#

def startTraffic():

    print "Starting traffic ... "

    wp.digitalWrite (GREEN_MAN, 0)
    wp.digitalWrite (RED_MAN,   1)
    wp.delay (500)
    wp.digitalWrite (YELLOW, 0)
    wp.digitalWrite (GREEN,  1)

    print "Going\n"


#
# The main program
#	Call our setup routing once, then sit in a loop, waiting for
#	the button to be pressed then executing the sequence.
#-------------------------------------------------------------------------------
#

print 'main'
setup()
while 1:
    waitButton ()
    stopTraffic ()
    walk ()
    graceTime ()
    startTraffic ()

texy
Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Don your testing hats, it's WiringPi2-Python

Fri Apr 12, 2013 10:20 am

gadgetoid wrote:At the moment PUD_UP, and all other constants are not defined in wiringpi. I was having problems with some other libraries trying to define them too ( although this was in Ruby ) and had made a mental note to see if there's a more graceful way to do it.

I'm in two minds about the constants, they hide the details of magic numbers which I think people should know, but on the flip side our goal is to reach Arduino levels of comfort and simplicity; so I'm going to add them back in!

It could also be that the wrapping code is not correctly passing the value of a pin from C to Python when reading, I will have to conduct some tests of my own.


Edit: A quick readback test seems to suggest that digitalRead is simply broken by my wrapper. Looking into it further.

Edit: Actually, I was being dense. My test was flawed. I need to hook up some buttons and try again.


Aha, for reference:

HIGH = 1
LOW = 0
MSBFIRST = 1
LSBFIRST = 0
WPI_MODE_PINS = 0
WPI_MODE_GPIO = 1
WPI_MODE_SYS = 2
MODE_PINS = 0
MODE_GPIO = 1
MODE_SYS = 2
INPUT = 0
OUTPUT = 1
PWM_OUTPUT = 2
PUD_OFF = 0
PUD_DOWN = 1
PUD_UP = 2

This is what I mean about hiding things like the value of PUD_UP in a constant. I had a feeling it was 2, but I had to double check.

Try using 2 instead of 1, and declare the above constants in your Python file for ease. I'm going to put them into the wrapper and push up a new version soon.
Hi,
first try-out with wiringpi2. Can't get the internal pull down enabling syntax correct. I have declared :

Code: Select all

import wiringpi2 as wiringpi
PUD_DOWN = 1
and the code for the gpio is :

Code: Select all

wiringpi.wiringPiSetup()
for pin in [UP, DOWN, SELECT]:
  wiringpi.pinMode(pin, IN) # set to input
  wiringpi.pullUpDnControl(pin, wiringpi.PUD_DOWN) # enable pull down resistor

....but I getting the error mentioned earlier i the thread :

Code: Select all

Traceback (most recent call last):
  File "testv1.py", line 80, in <module>
    wiringpi.pullUpDnControl(pin, wiringpi.PUD_DOWN) # enable pull down resistor
AttributeError: 'module' object has no attribute 'PUD_DOWN'
Where am I going wrong?

Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

johnnyvdberg
Posts: 6
Joined: Mon Mar 25, 2013 9:47 pm

Re: Don your testing hats, it's WiringPi2-Python

Fri Apr 12, 2013 1:28 pm

You're still trying to get the constant from wiringpi, use the global you made instead :)

texy
Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Don your testing hats, it's WiringPi2-Python

Fri Apr 12, 2013 1:54 pm

johnnyvdberg wrote:You're still trying to get the constant from wiringpi, use the global you made instead :)

Ah yes of course - this is the correct code :

Code: Select all

wiringpi.wiringPiSetup()
for pin in [UP, DOWN, SELECT]:
  wiringpi.pinMode(pin, IN) # set to input
  wiringpi.pullUpDnControl(pin, PUD_DOWN) # enable pull down resistor
Cheers ;)

Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri Apr 12, 2013 3:50 pm

I just used the number when I tried it :)
Alex Eames RasPi.TV, RasP.iO

shortyhughes
Posts: 8
Joined: Thu Sep 13, 2012 10:41 pm
Location: Co. Down, Northern Ireland

Re: Don your testing hats, it's WiringPi2-Python

Sun Apr 28, 2013 11:36 pm

This might be a completely daft question (and probably is) but is it possible for wiringPi and WiringPi2-Python to coexist? Reason I ask is I liked the feature of being able to do a quick check on the 'status' of the GPIO ports from terminal. :oops: :oops:
Why not jump in at the deep end and see if you can swim.......

gadgetoid
Posts: 152
Joined: Wed Mar 07, 2012 9:58 pm

Re: Don your testing hats, it's WiringPi2-Python

Mon Apr 29, 2013 7:26 am

shortyhughes wrote:This might be a completely daft question (and probably is) but is it possible for wiringPi and WiringPi2-Python to coexist? Reason I ask is I liked the feature of being able to do a quick check on the 'status' of the GPIO ports from terminal. :oops: :oops:
Yes, the two can co-exist peacefully. Just download, build and install WiringPi as normal.

shortyhughes
Posts: 8
Joined: Thu Sep 13, 2012 10:41 pm
Location: Co. Down, Northern Ireland

Re: Don your testing hats, it's WiringPi2-Python

Fri May 03, 2013 10:10 am

gadgetoid wrote:
shortyhughes wrote:This might be a completely daft question (and probably is) but is it possible for wiringPi and WiringPi2-Python to coexist? Reason I ask is I liked the feature of being able to do a quick check on the 'status' of the GPIO ports from terminal. :oops: :oops:
Yes, the two can co-exist peacefully. Just download, build and install WiringPi as normal.
Thank you for confirming my suspicions :P
Why not jump in at the deep end and see if you can swim.......

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri May 03, 2013 1:59 pm

gadgetoid wrote:With WiringPi 2, playing with an MCP23017 ( the chip found on the Quick2Wire expander and HobbyTronics expander amongst others ) is as simple as:

Code: Select all

import wiringpi2

pin_base = 65
i2c_addr = 0x20
pins = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]

wiringpi2.wiringPiSetup()
wiringpi2.mcp23017Setup(pin_base,i2c_addr)

for pin in pins:
	wiringpi2.pinMode(pin,1)
	wiringpi2.digitalWrite(pin,1)
You can then increment your pin_base to 81 and add another one there, giving you a seamless pair ( or more if you dare ) of IO expanders which you can very easily keep track of and enumerate.
Sorry it's taken so long Phil - busy busy. I've just tried the above with an MCP23017 and it works a treat. Thanks both.

If you want to add another, how is that handled? Do you split the i2c ports and give the second chip a different address on A0,A1,A2? Not quite sure how to wire/program that. [edit] I think I've figured that part out[/edit]

I've got some MCP23S17s to try as well. Got any pointers how to code that? After looking at the C directions for that, I'm a bit confused :lol: :oops: (I've made one of those work with a bitbang before, but I'd love to be able to do it with a "proper" spi driver).
Alex Eames RasPi.TV, RasP.iO

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri May 03, 2013 8:58 pm

OK, so I got three daisy-chained MCP23017 chips working. I do have 10, but I'm not going to be quite silly enough to try the maximum of 8 - maybe one day. :lol:

Having studied Drogon's site a bit more I think I've figured out the Python commands for the SPI variant. I'm going to try the following (without removing the i2c devices LOL)...

Code: Select all

import wiringpi2 as wiringpi

pin_base4 = 113 # already using up to 112 LOL
spiPort = 0 # using CE0
devID = 0 # all three ID pins to GND
wiringpi.mcp23s17Setup(pin_base4, spiPort, devID)
Yay - it worked :D, wonder if we can daisy-chain those or if we're limited to 2 spi ports? I think I read something somewhere (might even have been the data sheet about using one of the ports as the CS for the next chip).
Alex Eames RasPi.TV, RasP.iO

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri May 03, 2013 9:57 pm

alexeames wrote: Yay - it worked :D, wonder if we can daisy-chain those or if we're limited to 2 spi ports? I think I read something somewhere (might even have been the data sheet about using one of the ports as the CS for the next chip).
You're limited to the 2 SPI ports on the Pi - frankly I don't really want to put in extra code to wiggle GPIO lines (or use a mux) as the SPI CS lines. However you can connect up to 8 mcp23s17's on each SPI port, adding on 16 * 16 = 256 additional GPIO pins to the Pi using the SPI side, then if you really needed it another 8 mcp23017's on the I2C bus adding on another 128.

Then if you were desperate, you can use up to 4 595 shift-registers which use 3 pins to give you an additional 32 output pins per block of 4 595's. Using those .... etc. you'll run out of memory on the Pi to maintain the structures before you run out of potential GPIO ...

I "stress" tested it with a couple of 595 shifts using one pin from the Pi, one pin from an mcp23s17 and one pin from an mcp23017 to drive the clock/data/latch pins on the shift registers..

http://wiringpi.com/about/testing-wiringpi-v2/

-Gordon
--
Gordons projects: https://projects.drogon.net/

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Fri May 03, 2013 10:25 pm

Thanks Gordon. I think you're right, if it can't be done with 384 GPIO ports, it ain't worth doing :lol:
I've currently got 48 on i2c and 16 on spi and the regular onboard 8. It's probably enough for now.

I hadn't realised we could use the same hardware chip ID function on the same SPI port as we do with i2c. That is truly awesome because it gives us as many ports as we want, and those chips are very reasonably priced. :D

This is a really excellent addition to WiringPi-python.
Alex Eames RasPi.TV, RasP.iO

kevcook
Posts: 17
Joined: Sat Jan 19, 2013 5:57 pm

Re: Don your testing hats, it's WiringPi2-Python

Mon May 27, 2013 4:47 pm

Made an error here, still you learn. Upgraded to wiringpi2, changed all the programs. Gordons GPIO write etc all works as I expected BUT the Python side fails with *No module named wiringpi2* (or any variation thereof) can be found.
Wiringpi2 is all there and installed, everything followed to the letter on two RPis by two people and still the same message.

Import wiringpi2 followed by
"No module named wiringpi2*

hundreds of similar pleas on the net so it's a common problem but no-one has actually come up with a solution.

There must be a way of checking these files exist. Or are some Pis not looking everywhere when an import command is issued? I'd happily pay for a SD Card with it actually working!

texy
Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Don your testing hats, it's WiringPi2-Python

Tue May 28, 2013 11:53 am

How have you actally installed it?
I,ve installed it to 2 fresh images over the weekend without any issue using pip.

Code: Select all

sudo apt-get install python-dev python-pip
sudo pip install wiringpi2
That is from memory - I can confirm exact commands later............

Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

kevcook
Posts: 17
Joined: Sat Jan 19, 2013 5:57 pm

Re: Don your testing hats, it's WiringPi2-Python

Fri May 31, 2013 11:50 am

Some movement.
It appears to import and 'some' commands work such as :-
delay, PiBoard etc BUT not the GPIO commands such as wiringpi2.pinMode (1,1) and wiringpi2.digitalWrite(1,1) etc.
I have prefixed the commands with wiringpi2.wiringPiSetupGpio and Sys also.
The GPIO commands write,mode etc work in bash and from the command line so the electronics are OK and I've tried two RPIs. I've got an LED on the pins as well as a meter but nothing from the Python script.
I've reloaded wiringpi2 also.
The commands do not work under sudo Python either.
There has to be a reason or some further tests I can carry out before I give e-bay a ring!
The code is:-
import wiringpi2
wiringpi2.wiringPiSetup # and variations thereof
wiringpi2.pinMode(1,1) // Set pin 1 to output
wiringpi2.digitalWrite(1,1) // Write 1 HIGH to pin 1
wiringpi2.digitalRead(1) // Read pin 1

Kevin

texy
Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Don your testing hats, it's WiringPi2-Python

Fri May 31, 2013 12:48 pm

eBay ????

Difficult to diagnose without a pi in front of me, but here is a some code of mine that reads 3 switches using wiringpi2. Note that one of tha common problems is not switching the gpio line you think you are switching, ie the wrong mode being selected. In this case I have selected wiringpi mode, not bcm, so UP is physical gpio port pin 21, for example.

Code: Select all

import wiringpi2 as wiringpi
IN = OFF = 0
OUT = ON = 1
PUD_DOWN = 1

UP  = 13     # gpio pin 21 = UP
DOWN  = 2    # gpio pin 13 = DOWN
SELECT  = 11 # gpio pin 26 = LEFT

#set up the gpio's for the 3 buttons
wiringpi.wiringPiSetup()
for pin in [UP, DOWN, SELECT]:
  wiringpi.pinMode(pin, IN) # set to input
  wiringpi.pullUpDnControl(pin, PUD_DOWN) # enable pull down resistor

# run the loop
while True:
    input_value1 = wiringpi.digitalRead(UP)
    input_value2 = wiringpi.digitalRead(DOWN)
    input_value3 = wiringpi.digitalRead(SELECT)
    print "UP = ",input_value1
    print "DOWN = ",input_value2
    print "SELECT = ",input_value3
    time.sleep(.5)
I know this is reading an input, not outputing to an LED, but I hope you get the idea. Note - code untested, as I,ve taken loads out...........

Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

mattura
Posts: 20
Joined: Tue Aug 14, 2012 6:51 pm

Re: Don your testing hats, it's WiringPi2-Python

Thu Aug 29, 2013 8:37 pm

gadgetoid wrote:Managed to compile onto Arch. Found a couple of build issues that had snuck into the PiPy package and fixed them. Eeek! If anyone has had an error about a missing README.rst, it's now fixed.

Compiling for arch needs: pacman -S base-devel, along with the usual requirements. Except Python-dev headers should just come bundled with Python, so no need to source them separately.
I am trying to install wiringPi2 on Arch, but I get this:

Code: Select all

WiringPi/wiringPi/max31855.c:25:22: fatal error: wiringPi.h: No such file or directory
compilation terminated.
I'm not good with c code, any ideas?

mattura
Posts: 20
Joined: Tue Aug 14, 2012 6:51 pm

Re: Don your testing hats, it's WiringPi2-Python

Sat Aug 31, 2013 5:14 pm

mattura wrote:
gadgetoid wrote:Managed to compile onto Arch. Found a couple of build issues that had snuck into the PiPy package and fixed them. Eeek! If anyone has had an error about a missing README.rst, it's now fixed.

Compiling for arch needs: pacman -S base-devel, along with the usual requirements. Except Python-dev headers should just come bundled with Python, so no need to source them separately.
I am trying to install wiringPi2 on Arch, but I get this:

Code: Select all

WiringPi/wiringPi/max31855.c:25:22: fatal error: wiringPi.h: No such file or directory
compilation terminated.
I'm not good with c code, any ideas?

Never mind, I tried a fresh install of arch, wiringpi and wiringpi2 and it compiled this time

User avatar
meltwater
Posts: 1014
Joined: Tue Oct 18, 2011 11:38 am

Re: Don your testing hats, it's WiringPi2-Python

Mon Sep 16, 2013 9:27 am

1st off, I have only been using WiringPi2 recently and really like it, particularly the implementation of how the I/O expanders work.

I've been trying to use the LCD library with the Adafruit LCD character display (http://wiringpi.com/examples/adafruit-r ... -wiringpi/) but I can't get it to initialise correctly. Have I missed something out?

I'm just wondering if anyone else has had issues with this using Python.

Code: Select all

import wiringpi2
import time

AF_BASE=100
AF_E=AF_BASE+13
AF_RW=AF_BASE+14
AF_RS=AF_BASE+15

AF_DB4=AF_BASE+12
AF_DB5=AF_BASE+11
AF_DB6=AF_BASE+10
AF_DB7=AF_BASE+9

AF_SELECT=AF_BASE+0
AF_RIGHT=AF_BASE+1
AF_DOWN=AF_BASE+2
AF_UP=AF_BASE+3
AF_LEFT=AF_BASE+4
AF_BACK=AF_BASE+5

AF_GREEN=AF_BASE+6
AF_BLUE=AF_BASE+7
AF_RED=AF_BASE+8 #PB0

wiringpi2.wiringPiSetup()
wiringpi2.mcp23017Setup(AF_BASE,0x20)
wiringpi2.pinMode(AF_BLUE,1)
lcd=wiringpi2.lcdInit(2,16,4,AF_RS,AF_E,AF_DB4,AF_DB5,AF_DB6,AF_DB7,0,0,0,0)
wiringpi2.lcdHome(lcd)
wiringpi2.lcdPrintf(lcd,"Hello This is a Test")
wiringpi2.digitalWrite(AF_BLUE,1)
Things which may be an issue:
1. I’m trying to achieve this with Python3. The same circuit seems to be wired correctly (it works fine with the Adafruit example code with Python2.7) and I’ve checked the pin mapping matches the Af_ defines.
2. Using a 3rd party LCD (but does the same on two totally different models - including a 4 line one - works ok with the Adafruit lib but not wiringpi2).

Any thoughts? Thanks in advance.

UPDATE:
I've rewired it without the I/O Expander and got it to work. So shall retry with the I/O Expander now.
UPDATE2:
It was the R/W Pin not being controlled by the LCD Lib. All sorted.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Don your testing hats, it's WiringPi2-Python

Mon Sep 16, 2013 9:06 pm

meltwater wrote:1st off, I have only been using WiringPi2 recently and really like it, particularly the implementation of how the I/O expanders work.
Beautiful simplicity isn't it? It's my favourite WP2 feature so far as well, but I still have a couple to play with. :lol:
Alex Eames RasPi.TV, RasP.iO

Return to “Python”