The OrangePi Zero is a small PC, similar to a Raspberry Pi Zero, which is manufactured in China. I bought it for $6.99 + postage from China - see http://www.orangepi.org/orangepizero/ .The reason I bought it is that I have an IOT Cloud setup and I capture a lot of sensor data. I wanted to see if the device could meet the following criteria.
1) Available if I want to buy larger numbers. (YES unlike comparable devices in that cost bracket)
2) Regulatory Compliant (APPEARS TO BE)
3) Affordable (need to consider additional power supply, case, heat sink and fan)
4) Fit for Purpose ( This is what I will focus on in this instructable). I had sub requirements for this:
4.1. GPIOs easy to use.
4.2. Didn't overheat.
4.3. Could run from batteries, say a low cost power pack for my remote sensors..
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Introduction and Setting Up the OrangePi ZERO
To set it up, I burn an image onto a micro SD card ( ARMBIAN 5.27 stable Ubuntu 16.04.2 LTS 3.4.113-sun8i) and powered it up using a power pack with output voltage between 2.7 and 3 V. The power requirements are confusing and some say you need 5V 2A but this worked for me .
I connected an Ethernet cable from the Pi to my router and found the device IP address from my web browser - (192.168.1.254 is the url of my home router) - see image. I then use PUTTY to connect to the Pi (credentials are root/1234 which you are prompted to change) and then set up wi-fi. The device was ready for testing.
(Update 6th Aug 2017 -if you are having problems with the Armbian image - try this image Debian_server_dolphin-p2.img.xz - (http://www.orangepi.org/downloadresources/orangepizero/2017-05-11/orangepizero_a1d552c7f0247859389fe3c.html
You may have problems with the usb cable if powering from the micro usb port. Try a shorter cable if the device is not booting properly)
Step 2: Test If GPIOs Are Easy to Use
Log On to the OrangePi then you need to install the GPIO library - This is documented on https://github.com/zhaolei/WiringOP
sudo git clone https://github.com/zhaolei/WiringOP.git -b h3
chmod +x ./build
gpio readall - outputs the table shown in the image
Go to the examples directory in WiringOP directory and there are examples you can compile using the following syntax
e.g. sudo gcc -o blink okLed.c -lwiringPi -lpthread
Whilst you need to solder some pins onto the board, I concluded that this requirement had been met.
Step 3: Does the OrangePi Overheat in Normal Operation and Has It Good Power Consumption
After some research, I learned that a heat sink and fan is recommended for Orange Pi Zero. Given that I want to run the device remotely using batteries / power packs, I knew that a fan would drain the battery quickly. Therefore, I sought a software solution to reduce the CPU load thereby reducing the CPU temperature and power consumption. The OrangePi Zero has 4 cores so I decided to deactivate 3 of the cores. I added the following to Crontab (crontab-e)
@reboot sudo echo 0 >/sys/devices/system/cpu/cpu1/online
@reboot sudo echo 0 >/sys/devices/system/cpu/cpu2/online
@reboot sudo echo 0 >/sys/devices/system/cpu/cpu3/online
I decided that this would work given that my primary function for the OrangePi was simply to record and transmit temperature from a DHT22 temp / humidity sensor.
To log the CPU temperature, I wrote a bash script with two lines
curl -d sensor_data=$TEST -d sensor_id='16' -d id='16' -d Form_Submit='Send' http://xxxx.com/capture_chip.php
The first line assigns the CPU temperature to a variable.
The second line sends the temperature to a php script on my website which writes it to a MySql database. In the above image, I have shown the temperature value after executing a MySql query.
I put the bash script into crontab and polled it hourly on the hour.
0 * * * * /bin/chip_temp_to_web
There are a number of ways to find the uptime but I chose cat /proc/uptime - This returns two values, the first one being the uptime in seconds. e.g. 12315.82 11897.36
I then wrote a bash script to capture the first value (line 1) and then send it to a php script on my website which writes it to a MySql database (line 2)
MYUPTIME=$(cat /proc/uptime | head -n1 | cut -d " " -f1)
curl -d sensor_data=$MYUPTIME -d sensor_id='17' -d id='orange_uptime' -d Form_Submit='Send' http://xxxx.com/capture_chip.php
Again, I put this into Crontab and run it every hour at half past the hour.
30 * * * * /bin/myuptime
Again, from the image, you can see the uptime value in seconds in the MySql table. Obviously, this is how I have chosen to capture the data but you could use any cloud IOT site.
Step 4: Conclusion and Further Work
Following the approach alluded to previously, I have only been able to achieve an uptime of 1 day using a power pack and reduced CPU loading. Furthermore, the low overhead on the CPU is still leading to high CPU temperatures so it seems that I require a cooling fan and heat sink which will increase cost.
Therefore, as it stands, the OrangePi Zero seems only fit for usage with mains power (5V 2A). I may still consider it for certain applications particularly as it still cost effective and more available than say Raspbery Pi Zeros and C.H.I.P. PCs .
I will also try to remove unneeded server services, by modifying the init.d directory. I am also going to try to squeeze more power out of the power packs. What I mean is that the Pi appears to stop working when the powerpack voltage reaches about 2.2 V. I will try amplifying the power using an NPN transistor. I could use more expensive and powerful powerpacks but I want to keep this solution as low cost as possible.