Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with setup of emulator on Orange Pi Lite #149

Closed
nikoli280397 opened this issue Jan 13, 2018 · 78 comments
Closed

Help with setup of emulator on Orange Pi Lite #149

nikoli280397 opened this issue Jan 13, 2018 · 78 comments

Comments

@nikoli280397
Copy link

Hi everyone.

Im kinda stuck. I have installed Armbian on my orange pi lite so i can connect to it via putty. I can do that and i tried following the guide on the wiki page. But nothing comes up when searching for the hub in the app. Can someone help me through the setup, im not so strong in python?

Thanks

@mariusmotea
Copy link
Owner

mariusmotea commented Jan 13, 2018

can you start the script manually and provide the output?
ex: sudo ./HueEmulator.py

And what type of lights are you using and expect to be discovered?

@nikoli280397
Copy link
Author

Thank you for your quick answer. The problem is that when i enter the code "sudo ./HueEmulator.py" it says command not found. But all i did was follow your instructions on the wiki.

I plan on adding WS2812 LED strips with a Wifi 01 Mini ESP8266 Dev board.

@mariusmotea
Copy link
Owner

sudo ./HueEmulator.py" it says command not found.

check #20 there is a small tutorial. You receive that command because you are not in the directory where HueEmulator.py is located.

@nikoli280397
Copy link
Author

Thanks i got it up and running. But when i close Putty the connection disappears. Can i do something to make it auto run on startup without being connected to a computer?

@mariusmotea
Copy link
Owner

yes, you need to create the systemd service, i provide example in wiki. Be aware that you must correct the paths to HueEmulator.py script. In my example it was located in /home/pi

@nikoli280397
Copy link
Author

How can i find the location?

@mariusmotea
Copy link
Owner

pwd command display current location. If you managed to start the HueEmulator.py script by using sudo ./HueEmulator.py then it means the script is located in the current location.

@nikoli280397
Copy link
Author

Great. Can you then help with what i should do if i want to connect 120 LEDs connected on a WS2812 LED strip. I have the Wemos D1 mini pro with ESP8266. What files should i upload to the Wemos? and how is it through Arduino IDE?

@mariusmotea
Copy link
Owner

go to Lights -> Arduino -> WS2812BHueStrip
open WS2812BHueStrip.ino with Arduino

#define lightsCount 3 // put here the number of lights you want to emulate
#define pixelCount 120

write the code in Wemod D1 and follow the wiki to connect it to your wifi network. if you have issues with light discovery and you are sure the nmap package is installed, then check #144

@nikoli280397
Copy link
Author

Great what does Lightscount mean? and what number should i set it to?

@mariusmotea
Copy link
Owner

lightsCount let you setup more lights on one ESP8266 board. For example if you setup lightsCount to 4 then on light discover will be detected 4 new Philips Hue strips, first one will control first 30 leds, second the next 30 leds and so on. I like how default scenes are displayed when you set 3 or more lights per strip.

@nikoli280397
Copy link
Author

Okay. I have downloaded the board driver to my arduino IDE but it wont let me upload the code. It gives me this error

