|
Edited by DoubleHP at 2018-2-19 06:06
The final aim of the project is to develop a multifunction proxy for an air cooling system.
I want to be able to control the indoor units (I may call them terminals) via network, shut them down, change temperature, or be able to perform any operation remotely.
Because this installation is in an hostel, I also want to restrict the usage of users. Customers of the hostel are allowed to switch the system on and off, and choose temperature, but I want to limit some aspects to avoid various issues.
The master unit is
AOY30LMAW4
The detailed schematics are here:
http://www.airclim.com.ua/userfi ... BAJ_AOY_LMAW4sm.pdf
***
Users are allowed to manipulate the infra red controller.
The first problem I had was that some users have set the units to a too high value, and this may over consume electricity. To avoid this, I need to analyse the IR frames sent from the remote, to the unit, and do some tricks. Then, when I see a user asked for 26°C, I send a new frame with temperature set to 24°C.
The second issue is that the master unit manages 4 indoor terminals; when one is set as heater, and an other one as cooler, then, the master unit goes in "locked mode", and does nothing at all, but just blinks everywhere. To prevent this, I will force all terminals to always work in automatic mode.
The third issue is that I want an anti-freeze mode. The system does not allow any temperature below 18°C. I do not want to heat the whole house at 18°C when it's empty during weeks long; during winter, I only want to heat it at +6°C. And if indoor tempearture is between +6 and +18, I want to keep the whole system shutdown.
I also wanted to try to make the pi invisible; and avoid using a true IR emeter.
*** Hardware part, air cooling system.
The indoor units are very similar to the ones shown on page 9 of the above PDF.
Why do I have great hope things can be done when looking at this schematic ? I see several power supplies, connectors, and wires. The unit is not one big PCB, but there are wires around, and I can easily access them.
Points of interessed are:
- on top right side, in the indicator PCB, the SBX1810 is an infra red receiver. The out pin is the line 201-7, which becomes line 10-8, which goes to pin 63 after a weak pullup resistor. This part is designed the classic way; data line has a pullup, logic is inverted, what means, the line usually sleeps at +5V; and is shortcircuited to 0V to transmit things. I will call this line IR-OUT, or IR-DATA. In practice, this line is a long wire, about 60cm long running in the terminal; it's very easy to either cut the line and insert a derivation, or use a vampire connector.
- in the same region of the scematic, we easily find a "local ground", the 0V level.
- below the indicator PCB, we find a TEST plug, which includes an other ground pin. This pin has a better gauge than the ground wire of the INDICATOR, and is better suited for ground connections, and supply.
- The indicator PCB include a +5V line, but it comes from a 7805 which are usually rated for 1A or 3A. The Orange pi consumes between 0.2 and 0.3A; and I do not want to load the built-in/manufacturer's 7805 with this if it's designed for 1A. So I am notgoing to supply my opi from here; but on the DIFFUSER plug, there is a 14V pin. Again, I can easily catch this pin, and put a vampire connection on the wire. Conversion from 14V to 5V is done with a "car conversion module 12V-5V micro USB" https://www.amazon.fr/gp/product ... 3_s00?ie=UTF8&psc=1 ... or this model because I prefer the 90° plug (which turns in the good direction for opi) https://www.amazon.fr/Transforma ... Z9VVCEPHQV45B5CMP16 .
Please, pay attention to the fact the "local ground" (aka 0V, the small ground with vertical lines below) is NOT connected to "earth" (yellow wire coming with the live mains, phase and neutral, which uses a triple horizontal lines symbol). This detail is important. And I will do my best to use these words correctly: ground vs earth.
By plugging the pi directly to the IR-DATA line, I can at the same time:
- receive IR frames; the pi will receive exactly the same IR data as the main board of the terminal, disregarding any light condition, reflection, or else. I do catch exactly the same data as the terminal.
- because the IR receiver is iddleing at high state, and pulling the data line down to send data, it's trivial for the pi to also send data on this line, by grabbing the line down when required, and leaving the line floating otherwise.
*** Orange pi startings
I chose the Orange Pi Zero cheapest version 256M, H2+. For SDcard, I had many problems with cheap cards, so let's use good quality ones: Sandisk Ultra white-grey 16GB; a smaller card would be cheaper, but I could not find them anymore. The supply is mentionned above.
I will also use a DS18B20 1W (1wire) temperature probe. They are sold with 1m wires for 2€ on Amazon.
The disk image I used is Armbian_5.35_Orangepizero_Ubuntu_xenial_next_4.13.16.img
https://www.armbian.com/orange-pi-zero/
Note that the version 5.35 will change after update (after running aptitude update / aptitude distupgrade, the version will be updated to 5.38 or more ...).
Also, it's critical to know that this image is using a 4.13.16 Linux kernel. There have been huge changes between line 3 and line 4 kernels, and all other tutorials that were written before mid 2017 are deprecated and unusable on Linux 4.* . The explanations below do not apply to Linux 3.* .
Most people write the disk image using dd; I use a wrapper that does many tricks for me; I will not cover this part here. This tutorial is not about step-by-step complete setup; I will only cover what's specific to my project. But, I let you know that my wrapper does many things: get rid of root password change and user creation, setup fixed IPv4 and IPv6, and setup my VPN; and install many packages (make, unison, gcc, git ...). Before the very first time I log in the pi, all this is already done. I won't either talk about SSH. My wrapper sets-up RSA auth keys, so that I don't have to think about passwords at all.
*** Reading temperature.
This is probably the easiest part.
Edit /boot/armbianEnv.txt and on the line overlays, add the w1-gpio word; and param_w1_pin=PA15 on the next one; it will look like this:
- # cat /boot/armbianEnv.txt
- verbosity=1
- logo=disabled
- console=both
- disp_mode=1920x1080p60
- overlay_prefix=sun8i-h3
- overlays=cir usbhost2 usbhost3 w1-gpio
- param_w1_pin=PA15
- rootdev=UUID=ebe9dacf-124f-486c-b6c1-08749e209374
- rootfstype=ext4
- usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u
Copy code
Note that this setup is specific to the Orange Pi Zero H2+ (common for 256 and 512), due to the fact we have an additionnal memory chip on the first SPI bus.
On RAspberry Pi forums, I have learnt that 1w requires time critical commands, and that only the SPI bus is able to provide this; so, in short, 1W can be handled only on SPI pins. The oPi has two SPI bus; the first one is dedicated to the memory chip at the back (16MB IIRC), a small bsquare chip with 8 legs on the back of the pi, just in the middle, you can't miss it. Recent opi0 have a larger memory; opi that are not in the 0 range do not have it (and they have only one SPI bus). All this explains why the w1-gpio wrapper can not use the default first bus, and needs to be instructed to use the second SPI bus, the one on PA15. This may vary on other opi0 (the ones which are not H2+ or H3: H5 and other bananas). And it will differ on non 0 pis.
After this modification, you need to reboot. I give all commands in one shot:
- # ls /sys/bus/w1/devices/
- 28-041703225eff w1_bus_master1
- # cat /sys/bus/w1/devices/28*/w1_slave
- 4f 01 4b 46 7f ff 0c 10 46 : crc=46 YES
- 4f 01 4b 46 7f ff 0c 10 46 t=20937
Copy code
And from an other pi which has two probes:
- # ls /sys/bus/w1/devices/
- 28-0517023468ff 28-0517025727ff w1_bus_master1
- # cat /sys/bus/w1/devices/28*/w1_slave
- 8f 00 4b 46 7f ff 0c 10 a0 : crc=a0 YES
- 8f 00 4b 46 7f ff 0c 10 a0 t=8937
- 92 00 4b 46 7f ff 0c 10 88 : crc=88 YES
- 92 00 4b 46 7f ff 0c 10 88 t=9125
Copy code A quick conversion into °C :
- # cat /sys/bus/w1/devices/28*/w1_slave | grep "t=" | cut -d "=" -f2 | awk '{print $1/1000}'
- 8.937
- 9.125
Copy code
Note that if you have other non DS18B20 1W devices, this quick script will break.
I also remind you that things like 28-0517023468ff 28-0517025727ff are world uniq 64b identifiers. You can rely on them; they can not be predicted when you buy a new item. Once you installed a new item on a pi, this identifier will never change.
*** My failed attemps to use lirc-alsa
https://forum.armbian.com/topic/ ... s-on-orangepi-zero/
In that thread, I explain that I have found a bug in mode2, how to use (in theory) an Alsa sound card to read and emit IR frames, and how it all failed for me.
|
|