Category: Orange PI

Orange Pi Zero 2 : A new Raspberry Pi contender ?

The new Orange Pi Zero 2 Single Board computer

If you were searching for a very small and capable SBC to run some linux app on arm cpu , you were already able to buy the original Orange PI zero ,
but the board has some obvious flaws like .

  • 100mbps ethernet
  • very unreliable wifi
  • no display connector
  • Unreliable power connector (MicroB)

Now after a few years, the company responsible for the original board has created a successor with updated specs.
The size of the board is larger than the first , but this is still one of the smallest SBC available on the market at 60 x 53 mm

Bigger than the original OrangePi Zero

Here are the complete specs :

  • SoC – Allwinner H616 64-bit quad-core Arm Cortex-A53 processor @ up to 1.5 GHz with Arm Mali G31 MP2 GPU
  • Memory – 512MB or 1GB DDR3
  • Storage – MicroSD card slot
  • Wired Networking – Gigabit Ethernet
  • Wireless Networking – Dual-band 802.11 b/g/n/ac WiFi 5 + Bluetooth 5.0
  • USB – 1x USB 2.0 host port, 2x USB 2.0 interfaces via 13-pin header
  • 13-pin header with 2x USB, analog stereo audio output, CVBS video output, IR input, 3x GPIOs
  • 26-pin IO header with I2C, SPI, UART, multiple GPIOs
  • Debugging – 3-pin UART header for serial console
  • Power Supply – USB Type-C port 5V
  • Dimensions – (60 x 53 mm)

All this for a board that cost less than 20euros !
looking at the cpu, we have a quad core that might be able to match the performance of a raspberry pi4 but when you look at the cost , it’s more in competition with the Raspberry PI zero W witch has a lot less features than this board and is way less powerful !

I can completely see that board screwed behind a screen and used has an emulation machine .
Or a IP security camera server using MotionEyeOs
Or connected to a ISP router to run pihole (but i would still prefer the original pi zero for this , this one is too powerful for pihole).
Maybe a domotic server like Domoticz or Jeedom , the possibilities are endless !

The main flaw of this new board is the USB port . It’s only a USB2.0 port , and it will limit pretty severely the kind of projects that you can realistically do on this board,
Even if USB2 still has a 300mbps bandwidth. I would choose a board with USB3 to run a server like OpenMediaVault.

you can buy this board here

Orange pi zero – the battle against HEAT

As you know if you own the orange pi zero, the board run very hot. Running it without an heat sink is not really possible if your board is doing anything other than idling

and even with an heatsink you will encounter throttling if your application is a little intensive.

In an other article I managed to get a fan running controlled by the gpio’s.

A cron check every minute the cpu temperature, if it’s above a set temperature, the fan turn on.

On this photo you can see the NPN transistor fixed to the fan

 

If it’s under, the fan turns off.

The first time I did that project it was on my first orange pi zero. I made some mistakes in my wiring and, because of that, the fan only received 2.5v, it was spinning very slowly, and I was obliged to do some bash trickery to get the fan to start.

My original orangepi zero was lost during an apartment change.

I decided to order a new one and this time, I wanted to do the best work I could to integrate the fan and heatsink.

I found an acrylic case for the orange pi zero on aliexpress.

And after receiving my orange pi zero, I saw the board was a new revision, it was running even hotter than my previous orange pi zero.

Few days after receiving the board, the case arrived. It was very pretty but it was blocking any air circulation. And the heatsink had no medium to dissipate the heat since the air was hot and not circulating around the metal.
The CPU temperature rapidly ascended to 80°c.

I own several old fans disassembled from old graphics card, and one of the small fans was just the perfect size. I cut a circular hole in the top acrylic plate so the air from the fan could enter and go trough the radiator fins. The air should after exit from a void in a face of the case were optional usb port are placed.

How to use that fan?

The problem with gpio’s is that they only push very weak current and volts (3.3v). You cannot run a fan directly from a gpio.

But you can use a gpio to control an electronic switch (a transistor) that will be able to run the fan

You should use a npn transistor. They are the most common and cost next to nothing. You will find them for free when you tear down old broken power supply.

To turn on and off your switch, you just have to send 1 or 0 on it’s base.

A great way to control the gpio’s of the opi zero is with the help of that library called WiringPI

you will find instructions on how to install the library on the github page.

after installation lauch the command gpio readall

 

i chose the gpio.7 to control my fan ,

conveniently the gpio 7 is placed in the 7th place on the board , and his wPi alias is also 7

as you can see in the attached capture it’s not always the case !

 

 

 

 

 

 

i then solder my fan and transistor following this diagram :

To continue , i must write a script that check for the cpu temperature , and activate the fan if the cpu temperature is above a certain set threshold.

then , using crontab , set this script to launch every minutes.
add the line * * * * * /root/fan-control.sh to your cron jobs , using the command crontab -e

thanks to this script your fan should automatically launch when your Orange is charged , and stop when it’s return to idling.

InfluxDB insert multiples values at once using curl

If you have to insert multiples values in an influxdb database. You can use curl and insert the values one at the time.

But there is a better way like in this example

Let’s say you want to insert your tree loadaverage values in you influxdb database.

First put them into variables using these 3 lines.

Then using this curl line, insert them all at once in your influxdb database

Orange PI Zero Plus – A simple and, powerfull SBC

if you follow what’s new in the SBC world. You must know Xunglong Orange pi, they are a Chinese manufacturer known for making very cheap sbc’s based on Allwinner chip’s.

One of their most interesting sbc’s was the orange pi zero. It was small, powerful, and was ideal for a small headless server. (still available)

It was extremely cheap: less than 10€ but was plagued with some issues like very poor wifi stability, and poor software support from the manufacturer and, only 100mbps on the Ethernet port.

 

Now Xunlong has come up with an improved version of this board.

  • The wifi chip is now a well supported Realtek RTL8189FTV
  • The Ethernet port is now capable of 1Gb/s transfer rate
  • The cpu is improved with an Allwinner H5
  • The layout stay exactly the same so case are compatible.

I’ve already ordered one of these boards. At 16,02€ including shipping

It’s available at Aliexpress

OrangePI : Install OpenRTSP on a ARM device

One of my project with my OrangePI is to setup the device as a basic IP security camera server ,

the OrangePI zero , will connect to RTSP flux of the IP camera , and dump the stream on to an external disk , where it will be kept for 7 days before getting automaticly deleted
At a latter date i will run a motion detection program on these files and send a mail if motion is detected on a specific part of the frame.

after a little research , i found that a lot of people are using a program called openRTSP to record their RTSP stream to disk

But , after connecting on my OrangePi zero and trying to look for the program i found out that it’s not part of the default installation of armbian stable.

I tried to install the package using apt install openRTSP

I went to google and searched , openRTSP package ,and found out , on the debian website that openRTSP is part of the livemedia-utils package,

I went back to my SSH session and typed apt-get install livemedia-utils

There is no man pages associated with the program , you have to rely on the developer website to understand all the different options . The documentation is available here : http://www.live555.com/openRTSP/  or here if the website is down.
but as usual , in the officials repositories you only get dated version

you might want to compile the source code to have the last version available:

as root

Go to /usr/src: cd /usr/src
Get the live555 liveMedia source code: wget http://www.live555.com/liveMedia/public/live555-latest.tar.gz
Unpack it: tar -xzf live555-latest.tar.gz
Go into the  unpacked directory: cd live
Generate the make files: ./genMakefiles linux
Build the code: make
Install the latest version: make install

The new Orange pi  Zero Plus 2 |allwinner h3, 512mb, 4K hdmi, 8gb emmc

orange pi is an awesome sbc manufacturer known for excellent hardware and awful software support. 

I’m a very happy owner of the first generation orangepi zero witch I use as a headless Linux server on my network. 

