geeekpi / upsplus

UPS Plus is a new generation of UPS power management module. It is an improved version of the original UPS prototype. It has been fixed the bug that UPS could not charge and automatically power off during work time. It can not only perform good battery power management, but also provide stable voltage output and RTC functions. At the same time,it support for FCP, AFC, SFCP fast charge protocol, support BC1.2 charging protocol, support battery terminal current/voltage monitoring and support two-way monitoring of charge and discharge. It can provide programmable PVD function. Power Voltage Detector (PVD) can be used to detect if batteries voltage is below or above configured voltage. Once this function has been enabled, it will monitoring your batteries voltage, and you can control whether or not shut down Raspberry Pi via simple bash script or python script. This function will protect your batteries from damage caused by excessive discharge. It can provide Adjustable data sampling Rate. This function allows you to adjust the data sampling rate so that you can get more detailed battery information and also it will consume some power. The data sampling information can communicate with the upper computer device through the I2C protocol. UPS Plus supports the OTA firmware upgrade function. Once there is a new firmware update, it is very convenient for you to upgrade firmware for UPS Plus. The firmware upgrade can be completed only by connecting to the Internet,and execute a python script. Support battery temperature monitoring and power-down memory function. UPS Plus can be set to automatically start the Raspberry Pi after the external power comes on. The programmable shutdown and forced restart function will provide you with a remote power-off restart management method. That means you don’t need to go Unplug the power cable or press the power button to cut off the power again. You can set the program to disconnect the power supply after a few seconds after the Raspberry Pi is shut down properly. And you can also reconnect the power supply after a forced power failure to achieve a remote power-off and restart operation. Once it was setting up, you don't need to press power button to boot up your device which is very suitable for smart home application scenarios.
https://wiki.52pi.com/index.php?title=UPS_Plus_SKU:_EP-0136
MIT License
73 stars 25 forks source link

Errno 121 : Remote I/O error #86

Open jamesjohnson82 opened 3 years ago

jamesjohnson82 commented 3 years ago

I have been trying everything to get my RPi4B to communicate with the USP Plus but I continually get this error

pi@ImpactRemote:~/upsplus $ python3 OTA_firmware_upgrade.py
Traceback (most recent call last):
  File "OTA_firmware_upgrade.py", line 23, in <module>
    aReceiveBuf.append(bus.read_byte_data(DEVICE_ADDR, i))
  File "/usr/local/lib/python3.7/dist-packages/smbus2/smbus2.py", line 433, in read_byte_data
    ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 121] Remote I/O error
pi@ImpactRemote:~/upsplus $ 

Remote I/O error.

I have been unable to find any information on what this error means and how to troubleshoot it. as you can see below its stopping the install of the UPS Plus and failing

pi@ImpactRemote:~/upsplus $ sudo ./install.sh
[info] Welcome to 52Pi Technology UPS Plus auto-install Program!.
[info] More information please visit here:.
[info] -----------------------------------------------------.
[info] https://wiki.52pi.com/index.php/UPS_Plus_SKU:_EP-0136.
[info] -----------------------------------------------------.
[info] Start the configuration environment check....
[ ok ] Network status is ok....
[info] Start the software check....
[ ok ] git has been installed..
[ ok ] pi-ina219 library has been installed.
[info] Installing smbus2 library....
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: smbus in /usr/local/lib/python3.7/dist-packages (1.1.post2)
Requirement already satisfied: smbus2 in /usr/local/lib/python3.7/dist-packages (0.4.1)
[ ok ] smbus2 Installation successful..
[info] create /root/bin directory....
[info] Create python3 script in location: /root/bin/upsPlus.py Successful.
[ ok ] Create UPS Plus IoT customer service python script successful.
[info] Add into general crontab list..
[info] crontab has been created successful!.
------------------------------------------------------------
------Current information of the detected Raspberry Pi------
------------------------------------------------------------
Raspberry Pi Supply Voltage: 5.152 V
Raspberry Pi Current Current Consumption: 7029.773 mA
Raspberry Pi Current Power Consumption: 36245.585 mW
------------------------------------------------------------
Traceback (most recent call last):
  File "/root/bin/upsPlus.py", line 38, in <module>
    ina_batt.configure()
  File "/usr/local/lib/python3.7/dist-packages/ina219.py", line 175, in configure
    self._max_expected_amps)
  File "/usr/local/lib/python3.7/dist-packages/ina219.py", line 310, in _calibrate
    self._calibration_register(calibration)
  File "/usr/local/lib/python3.7/dist-packages/ina219.py", line 356, in _calibration_register
    self.__write_register(self.__REG_CALIBRATION, register_value)
  File "/usr/local/lib/python3.7/dist-packages/ina219.py", line 388, in __write_register
    self._i2c.writeList(register, register_bytes)
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_GPIO/I2C.py", line 127, in writeList
    self._bus.write_i2c_block_data(self._address, register, data)
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/smbus.py", line 368, in write_i2c_block_data
    self._device.write(data)
OSError: [Errno 121] Remote I/O error
[FAIL] UPS Plus Installation is Incomplete! ... failed!
[info] Please visit wiki for more information:.
[info] -----------------------------------------------------.
[info] https://wiki.52pi.com/index.php/UPS_Plus_SKU:_EP-0136.
[info] -----------------------------------------------------.
pi@ImpactRemote:~/upsplus $ 

Thanks for the assistance.

frtz13 commented 3 years ago

i2c communications on the RPi, and communication with the other INA219 sensor (ina_supply) look ok. I'd guess this is a hardware failure of the ina_batt sensor (i2c address 0x45) on the board.

jamesjohnson82 commented 3 years ago

is there a way to confirm that that is the issue, or should I reach out to the manufacture for a replacement? I would like to fix the issue if at all possible.

frtz13 commented 3 years ago

I think you did the necessary. I suggest you contact the manufacturer with reference of this issue on github.

jamesjohnson82 commented 3 years ago

Thanks @frtz13. Ill post again when i talk with the manufacturer.

hellresistor commented 3 years ago

what os are you using and arch ?

frtz13 commented 3 years ago

@jamesjohnson82 one more thing you could try is this command: i2cdetect -y 1 this should normally show you a reply on 0x17, 0x40 (ina_supply), 0x45 (ina_batt) and 0x68 (real time clock on the UPS board)

hellresistor commented 3 years ago

try use -y 2 or 3 if you are using an aarch64 debian 10

jamesjohnson82 commented 3 years ago
pi@ImpactRemote:~ $
pi@ImpactRemote:~ $
pi@ImpactRemote:~ $
pi@ImpactRemote:~ $ cat /etc/debian_version
10.11
pi@ImpactRemote:~ $ 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@ImpactRemote:~ $ uname -a
Linux ImpactRemote 5.10.63-v7l+ #1459 SMP Wed Oct 6 16:41:57 BST 2021 armv7l GNU/Linux
pi@ImpactRemote:~ $ 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        : BCM2711
Revision        : d03114
Serial          : 10000000a2abc0fa
Model           : Raspberry Pi 4 Model B Rev 1.4
jamesjohnson82 commented 3 years ago
pi@ImpactRemote:~ $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- UU -- -- --
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
pi@ImpactRemote:~ $

i2cdetect -y 0,2,or 3 do not result in anything. there is only one i2c bus on RPi4B

hellresistor commented 3 years ago

understand, just alert you in situation (is not your situation!!), if you decide use aarch64 (armv8), on debian 10 (this: https://raspi.debian.net/tested-images/ ), the '-y 1' will not detect ...

I say that because I have got same "ERROR" type before....

On THIS MOMENT I am installing the Debian 11 . I can give feedback.

The proof.

root@fifuproject:~# uname -a
Linux fifuproject 5.10.0-9-arm64 #1 SMP Debian 5.10.70-1 (2021-09-30) aarch64 GNU/Linux
root@fifuproject:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@fifuproject:~# cat /etc/debian_version
11.1

root@fifuproject:~# sudo i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         08 09 0a 0b 0c 0d 0e 0f
10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30: -- -- -- -- -- -- -- -- 38 39 3a 3b 3c 3d 3e 3f
40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70: 70 71 72 73 74 75 76 77
root@fifuproject:~# sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         08 09 0a 0b 0c 0d 0e 0f
10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30: -- -- -- -- -- -- -- -- 38 39 3a 3b 3c 3d 3e 3f
40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70: 70 71 72 73 74 75 76 77
root@fifuproject:~# sudo i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@fifuproject:~# sudo i2cdetect -y 3
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- 17 -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: 40 -- -- -- -- 45 -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
frtz13 commented 3 years ago

@jamesjohnson82 on a normally working board, you should have a response on 0x17 and 0x45, too. the response (like the response in hellresistor's comment (i2cdetect -y 3).

jamesjohnson82 commented 3 years ago

I have contacted the company, MakerHawk, and they are sending me a new unit. thank you to everyone on this thread. when I receive the new board, I will post an update.

ceckles commented 3 years ago

having same about the same issue, got a replacement and still having issues and idea?

disregard my comment, mine was not working because the amazon seller send me a EP -0118 and not the EP-0136 version I requested.

vali103 commented 2 years ago

Hi, my problem was solved by upgrading the UPS firmware.

mmaga commented 2 years ago

Hi, my problem was solved by upgrading the UPS firmware.

That is what @jamesjohnson82 is trying to do. Which firmware version did you get? Mine is version 10 and I still receive Errno 121 : Remote I/O error randomly.

ArjenR49 commented 2 years ago

I had the same issue and the discussion can be found at: https://github.com/frtz13/UPSPlus_mqtt/issues/23

(The error message Gindse invoer-/uitvoerfout is dutch for Remote input/output error.)

vali103 commented 2 years ago

Hi, my problem was solved by upgrading the UPS firmware.

That is what @jamesjohnson82 is trying to do. Which firmware version did you get? Mine is version 10 and I still receive Errno 121 : Remote I/O error randomly.

Now i have firmware v10 . But now other strange things started to happen:

  1. Randomly cut the power for raspberry, (no shut down sequence). And the same after 1 min if i unplug the power. https://github.com/geeekpi/upsplus/issues/71

  2. Randomly i got the error back ( Errno 121 : Remote I/O error) but is ok after 1 sec or so

  3. I never see the battery fully charged. pi@raspberrypi:~ $ i2cdetect -y 1
    0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- 17 -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 40: 40 -- -- -- -- 45 -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --

  4. I don't know what UU means :)) it suposed to be 68

hellresistor commented 2 years ago

try run command with sudo ?

mmaga commented 2 years ago

Dear @vali103,

I got rid of UU after disabling SPI interface, which I was using for the OLED. Yes, that address is 68.

I disabled the Serial Port interface also and I setup the I2C baud rate for 400MHz in /boot/config.txt (dtparam=i2c_arm=on,i2c_arm_baudrate=400000). OLED is much faster :-)

I planned my scripts (python) to make only sequencial access to the I2C interface (UPS reading/writing; OLED writing on display; Fan control writing). I'm still getting the I/O error, and its frequency is much lower after setting time.sleep() when sending I2C read/write commands.

Random shutdown totally went away.

The battery is never fully charged also, and the fourth led is always blinking, even when the UPS is off but connected to the power source.

hellresistor commented 2 years ago

The battery is never fully charged also, and the fourth led is always blinking, even when the UPS is off but connected to the power source.

Friend that was the fact .. battery will keep charge and discharge.. not exist a 'by-pass to Direct current cable, after full batteries'.. take it in consideration the 4th led blink it just a information the power cable its connected!

mmaga commented 2 years ago

I had to set baud rate back to 115200 (best rate based on the OLED specs) or the unit would never be out of OTA Firmware Upgrade Mode (0x18). Maybe some of you knows which is the recommended baud rate for the UPS Plus.

mmaga commented 2 years ago

The battery is never fully charged also, and the fourth led is always blinking, even when the UPS is off but connected to the power source.

Friend that was the fact .. battery will keep charge and discharge.. not exist a 'by-pass to Direct current cable, after full batteries'.. take it in consideration the 4th led blink it just a information the power cable its connected!

... and it looks like there is no way to use it connected to the power cable without batteries also. Is it true?

hellresistor commented 2 years ago

... and it looks like there is no way to use it connected to the power cable without batteries also. Is it true?

what is a propose about UPS ?? ... :\

mmaga commented 2 years ago

... and it looks like there is no way to use it connected to the power cable without batteries also. Is it true?

what is a propose about UPS ?? ... :\

Just in case you run out of batteries and have no one around.

hellresistor commented 2 years ago

on that situation.. umount UPS from PI put batteries in UPS and conect power cable in ups, if batteries not dead, will charge batteries. wait 20/30m , to charge a little , and you can assemble it again. That was my workaround when need.

ntahal commented 2 years ago

I had a similar problem where my ups device EP-0136 using the OTA firmware update. All my values were still showing up correctly when using the "Full-featured-demo-code.py" and "upsplus.py". but upgrading gave me the same error as: pi@device:~/upsplus $ python3 OTA_firmware_upgrade.py Traceback (most recent call last): File "OTA_firmware_upgrade.py", line 23, in aReceiveBuf.append(bus.read_byte_data(DEVICE_ADDR, i)) File "/usr/local/lib/python3.7/dist-packages/smbus2/smbus2.py", line 433, in read_byte_data ioctl(self.fd, I2C_SMBUS, msg) OSError: [Errno 121] Remote I/O error

I managed to upgrade the firmware by following the second way of upgrading using the EP-0136 wiki's Method 2. (https://wiki.52pi.com/index.php?title=EP-0136)

hellresistor commented 2 years ago

have you run thisi2cset -y 1 0x17 50 127 b and than shutdown rpi, REMOVE BATTERIES. and than put them again on ups... ?!?!?