Physically small Gateway (to fit inside Raspberry Pi case)
-
I would like to have the gateway within the Raspberry Pi case, instead of connecting for example Arduino Nano through the USB, and connecting the NRF24 using DuPont wires. But how do I do this? None of the examples I have tried so far have worked correctly with the latest Domoticz beta. And yes, as a starting point, the Serial Gateway on Arduino Nano as of Git tag 1.5.3 works perfectly.
What I have tried so far are
- SenseBender Micro as the Serial Gateway
- One the first glance this seems fine, but it will not transmit anything
- Forum posts about the subject
- Is this caused by the 1 MHz clock speed?
- NRF24 connected directly to the Raspberry Pi's GPIO pins
- https://www.openhardware.io/view/17/Raspberry-Pi2-GPIO-interface-for-NRF24L01
- https://github.com/mysensors/Raspberry
- The MySensors Raspberry Gateway software seems to be on MySensors 1.4 level
- I have great difficulties in the sensor presentation on Domoticz, i.e. my sensors (V_IR_RECEIVE, V_TEXT, V_LIGHT) do not reliably appear as devices on Domoticz. When looking at the properties of the 'MySensors' system device, the sensors are there, however???
Any help would be greatly appreciated... I'd really want to have a small gateway within the Raspberry case.
- SenseBender Micro as the Serial Gateway
-
Or, is it about the 115200 baud rate on a 3.3V ATmega328?
-
OK, found it. It's about the baud rate, 115200 does not work for a Serial Gateway running on a SenseBender. The real baud rate is too much off when the baud rate is generated from the ATmega 328's internal 8 MHz oscillator.
Unfortunately the 115200 baud rate is hard-coded into Domoticz. I just changed the hardcoded value to 38400 in hardware/MySensorsSerial.cpp, and also rebuilt the 1.5.3 version of the SerialGateway with 38400 as the baud rate.
Works fine now But I think I'll need to make a change & pull request to Domoticz.
-
One more thing. Gizmocuz (Domoticz author) was concerned about performance. Would you think it's fine to run the serial gateway on 8 MHz clock speed?
-
My first computer wasn't as fast as 8Mhz. It could still do a lot of things. All a gateway does is to receive and transmit tiny messages every now and then. Would be interesting to know what the basis for corncern is though.
-
OK, I think I'm good to go. I'll try to make a change & pull request into Domoticz (additional checkbox on 'MySensors USB gateway' device) to tell it's a '3.3V 8MHz ATmega328'. In that case the baud rate would be 38400, instead of 115200.
Maybe the MySensors code could also detect (is there a #define for it?) the clock speed/board model/operating voltage, and set the serial speed to 38400 for 8MHz on 8MHz boards.
-
This sounds really good. I will now also try to reuse my sensebender as a Gateway on the raspberry with a lower baudrate.
I'm using FHEM and it is possible to set the baudrate in the configuration.
The strange thing is, that the receiving Messages from nodes and sending the Content to the Controller was working. Only sending values from the Controller to the nodes was not working.
I think the raspberry is more tolerate in receiving Messages with a Little bit different Baudrate, than the ATmega.
-
@gloob said:
The strange thing is, that the receiving Messages from nodes and sending the Content to the Controller was working. Only sending values from the Controller to the nodes was not working.
Yep, I had exactly the same problem. Looks good on the surface, but no commands were sent out.
-
I made a pull request. The sketch GatewaySerial.ino now sets the serial speed to 38400 if the Arduino is running on 8MHz clock speed.
https://github.com/mysensors/Arduino/pull/391
EDIT: My pull request was accepted into the Domoticz master branch