Transport based on single wire PJON protocol



  • Hi, I wrote simple transport for MySensors based on PJON protocol (single wire multimaster bus system). Actually this implementation is beta version but in my test enviroment on 3 nodes is working stable.
    https://github.com/4ib3r/MyTransportPJON


  • Admin

    @4ib3r

    Really nice!

    Never head of PJON before. Seems simple enough.



  • Ciao, consider that PJON is a multimedia system, so can be used also with radio transceivers, see https://github.com/gioblu/PJON/wiki/OverSampling



  • @Giovanni-Blu-Mitolo I know, but MySensors has several radio transports, but there is no on the wire.


  • Admin

    Well, there's also:
    https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/core/MyTransportRS485.cpp

    Might be better if you do new development against the development branch. We won't be able to take in new things in the 1.5.



  • @hek Indeed I forgot about the RS485, but PJON don't require additional elements.
    Ok, I try to port this transport to development branch.



  • Ciao @4ib3r, I am testing it with MySensors that is indeed a great work!
    Maybe some considerations should be done on PJON's synchronous acknowledge (really efficient on noise free media like a single or a couple of wires), maybe in this case exchanging a higher level asynchronous acknowledge could be useless ontop of PJON, but I am still into the codebase, that its quite extensive, to be sure of what I am saying! Compliments again to MySensors creators and to you creating the PJON Transport.



  • I write new version based on development branch: https://github.com/4ib3r/Arduino
    Unfortunately in this version new transport is integral part of library, but use of this is much easier.
    Now I use synchronous send method with check acknowledge, and loop 500 times with random 100-600us sleep time for ACK, in tests this method is better than async.
    Self PJON library is still required to run this transport and is not included.



  • Ciao @4ib3r, really nice work. Can I ask you some help to write a brief documentation in the PJON's repository wiki to help users to have a nice experience using it with MySensors and your codebase? Compliments again!



  • Sory, I forgot commit MySensors.h file, with definitions.
    Definition "MY_PJON" sets transport to PJON.

    /* Simple serial gateway with PJON transport and error handling */
    
    // Enable and select radio type attached
    //#define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    #define MY_PJON //select PJON transport
    #define PJON_PIN 12 //optional to change pin (12 is default)
    
    #define MY_GATEWAY_SERIAL
    
    #include <MySensor.h>  
    void before() {
     //bus object is not initialized in this method
    }
    
    void setup() {
      bus.set_error(error_handler); //direct bus object access
    }
    
    void presentation() {
    }
    
    void loop() { 
    }
    
    void error_handler(uint8_t code, uint8_t data) {
      if(code == CONNECTION_LOST) {
        Serial.print("Connection with device ID ");
        Serial.print(data);
        Serial.println(" is lost.");
      }
      if(code == PACKETS_BUFFER_FULL) {
        Serial.print("Packet buffer is full, has now a length of ");
        Serial.println(data, DEC);
        Serial.println("Possible wrong bus configuration!");
        Serial.println("higher MAX_PACKETS in PJON.h if necessary.");
      }
      if(code == MEMORY_FULL) {
        Serial.println("Packet memory allocation failed. Memory is full.");
      }
      if(code == CONTENT_TOO_LONG) {
        Serial.print("Content is too long, length: ");
        Serial.println(data);
      }
      if(code == ID_ACQUISITION_FAIL) {
        Serial.print("Can't acquire a free id ");
        Serial.println(data);
      }
    }
    

    I created a pull request to PJON with change that allows define the broadcast address because in MySensors is 0xff.



  • Ciao @4ib3r , thank you for your support to the PJON project. I accepted your pull request. What you proposed highers portability and reduces compatibility issues like this one in particular with MySensors. I will soon use your attached example to make a brief wiki page where to explain how to use PJON with MySensors.



  • I should now point to your personal fork here https://github.com/4ib3r/Arduino and keep an eye on MySensors releases and change the link to MySensors master as soon as your proposal will be accepted, right?



  • I created pull request to main repository 6 days ago but as for now still hangs.



  • WOW, just find that PJON protocol, quite good stuff! Working more reliable than RS485 on my work table 🙂

    I'm creating smart home solution that will work 100% on cable. Because there are some known issues with RS485, PJON would be the great alternative for my project. Is there an official support for MySensors already?



  • Ciao gryzli133! I am happy to hear that.
    Are you testing SoftwareBitBang (PJDL v2.0) data-link?

    The system works also if using the human body as a common conductor, so yes, quite rugged I agree. There are a lot of setups around the world running PJDL, many of them have matured already years of operation. I have personally built a bus of more than 40 meters of wires in star topology, made by cat 5 ethernet (gnd, vin, PJDL bus, the rest is unused) positioned in the same channels where AC wiring is positioned.

    With AC wiring or appliancies in the vicinity, without any pull-down resistor, the induced 50Hz waveform may be present in the bus stealing half of the bandwidth (the PJDL protocol is perfectly able to avoid the wave crests and operate nominally in this scenario) obviously placing pull down resistors that can be erased obtaining the best performance.

    4ib3r worked out the support long ago and made a pull request, I am not sure what happened then and if that was accepted. Many things are changed since then in PJON so that work may be outdated, although it should be fairly simple to fix. I am obviously always available for support if required.





  • Ciao kimot, yes the class that adds to Mysensors the support to PJON was made by 4ib3r 2 years ago, looking at the source, it is 101 lines of commented code.
    It seems fairly simple to wire up PJON functions with Mysensor's.
    If you need some help I am here although I am not able to physically setup a testbed running Mysensors for now.



  • @giovanni-blu-mitolo would it be possible for you to refresh the PJON transport layer? Maybe even try with new pull request for PJON transport? I think I'm out of skills to do it by myself. The phissically setup is quite easy, you need one Arduino board as Serial Gateway and one as node. The communication is then running over PJON between arduinos. From Gateway you can see over Serial Monitor if the communication is running well.

    I'm trying to build a floor heating controller for all my house. The idea is to have an Arduino (probably ESP8266 with switched off WiFi) with OLED display (SH1106 using u8g2 lib) and BME280 sensor (Temp+Baro+Hum) in each room. All these should communicate with Arduino Mega as Serial Gateway and main controller for the Valves. For now the only problem is the communication between Arduino Mega and multiple ESP8266 over PJON. It would be even enough to get it work outside MySensors, but I get some trouble. For test I have programm the ESP8266 room thermostat that is communicating with other ESP8266 over PJON. But sometimes I cannot get any data over PJON. Have no idea where is the problem, sometimes it is working, sometimes not... Do you think, that the problem could be SW i2c for the OLED diplay?



  • Hi Giovanni, did I understood good, that PJON will be included in next release of MySensors? 🙂


Log in to reply
 

Suggested Topics

  • 1
  • 6
  • 1
  • 10
  • 3
  • 2

14
Online

11.4k
Users

11.1k
Topics

112.7k
Posts