Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
K

kimot

@kimot
About
Posts
251
Topics
1
Shares
0
Groups
0
Followers
1
Following
0

Posts

Recent Best Controversial

  • CAN bus transport implementation for MYS
    K kimot

    @gonzalonal
    Yes I am.
    But I have got a lot of other works, so It's going slowly.
    The problem is, that CAN can transfer only 29 bits ID ( 3 bytes + 5 bits ) and max. 8 bytes of data.
    MySensors message has got max. 32 bytes ( 7 bytes header and 25 bytes of data ).
    I must either send MySensors message like 3 packets of CAN messages or limit properties of MySensors protocol.
    Now I am working on second variant.
    I am able code to one CAN message:
    6 bits - destination
    6 bis - sender
    (gateway, broadcast, 62 nodes - it is enough for me for one bus. I plane three buses and gateway can " translate " or "expand" nodes ID from and to controller )
    1 bit - RACK
    1 bit - IS ACK
    3 bits - command
    6 bits - type ( MY sensors has 56 types max. now )
    6 bits - sensor id ( only 64 sensors per node ... )
    3 bits - payload type ( int, uint, long .... )

    The sum of these is not 29, but 32 so I am using a little "hacking" data length field in CAN frame to obtain additional 3 bits.
    For data I have got 8 bytes.
    It is enough for conventional data types from char to floating point.
    Only text messages are limited to 8 bytes. But for us, old boys, who remember old DOS file names, it is enough.

    In this time, I am able send and receive packets in that format between nodes and now I am working on transfer RS485 library to CAN library.
    The problem is, that RS485 library sends destination address, node id, length of message and then MySensors message, witch "surprisingly" contain again destination and sender bytes. A little bit redundant for me.
    So I must remove some fields from MySensors message, put it to CAN ID and send only payload in CAN data fields.
    When I receive CAN message, I must again assemble correct MySensors message format and put it to MySensors system.
    But unfortunately only documentation is library code itself :o(

    I try a "stress test" like here:
    https://forum.mysensors.org/topic/5051/rs485-stress-test

    I send 10 000 messages from two nodes to "gateway" ( 22kbps ).
    Result - zero messages lost.
    But it is expectable with CAN.

    My Project

  • remote control design idea
    K kimot

    Why sleep?
    Switch it completely off.
    Use button with two pairs of contacts.
    One pair on each button connect battery + pole with processor power pin.
    Second pairs to different inputs pins.
    You push button, processor will start execute program, immediately read inputs status,
    then send command and when you release button, it will be switched off.
    If you need longer processing time and do not want hold button all this time, then processor can hold power itself by logical output with connected transistor. When work will be done, then switch itself off.
    Your car remote key works the same way.

    Development

  • Problems with the neighbours
    K kimot

    @stevanov
    It seems, that both of you use MySensors in "outofbox" state.
    You do not write which radio module are using.
    If RFM69 - change netwotk ID, with NRF24 change channel or network ID
    Somewhere in config files.

    MyConfig.h

    #define MY_RF24_CHANNEL (76)
    /**
     * @def MY_RF24_BASE_RADIO_ID
     * @brief RF24 radio network identifier.
     *
     * This acts as base value for sensor nodeId addresses. Change this (or channel) if you have more
     * than one sensor network.
     */
    #ifndef MY_RF24_BASE_RADIO_ID
    #define MY_RF24_BASE_RADIO_ID 0x00,0xFC,0xE1,0xA8,0xA8
    #endif
    
    /**
     * @def MY_RFM69_NETWORKID
     * @brief RFM69 Network ID. Use the same for all nodes that will talk to each other.
     */
    #ifndef MY_RFM69_NETWORKID
    #define MY_RFM69_NETWORKID (100)
    #endif
    
    

    Of course you must reprogram all nodes and gateway :o(

    Or talk with your neighbours and ask them using different network ID if they only starting building their network and have got smaller number of sensors.

    General Discussion

  • best solution to monitor and log power usage
    K kimot

    Some Sonoff switching devices has got power metering.
    Upload ESPeasy or Tasmota firmware and connect with HA....

    General Discussion

  • Nano minimum voltage
    K kimot

    Why "plus" 7805.
    Nano has got voltage regulator on board.
    Original Arduinos 7805 I think, clones LM1117 usually.

    Hardware

  • 💬 Leaky - water detector
    K kimot

    @Sixkillers
    You can wake up every hour, but hold wifi modem off, increment "wake up counter" and go to deep sleep.
    Running time between deep sleeps will be very short
    And connect to wifi one per day for example.
    And make some tweaks for wifi connection:
    For inspiration from Step 6 here:

    https://www.instructables.com/ESP8266-Pro-Tips/

    And final tweak here:

    https://www.bakke.online/index.php/2017/06/24/esp8266-wifi-power-reduction-avoiding-network-scan/

    OpenHardware.io leak esp8266 home assistant mqtt water

  • Combining MySensors examples
    K kimot

    @bluezr1
    Do you see "MockMySensors" example sketch which comes with MySensors library?
    There are all sensors in one sketch together.
    Presentation, sending its values, receiving ....

    Development

  • Nano minimum voltage
    K kimot

    @bjacobse said in Nano minimum voltage:

    Datasheet: The device operates between 1.8-5.5 volts.
    and this means to bypass/remove the voltage regulator on the Nano board

    But it do NOT means with 16Mhz crystal on Arduino Nano ...

    Hardware

  • Domoticz data timeout
    K kimot

    @gbuico
    tmr.now() is LUA function
    NodeMCU LUA is firmware, which you load to your NodeMCU ( or other ESP2866 ) and then write your programs in LUA scripts, which stores in ESP2866.

    MySensors is writen In Ardfuino language ( C++ ), so Arduino IDE compile your program and load it to ESP2866. And there is not tmr.now(). Use millis() instead off.

    ESPeasy is firemware to load to ESP2866.
    It runs on ESP2866 and you can create sensors and write simple "program" when connected to ESP webpage.
    There are any timeouts, you can send message one per day or month, no problem.
    You do not need compile ESPeasy itself. Use compiled file and download it to your ESP2866.

    First you create your sensors in Domoticz as "Dummy" devices and remembers their "idx".
    Then connect with browser to your sensor with ESPeasy running and through its webpage you can define different sensors ( sensor type, GPIO where connected, its domoticz idx , sending interval, etc )
    For example, for DS18b20 you select pin for 1-wire bus, then you can see all sensors on this bus and select which you need. Temperature is automatically send to Domoticz.
    Different sensor - no problem, select for example pins for i2c bus, discover this bus and then select sensor.
    Display - select i2c address and it is done.
    But what I really love on ESPeasy is its communication model.
    If you cannot send some info through ESPeasy autmatically, you can write json command and send to Domotic whateverelse.
    Need send data from Domoticz to your ESPeasy - no problem.
    You can send commands from Domoticz with parameters and receive it in ESPeasy.
    You can transfer everything this way.
    No compilation, only write in your browser and hit "Apply" button.

    I like MySensors very much, but for wi-fi connected single sensors exists easier ways.

    But my dream is feature for MySensor ethernet gateway, when I can send to gateway something like this:
    http://gatewayip/control?cmd=23;5;24.5
    which means = to_node, sensor_id, value.

    Or opposite way, send from sensor to gateway command with domoticz sensor idx, type of domoticz value (svalue or nvalue ) and value itself and gateway will send to domoticz appropriate json command.

    Domoticz

  • ds18b20 on 2xAAA battery
    K kimot

    @pihome
    very power hungry (Quiescent current 13uA) ?
    And do you know, that with AAA (1000 mAh) it is 8 years in standby?
    Maybe self discharge is greater.
    Alternetively use 3xAAA with low quiescent current 3.3V LDO.

    Troubleshooting

  • Reset values measured by Power Meter Pulse?
    K kimot

    @koewacko
    You can set negative offset 86kWh in Domoticz counter setup.

    Domoticz

  • Using an 802.11g wifi transport
    K kimot

    If you plan using ESP chips or Raspberry as your sensors node, I think better way is ESPeasy or similar sw for ESPs.

    MyController.org

  • 💬 Leaky - water detector
    K kimot

    @openhardware-io
    I think this is not too useful concept.
    In circuit diagram, there is no connection GPIO16 to RESET - so no deep sleep mode.
    It seems, your node only connect to server when water leaks.
    But what after two years, you do not know if battery are still good and your detector alive.
    Better way use deep sleep, after some number deep sleep cycles ( one per day? ),
    connect to wifi and send battery voltage for example.
    If this message is missed, your controller can send you battery replacement message.

    wake up circuit

    OpenHardware.io leak esp8266 home assistant mqtt water

  • help for step by step wiring and configure a gateway with RS485 module and raspberry pi 3
    K kimot

    @Reza
    Remeber, that GPIO Uart on RPi3 is not ttyAMA0 like with RPi2( it is bluetooth now ).
    GPIO is ttyS0 on RPi3.

    http://raspberrypi.stackexchange.com/questions/45570/how-do-i-make-serial-work-on-the-raspberry-pi3

    Or read this thread too:
    https://forum.mysensors.org/topic/6015/serial-gateway-connect-problem-ttyama0

    Troubleshooting

  • Domoticz data timeout
    K kimot

    @gbuico
    Ok.
    Only do not forget, that ESPeasy webpage is mainly for setting, so it is not refreshed automatically like Domoticz. You must manually refresh it when check, if sensor value changed, for example.
    video

    Domoticz

  • RS485/RS232/Serial transport class for mysensors.org
    K kimot

    I think, that CAN transceiver chip is better then RS485 transceiver chip.
    Then we dont need direction setting pin and bus state is better determined, becose CAn bus is prepered for bus collisions, RS485 not.
    I mean only CAN bus transceiver, not CAN controller ! For example MCP2551 or MCP2562.
    And we can use normal serial library.

    Development rs485 serial rs485

  • HM-TRP Gateway
    K kimot

    @chanky said in HM-TRP Gateway:

    HM-TRP transceiver

    Look at "MyTransportRS485.cpp and try adapt for your module which has serial communication too.
    Initialize your module in "bool transportInit(void)" ?

    And etc.

    A lot of work .....

    My Project

  • Domoticz TEXT sensor triggering
    K kimot

    @alowhum

    bool MySensorsBase::WriteToHardware(const char *pdata, const unsigned char length)
    {
    	const tRBUF *pCmd = reinterpret_cast<const tRBUF *>(pdata);
    	unsigned char packettype = pCmd->ICMND.packettype;
    	unsigned char subtype = pCmd->ICMND.subtype;
    
    	if (packettype == pTypeLighting2)
    	{
    		//Light command
    
    		int node_id = pCmd->LIGHTING2.id4;
    		int child_sensor_id = pCmd->LIGHTING2.unitcode;
    
    		if (_tMySensorNode *pNode = FindNode(node_id))
    		{
    			_tMySensorChild *pChild = pNode->FindChild(child_sensor_id);
    			if (!pChild)
    			{
    				_log.Log(LOG_ERROR, "MySensors: Light command received for unknown node_id: %d, child_id: %d", node_id, child_sensor_id);
    				return false;
    			}
    
    			int light_command = pCmd->LIGHTING2.cmnd;
    			if ((pCmd->LIGHTING2.cmnd == light2_sSetLevel) && (pCmd->LIGHTING2.level == 0))
    			{
    				light_command = light2_sOff;
    			}
    			else if ((pCmd->LIGHTING2.cmnd == light2_sSetLevel) && (pCmd->LIGHTING2.level == 255))
    			{
    				light_command = light2_sOn;
    			}
    
    			if ((light_command == light2_sOn) || (light_command == light2_sOff))
    			{
    				std::string lState = (light_command == light2_sOn) ? "1" : "0";
    				if (pChild->presType == S_LOCK)
    				{
    					//Door lock/contact
    					return SendNodeSetCommand(node_id, child_sensor_id, MT_Set, V_LOCK_STATUS, lState, pChild->useAck, pChild->ackTimeout);
    				}
    				else if (pChild->presType == S_SCENE_CONTROLLER)
    				{
    					//Scene Controller
    					return SendNodeSetCommand(node_id, child_sensor_id, MT_Set, (light_command == light2_sOn) ? V_SCENE_ON : V_SCENE_OFF, lState, pChild->useAck, pChild->ackTimeout);
    				}
    				else
    				{
    					//normal
    					return SendNodeSetCommand(node_id, child_sensor_id, MT_Set, V_STATUS, lState, pChild->useAck, pChild->ackTimeout);
    				}
    			}
    			else if (light_command == light2_sSetLevel)
    			{
    				float fvalue = (100.0f / 14.0f)*float(pCmd->LIGHTING2.level);
    				if (fvalue > 100.0f)
    					fvalue = 100.0f; //99 is fully on
    				int svalue = round(fvalue);
    
    				std::stringstream sstr;
    				sstr << svalue;
    				return SendNodeSetCommand(node_id, child_sensor_id, MT_Set, V_PERCENTAGE, sstr.str(), pChild->useAck, pChild->ackTimeout);
    			}
    		}
    		else {
    			_log.Log(LOG_ERROR, "MySensors: Light command received for unknown node_id: %d", node_id);
    			return false;
    		}
    	}
    	else if (packettype == pTypeLimitlessLights)
    	{
    		//RGW/RGBW command
    		_tLimitlessLights *pLed = (_tLimitlessLights *)pdata;
    		//unsigned char ID1 = (unsigned char)((pLed->id & 0xFF000000) >> 24);
    		//unsigned char ID2 = (unsigned char)((pLed->id & 0x00FF0000) >> 16);
    		unsigned char ID3 = (unsigned char)((pLed->id & 0x0000FF00) >> 8);
    		unsigned char ID4 = (unsigned char)pLed->id & 0x000000FF;
    
    		int node_id = (ID3 << 8) | ID4;
    		int child_sensor_id = pLed->dunit;
    
    		if (_tMySensorNode *pNode = FindNode(node_id))
    		{
    			_tMySensorChild *pChild = pNode->FindChild(child_sensor_id);
    			if (!pChild)
    			{
    				_log.Log(LOG_ERROR, "MySensors: Light command received for unknown node_id: %d, child_id: %d", node_id, child_sensor_id);
    				return false;
    			}
    
    			bool bIsRGBW = (pNode->FindChildWithPresentationType(child_sensor_id, S_RGBW_LIGHT) != NULL);
    			if (pLed->command == Limitless_SetRGBColour)
    			{
    				int red, green, blue;
    
    				float cHue = (360.0f / 255.0f)*float(pLed->value);//hue given was in range of 0-255
    				int Brightness = 100;
    				int dMax = round((255.0f / 100.0f)*float(Brightness));
    				hue2rgb(cHue, red, green, blue, dMax);
    				std::stringstream sstr;
    				sstr << std::setw(2) << std::uppercase << std::hex << std::setfill('0') << std::hex << red
    					<< std::setw(2) << std::uppercase << std::hex << std::setfill('0') << std::hex << green
    					<< std::setw(2) << std::uppercase << std::hex << std::setfill('0') << std::hex << blue;
    				return SendNodeSetCommand(node_id, child_sensor_id, MT_Set, (bIsRGBW == true) ? V_RGBW : V_RGB, sstr.str(), pChild->useAck, pChild->ackTimeout);
    			}
    			else if (pLed->command == Limitless_SetColorToWhite)
    			{
    				std::stringstream sstr;
    				int Brightness = 100;
    				int wWhite = round((255.0f / 100.0f)*float(Brightness));
    				if (!bIsRGBW)
    				{
    					sstr << std::setw(2) << std::uppercase << std::hex << std::setfill('0') << std::hex << wWhite
    						<< std::setw(2) << std::uppercase << std::hex << std::setfill('0') << std::hex << wWhite
    						<< std::setw(2) << std::uppercase << std::hex << std::setfill('0') << std::hex << wWhite;
    				}
    				else
    				{
    					sstr << "#000000"
    						<< std::setw(2) << std::uppercase << std::hex << std::setfill('0') << std::hex << wWhite;
    				}
    				return SendNodeSetCommand(node_id, child_sensor_id, MT_Set, (bIsRGBW == true) ? V_RGBW : V_RGB, sstr.str(), pChild->useAck, pChild->ackTimeout);
    			}
    			else if (pLed->command == Limitless_SetBrightnessLevel)
    			{
    				float fvalue = pLed->value;
    				int svalue = round(fvalue);
    				if (svalue > 100)
    					svalue = 100;
    				std::stringstream sstr;
    				sstr << svalue;
    				return SendNodeSetCommand(node_id, child_sensor_id, MT_Set, V_PERCENTAGE, sstr.str(), pChild->useAck, pChild->ackTimeout);
    			}
    			else if ((pLed->command == Limitless_LedOff) || (pLed->command == Limitless_LedOn))
    			{
    				std::string lState = (pLed->command == Limitless_LedOn) ? "1" : "0";
    				return SendNodeSetCommand(node_id, child_sensor_id, MT_Set, V_STATUS, lState, pChild->useAck, pChild->ackTimeout);
    			}
    		}
    		else
    		{
    			_log.Log(LOG_ERROR, "MySensors: Light command received for unknown node_id: %d", node_id);
    			return false;
    		}
    	}
    	else if (packettype == pTypeBlinds)
    	{
    		//Blinds/Window command
    		int node_id = pCmd->BLINDS1.id3;
    		int child_sensor_id = pCmd->BLINDS1.unitcode;
    
    		if (_tMySensorNode *pNode = FindNode(node_id))
    		{
    			_tMySensorChild *pChild = pNode->FindChild(child_sensor_id);
    			if (!pChild)
    			{
    				_log.Log(LOG_ERROR, "MySensors: Light command received for unknown node_id: %d, child_id: %d", node_id, child_sensor_id);
    				return false;
    			}
    
    			if (pCmd->BLINDS1.cmnd == blinds_sOpen)
    			{
    				return SendNodeSetCommand(node_id, child_sensor_id, MT_Set, V_UP, "", pChild->useAck, pChild->ackTimeout);
    			}
    			else if (pCmd->BLINDS1.cmnd == blinds_sClose)
    			{
    				return SendNodeSetCommand(node_id, child_sensor_id, MT_Set, V_DOWN, "", pChild->useAck, pChild->ackTimeout);
    			}
    			else if (pCmd->BLINDS1.cmnd == blinds_sStop)
    			{
    				return SendNodeSetCommand(node_id, child_sensor_id, MT_Set, V_STOP, "", pChild->useAck, pChild->ackTimeout);
    			}
    		}
    		else {
    			_log.Log(LOG_ERROR, "MySensors: Blinds/Window command received for unknown node_id: %d", node_id);
    			return false;
    		}
    	}
    	else if ((packettype == pTypeThermostat) && (subtype == sTypeThermSetpoint))
    	{
    		//Set Point
    		const _tThermostat *pMeter = reinterpret_cast<const _tThermostat *>(pCmd);
    
    		int node_id = pMeter->id2;
    		int child_sensor_id = pMeter->id3;
    		_eSetType vtype_id = (_eSetType)pMeter->id4;
    
    		if (_tMySensorNode *pNode = FindNode(node_id))
    		{
    			_tMySensorChild *pChild = pNode->FindChild(child_sensor_id);
    			if (!pChild)
    			{
    				_log.Log(LOG_ERROR, "MySensors: Light command received for unknown node_id: %d, child_id: %d", node_id, child_sensor_id);
    				return false;
    			}
    
    			char szTmp[10];
    			sprintf(szTmp, "%.1f", pMeter->temp);
    			return SendNodeSetCommand(node_id, child_sensor_id, MT_Set, vtype_id, szTmp, pChild->useAck, pChild->ackTimeout);
    		}
    		else {
    			_log.Log(LOG_ERROR, "MySensors: Blinds/Window command received for unknown node_id: %d", node_id);
    			return false;
    		}
    	}
    	else if (packettype == pTypeGeneralSwitch)
    	{
    		//Used to store IR codes
    		const _tGeneralSwitch *pSwitch= reinterpret_cast<const _tGeneralSwitch *>(pCmd);
    
    		int node_id = pSwitch->unitcode;
    		unsigned int ir_code = pSwitch->id;
    
    		if (_tMySensorNode *pNode = FindNode(node_id))
    		{
    			_tMySensorChild* pChild = pNode->FindChildByValueType(V_IR_RECEIVE);
    			if (pChild)
    			{
    				std::stringstream sstr;
    				sstr << ir_code;
    				return SendNodeSetCommand(node_id, pChild->childID, MT_Set, V_IR_SEND, sstr.str(), pChild->useAck, pChild->ackTimeout);
    			}
    		}
    		else {
    			_log.Log(LOG_ERROR, "MySensors: Blinds/Window command received for unknown node_id: %d", node_id);
    			return false;
    		}
    	}
    	else
    	{
    		_log.Log(LOG_ERROR, "MySensors: Unknown action received");
    		return false;
    	}
    	return true;
    }```
    Troubleshooting

  • I can not add sensors
    K kimot

    It seems all OK.
    Simply click on green arrow to put sensors on Temperature tab and etc.

    Domoticz

  • RS485/RS232/Serial transport class for mysensors.org
    K kimot

    @andriej
    RS485 was not designet for multimaster communication, where 2 devices can communicate on the bus at same time. RS485 bus state at this time is not defined. For example if node on RS485 on one end of bus sends message end perform "control" lisening on bus if recieve the same message( what is with correct circuit of RS485 transsiever immposible ), then this received message can be the same. But if in the same time another node on oposite end of bus sends different message, then node on the middle of bus recieves something random.
    But CAN bus has allways defined state. It has dominate state and recesive state, so node witch send dominate bit cannot be pushed yb node witch at the same time sends recesive bit. I now, thet this feature we cannot use with normal serial communication, but still we can controll correct sending of datagram by lisening bus by sender. If we recieve the same message what we send, there is 100% shure, that the same message lisens every node on CAN bus. On RS485 this is not garanted. Bus topology is the same end we dont need "dePin". So we can use normal serial library. And CAN transciever is not so expensive as wrote LeoDesigner. Look here:

    http://www.ebay.com/itm/10PCS-MCP2551-I-SN-IC-TRANSCEIVER-CAN-HI-SPD-8-SOIC-NEW-/171541737564?hash=item27f0af305c:g:nbQAAOSwIBBUZU~k

    And sorry for my english

    Development rs485 serial rs485
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular