Closed PBE93 closed 8 years ago
Hi PBE93,
I've tried the 'TemperatureWebPanel' sample. With a refresh rate of 2s it is working. The CPU load is about ~74% (without any other background tasks) - This could be the limited factor.
If you have more than one client the problem is that the 32u4 can only serve one client at the same time. This can slow down your data transfer. A refresh rate of >2s should improve the speed with multiple clients.
You can try to precompile python modules:
python -m compileall
and
python -m compileall /usr/lib/python2.7/bridge
This can take some time, but should speed up the bridge...
If you don't need a website you can try to use the 'Bridge' sample for data transfer.
Hi Redsnake64, Thank you for your help Yes, the CPU is very high, but if I compare with another yun with the last linino, I do every 2 sec. 4 mesurements : temperature, humidity, atmosphéric pressure and 1 analogic with only 65% cpu load. 30-35% for uhttpd and 10% for the bridge.
with Chaos Clamer, now after compilation and some other check the bridge doesn't start. It's stange because the CPU load total is more than 80% with uhttpd at 1 or 2% and 2 or 3 processes at 1% and others processes at 0%
I have added to the wrt the avahi package to see the yun through the network in sketch. I try to restart the bridge tomorow, it doesn't start with run-bridge. I'm not surprised, it never works with other versions of wrt
PBE93
In fact the bridge didn't start because the init of the arduino wait the serial monitor (and I haven't start skech, when it works, the bridge use 64% CPU. the load of the bridge is dependant of the delay (50) in the arduino loop, but it's the same
Hi Redsnake64, I have installed the sample TemperatureWebPanel to have results independant of my code.
test 1 with Chaos Calmer and Navigator closed Total CPU load 8% and bridge CPU load 9%
test 2 with Chaos Calmer and Navigator open on the web page Total CPU load 75% and bridge CPU load 65%
test 3 with official attitude adjustment and Navigator closed (on same hardware) Total CPU load 6% and bridge CPU load 7%
test 4 with official attitude adjustment and Navigator open on the web page Total CPU load 66% and bridge CPU load 14% you can see my top page for each case in the attached file
I have tried to compile bridge.py and load bridge.pyc it's a little faster but the cpu load doesn't decrease. It's a limitation for use of Chaos Calmer with multiple mesurements.
do you know if there are some parameters on python interpreter which can increase the CPU load, I think at some debug parameters
PBE93
Hi PBE93,
sorry for the long response time. Yes - Chaos Calmer is a little bit slower than the orginal system. But you're running the system with the latest security updates & features... If i have time i will try to speed up the bridge. Please let me know, if you have found a solution.
Hi Redsnake64, I see that the bridge work at 250000 bauds, I have tried to fixe the speed in the 32U4 side but it doen't change. is it a too high speed ? now, I have reinstalled Chaos Calmer but the bridge doesn't work, the TemperatureWebPanel diplays only a zero, when it works, it diplays 3 or 4 line of text. I don't know how the bridge transmit data to the web server and if it's possible to activate debug log on the bridge. PBE93
Hi PBE93,
With default settings it is not working?
The Bridge communication transmit data with the serial interface - the bridge.py script 'translate' the 32u4 commands...
Edit: If you remove following lines from the sample sketch it will be also a little bit faster.
Process time;
time.runShellCommand("date");
String timeString = "";
while (time.available()) {
char c = time.read();
timeString += c;
}
Serial.println(timeString);
Hi RedSnake64, I have done some tests with the bridge sample, it's a more simple sample, It works, I can light the red light and turn off it, and I have a correct report on the Navigator, I can read a analog input. It works correctly exept the CPU used by the bridge more 55-60% during a read or a write and 47-55% with the navigator closed. exept this trouble this openwrt is very stable. PBE93
Hi RedSnake64 I have tried to compare the bridge folder of Chaos Calmer with the same folder on Linino. there are a new file "sockets_udp.py" in Chaos Calmer and a call to it in bridge.py, do you know why? pbe93
Hi PBE93,
see: https://github.com/arduino/YunBridge/commit/d2f4d999fff154597d76354aca64ad738d5794e9 Is the CPU usage a big problem for you?
Hi RedSnake64 The high cpu usage freeze some gauge, and the data logging stop to work sometime. It's very strange, yesterday, I have High CPU usage with the bridge sample, this night with the same program, I have a total CPU of 7-8.% and a bridge CPU of 8-9% and if I reload the web page everytime, the total CPU is 20% and a bridge CPU of 13%, it's correct values... before, I only try to run python benchmarks which don't work. it's benchmark-0.1.5.tar.gz from this site https://pypi.python.org/pypi/benchmark/0.1.5 (bridge files aren't compiled) PBE93
Hi PBE93,
Did you install the 'benchmark' package over pip?
opkg update && opkg install python-pip && pip install benchmark
After installing 'benchmark' the CPU load is still the same as before. Which changes did you make?
I've found a little workaround... You can decrease the CPU usage when you add 'sleep' to bridge.py
First post - 'time.sleep(0.01)' https://github.com/arduino/YunBridge/issues/22
If i increase the sleep value to '0.02', the cpu load is about ~25%
Hi RedSnake64 In fact I have tried to run the bench without install and It doesn't work. after 2 try, I have detected stange value of CPU load, sometime for one program the CPU is high sometime the CPU is low, for the bridge sample the CPU is low for TemperatureWebPanel sample the CPU is High. if you have the 2 URLs on the arduino, when you start to enter the URL of the bridge sample, chrome open some urls in the history which start the same. when you open the bridge sample URL chrome open TemperatureWebPanel sample URL this change the CPU load mesurement. with chome and bridge sample sometime i see the LED pin 13 changing of state before I finish to enter the URL... it's crazy.
This evening, I have detected something bad (I think) in the Python program, they have mixed tabs and spaces in the indentation in streamingjson.py (may be some other) there are some stanges indentations I don't know Python but in lot of Python sites, they write that it's not allowed (because one tab can be equivalent to 4 spaces or 6 or 8). the loop in Python is modified by the number of spaces. PBE
Hi RedSnake64 I do last tests with a bridge package without sockets_udp.py and with time.sleep(0.01) it works well. 6% cpu for bridge.py when the Navigator is close and 32% when the web page is open with four mesurements every 2 seconds. The web server is faster than the official version when I open the log file on the SD card. If it continue to work, next week, I upgrade my card with sensors in use. PBE93
Hi PBE93, which bridge package do you use? Does it also work for you when you are using the original bridge package and time.sleep(0.01)? Please keep me informed about your tests...
Hi RedSnake64 I use ChaosCalmer_v1.3 with cpu-mcu-bridge 1.5.1-1 (from lastest lilinoIO + 'time.sleep(0.01)' avahi-nodbus-daemon and avahi-daemon-service-http 0.6.31-12 to connect sketch to the arduino using the network (ip address).
I have tried to add 'time.sleep(0.01)' to cpu-mcu-bridge 1.6.0-1 but it stops to work I have installed temboo but I haven't tested, I use it to send mails alert, I will test it PBE93
Hi RedSnake64,
During my checks, I have detected another trouble, It's a very low bitrate in WiFi.
with 2 arduino yun just near, the Linino has a bitrate of 36 Mbits/s and the ChaosCalmer_v1.3 only a bitrate 1 Mbits/s. (see pictures)
the ratio signal/noise is correct 94-72 = 22dB, the pertormance should be better
The Linino isn't perfect because it disconnet usualy, I need to restart network every nights.
you can see pictures
PBE93
Hi PBE93, just tried it (AP <-> Yun) - working fine. I'm getting 1 Mbit when there's no data transfer. Once there is data transfer the speed increase to 54Mbit. Please try to change your WLAN country code ('Network' -> 'Wifi' -> 'Edit' your WLAN -> 'Advanced Settings' -> 'Country Code')
Hi RedSnake64, I'ts true, if I ping the wifi interface, the speed increase to 54Mb/s for RX and 36Mb/s for TX like LininoIO, is it to to reduce power consumption ? I use FR as country code. Before the end of this week I try to use it during a long period to see if it's more reliable than LininoIO. I think to increase the reliability, I need to add an external antenna because I have ratio signal/noise of only 10dB in the basement, but the 10cm antenna cable for the arduino is expensive, more than 30€, (half price of a Yun) and impossible to find it on eBay China. Thank you for your help. PBE93
Hi PBE93,
yes - It's a very useful feature. As far as i know Yun does not support an external wifi antenna: http://forum.arduino.cc/index.php?topic=188976.0 http://www.lucadentella.it/en/2014/11/08/yun-adattatore-wifi-usb/
Hi RedSnake64, I have seen this picture which is false http://lessons.julien-drochon.net/wp-content/uploads/cache/2014/04/yun-diagram-output/-2026247352.png
For the moment, I continue to use the internal antenna and with a cron, I ping the gateway every hour and I restart network if the network is down. Chaos Calmer is the most stable version for the Yun, It is in use during more than 1 yeek without crash. Only the bridge is to improve because the rest api access with password doesn't work. and the second bug, it's sometime the web server send response with no value (empty). I read data on analog input, on a BMP180, and on a DHT21, if I access to the DHT21, I have some empty responses on all sensors, if I stop to access to the DHT21 all works well. I haven't detected this trouble with the official openwrt. the problem is the same with sandard or unified driver. I use the pin 11 for this sensor, may be I can try to change of pin. PBE93
Hi PBE93,
The rest api access with password is working fine. (Tested with cpu-mcu-bridge 1.6.0 / Bridge sample) Which bridge version do you use? Please tell me more details about this issue... The bridge shouldn't affect the 32u4. This could be a timing problem (32u4). You can also try a different pin.
Hi RedSnake64, I use cpu-mcu-bridge 1.5.1-1 with time.sleep(0.01) because with the 1.6.0 the CPU load is very high and this version stop to work with a time.sleep. The time sleep doesn't change the problem. the problems of the bridge, it's there are no timing adjustements, no debug mode, no logs, no code documentation, no comments in the code. I haven't seen a document on each modules/objects of the bridge I agree with you, I think it's a problem of timing, may be, the bridge with more CPU load is faster than before and doesn't wait the 32U4 response if there are many sensors and a averaging for the analog input. tomorow I will try to change of pin and I try to remove the delay in the 32U4 loop PBE93
Hi RedSnake64, I have changed the delay in the 32U4 loop and the pin used by the DHT21 but it change nothing. I will replace all unified drivers by standard drivers to reduce the code size PBE93.
Hi RedSnake64, In fact, the bridge of ChaosCalmer is more sensitive to the delay of response of the 32U4. the reason for the problem is that the cycle to read temperature and humidity on the DHT21 take more than 270ms with Adafruit Library, I have reducted the cycle time to 5ms (respecting the datasheet) and now it works very well. May be, my Library is optimized for the DHT21 and isn't compatibles with other DHT sensors. I check now if it's reliable PBE93.
Hi PBE93,
the cpu-mcu-bridge 1.6.0 should also work with a 'time.sleep' Can you tell me more details about that problem? Unfortunately i haven't a DHT21 sensor, so i can't test it.
Hi RedSnake64, In fact, the DHT21 locked the arduino loop during 270ms, it's a very long time to read temperature and humidity, I read the datasheet https://kropochev.com/downloads/humidity/AM2301.pdf It's write that we must to put a 5.1k pull-up resistor on the data pin and the read start from a high level and stay to a low level during 0.8ms to 20ms. in the Adafruit DHT.cpp, DHT::read procedure start with : digitalWrite(_pin, HIGH); delay(250); this is not necessary because the pin is pulled up by the resistor since the end of the precedent read. I have removed these lines. after they put at low level during 20ms to start the read cycle digitalWrite(_pin, LOW); delay(20); for a DHT21, 1ms is enough, I replace delay(20); by delayMicroseconds(1000);
in DHT::begin procedure, after pinMode(_pin, INPUT_PULLUP); , I have added delay(250); to be sure that the pin stay enough time at high level before the first read
Now I have a board which works well, I don't touch it this week-end to check if it's reliable and next week I will try the cpu-mcu-bridge 1.6.0. with cpu-mcu-bridge 1.5.1-1, the CPU load of bridge.py is 8% when my Navigator is closed and and 30% with the Navigator open, I think it's good values (1 read 4 values every 3 seconds)
PBE93
Hi PBE93,
The new v1.4 image now includes the bridge workaround ;)
Hi RedSnake, I will try to install it this week-end, thank you ... I have tried to install a ralink usb wifi antenna, to have a better signal, but it doen't work. I think it's a problem of dependancies with mac80211 driver, I will restart with a fresh install. PBE93
Hi RedSnake64 I used a Yun to do some mesurements with official openwrt but it crash after 1 or 2 weeks. I use now the Linino version it's more stable but the wifi disconnect sometime, to avoid this I restart the network every nights.(may be it's because the signal is low I wait a better antenna). Now, I try your version, I do some tests with a code like the TemperatureWebPanel sample in the bridge Library. I haven't the sensor I transmit always the same value to check. when I open the web page, the command is transmited to the 32U4, the value transmited by client.print function is correct but the web page take long time to udate the value ( or the web page do 2 or 3 request tu have 1 response). the same code works well with the official wrt version. I have do the same test with your bridge Library but it doesn't solve problem. by against, if I open a file on the SD card with the web server, it's faster than with the official version. to check the speed, I have removed the https redirect of the web server. Do you know why the communication from the 32U4 to the openwrt is slow? PBE93