PiSerialGateway and Domoticz



  • So I'm trying to setup PiSerialGateway with a nrf24l01+. I'm getting some output but I don't understand it. If the sensors only scream out into the air or if they are communicating?

    I know that my sketch is working, because if I attach it to my Pi3 with USB cable as a ordinary SerialGateway my sensors appear in Domoticz.

    This it the output I have from my sketch with debug turned on. Don't know where it starts or ends so I just copy a few lines.

    TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSF:MSG:FPAR RES,ID=0,D=0
    TSF:MSG:FPAR OK,ID=0,D=1
    TSM:FPAR:OK
    TSM:ID
    TSM:ID:OK,ID=1
    TSM:UPL
    TSF:PING:SEND,TO=0
    TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    TSF:CHKUPL:FAIL
    !TSM:UPL:FAIL
    TSM:FPAR
    TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSF:MSG:FPAR RES,ID=0,D=0
    TSF:MSG:FPAR OK,ID=0,D=1
    TSM:FPAR:OK
    TSM:ID
    TSM:ID:OK,ID=1
    TSM:UPL
    TSF:PING:SEND,TO=0
    TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    TSF:CHKUPL:FAIL
    !TSM:UPL:FAIL
    TSM:FPAR
    TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSF:MSG:FPAR RES,ID=0,D=0
    TSF:MSG:FPAR OK,ID=0,D=1
    TSM:FPAR:OK
    TSM:ID
    TSM:ID:OK,ID=1
    TSM:UPL
    TSF:PING:SEND,TO=0
    TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    TSF:CHKUPL:FAIL
    !TSM:UPL:FAIL
    TSM:FPAR
    TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSF:MSG:FPAR RES,ID=0,D=0
    TSF:MSG:FPAR OK,ID=0,D=1
    TSM:FPAR:OK
    TSM:ID
    TSM:ID:OK,ID=1
    TSM:UPL
    TSF:PING:SEND,TO=0
    

    And this is what the PiSerialGateway "says":

    read: 1-1-0 s=255,c=3,t=24,pt=1,l=1:1
    read: 1-1-255 s=255,c=3,t=7,pt=0,l=0:
    send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,st=ok:0
    read: 1-1-0 s=255,c=3,t=24,pt=1,l=1:1
    read: 1-1-255 s=255,c=3,t=7,pt=0,l=0:
    send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,st=ok:0
    read: 1-1-0 s=255,c=3,t=24,pt=1,l=1:1
    read: 1-1-255 s=255,c=3,t=7,pt=0,l=0:
    send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,st=ok:0
    read: 1-1-0 s=255,c=3,t=24,pt=1,l=1:1
    read: 1-1-255 s=255,c=3,t=7,pt=0,l=0:
    send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,st=ok:0
    read: 1-1-0 s=255,c=3,t=24,pt=1,l=1:1
    read: 1-1-255 s=255,c=3,t=7,pt=0,l=0:
    send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,st=ok:0
    read: 1-1-0 s=255,c=3,t=24,pt=1,l=1:1
    read: 1-1-255 s=255,c=3,t=7,pt=0,l=0:
    send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,st=ok:0
    read: 1-1-0 s=255,c=3,t=24,pt=1,l=1:1
    read: 1-1-255 s=255,c=3,t=7,pt=0,l=0:
    send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,st=ok:0
    read: 1-1-0 s=255,c=3,t=24,pt=1,l=1:1
    read: 1-1-255 s=255,c=3,t=7,pt=0,l=0:
    send: 0-0-1-1 s=255,c=3,t=8,pt=1,l=1,st=ok:0
    

    I only had 470ยตF capacitor, don't know if it is too big and that could be a problem?

    Also, I don't know how to get a decent log file from PiSerialGateway? The only way I can get some output is to start it manually. I've been reading as much as I can find, but don't know how I can get this to work.



  • Try with 10ยตF capacitor. 470 is too big .



  • Thank you. Bought some 10ยตF.

    But I don't see any change in the output from the sensor or the gateway. Have been waiting 5-10 minutes, but nothing appears in Domoticz. Is there anything I can do to try to find the problem? I seem to get the output described on other webpages for working sensor/gateway. But they don't seem to connect.

    And how do I get the log function to work? The few times when a log is created I only see some startup message. Nothing about the communication going on. I have to start PiSerialGateway manually to see any communication output. Or isn't that possible to see in the log file?

    Here is the sensorsketch, if I have forgotten something. Works fine with plain USB connection to my Pi.

    // Enable serial gateway
    //#define MY_GATEWAY_SERIAL 
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <OneWire.h>
    #include <DallasTemperature.h>
    
    #define TEMP_ID 1
    #define RELAY_ID 2
    
    //Temperatur sensor
    #define ONE_WIRE_BUS 4
    #define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No
    float lastTemperature = 0;
    MyMessage tempMsg(TEMP_ID, V_TEMP); // Initialize temperature message
    OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
    DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature. 
    unsigned long SLEEP_TIME = 5000; // Sleep time between reads (in milliseconds)
    
    //Relay to water valve
    #define RELAY_PIN  5  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define RELAY_ON 1  // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
    
    void setup(void)
    {
    	// start serial port
    	Serial.begin(115200);
    
    	pinMode(RELAY_PIN, OUTPUT);
    	digitalWrite(RELAY_PIN, RELAY_OFF);
    }
    
    void presentation() 
    {
    	// Send the sketch version information to the gateway and Controller
    	sendSketchInfo("FishTank", "1.0");
    
    	present(TEMP_ID, S_TEMP, "Water temperature");
    
    	present(RELAY_ID, S_BINARY, "Water valve");
    }
    
    void loop(void)
    { 
    
    	DeviceAddress tempDeviceAddress; // We'll use this variable to store a found device address    
    	// For testing purposes, reset the bus every loop so we can see if any devices appear or fall off
    	sensors.begin();
    	sensors.requestTemperatures(); // Send the command to get temperatures
    	
    	// Search the wire for address
       if(sensors.getAddress(tempDeviceAddress, 0))
       {
    		float tempC = sensors.getTempC(tempDeviceAddress);
    		//Serial.print("Temperature=");
    		//Serial.println(tempC); 
    #if COMPARE_TEMP == 1
    		// Only send data if temperature has changed and no error
    		if (lastTemperature != tempC && tempC != -127.00 && tempC != 85.00)
    		{
    #else
    		if (tempC != -127.00 && tempC != 85.00)
    		{
    #endif
    			// Send in the new temperature
    			send(tempMsg.set(tempC, 1));
    			// Save new temperatures for next compare
    			lastTemperature = tempC;
    		}
       } 
    
    	delay(SLEEP_TIME);
    }
    
    void receive(const MyMessage &message) 
    {
    	// We only expect one type of message from controller. But we better check anyway.
    	if (message.type == V_STATUS) 
    	{
    		// Change relay state
    		digitalWrite(RELAY_PIN, message.getBool() ? RELAY_ON : RELAY_OFF);
    		// Write some debug info
    		Serial.print("Incoming change for sensor:");
    		Serial.print(message.sensor);
    		Serial.print(", New status: ");
    		Serial.println(message.getBool());
    	}
    }
    


  • Connect gateway to comp usb and check what happening with arduino ide serial monitor.



  • @Fat-Fly
    I don't really understand. The gateway is on a Raspberry Pi, and I have a piece of what is happening in my first post. The output from PiSerialGateway. Otherwise you have to explain a little more on how I should connect my RPi to USB and what to look for.



  • Connect arduino with nrf to comp. Not raspberry. And check serial monitor.



  • @Fat-Fly

    But the NRF is connected directly to the Raspberry. There is no Arduino on the gateway. And the output from my node (Arduino and NRF) with sensors is also shown in my first post.

    I'm really lost on what you want me to test.



  • Okay. With mysensors 2.0 not working nrf directly. Use 1.5 library.



  • @Fat-Fly

    Really? They removed that or is it a bug? Didn't think that 2.0 would be a problem. But could test, but sad to not be able to use the latest version.


  • Mod

    @raptorjr this thread discusses an alternative implementation of the Raspberry Pi gateway, compatible with MySensors 2.0.



  • 2.0 is compatible connect nrf directly to raspberry? I do not know and not read this. Maybe i sleep this moment when somebody writing from this. ๐Ÿ™‚



  • @mfalkvidd

    Thank you, will check it out. Would be sad to leave 2.0. It seems to be a big step forward in the development.



  • ๐Ÿ˜„ ๐Ÿ™‚ ๐Ÿ™‚



  • It works ๐Ÿ˜ƒ



  • Beer from you.


Log in to reply
 

Suggested Topics

  • 3
  • 8
  • 2
  • 5
  • 1

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts