Category Archives: Raspberry Pi 3

RPI Prototyping

Prototype boardRemember a few blogs back where we were talking about prototyping boards for Raspberry Pi and similar and I showed a sample board and someone came back and said “Ah but you can get cheaper on AliExpress” – well, I bought one…

Here’s the link - £1.09 in sterling, free postage…. and I have to say… pretty good. Took a few minutes to solder the gold plated connector – holes are PTH and look ok.

So – if you click on the image you might get a larger version… the board came with the connector and nuts and bolts which I managed to lose within minutes of bringing the board into my office.  So you get a 5v rail and ground rail on the left. Over on the right there are full length 3v3 and ground rails and a whole line of holes for every pin (other than ground and power as you already have them).  The rest are all uncommitted runs.  

I have to say, for that price if you’re into tinkering – it’s a winner.  Should work with any of the Pi-type boards with the same connector – though clearly some of the IO pins will be wrong on some boards.  Very nice – just ordered another one.

Facebooktwittergoogle_pluspinterestlinkedin

Enter Monitorix

MonitorixI recently did a post asking for input about useful tools for the Raspberry Pi and other SBC boards and the first to some out of this is Monitorix.

This is just a short blog – I’ve not had enough time to ensure I understand the usefulness of this – but at least on the Pi3 (which is happily running on my desk from a hard disk!!)  and at least in the short time I’ve played with it – this looks like a useful tool. Reader @thebaldgeek pointed me to a system monitoring tool called Monitorix – sadly the first set of online instructions I read failed miserably – however after a short exchange of messages we got it running.

Continue reading Enter Monitorix

Facebooktwittergoogle_pluspinterestlinkedin

The Script and RPI 3 Update

Having started putting together “the script” a long time ago, long before the Raspberry Pi 3 came out – and having developed it to handle a wide range of boards and scenarios including of course the Pi3, I found it interesting to return today to installing “the script” on the Raspberry Pi 3 – and of course I wanted to ensure that nothing had changed recently which might stop others doing the same.

Continue reading The Script and RPI 3 Update

Facebooktwittergoogle_pluspinterestlinkedin

Grafana and InfluxDB

GrafanaSome time ago I wrote a blog entry about garden sensors inside of which was buried some information about using Grafana and InfluxDB. At the time the install was not that easy – and when along came STRETCH for the Raspberry Pi (2 and 3) it got worse.

However, reader Antonio and I have been working on this and we have an install for the latest Grafana with Influx.

Continue reading Grafana and InfluxDB

Facebooktwittergoogle_pluspinterestlinkedin

The Real Raspberry Pi

I’ve been using the likes of FriendlyArm boards and similar for so long now, struggling at first with GPIO and I2c and as regular readers will know, finally pretty much mastering it due to hard research and more importantly, the works of people you’ll find links to in other articles in here….. that I’ve pretty much ignored the actual Raspberry Pi for some time.

Until this week when my friend Jonathan sent me a Raspberry Pi 3 to check, as he’s been having trouble with “the script” and I could not help as my RPI2 installations worked just fine.

Continue reading The Real Raspberry Pi

Facebooktwittergoogle_pluspinterestlinkedin

Raspberry Pi 3 Serial

Just bought a new Raspberry Pi 3 with WIFI and Bluetooth?  Using it in a project with serial? Happy?

Well, you might not be so happy when you find out what I just found out.  I had my Node-Red project that has been controlling the house for around 18 months on a Pi2 and I was starting to have issues -  I thought it time to upgrade. So I made a new installation, faithfully copied everything over, plugged in the board… everything was fine.

Except it wasn’t – nothing was coming out of the serial port. Well, it turns out they stole the serial port for the Bluetooth. There is a second port – of a kind – which can be set to work with the GPIO pins 14 and 15…  but Node-Red serial node was NOT having it – I put a scope on the output – nothing.  I followed instructions to use an alternative “serial port” – which appeared and – the Node-Red Serial port input would not recognise it.

Anyway, it isn’t all bad – thanks to Dave at IBM who put me onto this link…

http://raspberrypi.stackexchange.com/questions/45570/how-do-i-make-serial-work-on-the-raspberry-pi3

Ignore most of the content and head to the end – Answer number FIVE.  This got me back up and running with a high speed serial port – but – no Bluetooth of course. I’m assuming I can just stick in a Bluetooth dongle – time will tell.

Essentially assuming an up to date Pi3, the key line is the one where you add

dtoverlay=pi3-miniuart-bt”"

to the /boot/config.txt file.

I’m liking FriendlyArm more and more (I’d like them even MORE if they’d put more RAM in their boards) but at least, for today, I’m up and running.

Facebooktwittergoogle_pluspinterestlinkedin

I2C Expansion for Pi and ESP8266

Pi ExpansionWant 64 GPIO pins on your ESP8266 or Raspberry Pi? Read on.

If like me you are not THAT familiar with I2c, you might find the results of my  experiments interesting and perhaps even useful.

If like me you are not THAT familiar with I2c, you might find the results of my  experiments interesting and perhaps even useful.

PCF8574TSo I bought a couple of these i2c port expanders from China – mainly because I wanted something simple to mess with i2c on the ESP8266. It occurred to me that if I could get these working on a Pi, so I was sure of the addresses and commands etc., then on the ESP, I’d then get the confidence to do something more dramatic on the ESP8266 with i2c.

So ignoring for a minute the interrupt capability, these are pretty basic devices – using up 2 port bits (SDA and SCL) on your Pi or ESP, send an i2c start to them followed by an address then a byte to them – and the outputs light up accordingly. Set the outputs to 255 and read back a byte and you get the state of the pins as inputs. It doesn’t get any easier.

Well, not unless you completely mis-interpret the addressing as I did and spend ages chattering away to the wrong address. Anyway, let’s not dwell on that.

I noted that the outputs are HIGH by default.  Also note that in my experiments I have set the 3 DIP switches to ON (NOT as in the photo above).

Armed with the latest version of Raspbian Jessie on a pi2 or Pi3, connect ground on the device to ground on the Pi, VCC to 3v3 on the Pi, SDA to SDA (blue) on the Pi, SCL to SCL on the Pi. Simples. The boards have built-in pull-up resistors for i2c (which could pose an issue if you parallel a bunch of them up of course) so that’s it – no other new components needed other than a LED for testing. I used a 470r resistor in series with the LED.

Open a terminal on the Pi and type:

sudo pigpiod

That starts the new GPIO library daemon running in the background.

Now here is a short file that will set all the outputs to 0 – running Python…

import pigpio

pi1 = pigpio.pi()
pi1.write(18, 0)

b=pi1.i2c_open(1,39)
pi1.i2c_write_byte(b,0)
pi1.i2c_close(5)

Nice but then my pal Peter Oakes pointed out to me that I’d end up loading the entire Python environment  every time I wanted to change an output.. so I started experimenting with C code… just turning GPIO18 (on the Pi) on and off for starters…. see the line that says gpioWrite(18,0);  that turns the port off. Substitute a “1” to get the opposite effect.   All of this worked a treat.. “b” here ends up containing a handle.

#include <pigpio.h>
#include <stdio.h>

void main()
{
if (gpioInitialise() < 0)
{
puts("erm no"); // pigpio initialisation failed.
}
else
{
gpioSetMode(18, PI_OUTPUT);
// pigpio initialised okay.
gpioWrite(18, 0);
}
}

The code above once compiled failed the first time – I realised you must NOT have the daemon running when using this. so a quick reboot later and I was in business.

Oh, here’s how to compile a simple C program like that – make sure it’s a text file, say in your /home/pi directory.

gcc -Wall -pthread -o prog prog.c -lpigpiod_if2 –lrt

See where it says “prog” – change that to the name of your program. Takes seconds.

Anyway, I was just about to set everything up in C for i2c etc. when I discovered… PIGS

sudo pigpiod
pigs w 18 0
pigs w 18 1

Note – no sudo needed for the commands and presumably one would run that daemon (pigpiod) at startup. This looked like a nice simple route – dead easy for Node-Red as you can just issue the commands in an EXEC function and pass the parameters in the payload – so next would be to try i2c….

pigs i2co 1 39 0
pigs i2cwb 0 0 0
pigs i2cwb 0 0 255
pigs i2cwb 0 0 1
pigs i2cwb 0 0 2
pigs i2cc 0

The first command visually returned 0 – hence my use of 0 later in the code as the “handle”. I order, I set the expander to all off, all on, then the first bit only on – then the second bit only on and finally I closed the handle.

Something to note is that I2c lines need pull-up resistors – and this board has them already built in – unfortunately they are 1k pullups – fine if you only have one board, not a lot of use if you want to put several in parallel. After discussion we think that possibly the two relevant resistors might be replaced by 10k in which case you could then run several in parallel (with different addresses) but we’ve not tested that.

Oh, making that daemon permanent… I did that with a command line edit “sudo nano /etc/rc.local” -  and added the line “sudo /usr/bin/pigpiod” – and rebooted…. no problem.

Update November 9, 2016

