France
Asked

Ezbpi Server - Access To The Pi Gpios

Hi,

I have successfully connected ARC to the Pi using the EZBPi server, but I don't understand how to access the GPIOs of the Pi. If I want to set or read a digital port, how do I know which port in ARC correspond the right GPIO pinout?


Related Hardware Raspberry Pi
Related Controls Read Digital Set Digital

ARC Pro

Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

#2  

Thanks PTP,

I was aware of the Pi GPIOs map, but I didn't get that there was a direct match between ARC port numbers and the Pi GPIO numbers. I am going to test it tonight.

PRO
USA
#3  

Bear in mind the raspberry pi is not 5v tolerant.

if you are reading logic voltages the limit is 3.3v

#4  

Ok, I made a test and it doesn't work. As a test, I try to switch on/off a LED with the "Set Digital" control. It works with my EZB v4 (so no issue with the LED), but not with the Pi (I have tested different pinouts)...

PRO
USA
#5  

Can you explain how you wire the led ?

you can’t wire a led without a resistor.

#6  

The LED is indeed wired with a resistor and works with the EZB v4 (I can switch it with the Set Digital control). It works also on the Pi if I plug it on the 3.3v pinout (+ground). It just seems that i cannot set digital on other GPIOs...

PRO
USA
#7   — Edited

Let's troubleshoot the issue:

connect your led (and the resistor) to pin 12 (GPIO 18)

open a console and run the commands below:

initialize the pin direction:


echo "out" > /sys/class/gpio/gpio18/direction

switch on:


echo "1" > /sys/class/gpio/gpio18/value

switch off:


echo "0" > /sys/class/gpio/gpio18/value

Let me know if you can toggle the led.

#8  

OK, thanks ptp

But first command, first error.

bash: /sys/class/gpio/gpio18/direction: No such file or directory

I don't have a /gpio18 folder in  /sys/class/gpio

#9  

Update:

Ok, all commands work now after some reading in the Pi forums. I had to run:

echo "18" > /sys/class/gpio/export

Then, I have successfully toggle the led.

PRO
USA
#10  

And ezbpi server can toggle the gpio18 / port 18?

#11  

No, no success with ARC via the ezbpi server...

PRO
USA
#12  

One question the led should switch ON with digital ON or digital OFF ?

#13  

On the EZB v4, the led is switched ON with digital ON.

PRO
Canada
#14  

There was an issue with setting the pin to LOW and also with reading its value. I tested it and it works now (port mappings are GPIOX <> DX as already mentioned). I have uploaded a new version 5 here https://synthiam.com/Firmware/EZBPi-Server-SXQJXC3FIQ5.

Please give it a try and let me know how it goes.

User-inserted image

#15  

Hi Amin,

Thanks for your help and the new firmware. Sadly, it is not working and I still cannot switch ON the led.

When I add the "read digital" control on the same port 18, it doesn't go green when i put the "set digital" ON.  Moreover, when I put the "read digital" control on the same port than "set digital" control, this later does not stay green when I click on it and go back to red immediately. I don't know if that makes ant sense to you...

PRO
USA
#16  

@fredebec

Please post the output of the following commands:

cat /sys/firmware/devicetree/base/model
cat /proc/cpuinfo
cat /etc/os-release
uname -a
gpio -v
pip show rpi.gpio
PRO
Canada
#17  

@fredebec what you are describing is very similar to the behavior of the old firmware. Reading a port used turn it off. Can you please report the version that is running on your Pi? The version is in the first lines that EZBPi.exe prints to the console when you run it.

#18  

@amin, I have the last version. The first line says: "Raspberry EZBPi Version: 2019.8.27.1"

#19  

@ptp, here we go:

pi@fredebec-pi:~ $ cat /sys/firmware/devicetree/base/model
Raspberry Pi 4 Model B Rev 1.1pi@fredebec-pi:~ $ 
pi@fredebec-pi:~ $ cat /proc/cpuinfo
processor   : 0
model name   : ARMv7 Processor rev 3 (v7l)
BogoMIPS   : 108.00
Features   : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer   : 0x41
CPU architecture: 7
CPU variant   : 0x0
CPU part   : 0xd08
CPU revision   : 3

processor   : 1
model name   : ARMv7 Processor rev 3 (v7l)
BogoMIPS   : 108.00
Features   : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer   : 0x41
CPU architecture: 7
CPU variant   : 0x0
CPU part   : 0xd08
CPU revision   : 3

processor   : 2
model name   : ARMv7 Processor rev 3 (v7l)
BogoMIPS   : 108.00
Features   : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer   : 0x41
CPU architecture: 7
CPU variant   : 0x0
CPU part   : 0xd08
CPU revision   : 3

processor   : 3
model name   : ARMv7 Processor rev 3 (v7l)
BogoMIPS   : 108.00
Features   : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer   : 0x41
CPU architecture: 7
CPU variant   : 0x0
CPU part   : 0xd08
CPU revision   : 3

Hardware   : BCM2835
Revision   : c03111
Serial      : 1000000082e0e07d

pi@fredebec-pi:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/";
SUPPORT_URL="http://www.raspbian.org/RaspbianForums";
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs";

pi@fredebec-pi:~ $ uname -a
Linux fredebec-pi 4.19.66-v7l+ #1253 SMP Thu Aug 15 12:02:08 BST 2019 armv7l GNU/Linux

pi@fredebec-pi:~ $ gpio -v
gpio version: 2.50
Copyright (c) 2012-2018 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

Raspberry Pi Details:
  Type: Unknown17, Revision: 01, Memory: 0MB, Maker: Sony 
  * Device tree is enabled.
  *--> Raspberry Pi 4 Model B Rev 1.1
  * This Raspberry Pi supports user-level GPIO access.

pi@fredebec-pi:~ $ pip show rpi.gpio
Name: RPi.GPIO
Version: 0.7.0
Summary: A module to control Raspberry Pi GPIO channels
Home-page: http://sourceforge.net/projects/raspberry-gpio-python/
Author: Ben Croston
Author-email: ben@croston.org
License: MIT
Location: /usr/lib/python2.7/dist-packages
Requires: 
Required-by: skywriter, rainbowhat, phatbeat, motephat, envirophat, Cap1xxx, blinkt, automationhat

PRO
Canada
#20  

@fredebec I did more tests and couldn't reproduce this issue even after updating my rpi.gpio package to match yours. Can you please run EZBPi in verbose (with --verbose) and try to set the port and copy paste whatever is printed on EZBPi console?

#21  

@amin, I am afraid that it is not so verbose...

Here is what happens if I set the port on & off and disconnect

pi@fredebec-pi:~/EZBPi $ sudo mono ./EZBPi.exe -verbose
Raspberry EZBPi Version: 2019.8.27.1
Verbose logging is: True
Serial port is: /dev/serial0
EZB: TCP Started on port 23
EZ-B Server started on TCP Port: 23
Camera: TCP Started on port 24
Camera Server started on TCP Port: 24
Press ESC to quit
EZB: TCP Connection from: 127.0.0.1
Connection on TTY0
Ping
EZ-B v4 Command
Get CPU temp
Digital port 18 ON
Digital port 18 OFF
Digital port 18 ON
Digital port 18 OFF
TCP Server TTY0: System.Exception: Disconnected by remote host
  at EZBPi.EZBProgram._TCPServer_OnConnection (System.Net.Sockets.TcpClient tcpClient, System.Net.Sockets.NetworkStream clientStream, System.Int32 id) [0x00032] in :0 
EZB disconnected on tty:0

Here is what happens if I do the same but with the "read digital" control

EZB: TCP Connection from: 127.0.0.1
Connection on TTY1
Ping
EZ-B v4 Command
Get CPU temp
Return port 18 status
Return port 18 status
Return port 18 status
Return port 18 status
Return port 18 status
Return port 18 status
Return port 18 status
Digital port 18 ON
Return port 18 status
Return port 18 status
Return port 18 status
Return port 18 status
Return port 18 status
Return port 18 status
Digital port 18 ON
Return port 18 status
Return port 18 status
Return port 18 status
Return port 18 status
TCP Server TTY1: System.Exception: Disconnected by remote host
  at EZBPi.EZBProgram._TCPServer_OnConnection (System.Net.Sockets.TcpClient tcpClient, System.Net.Sockets.NetworkStream clientStream, System.Int32 id) [0x00032] in :0 
EZB disconnected on tty:1

Also, I don't know if it is off any help, but when I run the EZBPi server, I can still run the Pi commands

pi@fredebec-pi:~ $ echo "18" > /sys/class/gpio/export
pi@fredebec-pi:~ $ echo "out" > /sys/class/gpio/gpio18/direction
pi@fredebec-pi:~ $ echo "1" > /sys/class/gpio/gpio18/value
pi@fredebec-pi:~ $ echo "0" > /sys/class/gpio/gpio18/value

and successfully switch on the led, without any interference or impact on the EZBPi server or ARC...

#22  

Hi,

Just for you to know, I am still not able to use the Digital control...

Another thing I have observed is that there is a 1-2 seconds latency when I use the PiCamera through ARC. There is no latency when I use a PiCam program. So, not much luck for me with the EZBPiServer so far...

PRO
USA
#23  

@Fredebec: I have the same issue digital ports don't work too.

I wrote an EZB Server version codename:Blueberry Server inline with Raspberry and B for Blueberry:)

Check the instructions: https://synthiam.com/Firmware/EZB-Server-BlueBerry-Server-DBJJ5DRNAAH

Audio is supported, but is deactivated on the code.

If you want explore more my implementation drop some posts on the above thread.

#24  

@ptp

Cool, thanks. For sure, I am going to test it. See you on the other thread...:)