I have covered the FriendlyArm NEO and NEO2 boards here before now and generally been in favour – but for one little item in common with many other boards – little or no IO support – well, that just changed. Read on…
With no apparent way to get to the IO on this cute little board, I promised I would write to FriendlyArm and ask for WIRINGPI and that I did. In the meanwhile if you take a look at the relevant blog entry you’ll see I made a start at using GPIO the hard way and even found a WIRINGOP (OP – Orange Pi) variation that would do basic IO if you could guess the right IO pins, but that was about it.
Days later I received an email from FriendlyArm asking me to test their new WIRINGNP (as they call it) for both the NEO and NEO2. I rushed to do the updates they suggested for existing setups but I hit a couple of snags (and reported my problem) – but they’ve also brought out a new ROM with the updates incorporated so I tried that on the H5-based NEO2. They have a WIKI on the subject. There are C examples for setting up soft PWM etc etc - but here I mainly use the GPIO utility that runs as user Pi and hence can easily be called from Node-Red or indeed – the command line.
The Ubuntu command line is pretty much what you might expect on any similar “Pi” and certainly it runs my script so I had no trouble testing the new WIRINGNP as they call it. I was particularly interested in the GPIO program which a non-root user can run from the command line.
Using their npi-config menu-driven command line tool I told the NEO2 I want to use PWM – you can also set audio, the welcome message, serial, I2c, SPI and PWM enable/disable. At that point the board rebooted with the new settings.
Now- I’m terribly excited, the serial setup allows for enabling and disabling serial ports 0-3 (yes, FOUR serial ports) with serial port 1 enabled – we’d discussed this by email and this is what I was expecting – I didn’t expect a nice, easy menu setup for this – well done if it works…
After some diversion as they originally chose to refer to physical pins as against wPi or BCM pin designations - I eventually realised that pin 38 (on a separate 4 pin connector) is the hardware PWM pin
gpio mode 1 pwm
gpio pwmr 1024
gpio mode 38 pwm
gpio pwm 38 100
The first four lines are setup and I discovered that line 1 was necessary despite being of no relevance to this board (1 on the Raspberry Pi is the PWM pin) – the setup for pin 38 follows as the second last line before setting the PWM value to 100 (out of 0-1024). A handy LED on pin 38 confirmed that the hardware PWM on that pin works. I've asked FriendlyArm to check. Also if the LED load on this pin is too heavy, reboot does not work but that I think is more down to the H5 processor.
Note also there is some kind of screen debug output when you run these commands and the C example – again I’ve reported that back to FriendlyArm as you don’t get this on the Rasperry Pi.
You can’t do any other kind of PWM on the other pins using GPIO – but that also applies to the Raspberry Pi.
For simple GPIO – let’s say pin 12
gpio mode 12 out
gpio write 12 1
Works a treat.
FriendlyArm also have conveniently made a user PI – so you don’t even have to create that though they persist on their site in assuming quite often that you are user ROOT – I have suggested they think about that as people are usually encouraged NOT to run as root. Running my script is as simple as dropping it into the PI directory – giving it execute permissions and running it. I ran my script to install Node-Red etc., so I could check out the serial ports. Serial port 0 is normally used for debug and FriendlyArm suggested making serial port 1 available by default.
As you can see in the image of my Node-Red setup for the serial ports (standard serial node) – I hooked up all 4 serial ports and in the case of serial port 1 – I shorted the input and output pins together. As you would expect – injecting into the ports brought back failures in 3 of them as they’re disabled – but in the second case – the timestamp was sent back. Perfect. I’m out of time but quietly confident the rest would work if I needed them. So in just this one respect – compare this to the Raspberry Pi 3 – it has Bluetooth and that conflicts with the serial port – you don’t actually have a spare serial port – here you have three.
At the end of this – the little NEO2 is going to end up talking to an Arduino Mega running that 433Mhz RFLink board as well as lots of other tasks.
I have yet to test SPI but as it stands – these boards are in very select company in getting support from their own manufacturer! Also - see the blog entry on the NAS - which ends up being about the NEO2 - thanks to the open source Bakebit I now have OLED displays running on these boards.
The following day I received an update: We’d discussed the various naming systems for pins – physical – ie. the actual pin number, wPI (Wiring Pi) and the BCM numbering schemes. I suggested physical was probably best – but when the update came they’d implemented both for those for programming in C.
//using wiringPi Pin Number
int pin = 18;
//using Physical Pin Number
int pin = 38;
//using BCM Pin Number
int pin = 5;
Well, I thought that was quite satisfactory! Here’s a little test I tried – on physical pin 38…
such a program needs to be compiled as such:
gcc -Wall -o flashtest flashtest.c -lwiringPi -lpthread
The end program needs to be run as root - WHY!!!!!!!
Anyway, sudo ./flashtest works – and I tested in the Node-Red EXEC function – it works in there (again using sudo - no big deal). So it should be possible to make little C programs to do just about anything you want with GPIO and call them from the EXEC node – which conveniently tells you when they’ve finished running – WITHOUT holding up the show!
More later – I’m hoping they’ll get rid of some debug stuff in there but this according to the WIKI can be setup for both the NEO (cheap) and the NEO2 (more powerful).
MEANWHILE a parcel turned up this morning – up to now I’ve not used the heatsinks on the NEO2 – ok it gets quite warm but not stinking hot – however – as the heatsink and board conveniently fit into the cute 3d printed box… I’ve now fitted it… all looking very spiffy. Ok, 3d printed cases are not perfect- but for this – good enough!