Today orangepi release a new version of the orange pi zero called the “orange pi zero 2 plus” the cpu goes from the H2+ to the H3, the wlan controller is better, you get a csi camera interface. And 8gb onboard mmc flash. 

Also the board gain an hdmi port witch enable easy video output to a screen or a TV. 

The board also gain bluetooth support if that something that’s useful to you. 

Overall its seems the addition of the hdmi port is at the expense of the disappearance of the ethernet port witch was for me one of the best feature of the first edition of the orange pi zero. 

The board is made for a different purpose, the 2 plus is going to be ideal for a very small media player or a emulator gaming device. Since the video output and the 4k capability are adding  this kind of possibilities 

The board is also much more expensive than its predecessor at 18$90 compared to the original 512MB orange pi zero at 8$99.

Since I don’t require a video output the original orangepi zero suits better my purpose, but for most people a video output is mandatory, 

The orange pi zero 2 plus is going to be be an excellent board once the armbian team release an image for it. 

Control the orange pi zero GPIO

THIS POST HAS BEEN UPDATED

 

 

After installing my orange pi zero. I tried to use my board the reencode some video file that use xvid/ac3 to x264/aac with the ffmpeg linux command.

The problem was that it took more than two hours at 100% cpu usage on the 4 cores to reencode the video, during that time the cpu was getting instantly too hot and, as a result, was heavily throttling . I tried to use a radiator, and it significantly reduced the amount of throttling but it was not eliminating it, since eventually the cpu reached pretty high temperature.

I decided to add a fan to blow on the radiator to reduce even further the cpu temperature.

I didn’t want the fan to be running all the time so I decided to use the gpio function of my board to control the state of a pin to start and stop a fan.

The problem is that the logic levels sent by the gpio is 3.3v which is much to low to start the fan i own.

My fan is a 12v fan, but it turns out that it can run at 5v, it just have a lot of trouble starting, most of the time when I put 5 v on the fan, I just see a very small movement, and then nothing, I just have to give a little push, and then it will start

Of course, this is not going to be OK. I must find a way to start that fan without that initial push.

To send 5v instead of 3.3v to the fan I used a PNP transistor that will be controlled by the 3.3v signal.

On this photo , the GPIO control pin is wired to PIN number 23 , after i took that picture i changed it to pin number 7

 

As you can see on the photo, the pin one of the PNP transistor is wired to a GPIO pin, the pin 2 is wired to the pin 2 of the board which provide constant 5v,and then the pin 3 is wired to the the red wire of the fan.
The black fan wire is connected to the pin number 6 of the board.

Here is a little schematic of the wiring.

To control the gpio I used wiringpi program that I found at this URL

At first I tried to use the gpio pin number 23 but, for some reason I failed to change the state of that pin using the wiring pi library.

I then chosed to use the pin number 7 which is named GPIO.7 in the “gpio readall” command.

First I configured the pin 7 as an output using that command

gpio mode 7 out

Then i use that command to set pin 7 at logic level 1 (3.3v)

gpio write 7 1

But even with all that, my fan still needed a little push to start turning.

After a good afternoon where I considered buying a cheap and small 5v fan on one of the classic Chinese website, i remarked that if my control GPIO pin was not soldered and I disconnected and reconnected very rapidly the control wire, the fan was starting every time.

The idea of a bash script exploiting this fact was born.

Here is the script that works for me every time!

#!/bin/bash

gpio mode 7 out
i=0
while (($i < 10))
do
gpio write 7 1
sleep .1
gpio write 7 0
sleep .05
i=$(($i+1))
echo $i
done

gpio write 7 1

This  script put the pin 7 in output mode, then switch the state of pin 7 rapidly provoking the startup of the fan.  At the end of the script the pin 7 is left in the 1 state.

To be sure the fan started, I usually launch this script 3 times, but it’s overkill and one time is enough most of the time.

When I want to stop the fan, I just launch the command

gpio write 7 0

And the fan stop immediately,

Now creating a script that launch automatically the fan when the cpu get above a predefined temperature is going to be extremely easy, I will describe it in another article.

