Pi GPIO in RISC O/S
RMAC Harvey (9300) 8 posts |
Well the excitment here is quite palpable. I have managed to get a PIR sensor sensing, a motor motoring and a reed switch switching over the GPIO (R-PI3 B+), mainly thanks to Andrew C and his programs (in the Programming Dir on RISCOS Direct) which are a great step into the world of GPIOs. Thanks Andrew. My next task is to get a sensor value reading. i.e. up until now my work has been pretty binary motor on, motor off, PIR sensor active/in-active but can I expand on that? Is there a simple BBC BASIC program I can play around with that would allow me to get various values from a GPIO pin or is it not that simple? I have (for example) a three pin temperature sensor; can I just “plug” it in or do I need something from RS that does most the talking and I connect it to the GPIO? Note the emphasis on “simple”. I will blatantly use the excuse that I am going to start teaching my son BBC BASIC but if we are honest a simple program would also help me with understanding things. I think this is probably the most relevant thread but happy to post else where. |
Chris Hall (132) 3544 posts |
It is fairly simple to interface an analogue to digital chip – using GPIO pins. A good start is the ADS 1015 from Adafruit. I described how to read this from BASIC in my articles in Archive magazine about SatNav. See also here www.svrsig.org/PiGPS.htm. The internet seems to have suddenly become case sensitive so some of the images aren’t rendering at the moment. It may be an idiosyncracy of my ISP though. |
Alan Adams (2486) 1140 posts |
I suspect you actually have a one-wire sensor, (which has three wires – supply, ground and data). This does not interface directly with IIC. (Like these? https://shop.pimoroni.com/products/ds18b20-programmable-resolution-1-wire-digital-thermometer?variant=32127344640083) It is possible to access these by bit-banging GPIO pins, but a simpler solution is an interface (like these: https://www.sheepwalkelectronics.co.uk/product_info.php?cPath=22&products_id=73&osCsid=o4fg7m5vq3p99r7hs8fslgbgm5) The software I posted a while back is to use this interface with these sensors. The interface is an IIC device which translates commands into one-wire data. |
RMAC Harvey (9300) 8 posts |
Hi Chris, thanks for the reply. I’ll see what I can get out of my Archive archive. I did have a subscription at some point. Is there BBC BASIC code for communicating with an ADS 1015? |
RMAC Harvey (9300) 8 posts |
Hi Alan, thanks also. That looks like a respectable amount of code. Would that also hook up with a barometer? As far as baometers go, all I could find were things like ICP-10125 Air Pressure Sensor or the all singing all dancing Adafruit BME688. So nothing simple. |
David J. Ruck (33) 1582 posts |
I use the BME280 for temperature/humidity/pressure which seem pretty rock solid. I was after some more but bought a batch which turned out to be BMP280 temperature/pressure devices, I got a refund, and teamed some of them up with the HTU21DF temperature/humidity sensors. But the BMPs read high on temperature and pressure compared to the other sensors, even after calibration, so I’d go for the BME280s. They are all reasonably priced I2C sensors which work on the Pi, they each require a different small Python to produce a calibrated output. There isn’t any reason they couldn’t be used on RISC OS with modified Python, or porting to BASIC if you really wanted to. |
Alan Adams (2486) 1140 posts |
If you find a barometer with one-wire interface, then yes. I was hoping to find one of the Dallas one-wire weather stations – out of production for many years now. The chips are made by Maxim semiconductor, and still available. Most of that code is to identify the devices on the bus by address, and then to read the data from them. Converting to a temperature display is a tiny part of it. The first byte of the address is the device type – 28hex is a temperature device. It’s a Wimp application, so quite a lot of the code is just handling the screen and mouse. |
Gareth Lock (2186) 51 posts |
Can anyone post a quick reply here to the question of how to set an input line to pull down. Thanks in advance… |
Andrew Conroy (370) 725 posts |
Setting bit 5 of R1 enables pullup/pulldown, and setting bit 6 enables pullup whilst unsetting bit 6 enables pulldown behaviour. To populate bits 0-4 with the correct mode number, you have to use GPIO_Info to iterate through all the GPIOs to find the current (and other available) modes for that GPIO and set the mode to be what you wish (usually the current mode). |
Robin Hodson (438) 4 posts |
I’m having a problem accessing GPIO on the original Pi Zero: I found a module which reports the correct system, and apparently can set pins to input/output, but when I read the status of those pins, their status is unchanged. This suggests the module version I used is not working. Advice suggests I should look for the earliest version of the GPIO module, within an early version of RISC OS 5, in the build environment: Where exactly do I find this? |