Hacker News new | past | comments | ask | show | jobs | submit login
How we made the PJON network protocol from scratch (pjon.org)
125 points by gioscarab on Dec 20, 2020 | hide | past | favorite | 33 comments



Very interesting! I enjoyed testing PJON with 2km of twisted pair cable for my university project: https://jda.tel/pdf/lanc_video_camera_control.pdf


I use PJON in combination with MYSENSORS in my smart home system. . It is the first wired protocol that works so stable and don't even need extra hardware - just one free IO pin. I have over 200 smart sensors and devices around my house. PJON was a perfect solution for all problems I was facing with wired and wireless communication for DIY smart home solutions. With some luck PJON will be officially supported by MySensors already from next release - beta test are already done. I think this will make PJON more common.


> over 200 smart sensors and devices around my house

I need to know!


So he remade CAN without requiring a specific physical layer?

This jumps around a bit between the transport and phy a bit, I guess I didn’t really get where the special sauce is. I also never saw a kbps number.

There is potential I would have use for such a thing I guess. Although LIN works pretty well over 1wire and is built in to most UARTs now.

It makes me cautious when I read these things and don’t see specific talk about what hardware module is expected to do the work. Yea, they got two wire twisted pair distance, is that using a specific transceiver? Does that hook to a USART or CCP or SPI? It sounded async because of the longer bits as start of frame, but bit banging and capture/compare kinda sucks.... IDK maybe it addresses this all and I missed it.

What I didn’t miss is he is selling a book at the end.


Here you can find the implementation of PJDL used by Jack Anderson to determine the maximum range:

https://github.com/gioblu/PJON/tree/master/src/strategies/So...

All devices listed in the compatibility section are able to communicate over a twisted pair with no additional hardware, as Fred well noted, you just need one wire and connect directly the IO pins. And up to 255 devices can share the same twisted pair.

As you can read in Video Camera Control Jack just used two arduinos, 2km of wiring within his university's network and a couple of pull-down resistors. The protocol works even when the human body is used as a conductor as shows the gif present in the article.

On social compare someone made this: https://socialcompare.com/en/comparison/comparison-of-networ...

I think the comparison between PJON and LIN there is revealing. As you can see LIN handles up to 16 devices, it is master-slave and has a range of 40, with a complex front-end at a relatively high voltage.

PJON is free for use, it is all open-source. We do sell products to fund the development of the project.


Thanks, that helps.

I had to check quick at a gas station and post this.

For the most part, I took away 27kbps, and it seems the intention is software bit bang.

Sure, it’s not master/slave like LIN, and with an arbitration scheme more like CAN. But, without hardware codec, DMA buffering and interrupts, I feel it’s a lot less useful to me as my embedded projects are already pushing their limits with hardware communication.

Still, while it’s not good for me, I do see utility in a bit bang format for LED, IR, simple RF, etc. This makes sense and seems well thought out.


No worries, for sure the SoftwareBitBang implementation is not designed to stream digital audio or video at high speed but it is handy for many to move few bytes from sensors in a local network that can be built very quickly and at a low cost.

Have a nice Christmas :)


I had a constraint of having to use existing unshielded and untwisted wires in parallel to 220V mains wiring. Basically I'm doing DIY thermostats for floor heating and only 4 copper conductors were available. Stumbled on PJON with Softwarebitbang and it seemed to fit the bill, although they do recommend twisted and/or shielded cabling.

With no background in hardware and Arduino there was a lot of learning to do, but in the end I'm really happy that it's been working flawlessly for a few months now and one copper conductor is even unused.

Don't have an oscilloscope so no idea how "ideal" the situation is on the wire with regards to electrical interference, but for anyone interested, it's running in a star topology with wire lengths about 20 metres on, with ESP32's as the microcontrollers.

edit: thanks for PJON, gioscarab!


Thank you for your feedback, happy to know it helps :)


Giovanni,

Can you highlight some "real world" use cases where PJON is/was used? I'm curious what folks have used PJON for, especially over RF (excluding Wi-Fi), such as the "video camera control" project in another comment.


I have used PJON, with the SWBB and DUDP strategies, for my home automation setup for at least 4 years. I do not need the kilometer range of SWBB, but have stretches of tens of meters running alongside 220V AC wires with no problems, in both star and daisy-chained topologies. The system is very stable, and I would like to point out that the alternatives I looked at before required me to buy extra hardware/shields that cost more than the Arduinos themselves to get going. With PJON it is just connecting to the pins in the most inexpensive way. This plus multimaster, the strength against interference, the long cable lengths and few topology limitations makes it a clear choice for many purposes. Plus, it is free :-)


Ciao jlgaddis Jack in Video Camera Control used PJON over PJDL which is a wired data link that needs only ground and a data cable to connect up to 255 devices, cables can be up to 2km long at the slowest baudrate (1.97kB/s - 15808Bd). PJDL in few words is a sort of open 1-Wire with a longer range, support for more devices and a stronger immunity to noise. See: https://github.com/gioblu/PJON/blob/master/src/strategies/So...

The core of the community uses PJON over PJDL in home automation systems, irrigation systems, feeding systems ecc. Soon Mysensors will include PJON over PJDL in their list of supported transports. PJON works also over TCP, UDP, MQTT, ESPNOW, LoRa ecc. so generally a router is built and programmed to run 2 instances of PJON for example PJDL and MQTT, to then route data to and from a process running on a real-time operative system

See: https://github.com/gioblu/PJON/blob/master/examples/routing/...

which can also run PJON thanks to the wide support of the implementation.

See: https://github.com/gioblu/PJON/wiki

Looks to be handy for many to connect devices, even on different media.

Although many also use PJON to implement mesh or peer-to-peer networks, there is a group in Australia building such a network using PJON over LoRa.

I must say I hope we will be able to start building a private network infrastructure with it, that would be awesome.

Companies and institutions are also implementing PJON within their products and services. AD24, a Czech company, recently created a mesh network over PJON to connect advertising monitors around the city of Prague. It looks there are also few companies in Germany which use PJON to create real world automation systems.

Recently contacted by the Universitat Politècnica de València (UPV) to support the development of a PJON network of temperature and humidity sensors to monitor the vault of the Cathedral of Valencia and avoid its decay, I hope this will end up done, it would be really rewarding.


I appreciate your in-depth response as well as the replies from the others as well.

Before asking. I did spend perhaps 15-20 minutes exploring the web site and Git repo. I found the "how?" and "why?" but I was having trouble coming up with valid, "real world" use cases for PJON and wasn't finding a lot of examples. I was impressed by all of the (minimal) hardware and mediums/transports that could be used -- I just couldn't think of what to actually do with it!

I've just recently started to become interested in "home automation", though -- mostly because I'm a geek and, as I looked around, I realized that there's so much data that I could be gathering and things that I could be controlling and/or interacting with or, at the least, monitoring.

Knowing what others are using PJON for is enlightening, however, and is giving me ideas and inspiration. Hopefully I'll think things through and come up with a real plan before I go on a shopping spree and end up with even more piles of electronics laying around!

Thanks again -- to you and the others -- for taking the time to enlighten me!

(On a side note, I sincerely feel that it's a shame that your "Show HN" got flagged and I apologize on behalf of HN. I can only say that, like anything else, it isn't perfect and odd things can happen at times. At the least, though, your submission was successful in making PJON more widely known!)


The main thing that originally sparked my interest in PJDL was multi master, which is clearly a massive advantage over 1-wire


Yes Jack is right, another massive advantage is that with PJDL devices can arbitrarily transmit data safely, enabling new ways of building things, for example sensors and actuators can communicate directly with each other without a master in the middle.


I use PJON in combination with MYSENSORS in my smart home system. It is the first wired protocol that works so stable and don't even need extra hardware - just one free IO pin. I have over 200 smart sensors and devices around my house. PJON was a perfect solution for all problems I was facing with wired and wireless communication for DIY smart home solutions. With some luck PJON will be officially supported by MySensors already from next release - beta test are already done. I think this will make PJON more common.


Impressive work! The first programming class I took had us implement communication using IR LEDs between Arduinos as a final project. It's a more difficult problem than it seems at first because of all the constraints. The Arudino Uno only has 2K RAM which means you need to be very conservative with buffers. Additionally, you usually want the RNG for the two nodes to be different which means you can't just use the time to seed it and need to look for other sources of entropy like reading the voltage on an open port.



I use PJON as communications protocol in my self build smart home controlling lights, door bells motions sensors. Fantastic work and fabulous support from the team.


It's beyond suspicious that 4 newly created users all have positive experience with PJON and only posted on this submission.

- https://news.ycombinator.com/threads?id=vt_rack

- https://news.ycombinator.com/threads?id=jdaandersj

- https://news.ycombinator.com/threads?id=gryzli133

- https://news.ycombinator.com/threads?id=BoldAndBald

I wonder if there are other similar submissions that also "creates more accounts" than usual and why that is.


I have been here a lot longer than that, and I do recognize some of these comments coming from long-time PJON users parttaking in the PJON gitter channel, asking for advice from other users, asking for new features, etc.

What is wrong with users of an open-source library commenting on the library? Who is better qualified to comment, and what is to be gained -- it is open source, free for all?


I am the author of the report I linked in another comment, if you care to verify please visit the website linked from the report and use the email address there to contact me. Hopefully the size and detail of the report will show I am genuine.


> It's beyond suspicious that 4 newly created users all have positive experience with PJON and only posted on this submission.

I will freely admit that I am, quite often, overly suspicious when there's a bunch of "green" users commenting (overwhelmingly positive) on a Show HN thread too -- especially when there's any money potentially involved (i.e., a product for sale, seemingly "technical" blog posts which are, in reality, just carefully prepared sales/marketing material, and so on) [0]. To be quite honest, I'm overly suspicious of damn near everything and I particularly despise "spam" of any kind [1].

In this case, though, I don't think there's anything dishonest going on, though [2].

The project has been around for about a decade and there's obviously a community behind it. I only spent about 20 minutes exploring the web site and Git repo and while I don't recall seeing any obvious links to a mailing list, message board, or IRC channel, I'm sure the project has someplace where they "hang out" and collaborate.

To me, at least, it's quite easy to imagine that the founder of the project -- the same person who posted this Show HN, AFAICT -- may have told the PJON community "Hey everyone, I just posted a link PJON to HN; here's the URL if anyone wants to join the discussion ..." or something else similar to that. I don't know whether something like happened here or whether the PJON users who just created their HN accounts to comment in this thread discovered it via some other means. I do think that there are several possible explanations that are more likely than all of them being (paid) shills for a piece of software that's both free as in speech and free as in beer [3].

Personally, my own smell test considers things like "what's being promoted?", "what's the real benefit/goal of posting this here?", and, of course, "who benefits from this and in what ways?".

As I said before, I don't have any doubt that there's an ulterior motive here -- the goal seems to simply be to share and promote an ~10 year old open source implementation of an open network protocol that 1) is exactly the type of thing that's generally of interest to HN'ers, 2) was founded on ideals and principles that many of us here on HN share and believe in (autonomy/self-hosting/decentralization), and 3) has (verifiably) been used, successfully, in the real world.

Besides, HN guidelines implore us all to extend the benefit of the doubt. Blatant, obvious "violations" should obviously be pointed out -- but this isn't one of them.

In fact, this project is EXACTLY the type of project that belongs on HN. It's a damn shame that it's now "[flagged]"!

It's almost as if "somebody" doesn't want projects like this one to succeed. Who would benefit if PJON and others like it didn't exist? Who would benefit if users instead had no other option but to pay a for-profit company for the hardware, software, and (of course!) the recurring monthly subscription fee instead of just doing it themselves? Hmm... (see how easy that is)?

--

[0] Hell, I get annoyed when User A posts a "Show HN" for their new project and then User X (and, sometimes, User Y and User Z) takes advantage of the "opportunity" to post a "This is similar to $foo, $URL, which is an [app|company|service] that also does $thing" comment in the thread ("Submit your own Show HN, then!" is what I want to say!). Bonus points to those who somehow manage to work in a reference to their own product/service even when the two have only the most minimal of commonalities or similarities ("Interesting. Our service, $bar, is also a web site" is only a slight exaggeration).

[1]: Spam doesn't just arrive via e-mail. To me, "spam" is rather loosely defined and includes any unsolicited and/or unwanted sales/marketing/promotional material (or similar) and, in some cases, even includes anything "off-topic" (depending on the forum, usually).

[2]: My HN account is only ~8 years old and I only lurked for a few years before I finally decided to devote the time, effort, and energy necessary to create an account. I'm not sure if that's long enough to pass your "shill test" or not; If necessary, I would sign a sworn affidavit attesting that I had never even heard of PJON before today but, then again, that's just the kind of thing a shill would say!

[3]: It's available under the Apache license.


> To me, at least, it's quite easy to imagine that the founder of the project -- the same person who posted this Show HN, AFAICT -- may have told the PJON community "Hey everyone, I just posted a link PJON to HN; here's the URL if anyone wants to join the discussion ..." or something else similar to that.

Coming from the project's Gitter that is exactly what happened. I am pretty sure some of us over there do not have an account at HN. As far as I am concerned, this is just the third time I wrote something here since creating my account in 2017.


>It's almost as if "somebody" doesn't want projects like this one to succeed. Who would benefit if PJON and others like it didn't exist? Who would benefit if users instead had no other option but to pay a for-profit company for the hardware, software, and (of course!) the recurring monthly subscription fee instead of just doing it themselves? Hmm... (see how easy that is)?

jlgaddis, probably there could not have been a better way to describe the situation.


No, conspiracy theories are not a good way to describe the situation, and certainly don't help people believe you if they are doubting the legitimacy of a submission.


Many of you accused some users of our community to be fake and guilty of trying to influence the narrative, they did everything to prove their feedback was sincere, you gave them the benefit of the doubt.

Another user postulated the same could have happened in the opposite direction (trolls trying to discredit this submission), I told him he might have a point, you label me as a conspiracy theorist.

That's for sure fair.


> I told him he might have a point,

you didn't just do that. you edited your comment since I replied to it, so my comment now looks out of place.

(And there is some difference between "fake" and "just signed up to help promote a thing". And yes, suggesting that is also somewhat of a conspiracy theory, but one where we know that people asking their users to help upvote and promote a HN submissions happens regularly at least)


In my opinion your comment is clearly out of place.

This post was in the first page thanks to dang, who decided to let me make a repost, after this comment generated a lot of interest: https://news.ycombinator.com/item?id=23589798 now 6 months ago

and this post I created immediately after got huge interest although being only visible in the "show" first page because it was "flagged": https://news.ycombinator.com/item?id=23591953

and that is just the standard policy of HN.

But you could have just discovered most by yourself just checking my account info, instead it looks you are prone to see conspiracy behind everything.


I responded to your (paraphrased, since you edited the comment I can't quote the exact text) "I'll say that next time", saying that you shouldn't do that because it'll look unconvincing.

I am not saying that you "faked" anything, and don't think you did, but understand why it looked suspicious to other commenters, because it looks pretty much like what happens if someone tries to game the system by asking others for upvotes.


All created between a 8 hour range. Definitely something fishy going on.


I guess there is no way to prove it either way (option A: bunch of shills or option B: honest feedback)

Mine is a throwaway account for privacy reasons, because I don't want details about my home to be linked to any other bit of information online.


Probably just a bunch of users trying to help out and not realizing it would backfire.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: