-
Notifications
You must be signed in to change notification settings - Fork 239
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
Local bus going through walls / outdoors #222
Comments
ciao @drtrigon for sure LoRa is a choice, but if the requirement is a point to point connection, maybe HC-12 it can be cheaper and simpler. It can be used with SoftwareSerial and it has a range of around 150 meters without line of sight. If "paranoid" and you dont want to broadcast your data over a relatively wide range, you may also use AS along with a couple of laser diodes, although it is for sure a solution that would require some more tinkering and collimation, with line of sight it can work for hundreds of meters. Obviously it is required to take extreme care working with laser specially when collimating paths, always wear protective glasses and if installing a definitive setup be sure its path cannot intersect human or other living creatures eyes' nearby. The use of infrared spectrum does not reduce the risk but just keeps the emitted light invisible. In not recent tests I got more than 100m range out of a 10mW laser diode. |
@drtrigon I do not have personal experience with Yun and Dragino. Who has more experience with LoRa is @Matheus-Garbelini who is the creator of the ThroughLoRa strategy. For sure I would choose from the list of supported devices if possible. |
@drtrigon another thing, if you use a shared medium, be sure to use PJON in shared mode, in order to avoid potential collisions with others' devices nearby. |
@drtrigon Interesting, application. As @gioblu suggested, there are other options for point to point communication, but as your application has more than one wall/window sections (B option), LoRa.strategy.setSpreadingFactor(7) and in the other segment: LoRa.strategy.setSpreadingFactor(8) This ensures that each PJON message frame is transmitted in an orthogonal way, avoiding broadcast issues. Be aware that LoRa support in pjon is new so you need to tweak some timeout default values as discussed ni #220 (You'd need to modify 2 definitions). As you already have a Lora Gateway at your disposal and it uses an SX1278 internally, the current PJON strategy appear to be compatible with your device. Looking through the software support for this gateway, it uses Radiohead rf95 library to communicate with the Lora, it means that the sx1278 is attached to the default SPI pins of the Arduino UNO that is inside Dragino LG01-S. Tell us about your tests an we'd be happy to add to the documentation your device as supported. Thanks. |
@gioblu: Thanks for your fast reply! I don't know the HC-12 radios and a quick view into google showed me no local distributor so I'll keep looking, but for now it does not seem like a quick alternative. Laser diodes are something I did consider too at some point. Do you have experience? How well does the beam need to be aligned to the receiving diode? |
@Matheus-Garbelini: Thanks for your post and verifying the specs with the manual! That sounds great! I actually already wrote the SWBB - LoRa tunneler and the plan was to use it twice [1]. The thing is - I was not able to progress to that point, as the SWBB bus communication between my Uno+ETH (LUDP-SWBB tunneler [2]) and the Dragino LG01 SWBB part did not work properly. It did on a test setup with Nano (TS-SWBB tunneler [3]) so I currently have no idea (may be the bidirectional level shifter [4] causes issues) ... in any case I have to fix that first ... so at this point I first wanted to verify that my concept can work theoretically at least. [1] https://github.com/drtrigon/sketchbook/blob/master/OWPJON/ARDUINO/Local/SoftwareBitBang/Tunneler/BlinkingSwitch_SWBB-TL_DRAFT/BlinkingSwitch_SWBB-TL_DRAFT.ino |
I have experimented a lot with light pulses communication and laser communication using PJDLS, that is quite effective. Depending on the beam diameter at the receiver side a certain deviation in the path can be present without issues. So using a lens that has an extremely wide beam at a short distance (let's say a meter) the deviation can be big (a lot of degrees of error) although the maximum range will be obviously limited. In the opposite situation, with a small beam, you will have a longer range but a smaller acceptable deviation. The acceptable deviation is slightly less than the beam radius at receiver side. The beam diameter grows with the distance between transmitter and receiver. Knowing the beam diameter then with simple geometry is possible to determine at a given distance which is the maximum acceptable deviation for a system of this sort. Consider that the smaller is the beam the more dangerous the system is for eyes :) |
Good news! I got most of it working! For the 2nd TL-SWBB tunnel, the time I had was to short - will follow. LoRa works! (I have that stuff - for laserdiodes I would have to wait several weeks.) |
@gioblu: How can I enable the "PJON shared mode" ? https://github.com/gioblu/PJON/wiki/Configuration does not seem to work for LoRa tunnel with PJONAny? |
Ciao @drtrigon my stupidity to leave outdated pages in the wiki, that will be deleted now. This is the configuration docs (that are also linked in the wiki menu): https://github.com/gioblu/PJON/blob/master/documentation/configuration.md Sorry for the inconvenience :) |
@drtrigon forgot to say previously that, considering the stability of PJDL using also unconventional conductors (human body, fruits and vegetables ecc.) for communication, if conductive parts of the house/fixtures that are not grounded are present they could be considered as a potential path for a PJDL bus if the necessary caution is taken to protect the IO pins. |
Ciao @drtrigon about the level shifter, what about this design: Schottky diode
|---[___|_]---|
3v3 IO ---| |--- 5v BUS
|---\/\/\/\---|
resistor so 3v3 from 3v3 device can pass through the path with less resistance (the diode) and conserve its voltage - the diode voltage drop across its ends (using a schottky the drop can be negligible). In the opposite case the 5v would pass through the resistor and its voltage can be brought down to 3v3 selecting the required resistance value. |
@drtrigon here a simulation with circuitjs: Closing the active switches (clicking on them) and activating the others you can simulate the opposite case. It seems it is required to have:
|
@gioblu: Thanks for all your answers! I try to answer properly: Thanks for the info in https://github.com/gioblu/PJON/blob/master/documentation/configuration.md about shared mode - will consider that. However I am a bit confused by "Medium" column in the table; why is it radio for OverSampling but serial port for ThroughLoRa? That's radio too (actually the medium is "air" ;). Then I am also missing the more exotic ones you mentioned "unconventional conductors (human body, fruits and vegetables ecc.)". Because this is one of the main reasons why I love PJON meanwhile. Additionally I would strongly suggest to mention that security measures to protect human body might be needed for several of them (e.g. laserdiodes, etc.). I used this circuit (somehow inspired by V-USB but is not the same):
It works but has at least these disadvantages:
Because of the 2nd item I plan to setup a "3 way" tunneler (LUDP, SWBB, SWBB) that gives me 2 SWBB pins (on same bus). That way I could put all 5v divices on 1 pin and the 3.3v on a separate, isolating the 2 parts from each other. |
I should may be also mention that I got the system working: LUDP - SWBB - LoRa - SWBB where on the two SWBB buses my devices are connected. I also setup a device that can connect to DS2438 and DS18B20 1wire devices in order to be able to use the old sensors with my new network also. Very nice! Some issues still remain, e.g. sometimes the first message does somehow get lost or the answer is related to an request done earlier. |
Ciao @drtrigon thank you for reporting the inconsistencies in configuration docs, will follow commits to solve those issues. I agree with you must follow also a remark about safety. The working principle of the circuit I was suggesting to try is to use a Schottky diode to reduce the amount of voltage loss (if compared to a normal diode) when electrical impulses pass through it making a high pulse from 3v3 side high enough (3/3.1v) for the 5v side to detect it as a 1 also if there is a considerable voltage drop in between. On the other side a single resistor reduces the voltage of the 5v pulses to 3v3 while the Schottky blocks the flow in that direction. My compliments for having a network that complex in operation already :) |
Hmmm, thanks for the simulations I had a look also at mines and replaced the Schottky with an other type, now I can see how this is supposed to work. I have the impression that the resistor needs to have quite the right value as the level (3v3) depends on the divider 1M / (1M + 510k). My PJON network is very nice - I enjoy playing with it. But it will take some more time to get it working properly as I use solar cells for power supply and thus the used Yun is a bad choice (very power hungry - need to be replaced by an Uno). |
@gioblu: Thanks a lot for the wiki updates and fixes! You added a few nice hints I did not think about yet! Just tried to use the code from https://github.com/gioblu/PJON/wiki/Error-handling and found that the constant names are not correct anymore:
|
As mentioned earlier sometimes the first message does somehow get lost or the answer is related to an request done earlier. Other issues like delay resp. not replying on first message also exist mainly on the LoRa tunnel part. The SWBB-TL tunnel reports this:
(the devices on the bus have ids 42, 44, 45 and 46 - 0 and 1 do not exist) |
Ciao @drtrigon thank you for reporting the outdated wiki pages. I have cleaned up removing all the outdated pages. Could you describe me more in detail what you are sending and in which section this problem appears? |
@drtrigon about possible serial output related to stuff happening before the reset, it may happen in general if serial data was incoming before reset. Probably data still in one of the buffers. I would say that is an issue of the Arduino IDE. |
@gioblu: Let me first write down the hardware setup:
so that debug output was coming from (2). As I derived all the tunnels from Forgot the what:
...but sometimes is screws the returned values (on SWBB C mainly), e.g.:
not only that there are wrong values (comming from other devices), there are also correct values at the wrong place (e.g. comming 1 call later). Somehow looks like a buffering issue - but I am not sure what would be better for (Watchdog reset of (2) and (3) helps the whole system to recover faster - within seconds to minutes.) May be I should also add that my program on the linux side does NOT run continuously. It starts, sends a command (1 byte usually) and waits for an answer, after that it closes. If no answer arrives it re-tries to send. So it is possible that some messages keep hanging in some buffer on the bus. Adding a short period of receiving "old" messages before sending seems to improve the situation. Is there a command to find and /or drop "old" messages from the bus when connecting to it? |
@gioblu: Am I right in assuming that
so this is Is there any statement possible whether |
@drtrigon I searched for the "Connection with device ID" text, and found it only in the SendAndReceive examples, not in any router/switch-related code. I therefore assume that the errors are coming from SendAndReceive device1 or device2, not a switch. I do not see how it can print that message if the SendAndReceive example is trying to send to device id 44 or 45, but I do not think this message is routing related. Can you share the actual sketch writing these messages, assuming it is a modified example? Are you running |
Comments to a couple of questions (quoted):
Regarding the use of LoRa and different spreading factors for multiple LoRa switch pairs, given the long range of LoRa, would it not be possible to avoid this by having one SWBB-LoRa switch indoor, and a common LoRa bus for all outdoor SWBB-LoRa switches? This would reduce the number of devices and wireless complexity. @Matheus-Garbelini and @gioblu, what do you think about this? |
CIao @drtrigon sorry for the delay, I suspect you are seeing the effect of the notebook not being able to discharge induced interference not having a direct link to ground. To solve the issue in SWBB bus, reduce the resistivity of the pull-down resistor, or place it if not present. |
I dont think so (or I don't understand) - the notebook is not connected (physically) to the SWBB part. The notebook is connected via wifi only. I really think it is a timing issue related to udp socket respective ethernet hardware. When I remove the code block to make it "non-blocking" essentially all BUSY and connection lost are gone. So to do it properly I increased
before Question: Does |
I did a very naiive test using ping to my router, here the results: battery powered:
average ping time: 1.555 ms / minimal ping time: 1.130 ms from power supply:
average ping time: 1.124 ms / minimal ping time: 0.858 ms As you can see on battery the ping time is always >1ms. As it seems this is quite relevant for my setup and even more for the devices behind the lora channels/3 switches. This would really explain a lot of the stuff I have seen and reported here. It is not 1 single cause but a combination of:
all that leads to lot of repetitions on the bus and that again to BUSY or even connection lost (and these to completely messed up returned values in my case). Here some info that might be relevant: https://www.ctrl.blog/entry/linux-wifi-dpm-latency and https://www.howtogeek.com/217463/wi-fi-vs.-ethernet-how-much-better-is-a-wired-connection/ Also switches on ethernet will increase the latency in order of ms, see https://www.edn.com/Pdf/ViewPdf?contentItemId=4135948. |
(also useful to find free frequencies/channels for PJON TL) improvement; * make OWPJON bus a lot more stable see gioblu/PJON#222 * network delay/latency (especially when on battery powered wifi) * a lot of switches in row (here 3) * possibility of blocked lora channels (increasing delays)
Now that you have LUDP and SWBB buses under control, I think I would thave tried an alternative to LoRa just to have tested alternatives. What about HC12 or the very simple ASK modules? Reduced sensitivity may reduce problems? In my earliest setups I used a Nordic Semiconductors NRF24 transceiver which worked well, except for strange temporary periods of a few hours with no communication. I never found a reason for these, as they came and passed with no action from my side. Most probably external interference, potentially from a neighbor. Later I was lazy and dug down a long wire instead of solving the wireless problem :-) |
@fredilarsen: I agree I was thinking about alternatives, 2 things came to my mind:
The reason why I did not continue this route (for now):
|
Then there is the alternative already mentioned by @gioblu, using AS with normal or IR LEDs. Just putting a couple of LEDs face to face should do it. Low power usage and no chance of anybody picking up or interfering with the traffic. Perhaps @gioblu has done experiments with capacitve coupling, But I suppose the wires will act as antennas and be more susceptible to electromagnetic interference, just like the radios. It is on my agenda to try out the HC12 and LoRas at some point. I tried the green very cheap ASK modules without much luck, then bought some blue ones that should work better, but in the meantime I have gone wired, so wireless lost priority. |
The AnalogSampling ... I could talk for days about it (I fell in love with it when I first read https://www.researchgate.net/publication/221568729_Very_Low-Cost_Sensing_and_Communication_Using_Bidirectional_LEDs?_sg=r-MhohoC0ihWf5g5jnBHao8JNqV8qDvtWdMB82RV-eAN4Q2GThLUM4gKbKWp-wSdY0nTkxuhig years ago and sweared to use it myself someday ;) ... the points holding me back currently are:
... nevertheless I am currently looking into ordering some ir leds ;) ... any recommendation? I configured my outdoor network now to be the productive one even though it does not work perfectly yet. That way I can easily get more experience with it, test some parameters and last but not least the error and recovery behaviour of PJON is in any case better than that of owfs. Meanwhile I had 2 freezes of the SWBB-lora switches and am considering to use an 8s watchdog there. @fredilarsen: Any update regarding FIFO LUDP-StdIO or wireless setup are very welcome and will make me very happy! So I look forward to hear from you! ;) |
Ciao @drtrigon that paper is a bible I agree, although it does not describe the AnalogSampling procedure. They apply there the reverse bias technique (charge inversely the LED, sample voltage discharge time that is proportional to incident light) also popularized by the Arduino LED sensor example: Years of experiments have practically determined that for communication is better to use forward bias, instead for detecting distances, without a signal amplification stage, it may be more sensitive reverse bias, at the cost of a lower sampling frequency. I have chosen to use LEDs as photodiodes in forward bias (or as photo-cells/solar cells) to be able to potentially obtain the highest baudrate and in the worst case need an op-amp. The biggest difference is that we use a passive analog reading (from where comes the name AnalogSampling) instead of an active procedure (reverse biasing the LED then swap the pin state and determine the duration of a digital impulse).
For the reasons described above AnalogSampling was designed as it is, and I would say that the paper describes a less "direct" and more convoluted way to obtain the same result (the discharge time it is strictly related to and is direct consequence of the photo-voltaic effect AS uses in the first place). See this issue here: #228 |
Ciao @drtrigon sorry, about LED suggestions, use 5mm infrared LEDs, this:
or you can buy a bunch and evaluate their performance, see how to do that here: |
this is bad, probably third-party lora library, should be investigated further, looking into it. Thank you very much for reporting this :) |
@drtrigon I see there are some unanswered questions in your posts above, relating to LUDP. First, if the PC goes on battery, you may still change the WiFi behavior in power savings settings, and ask the network card to stay on high performance while on battery. Probably it just wakes up now and then when on max battery saving. The LUDP_RESPONSE_TIMEOUT is used also in a switch. We should change this timeout to be overridable in the strategy. Have you done this, or should I do it? As a third comment , I have been struggling with UDP based networking on the W5100 based cards. It seems there is a bug in the W5100 chip that makes it lock up at random times when it tries to send when a reception starts. I am experimenting to see if it can be compensated for by changes to the Arduino network library. Otherwise we will have to use the watchdog timer to do a reset when it locks up. In my setup a lockup appears between 6 hours to 10 days after startup. Incredible to see such behavior in a product sold in millions. |
No I did not do it, I just did this: https://github.com/drtrigon/sketchbook/blob/master/libraries/PJON-master/src/strategies/LocalUDP/LocalUDP.h#L32 Regarding the UDP switch issue, I am currently experimenting a bit with watchdog on my SWBB-lora switches: https://github.com/drtrigon/sketchbook/blob/master/OWPJON/ARDUINO/Local/SoftwareBitBang/Tunneler/BlinkingSwitch_SWBB-TL/BlinkingSwitch_SWBB-TL.ino#L179
The W5100 chip lock up; what is the effect of this? A freeze or a delay in packet processing? I suffer more from freezes in the SWBB-lora switch. May be my system was just not running stable and long enough to uncover the UDP switch flaws yet. |
The UDP bug in the W5100 makes the while loop in the sendUDP function in socket.cpp in the Arduino Ethernet library loop forever when it happens. So the switch is just hanging on this function forever. It happens when an incoming packet arrives while sending, so the status is set to RECV instead of SEND_OK, and it waits forever for sending to complete. So I guess it will not happen in a strict master-slave based setup where a packet will not be received while trying to send. But I have two master-slave setups running at the same time on the same LUDP bus for testing, and also my ModuleInterface library supports exceptions from the master-slave principle, allowing in my case a movement sensor to be broadcast immediately without waiting for the regular request from master. This will heighten the probability of this happening as well. I am testing modifications to the Ethernet library, but with days of waiting between each attempt it is slow going. Currently trying to detect the eternal loop with a loop counter, closing the socket in 2 layers, and trying to open a new one and continue. Hoping the network shield and the Arduino does not actually need to be rebooted. I have not tried the watchdog timer yet, to see if the reboot also reboots the network shield enough to get it working again. This is the least preferred solution for me. |
Hi @fredilarsen , You mentioned ..
May I ask how you were able to do that with PJON? .. my understanding is that ThroughSerial accepts a serial (or software serial ) which is OK for HC-12, but NRFs has SPI interface .. apologies if the question is naive .. I'm still a newbie who just discovered PJON! .. Thanks a lot |
@mrfawy: I guess he is referring to "OverSampling" strategy. @gioblu: Just came across "If using OverSampling, the asynchronous acknowledgement is suggested as acknowledgement mechanism because includes in the packet's meta-info a packet id, avoiding duplicated receptions." Can you elaborate whether this is useful for lora too? (You recommended to me to use it for ThroughSerial some time back...) Is this id not included by default? Is it also compatible wit attiny85 (code size etc)? |
@mrfawy I used the NRF24 before I switched to PJON. I used a more primitive serialization and routing at that point. Surely a PJON Strategy could be made for the NRF, but it would have to be on top of SPI. @drtrigon There is a PJON_INCLUDE_ASYNC_ACK preprocessor definition that must be set to include support for async ack. It will allocate memory to keep a list of recent packets, but you can reduce the size of this list by setting PJON_MAX_RECENT_PACKET_IDS (for example to 2 instead of 10). Try setting these defines and see if it fits along with your own code on a tiny. It may get crowded. |
Ciao @drtrigon if you are looking for packet uniqueness, and so avoid the duplicate reception of packets you could include just the packet id see docs here: https://github.com/gioblu/PJON/blob/master/documentation/configuration.md#extended-configuration I would suggest you to start from adding the packet id, the asynchronous acknowledgment can be useful to have transmission certainty in a multi-hop path |
@fredilarsen @drtrigon thanks a lot for clarification... yeah I guess that would be great to implement an over sampling strategy for NRF24s over SPI .. |
@gioblu: Quick test on tiny85 shows about +500 Bytes to end up with about 6 kBytes (70-75% of space) this is not to much of free space for other code but works theoretically. Asynchronous acknowledgment adds another about 100 Bytes. |
Ciao @drtrigon thank you very much for the test, #define PJON_MAX_PACKETS 0 // Spare memory with an empty packet buffer
#define PJON_PACKET_MAX_LENGTH 25 // Maximum packet length of 25B - overhead
The LEDAR program:
Async ack does not work on ATtiny (because the packet handler requires too much ram). |
@gioblu: Here is the code I use https://github.com/drtrigon/sketchbook/blob/master/OWPJON/ATTINY/Local/SoftwareBitBang/DeviceGeneric/DeviceGeneric.ino#L56 ... Do I assume correct that I cannot mix async and sync ack? So if I want to use tiny85 on my bus I cannot use async ack at all?
What does that mean? Even though I activate it it will not work? Or does it mean it is not activated by default? Going back to my very initial question ... from my side we can clean up this issue as I got a lot of advices regarding on how to setup a solution for an isolated connection going through a wall or a window - thanks! Other issues raised here that need further work:
did I forget anything...? |
Beautiful, thank you very much @drtrigon for your valuable and passionate support to the project :) |
Ciao @drtrigon :
|
Most hints I have so far indicate that it seems to be Sw B more often than Sw C. May be also a send receive clash when a alien lora transmission comes in? Don't know yet... I need #242 for more debug info - I need to find the proper condition for the watchdog resp. more details on what happens; which bus stops sending? what error does get triggered? does it freeze completely? etc... |
We should change LUDP_RESPONSE_TIMEOUT to be overridable in the strategy. See also: * gioblu#222 (comment) * TS_RESPONSE_TIME_OUT (we should also use a consistent naming; either TIMEOUT or TIME_OUT - not both)
Now as I have my minimal bus up and running (linux/raspi - LUDP - Uno+ETHshield - SWBB - devices) I would like to extend it to outdoor sensors. What setup would you suggest to go through walls (without drilling holes) or windows? I can imagine these setups:
A) SWBB - AS+LED - window - AS+LED - SWBB
B) SWBB - LoRa/radio - window/wall - LoRa/radio - SWBB
C) ?
for A+B I would like to use 2 tunnelers. The LoRa radio setup would be preferred as that would allow also to add devices to the LoRa bus (between the 2 tunnelers) and I do not need to setup LED line-of-sight communication. If LoRa is the best choice, I would like to use a Dragino LG01-S (Uno/Yun combo) for the SWBB - LoRa part, so also direct LUDP - LoRa tunneler is a possibility...
What would be your advice?
The text was updated successfully, but these errors were encountered: