Changes

Jump to navigation Jump to search

X708-script

6,744 bytes added, 19:40, 24 July 2023
Created page with "{{GD Template Impl}} ==Overview== This is script installation tutorial for X708 shield, it will replace X708 Software installation tutorial, although..."
{{GD Template Impl}}

==Overview==
This is script installation tutorial for [[X708]] shield, it will replace [[X708-Software | X708 Software installation tutorial]], although [[X708-Software | X708 Software installation tutorial]] is still available, but we strongly recommend that you use this script tutorial, which simplifies the installation process and reduces dependencies on third-party python libraries.

<!--
The core shell script of [[X708-script]] comes from from [https://github.com/pimlie/geekworm-x-c1 pimlie/geekworm-x-c1], pimlie implements the pwm fan shell script, which does not depend on third-party python libraries at all. Thanks to pimlie.
-->
Now we think you have successfully flashed the OS Image into Micro SD and and power on the device, and you have also completed the operations such as creating new user required in some OS. You need to perform the following operations in <code>Terminal</code>.

==OS that has been tested==
* Raspbian
* DietPi
* Manjaro
* Ubuntu
* myNode
* Umbrel
* Volumio
* RetroPie
* Twister
==Install==
Please follow the steps below:
===Enable I2C===
Reter to [[How to enable I2C]]

NOTE: sample/x708-v2.x-bat.py or sample/x708-v1.x-bat will run with error if you don't enable I2C.

'''Check & review I2C address:'''
<PRE>
pi@raspberrypi:~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- 36 -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
</PRE>
Explaination:
<PRE>
#36 - the address of the battery fuel gauging chip
</PRE>

===Clone the script===
<pre>
git clone https://github.com/geekworm-com/x708-script

cd x708-script
chmod +x *.sh
</pre>

===Create the x708-pwr service===
x708-pwr service will be responsible for power management and hardware safe shutdown.
<pre>
sudo cp -f ./x708-pwr.sh /usr/local/bin/
sudo cp -f x708-pwr.service /lib/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable x708-pwr
sudo systemctl start x708-pwr
</pre>
Now, if you press and hold the onboard switch for 3 seconds, then the blue LED will flash slowly and the shutdown is going then all LEDs will be off until the device is completely powered off.

===Prepair software shutdown script===
sudo cp -f ./x708-softsd.sh /usr/local/bin/x708-softsd.sh
Create a alias <code>x708off</code> command to execute the software shutdown
<pre>
echo "alias x708off='sudo /usr/local/bin/x708-softsd.sh'" >> ~/.bashrc
source ~/.bashrc
</pre>
Then you can run <code>x708off</code> to execute software shutdown as follows
x708off

===Test safe shutdown===
'''Software safe shutdown command''':
x708off
<span class="tb_red">DON'T run the 'shutdown' linux command to shut down, otherwise the power of x708 shield will not be shut down.</span>

'''Hardware safe shutdown operation''':

You can verify the safety switch through the onboard switch, press and hold the switch for <code>3</code> seconds, then the blue LED will flash slowly and the shutdown is going then all LEDs will be off until the device is completely powered off.
* press on-board button switch <code>1-2</code> seconds to reboot
* press button switch <code>3</code> seconds to safe shutdown,
* press <code>7-8</code> seconds to force shutdown.

===Sample Files===
The example programs are only suitable for advanced players, and you can construct your own usage scenarios according to the example programs.

Each example program demonstrates a different function:

'''x708-bat.py''': Script to read battery power and voltage;
cd ~x708-script
sudo python3 sample/x708-bat.py

'''x708-pld.py''': Script to AC Power supply loss dection
cd ~x708-script
sudo python3 sample/x708-pld.py

'''x708-plsd.py''': Script to AC Power supply loss dection
cd ~x708-script
sudo python3 sample/x708-plsd.py

1. Al sample python files maybe depends on the third-party python library `Rpi.GPIO`. In the official Raspberry Pi OS and most third-party OS, this library is installed by default. If you run this file and get some errors, try to run the following command to install the Rpi.GPIOy library.
sudo apt-get install -y python3-smbus python3-rpi.gpio

Or you can refer to [[How to Install RPi.GPIO Python Library]]

2. The sample file based on the version number is just because different versions of x708 shield use different GPIOs, they are basically the same. You can use a file comparison tool to view it, if you get it wrong, most likely you are using the wrong version of the sample file. You can refer to [[x708-hardware#Pins_and_GPIO_used |x708 hardwar]] to check the PIN occupancy of x708 shield.

3. The sample program is only to demonstrate how to use the advanced functions of the shield, we do not provide the development function of the sample program.


==Support==
Email: support@geekworm.com

==FAQ==
<html>
<details>
<summary>Q: How to login <b>volumio</b> via SSH?</summary>
<p>1. Enable SSH:</p>
<p>Visit http://volumio.local/dev/, then click <b>ENABLE SSH</b> button</p>
<p>2. URL connection is IP address, and the default user name is <b>volumio</b>, default password is <b>volumio</b></p>
</details>

<details>
<summary>Q: How to login to <b>Umbrel</b> via SSH?</summary>
A: ssh umbrel@umbrel.local (or ssh umbrel@<IP address of your Umbrel>). the default user name is <b>umbrel</b>, default password is <b>moneyprintergobrrr</b>
</details>

<details>
<summary>Q: How to login to <b>myNode</b> via SSH?</summary>

A: URL connection is IP address, and the default user name is <b>admin</b>, default password is <b>bolt</b>
</details>

<details>
<summary>Q: How to login to <b>DietPi</b> via SSH?</summary>

A: URL connection is IP address, and the default user name is <b>root</b>, default password is <b>dietpi</b>
</details>

<details>
<summary>Q: Is <b>LibreELEC</b> supported?</summary>

A: TODO
</details>

</html>

==Other resource==
* Chip-Specifications:[[File:MAX17040-MAX17041.pdf]]
*[https://www.sparkfun.com/datasheets/Components/DS1307.pdf I2C address: 0x36 for battery fuel gauging, 0x68 for RTC]
*References: [https://www.instructables.com/Raspberry-Pi-Tutorial-How-to-Use-a-Buzzer/ Raspberry Pi Tutorial: How to Use a Buzzer]

Return to [[X708]] or [[X708-hardware]]


<!--Add review function! -->
<comments />

<!--Please choose the -->
<!--Remove other categories, just keep the appropriate categories -->

[[Category:Product Manual]]
[[Category:Raspberry pi]]
[[Category:Knowledge]]

Navigation menu