The final stage of this experiment gives my ESP8266 software the ability to achieve the same thing, losing 2 wires to get 64 new ones (YES, 64), a net benefit of 62 I/O lines, could be worthwhile as the ESP8266 isn’t exactly brimming with IO lines.

I2C

Above you see (blue) our ESP-12 board, fastened to an FTDI for power, and wired by jumper to one of the PCF8574T boards - clearly you'd need 8 of them to get 64 lines and I'd be wary as they have pullup resistors on the data lines. I'd remove them on all but one.

With a typical Chinese PCF8574T board which includes pullups, I’ve added new commands to the ESP8266 Home Control software as of my software version 1.6.52 – the xport command.

Example:

{xport:0,1}

sets the lowest bit of the first (address 39) expander high (the 0 is a mandatory argument above – see future blogs) whereas:

{xport:0}

returns the state of the first (LSB) bit of the first of up to 64 bits.

On power up these devices are HIGH - and the software defaults to high on power up. If you mess with a port bit, you need to set a bit high before you can use it as an input. Here is the datasheet for this chip – and here is a typical Chinese expansion board.  With GPIO4 on our little boards hooked to SCL and GPIO5 hooked to SDA – the new commands work a treat.

In the above photo – address 39 equates to all DIP switches set to ON (that’s high or 7). If you set number 3 to off – that is address 38 (bits 8-15) etc. (simple binary selections – you can make the device work as anything from 32 (all switches OFF) to 39 (all switches ON) but before you go connecting eight of them up – bear in mind the comments about pull-ups above.

I’ve been doing a little more on these as you’ll see in other parts of the blog – but the upshot is – you have to ask yourself if these are worth the money. In my original blog I pointed to an Ebay price of £2.35  - but in fact from AliExpress they are only £1.20 and so I’ve amended the link in the blog accordingly.  However as you’ll see in other blog items – as I’ve learned I’ve realised they are not necessarily the best bet. I’ve now made a simple “Nano i2c peripheral” from a Nano board – and they cost just a few pence more – but you can make  NOT only an 8-bit expander but also get some A/D, some PWM and some A/D thrown in – hell I’m even putting an LCD display driver in just for the sake of it – and I’ll call it the kitchen sink peripheral.

However if you do like the look of these chips, you’ll note they say they work on 100Khz I2c. That of course is true and I’ve not experimented with anything other than close up – lets say less than 250mm away – but I’m currently running them a HELL of a lot faster than that. I’ve only speeded up the clock for writes and reads – note the wide bits around the edges but still – quite nippy.

faster I2c

Hope you found the above useful. For more information on the ESP software – go to the relevant page on the blog. There is of course the main Home Control 2016 page.

Facebooktwittergoogle_pluspinterestlinkedin

Sparkly new Pi

Just a very quick one (and somewhere to park the conversation)– there’s a new Raspberry Pi update out promising a new smoother, simpler look, better video etc. Up to now it looks like the claim is correct.

I have several RPI installations…including TightVNC and so I didn’t want to lose that. I did however, want the Chromium browser. I’m not interested in PI-HATs and similar so here’s all I did to get the upgrade…

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install -y rpi-chromium-mods

That’s it – nothing more –takes a few minutes all in - there is one Y for confirm and a reboot – and Bob’s your uncle. To test things out I went to the BBC website and of course got the usual message about Flash – things haven’t change there much – but with a signup for the BBCs “beta” HTML5 version (it’s a bit late for a beta, isn’t it? HTML5 has been out  for longer than I can remember) all is well, videos no problem!

New Pi Interface

The new interface is to be given it’s own name “PIXEL” – that’ll make searching for information about it a whole lot of fun… they could have picked something unique like “PIXL” or something – however it all seems to work – more modern appearance – slick – file manager is nice and apparently if not faster it is at least no slower than it’s predecessor so really no reason not to go for it.

Here’s the link in case you need more info. Given this new look – with hardware graphics support – which likely means you could be using your Raspberry Pi 3 for a media centre… AND the best backup program out there which can replicate the system even on a different size SD  -something as far as I’m aware NO-ONE else has – one has to ask – what are the other SBC board manufacturers going to do now!!!

Facebooktwittergoogle_pluspinterestlinkedin

NOT Rip-Off Britain for Raspberry Pi

Here’s a bit of a reversal.. normally I steer clear of the UK for pricing as we tend to pay over the top… I can’t help thinking I’m reading this incorrectly….

Raspberry Pi 3

However – here above is RS Components latest pricing for the Raspberry Pi 3 – the latest model – at just over £27

http://uk.rs-online.com/web/p/processor-microcontroller-development-kits/8968660/

And that’s fine – compares to what, say the USA would pay. I think I bought a model 2 last year in the USA for slightly less.

But check this out…

Raspberry Pi 2AliExpress who you can normally count on a decent price…

http://www.aliexpress.com/item/Original-Raspberry-Pi-2-Model-B-Broadcom-BCM2836-1GB-RAM-900Mhz-Quad-Core-ARM-Cortex-A7/32661146230.html?spm=2114.40010708.4.11.OMbRzQ

Claiming 65% off and charging £38 for the old model 2 !!!

Am I missing something here?

The funny thing is – after seeing this – I found more – I found a Raspberry Pi 3 all on AliExpress – for £29.29 with free shipping – which is a GOOD price – then the older Pi2 for an amazingly high £53.98 (they are kidding, right~?)  – the two prices sitting right next to each other!!

Oh, here’s the link for the 3 in case anyone’s interested…

Facebooktwittergoogle_pluspinterestlinkedin

Cheap Pi Screen

LCD[6]I have a Raspberry Pi 3 and recently bought a 5” screen from here at sub-£20:

While the instructions on Ebay totally miss talking about the touch screen which does not work by default, this blog entry - https://blog.ask-a.ninja/?p=48  is absolutely bang on – the screen instructions are more precise than the Ebay ones AND you get the touch screen working – note the calibration information.

Here is the setup.. in boot/config.txt. I didn't bother uncommenting the existing ones - I just added this lot in - then rebooted.

gpu_mem=32
framebuffer_ignore_alpha=1
framebuffer_swap=1
disable_overscan=1
init_uart_clock=16000000
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 800 480 60 6 0 0 0
For touch, add the below additional lines to the configuration file (in /boot/config.txt when Raspbian is running):
dtparam=spi=on
dtoverlay=ads7846,penirq=25,speed=10000,penirq_pull=2,xohms=150
The writer goes on to say... It is worth noting that the values in the sample suggested file are approximate – your pen will NOT be accurate – when you run the calibration program (in a terminal – which then triggers a graphical desktop program) you will see as a result in the terminal – the correct values – you have to update that file by hand otherwise next time you power up you’re back to square one.
So when you plug the screen into the Pi, it works – but the screen size is not right – the Ebay article gives you some of the picture – the blog entry gives you more.  Then you need SPI turned on on the Pi and the rest of that blog gets you up and running with the touch screen. You do NOT need a USB lead in the display. Just the HDMI adaptor and of course the display plugged into the Pi.
The calibration instructions gave me some grief (and there are other instructions out there that are just WRONG) until I realised the so called file “99-calibration” is actually “99-calibration.conf” – and make sure there are no special characters in there (backwards quotes etc).

Once I got that far and rebooted – the screen registration was SPOT ON. The TERMINAL I found too large but you can resize that – there’s a lot of stuff out there about changing it’s size in the config file – well, alI can say is that in RPI3 at least it does not make a bit of difference.  I think it’s fair to say that 480px is a little on the low side so I don’t think that detracts too much from the value. A solution turned out to be simple – in the /boot/config.txt file

# uncomment to force a console size. By default it will be display's size minus
# overscan.
framebuffer_width=1024
framebuffer_height=600

This made for a rather small font but solved the problem. I’m sure a little tweaking would make it even better.

Facebooktwittergoogle_pluspinterestlinkedin

Useless Pi Browser and Firefox

 

Why oh WHY do they keep that utterly USELESS Web browser in Raspbian?  I powered up my new Raspberry Pi today on my new 5” LCD display and tried loading up Node-Red on the browser.

That went well until I tried to edit a function – blank white window. I figured it was the LCD – so I tried it in TightVNC instead – still a white window.

I remembered that on my non-Pi machines they install Iceweasel – so off I went to get Iceweasel instead.

Surprised to say the LEAST when I installed the latter it also came with FIREFOX!!  Now I’m a Chrome man but there’s nothing wrong with Firefox and so I was delighted to see that. I tried Node-Red on it and LO – worked a treat. So I’ve taken off the horrible default browser from my Pi3 and put Firefox up there instead. Looks lovely on the top.

While I was on, having learned from the experience with the NanoPis – I installed WICD while I was on – nice visual setup for WIFI.

And there it is – my sparkly Pi3 home screen.

Pi3

But here’s the BIG thing – NOW all the BBC’s videos work all of a sudden – gone are the “you need Flash” messages – even BBC videos work (mind you – they won’t work on the little 5” LCD – back to “you need to install Flash” – which then doesn’t work. I’ll put that down to the LCD and have griped to my Ebay supplier. More on the touch screen later – it’s a winner.

Facebooktwittergoogle_pluspinterestlinkedin