exit status 1
Error compiling for board WeMos D1 R2 & mini.
jssc.SerialPortException: Port name - COM8; Method name - closePort(); Exception type - Port not opened.
at jssc.SerialPort.checkPortOpened(SerialPort.java:878)
at jssc.SerialPort.closePort(SerialPort.java:1088)
at cc.arduino.plugins.wifi101.flashers.java.FlasherSerialClient.close(FlasherSerialClient.java:98)
at cc.arduino.plugins.wifi101.flashers.java.JavaFlasher.testConnection(JavaFlasher.java:56)
at cc.arduino.plugins.wifi101.UpdaterImpl$2.run(UpdaterImpl.java:110)
processing.app.SerialException: Error opening serial port 'COM8'.
at cc.arduino.plugins.wifi101.flashers.java.FlasherSerialClient.open(FlasherSerialClient.java:86)
at cc.arduino.plugins.wifi101.flashers.java.JavaFlasher.testConnection(JavaFlasher.java:50)
at cc.arduino.plugins.wifi101.UpdaterImpl$2.run(UpdaterImpl.java:110)
Caused by: jssc.SerialPortException: Port name - COM8; Method name - openPort(); Exception type - Port busy.
at jssc.SerialPort.openPort(SerialPort.java:164)
at cc.arduino.plugins.wifi101.flashers.java.FlasherSerialClient.open(FlasherSerialClient.java:54)
... 2 more
jssc.SerialPortException: Port name - COM8; Method name - closePort(); Exception type - Port not opened.
at jssc.SerialPort.checkPortOpened(SerialPort.java:878)
at jssc.SerialPort.closePort(SerialPort.java:1088)
at cc.arduino.plugins.wifi101.flashers.java.FlasherSerialClient.close(FlasherSerialClient.java:98)
at cc.arduino.plugins.wifi101.flashers.java.JavaFlasher.testConnection(JavaFlasher.java:56)
at cc.arduino.plugins.wifi101.UpdaterImpl$2.run(UpdaterImpl.java:110)
processing.app.SerialException: Error opening serial port 'COM8'.
at cc.arduino.plugins.wifi101.flashers.java.FlasherSerialClient.open(FlasherSerialClient.java:86)
at cc.arduino.plugins.wifi101.flashers.java.JavaFlasher.testConnection(JavaFlasher.java:50)
at cc.arduino.plugins.wifi101.UpdaterImpl$2.run(UpdaterImpl.java:110)
Caused by: jssc.SerialPortException: Port name - COM8; Method name - openPort(); Exception type - Port busy.
at jssc.SerialPort.openPort(SerialPort.java:164)
at cc.arduino.plugins.wifi101.flashers.java.FlasherSerialClient.open(FlasherSerialClient.java:54)
... 2 more

@mariusmotea
Copy link
Owner

mariusmotea commented Jan 14, 2018

Don't try to write the firmware with leds connected to board. Are you sure COM8 is the Wemos D1 board?

@nikoli280397
Copy link
Author

The LEDs are not connected. Yes i used COM8 with the board. I restarted the computer and got futher but still not uploaded now it says "espcomm_upload_mem failed" so i think i downloaded the wrong library what should i download?

@mariusmotea
Copy link
Owner

"espcomm_upload_mem failed" is a generic error. Based on esp8266/Arduino#2801 the options are " you either have bad wiring, or a bad module, or you're doing something wrong"
Try another computer, different upload speeds.

@nikoli280397
Copy link
Author

i again found the solution i had set the flash size to 4M (3M SPIFFS) i changed it to 4M (1M SPIFFS) and now it got uploaded.

@nikoli280397
Copy link
Author

Okay i tried to make the file that would make the orangepi auto start the program. It did not work. Now i cant even start the program via putty. It says its started and sending M-search response to diffrent IP adressess. But after i turned on the power to the LEDs and the ESP8266 my mobile app of Philips Hue wont find the Brigde anymore.

@nikoli280397
Copy link
Author

Okay now the program let me get into the app. But i cant find any lights? How do i connect to the LEDS

@nikoli280397
Copy link
Author

Ah okay there is still a problem with the bridge when i close putty then the connection disappears. Im stuck.

@mariusmotea
Copy link
Owner

you need to start the emulator as service, this way it will not be killed once you disconnect your session.

@nikoli280397
Copy link
Author

How can i do that?

@mariusmotea
Copy link
Owner

@nikoli280397
Copy link
Author

I have followed the wiki, and both made the sudo nano /lib/systemd/system/hue-emulator.service in the first library i come to after login into my orangepi and also here /diyHue/BridgeEmulator. But still does not work when closing putty

@mariusmotea
Copy link
Owner

i believe your service is not working.
execute the following:
sudo systemctl start hue-emulator.service
then
systemctl status hue-emulator.service

provide me the output.

@nikoli280397
Copy link
Author

root@orangepilite:# sudo systemctl start hue-emulator.service
root@orangepilite:
# systemctl status hue-emulator.service
● hue-emulator.service - Hue Emulator Service
Loaded: loaded (/lib/systemd/system/hue-emulator.service; disabled; vendor pr
Active: activating (auto-restart) (Result: exit-code) since Sun 2018-01-14 17
Process: 6183 ExecStart=/home/pi/HueEmulator.py (code=exited, status=200/CHDIR
Main PID: 6183 (code=exited, status=200/CHDIR)

Jan 14 17:35:43 orangepilite systemd[1]: hue-emulator.service: Unit entered fail
Jan 14 17:35:43 orangepilite systemd[1]: hue-emulator.service: Failed with resul

@mariusmotea
Copy link
Owner

ok, you just copy and paste the content of the service from wiki, without to replace the path to python script. In my example it was located in /home/pi/HueEmulator.py, in your case must be different. For this reason i provide you pwd command, to see the location of HueEmulator.py file

Look here another way to see the path:

pi@raspberrypi:~ $ sudo find / -name HueEmulator.py
/home/pi/HueEmulator.py

/home/pi/HueEmulator.py is in my case, in your must be different.

@nikoli280397
Copy link
Author

Here is my location.

/root/diyHue/BridgeEmulator/HueEmulator.py

should i then create the file like this

sudo nano /root/diyHue/BridgeEmulator/HueEmulator.service

@mariusmotea
Copy link
Owner

mariusmotea commented Jan 14, 2018

stop!

i correct here your path. The wiki for you look like this:

sudo nano /lib/systemd/system/hue-emulator.service

paste this:

[Unit]
Description=Hue Emulator Service
After=multi-user.target

[Service]
Type=idle
Restart=always
RestartSec=30
StartLimitInterval=200
StartLimitBurst=5

WorkingDirectory=/root/diyHue/BridgeEmulator
ExecStart=/root/diyHue/BridgeEmulator/HueEmulator.py

[Install]
WantedBy=multi-user.target

save and execute the following commands:

sudo chmod 644 /lib/systemd/system/hue-emulator.service
sudo systemctl daemon-reload
sudo systemctl enable hue-emulator.service 
sudo systemctl start hue-emulator.service

@nikoli280397
Copy link
Author

Still the same. The instant i close putty the connection dissapears.

@mariusmotea
Copy link
Owner

systemctl status hue-emulator.service ?

@nikoli280397
Copy link
Author

Just a last question. When trying to make a Philips Hue account i need to press the bridge but ofcourse i dont have a button to press. Is there a function for this in your firmware?

@mariusmotea
Copy link
Owner

To create a Philips Hue account you will need a real bridge. There is a communication from hue bridge to Philips cloud servers and the api is not public, so it cannot be implemented. Functionality of hue emulators are restricted just to local communication, everything that involve the remote api will not work.

@nikoli280397
Copy link
Author

Ah okay good to know. Thanks

@nikoli280397
Copy link
Author

Hi again. Now its a nother problem. I can control the lights but the bridge seems to loose connection to internet avery 2-6 hours so i can set an alarm for sunrise light in the afternoon but no connection to do so in the morning. I can not seem to find out why its happening.

I have tried to add a reboot command so the pi will reboot every 6 hours. But it still brings problems.

@mariusmotea
Copy link
Owner

Is your pi connected using wifi to your network?

@nikoli280397
Copy link
Author

Yes. And it works but then its like it gets disconneted

@mariusmotea
Copy link
Owner

did you added the cron job from #154 ?

@nikoli280397
Copy link
Author

Yep. Its also were i added the reboot code.

@nikoli280397
Copy link
Author

The problem with the cron job code is that i end up having my bridge connected to my 5Ghz network, but my lights are connected to my 2.4 Ghz network so they can not communicate. I can connect to one of the IP's that the ESP makes but it only lets me change light settings not network settings.

@nikoli280397
Copy link
Author

After a couple of months with 4-6 disconnects every day that required restart i startet from scratch. But this time i can not get futher than this

image

@mariusmotea
Copy link
Owner

I suggest to start with automatic script installation, check wiki

@nikoli280397
Copy link
Author

nikoli280397 commented Feb 28, 2018 via email

@mariusmotea
Copy link
Owner

Execute manually the script to see the error on exit.

@nikoli280397
Copy link
Author

nikoli280397 commented Feb 28, 2018 via email

@nikoli280397
Copy link
Author

Please help me i am doing exactly what you tell me but it just does not work

image

@mariusmotea
Copy link
Owner

No usefull informations here. You need to start manually the script manually to see the error. Better start from scratch and use automatic install method, it must work.

@nikoli280397
Copy link
Author

Yes you say that. But if i start from scratch again i get same result. Starting from scratch was the exact thing i did 2 days ago and it ended me here.

@mariusmotea
Copy link
Owner

If you have a clean installation then try to execute the script from:

sudo /opt/hue-emulator/HueEmulator3.py

@nikoli280397
Copy link
Author

image

@mariusmotea
Copy link
Owner

Is not a completed installation. Execute again the easy_install script from wiki and provide the output.

@nikoli280397
Copy link
Author

image

@mariusmotea
Copy link
Owner

Better paste the text, don't upload pictures.

@nikoli280397
Copy link
Author

Okay
root@orangepilite:# sudo /opt/hue-emulator/HueEmulator3.py
sudo: /opt/hue-emulator/HueEmulator3.py: command not found
root@orangepilite:
# curl -s https://raw.githubusercontent.com/mariusmotea/diyHu e/master/BridgeEmulator/easy_install.sh | sudo bash /dev/stdin
Reading package lists... Done
Building dependency tree
Reading state information... Done
git is already the newest version (1:2.11.0-3+deb9u2).
nmap is already the newest version (7.40-1).
python3-pip is already the newest version (9.0.1-2).
python3 is already the newest version (3.5.3-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Requirement already satisfied: requests in /usr/lib/python3/dist-packages
Collecting ws4py
Using cached ws4py-0.5.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named 'setuptools'

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-oct766p6/ws4py/
root@orangepilite:~#

@mariusmotea
Copy link
Owner

Execute again and provide the output. I made some changes for you on installation script

@nikoli280397
Copy link
Author

It did something, but the hue brigde is still not found in the app
root@orangepilite:~# curl -s https://raw.githubusercontent.com/mariusmotea/diyHue/master/BridgeEmulato r/easy_install.sh | sudo bash /dev/stdin
Reading package lists... Done
Building dependency tree
Reading state information... Done
git is already the newest version (1:2.11.0-3+deb9u2).
nmap is already the newest version (7.40-1).
python3-pip is already the newest version (9.0.1-2).
python3 is already the newest version (3.5.3-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Requirement already satisfied: requests in /usr/lib/python3/dist-packages
Collecting ws4py
Using cached ws4py-0.5.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named 'setuptools'

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-s1i2dvuv/ws4py/
Cloning into 'diyHue'...
remote: Counting objects: 1988, done.
remote: Compressing objects: 100% (86/86), done.
remote: Total 1988 (delta 46), reused 40 (delta 12), pack-reused 1888
Receiving objects: 100% (1988/1988), 38.36 MiB | 5.95 MiB/s, done.
Resolving deltas: 100% (914/914), done.
Installation completed. Open Hue app and search for bridges.
root@orangepilite:~#

@mariusmotea
Copy link
Owner

Try a reboot. Is the service running now?

@nikoli280397
Copy link
Author

Yes now it works i will try the following days and see if it disconnect like last time. Thanks again for great support

@nikoli280397
Copy link
Author

nikoli280397 commented Mar 3, 2018 via email

@nikoli280397
Copy link
Author

nikoli280397 commented Mar 3, 2018 via email

@mariusmotea
Copy link
Owner

Replace your board with something that has physical network port. Your issue is hardware related, not software. If you have an usb wifi dongle you can try to use that for wifi connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants