USB Power Gauge talking to RPi?

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
TokyoJoe
 
Posts: 3
Joined: Sat May 24, 2014 11:05 pm

USB Power Gauge talking to RPi?

Post by TokyoJoe »

Hello ADA Fruit,

Just got one of your cool USB Power Gauge Mini Kit. Fascinated by TX pin that sends out the Voltage, Current and Power. I would like to hook up this TX pin to my Raspberry Pi but I am little bit not sure about voltage levels 5v or 3v?. Can USB Power Gauge TX pin be directly wired up to the Pi? ( presumably connecting to GPIO15 UART RXD?)

I am guessing that if it's safe to wire up then it's just a hop, skip and jump to be reading those values inside the pi?

any help appreciated, thank you

Tokyo Joe.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: USB Power Gauge talking to RPi?

Post by adafruit_support_rick »

TX runs at 5V. You can use a resistive divider to protect your Pi.
Connect a 10Kohm resistor between the TX pin and the Pi GPIO pin, and connect another 10K resistor between the Pi GPIO pin and GND. This will reduce the voltage from the TX pin to 2.5V, which will still be readable by the Pi.

User avatar
thalesvon
 
Posts: 5
Joined: Thu Jun 09, 2016 3:04 pm

Re: USB Power Gauge talking to RPi?

Post by thalesvon »

Hello,

did this set up worked for you? I am trying to read the TX pin from the USB power gauge mini kit connected to my PI. I used the resistor divider like described. But what is the format of the data out of the TX pin ? In the meanings of parity ,stop bits , data size ?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: USB Power Gauge talking to RPi?

Post by adafruit_support_rick »

8 bits, no parity, 1 stop bit. 9600 baud.
It's a readable string of the voltage, current, and wattage readings

User avatar
thalesvon
 
Posts: 5
Joined: Thu Jun 09, 2016 3:04 pm

Re: USB Power Gauge talking to RPi?

Post by thalesvon »

Hello,

I used the resistor divider to connect the TX to the RX of the PI (GPIO 15) and GND from the power gauge to GND to the PI and still I get no reading on the PI. How can I test if the TX on the power gauge is working properly ?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: USB Power Gauge talking to RPi?

Post by adafruit_support_rick »

Can you post some pictures of your wiring?

Do you have the console serial port enabled or disabled on the Pi? How are you attempting to read the serial data?

User avatar
TokyoJoe
 
Posts: 3
Joined: Sat May 24, 2014 11:05 pm

Re: USB Power Gauge talking to RPi?

Post by TokyoJoe »

hello thalesvon

This page is really useful, it showed me how to connect python to the PI's UART https://electrosome.com/uart-raspberry-pi-python/

Once you know you can talk to you PI's UART you'll be in a better position to debug the next step of getting the PI to talk to the USB power gauge.

happy hacking and post some photos

(And thank you Rick for supporting too :-)

User avatar
thalesvon
 
Posts: 5
Joined: Thu Jun 09, 2016 3:04 pm

Re: USB Power Gauge talking to RPi?

Post by thalesvon »

Hello guys,
sorry for the delay. I didn't have access to the devices during the weekend.
I noticed I am running a newer version of Raspbian on my PI. So my PI doesn't have the inittab file.

This is how the cmdline.txt looks like in my PI:

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=$

On the /boot/config.txt I changed the field

enable_uart=1

The python code I am running on the PI is:

import serial

ser = serial.Serial(port= "/dev/ttyAMA0",
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1)

while True:
rcv = ser.readline()
if len(rcv) > 1 :
print rcv


And the code is always stuck on the ser.readline().

Do you guys know what I am doing wrong.
Thanks for the help
Attachments
That is the setup. The voltage divider is with two 10k resistor and  the GND of both devices are common.
That is the setup. The voltage divider is with two 10k resistor and the GND of both devices are common.
13411914_1136820629716873_4036461661919720561_o.jpg (248.49 KiB) Viewed 193 times
That is the PI with the orange wire being the RX (GPIO 15) and white being GND
That is the PI with the orange wire being the RX (GPIO 15) and white being GND
13411760_1136820566383546_4412352830134685665_o.jpg (319.96 KiB) Viewed 193 times

User avatar
thalesvon
 
Posts: 5
Joined: Thu Jun 09, 2016 3:04 pm

Re: USB Power Gauge talking to RPi?

Post by thalesvon »

Hey guys just an update,

I figured out what was going on. I am using the Pi 3 and things changed a little.
On the Pi 3 the UART port at the GPIO header is available at "/dev/ttyS0".
So to access it I added the line

Code: Select all

core_freq=250
to the

Code: Select all

/boot/config.txt
saved it and rebooted it!
After that I changed the device on the python code and it worked great. I am getting the readings now.

Here is the link that I looked:
https://frillip.com/raspberry-pi-3-uart ... orkaround/

Thank you again

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”