Even if the fan is turning very very slowly , it does have a very significant effect on cpu temperature

Reduction of more than 10 degrees

add custom metrics in influxDB

 

If you have a influxdb server running , there is some data collector like Collectd that can be used to automatically write data in your database.
But collectd is very difficult to personalise. and the documentation is pretty bad, (try using the curl plugin and greping data)
You can’t easily add the result of a piped bash command to the collected data for example.

in my case i’ve decided to ignore these pre made solutions that never completely satisfy my needs or write exactly the value i want in the database,

there is a simple way to use a http request to write in the influxDB database.
first before you even write something in ingluxDB, you have to create a database (you only have to launch this command once)

curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE metrics"

then lets say i want to log every 5min the disk usage in percent of my primary storage device. which is named /dev/mmcblk0p1

the df command is only giving me a rounded value : for example 22%

for my example i want a much more precise percentage ,  this little script does exactly that.

#!/bin/bash
#change mmc by the name of your drive , ex: sdba
df_total=$(df |grep mmc |awk -F' ' '{print $2}')
df_used=$(df |grep mmc |awk -F' ' '{print $3}')
df=$(echo "$df_used * 100 / $df_total" | bc -l | head -c 6)
curl -i -XPOST 'http://localhost:8086/write?db=metrics' --data-binary "disc_space,df=used value=$df"

this is writing in the database metrics the percentage used with 3 decimals if you are using 10% or more and 4 decimals if you use 10% or less
the changing precision is not a concern in my use case.

then if you want a value every 5min for example do a crontab -e  and add the line :

*/5 * * * * bash /root/myscript.sh

 

you can then use grafana for example to graph the data.

install Grafana 5 on a PI

If you have a OrangePi or a raspberry pi ,

there is high chance that the version of grafana package in the repositories of your distribution is outdated
in my case , i use armbian , the repo is from ubuntu xenial .

the version of Grafana in the xenial repo is antique (grafana 2.6.0) and the version is bugged if you use a Headless version of the os ,
the icon are not displayed when you are connected to the grafana interface. (because of a bug in phantomJS).

if you have already the 2.6.0 runing , remove it first

apt-get remove grafana

Then use this page to download a recent version of grafana compiled to run on a arm cpu

wget https://github.com/fg2it/grafana-on-raspberry/releases/download/v5.0.4/grafana_5.0.4_armhf.deb
then 
dpkg -i grafana_5.0.4_armhf.deb

if the grafana service is not auto starting at the system boot , you can launch that command :

systemctl enable grafana-server.service

you can check with netstat that your grafana service is running if your server is listening on the tcp port 3000

netstat -tcp -l

now start your browser and try to connect to http://ip-of-your-server:3000

 

Influx DB 1.2.0 on armbian or raspberry PI

If you like me you purchased an orange pi Zero , or a raspberry pi you have the option to use the great OS : Armbian ,
the problem is the repository used is from ubuntu xenial .

the influxdb package contained in the repo is currently only in version 0.10.0 and some critical functionality are missing in this version. (like moving average)

first use apt-get to install influxdb to install the old version

apt-get install influxdb

then stop the server

service influxdb stop

then on the influxDB official website you can find this command to download the latest arm version

wget https://dl.influxdata.com/influxdb/releases/influxdb-1.2.0_linux_armhf.tar.gz
tar xvfz influxdb-1.2.0_linux_armhf.tar.gz

then use rsync -a  influxdb-1.2.0_linux_armhf /  to copy the content of the extracted folder to the / directory and overwrite everything.

the restart the server

service influxdb start

to look if the service is starting correctly you can tail syslog

tail -f /var/log/syslog

in my case i had an error forcing me to do a complicated conversion of the database , or reset the database ,
My database was 2 days old , so i reseted the database ,

rm /var/lib/influxdb/meta/raft.db

the service should now be running ,

you can check that the server is listening on the 8086 tcp port ,

 netstat --tcp -l