<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Cheap dirty way to send a raw-mysensors message?]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">is it possible to "inject" a sensor-value into the gateway by hand-crafting a data packet?</p>
<p dir="auto">I recently got some of these little guys (<a href="https://wemakethings.net/chirp/" rel="nofollow ugc">https://wemakethings.net/chirp/</a>)</p>
<p dir="auto">Now my idea was to slap a NRF24 on the ISP header (+2 extra pins for CE and CSN).</p>
<p dir="auto">So far so good .. now I want to craft a simple packet to get data to my gateways ..</p>
<p dir="auto">This is what I got so far but my gateway is not picking up anything.</p>
<pre><code>    radio.begin(); // Start up the radio
    radio.setDataRate(RF24_250KBPS);
    radio.setAutoAck(1); // Ensure autoACK is enabled
    radio.setRetries(15,15); // Max delay between retries &amp; number of retries
    byte station_address[] = { 0x00, 0xFC, 0xE1, 0xA8, 0xA8 };
    //byte station_address[] = { 0xA8, 0xA8, 0xE1, 0xFC, 0x00 };
    radio.openWritingPipe(station_address); // Write to device address 0x00,0xFC,0xE1,0xA8,0xA8
    radio.stopListening();
    byte test[] = { 250, 250, 0, 0b10000001 /* version_length */, 0b00100001,  7 /* S_HUM */ , 1 /* V_HUM */, 123};
    radio.write(test,8);
</code></pre>
<p dir="auto">And no .. I can't cram the mysensors library on the ATTINY44.</p>
<p dir="auto">I am currently happe that I got the basic chirp functunality for measuring the humidity of the soil, attiny debug serial and nrf24 all running on 4k of flash.</p>
<pre><code>Der Sketch verwendet **4046 Bytes (98%)** des Programmspeicherplatzes. Das Maximum sind 4096 Bytes.
Globale Variablen verwenden 150 Bytes (58%) des dynamischen Speichers, 106 Bytes für lokale Variablen verbleiben. Das Maximum sind 256 Bytes.
</code></pre>
<p dir="auto">If anybody know if this is even possible I would like to hear from you.</p>
<p dir="auto">Best regards Marc</p>
]]></description><link>https://forum.mysensors.org/topic/7123/cheap-dirty-way-to-send-a-raw-mysensors-message</link><generator>RSS for Node</generator><lastBuildDate>Fri, 16 Oct 2026 06:20:52 GMT</lastBuildDate><atom:link href="https://forum.mysensors.org/topic/7123.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 07 Jul 2017 21:32:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Cheap dirty way to send a raw-mysensors message? on Tue, 29 Jan 2019 12:18:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cimba007" aria-label="Profile: cimba007">@<bdi>cimba007</bdi></a><br />
Can you post the complete code of the chirp including the headers?<br />
Did you only include these libraries:<br />
#include &lt;SPI.h&gt;<br />
#include "nRF24L01.h"<br />
#include "RF24.h"<br />
?</p>
]]></description><link>https://forum.mysensors.org/post/97024</link><guid isPermaLink="true">https://forum.mysensors.org/post/97024</guid><dc:creator><![CDATA[Mickey]]></dc:creator><pubDate>Tue, 29 Jan 2019 12:18:49 GMT</pubDate></item><item><title><![CDATA[Reply to Cheap dirty way to send a raw-mysensors message? on Fri, 04 Jan 2019 19:43:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kasparsd" aria-label="Profile: kasparsd">@<bdi>kasparsd</bdi></a> I'm also interested in using ATTiny with a RFM69CW module as a MySensor node. How have you initialized the radio with your modified library? Can you show a complete example?</p>
]]></description><link>https://forum.mysensors.org/post/96302</link><guid isPermaLink="true">https://forum.mysensors.org/post/96302</guid><dc:creator><![CDATA[blachner]]></dc:creator><pubDate>Fri, 04 Jan 2019 19:43:19 GMT</pubDate></item><item><title><![CDATA[Reply to Cheap dirty way to send a raw-mysensors message? on Wed, 18 Jul 2018 08:31:13 GMT]]></title><description><![CDATA[<p dir="auto">Turns out that the RFM69 arduino library was missing two additional bytes from the packet header -- <code>rfm69_header_t.version</code> and <code>rfm69_header_t.sequenceNumber</code> in <code>RFM69::sendFrame()</code> (see <a href="https://github.com/kasparsd/RFM69/blob/863bf6222c1f074baa5ce478f965b3c757968bbb/RFM69.cpp#L316-L327" rel="nofollow ugc">the diff</a>).</p>
<pre><code>  select();
  SPI.transfer(REG_FIFO | 0x80); // Select the FIFO write register.

  SPI.transfer(bufferSize + 5); // rfm69_header_t.packetLen
  SPI.transfer(toAddress); // rfm69_header_t.recipient
  SPI.transfer(1); // RFM69_PACKET_HEADER_VERSION = (1u) rfm69_header_t.version header version (20180128tk: &gt;=3.0.0 fused with controlFlags)
  SPI.transfer(_address); // rfm69_header_t.sender
  SPI.transfer(CTLbyte); // rfm69_header_t.controlFlags
  SPI.transfer(0); // rfm69_header_t.sequenceNumber

  for (uint8_t i = 0; i &lt; bufferSize; i++)
    SPI.transfer(((uint8_t*) buffer)[i]);
  unselect();
</code></pre>
<p dir="auto">So after adding <code>SPI.transfer(1);</code> as <code>rfm69_header_t.version</code> and <code>SPI.transfer(0);</code> as <code>rfm69_header_t.sequenceNumber</code> the packets are now being parsed correctly:</p>
<pre><code>DEBUG TSF:MSG:READ,1-1-255,s=3,c=1,t=16,pt=1,l=1,sg=0:1
DEBUG TSF:MSG:BC
</code></pre>
]]></description><link>https://forum.mysensors.org/post/91782</link><guid isPermaLink="true">https://forum.mysensors.org/post/91782</guid><dc:creator><![CDATA[kasparsd]]></dc:creator><pubDate>Wed, 18 Jul 2018 08:31:13 GMT</pubDate></item><item><title><![CDATA[Reply to Cheap dirty way to send a raw-mysensors message? on Wed, 18 Jul 2018 07:14:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cimba007" aria-label="Profile: cimba007">@<bdi>cimba007</bdi></a> Could you please share your latest working code for generating the packet?</p>
<p dir="auto">I've created an ATTiny841 node with the RFM69CW radio (with <a href="https://github.com/kasparsd/RFM69/pull/1/files" rel="nofollow ugc">a modified RFM69 library</a> to match the radio config registers of MySensors) but the Raspberry Pi gateway is seeing the packets different.</p>
<p dir="auto">Here is the sending part:</p>
<pre><code>byte test[] = {
  1, // last
  1, // sender
  255, // destination
  0b00001010, // version_length: 2 bit - Protocol version (2), 1 bit - Signed flag (no), 5 bit - Length of payload (1 byte)
  0b00100001, // command_ack_payload: 3 bit - Command type (C_SET), 1 bit - Request an ack (no), 1 bit - Is ack message (no), 3 bit - Payload data type (P_BYTE)
  16, // type: V_TRIPPED
  3, // sensor ID
  1 // Value: 1
};

radio.send(255, packet, strlen(packet));
</code></pre>
<p dir="auto">which is received as:</p>
<pre><code>DEBUG TSF:MSG:READ,10-255-33,s=0,c=3,t=1,pt=0,l=2,sg=0:
DEBUG !TSF:MSG:LEN,6!=9
</code></pre>
<p dir="auto">where none of the fields match the packet :(</p>
<p dir="auto">Here is the packet definition in <a href="https://github.com/MySensors/MySensors/blob/d21994f4fa8fae2a7d8f4066094db4520342c590/core/MyMessage.h#L480-L522" rel="nofollow ugc">core/MyMessage.h</a>:</p>
<pre><code>uint8_t last;            	 ///&lt; 8 bit - Id of last node this message passed
uint8_t sender;          	 ///&lt; 8 bit - Id of sender node (origin)
uint8_t destination;     	 ///&lt; 8 bit - Id of destination node

/**
 * 2 bit - Protocol version&lt;br&gt;
 * 1 bit - Signed flag&lt;br&gt;
 * 5 bit - Length of payload
 */
uint8_t version_length;

/**
 * 3 bit - Command type&lt;br&gt;
 * 1 bit - Request an ack - Indicator that receiver should send an ack back&lt;br&gt;
 * 1 bit - Is ack message - Indicator that this is the actual ack message&lt;br&gt;
 * 3 bit - Payload data type
 */
uint8_t command_ack_payload;

uint8_t type; ///&lt; 8 bit - Type varies depending on command
uint8_t sensor; ///&lt; 8 bit - Id of sensor that this message concerns.

/*
 * Each message can transfer a payload. We add one extra byte for string
 * terminator \0 to be "printable" this is not transferred OTA
 * This union is used to simplify the construction of the binary data types transferred.
 */
union {
    uint8_t bValue; ///&lt; unsigned byte value (8-bit)
    uint16_t uiValue; ///&lt; unsigned integer value (16-bit)
    int16_t iValue; ///&lt; signed integer value (16-bit)
    uint32_t ulValue; ///&lt; unsigned long value (32-bit)
    int32_t lValue; ///&lt; signed long value (32-bit)
    struct { //&lt; Float messages
        float fValue;
        uint8_t fPrecision; ///&lt; Number of decimals when serializing
    };
    struct {  //&lt; Presentation messages
        uint8_t version; ///&lt; Library version
        uint8_t sensorType; ///&lt; Sensor type hint for controller, see table above
    };
    char data[MAX_PAYLOAD + 1]; ///&lt; Buffer for raw payload data
} __attribute__((packed)); ///&lt; Doxygen will complain without this comment
</code></pre>
<p dir="auto">I'll try and log the raw incoming packet on the Pi side just to confirm that the radio config is actually matching.</p>
]]></description><link>https://forum.mysensors.org/post/91781</link><guid isPermaLink="true">https://forum.mysensors.org/post/91781</guid><dc:creator><![CDATA[kasparsd]]></dc:creator><pubDate>Wed, 18 Jul 2018 07:14:46 GMT</pubDate></item><item><title><![CDATA[Reply to Cheap dirty way to send a raw-mysensors message? on Fri, 14 Jul 2017 16:54:43 GMT]]></title><description><![CDATA[<p dir="auto">Its not "that" bad .. the Attiny44A is compatible with Arduino thanks to <a href="https://github.com/SpenceKonde/ATTinyCore" rel="nofollow ugc">https://github.com/SpenceKonde/ATTinyCore</a></p>
<p dir="auto">For now I got Humidity and Voltage(VCC) running up fine.</p>
]]></description><link>https://forum.mysensors.org/post/71206</link><guid isPermaLink="true">https://forum.mysensors.org/post/71206</guid><dc:creator><![CDATA[cimba007]]></dc:creator><pubDate>Fri, 14 Jul 2017 16:54:43 GMT</pubDate></item><item><title><![CDATA[Reply to Cheap dirty way to send a raw-mysensors message? on Sun, 09 Jul 2017 22:56:40 GMT]]></title><description><![CDATA[<p dir="auto">I wish the chirp had been designed with an atmega328p.  Cost and footprint for the smd is similar I believe</p>
]]></description><link>https://forum.mysensors.org/post/70859</link><guid isPermaLink="true">https://forum.mysensors.org/post/70859</guid><dc:creator><![CDATA[NeverDie]]></dc:creator><pubDate>Sun, 09 Jul 2017 22:56:40 GMT</pubDate></item><item><title><![CDATA[Reply to Cheap dirty way to send a raw-mysensors message? on Sat, 08 Jul 2017 22:00:06 GMT]]></title><description><![CDATA[<p dir="auto">From time to time I run into this bug .. not sure if this is related:</p>
<pre><code>0;255;3;0;9;TSM:READY:NWD REQ&lt;\n&gt;
0;255;3;0;9;TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:&lt;\n&gt;
Fatal exception 28(LoadProhibitedCause):&lt;\n&gt;
epc1=0x40202704, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000003, depc=0x00000000&lt;\n&gt;
&lt;\r&gt;&lt;\n&gt;
</code></pre>
]]></description><link>https://forum.mysensors.org/post/70808</link><guid isPermaLink="true">https://forum.mysensors.org/post/70808</guid><dc:creator><![CDATA[cimba007]]></dc:creator><pubDate>Sat, 08 Jul 2017 22:00:06 GMT</pubDate></item><item><title><![CDATA[Reply to Cheap dirty way to send a raw-mysensors message? on Sat, 08 Jul 2017 17:09:10 GMT]]></title><description><![CDATA[<p dir="auto"><s>I might have run into a bug in the calculation of message length.</s></p>
<p dir="auto"><s>In my handcrafted packet I use this as the 4thy byte send:</s></p>
<p dir="auto"><s><strong>0b10000001</strong></s></p>
<p dir="auto"><s>So to craft this I looked at MyMessage.h which showed me this:</s></p>
<pre><code>uint8_t version_length;		 // 2 bit - Protocol version
		                 // 1 bit - Signed flag
		                 // 5 bit - Length of payload
</code></pre>
<p dir="auto"><s>So from my understanding:</s></p>
<p dir="auto"><s>Protocol Version = 2 =&gt; 0b10</s><br />
<s>Signed Flag = 0 =&gt; 0b0</s><br />
<s>Length of Payload = 1 = 0b00001</s></p>
<p dir="auto"><s>Which results in 0b10 0 00001 = 0b10000001</s></p>
<p dir="auto"><s>But I get this error:</s></p>
<pre><code>LEN,8!=23
</code></pre>
<p dir="auto"><s>So .. where might this come from?</s></p>
<pre><code>radio.write(test,8);
</code></pre>
<p dir="auto"><s>Mycontroller received a packet with the length of 8 but expected a packet with the length of .. 23 ?!</s></p>
<pre><code>#define mGetLength(_message) ((uint8_t)BF_GET(_message.version_length, 3, 5)) //!&lt; Get length field
</code></pre>
<p dir="auto"><s>Which in essential is BF_GET ..</s></p>
<pre><code>#define BF_GET(y, start, len)   ( ((y)&gt;&gt;(start)) &amp; BIT_MASK(len) ) //!&lt; Extract a bitfield of length 'len' starting at bit 'start' from 'y'
</code></pre>
<p dir="auto"><s>So what is happening?</s></p>
<pre><code>BF_GET(0b10000001, 3, 5)   ( ((0b10000001)&gt;&gt;(3)) &amp; BIT_MASK(5) ) //!&lt; Extract a bitfield of length 'len' starting at bit 'start' 
</code></pre>
<p dir="auto"><s>Whoops? This will throw away all the length-information!!!</s><br />
<s><strong>(0b10000001)&gt;&gt;(3)</strong></s><br />
<s>This should result in:</s><br />
<s>0b11110000 &amp; BIT_MASK5 = 0b1111000 &amp; 0b00011111 = 0b00010000 = 16 decimal</s></p>
<pre><code>const uint8_t expectedMessageLength = HEADER_SIZE + (mGetSigned(_msg) ? MAX_PAYLOAD : msgLength);
</code></pre>
<pre><code>const uint8_t expectedMessageLength = 7+ 16); // = 23
</code></pre>
<p dir="auto"><s>Yeah .. the lib is right .. 8 != 23 .. but the handcrafted length = 1 + header_length (7) = 8</s></p>
<p dir="auto"><s>Am I wrong or is this a bug?</s></p>
<p dir="auto"><strong>Edit: I might have read the comments in the source code the wrong way</strong></p>
]]></description><link>https://forum.mysensors.org/post/70793</link><guid isPermaLink="true">https://forum.mysensors.org/post/70793</guid><dc:creator><![CDATA[cimba007]]></dc:creator><pubDate>Sat, 08 Jul 2017 17:09:10 GMT</pubDate></item><item><title><![CDATA[Reply to Cheap dirty way to send a raw-mysensors message? on Sat, 08 Jul 2017 15:01:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cimba007" aria-label="Profile: cimba007">@<bdi>cimba007</bdi></a> very nice work! Great way to be compatible with the MySensors protocol/ecosystem on a limited device when the full MySensors feature set is not needed.</p>
]]></description><link>https://forum.mysensors.org/post/70785</link><guid isPermaLink="true">https://forum.mysensors.org/post/70785</guid><dc:creator><![CDATA[mfalkvidd]]></dc:creator><pubDate>Sat, 08 Jul 2017 15:01:17 GMT</pubDate></item><item><title><![CDATA[Reply to Cheap dirty way to send a raw-mysensors message? on Sat, 08 Jul 2017 17:43:48 GMT]]></title><description><![CDATA[<p dir="auto">After many hours trial and error I present you .. the raw-mysensors-client!!</p>
<p dir="auto">MyGateway: ESP8266 + mysensorsMQTT<br />
MyNode: <a href="https://github.com/Miceuz/PlantWateringAlarm" rel="nofollow ugc">https://github.com/Miceuz/PlantWateringAlarm</a><br />
MyNode-MCU: Attiny44 (MemoryFootprint: 87% of 4KB)<br />
ArduinoCore: <a href="https://github.com/SpenceKonde/ATTinyCore" rel="nofollow ugc">https://github.com/SpenceKonde/ATTinyCore</a><br />
ArduinoCore-PinLayout: Counterclockwise (like AttinyCore)<br />
<strong>Note: The default "counterclockwise"pinout is the alternate pinout shown here:</strong> <a href="https://github.com/SpenceKonde/ATTinyCore/blob/master/avr/extras/ATtiny_x4.md" rel="nofollow ugc">https://github.com/SpenceKonde/ATTinyCore/blob/master/avr/extras/ATtiny_x4.md</a></p>
<p dir="auto">The important hint is here (<a href="http://tmrh20.github.io/RF24/ATTiny.html" rel="nofollow ugc">http://tmrh20.github.io/RF24/ATTiny.html</a>)</p>
<p dir="auto">Connect MOSI of the RF24 to PA5 of the attiny and MISO of the RF24 to PA6 of the attiny.<br />
CE = 8<br />
CSN = 7</p>
<p dir="auto">To get the connection done right DONT .. i mean DO NOT BECAUSE IT DOESNT FUCKING WORK connect MOSI of the RF24 to MOSI of the attiny. RF24 uses a embedded implementation of the USI-engine found on some AtTiny's.</p>
<p dir="auto"><em>radio-initilisation</em></p>
<pre><code>    radio.begin(); // Start up the radio
    radio.setDataRate(RF24_250KBPS);
    radio.setAutoAck(1); // Ensure autoACK is enabled
    radio.setRetries(15,15); // Max delay between retries &amp; number of retries
    //radio.setPayloadSize(8);
    radio.enableDynamicPayloads();
    radio.setPALevel(RF24_PA_MAX);
    byte tx_address[] = { 0x00, 0xFC, 0xE1, 0xA8, 0xA8 };
    //byte tx_address[] = { 0xA8, 0xA8, 0xE1, 0xFC, 0x00 };
    radio.openWritingPipe(tx_address);
    radio.stopListening();
</code></pre>
<p dir="auto"><em>Send-Function:</em></p>
<pre><code>void sendHumidity(uint16_t humidity)
{
    // snprintf_P(_fmtBuffer, MY_GATEWAY_MAX_SEND_LENGTH, PSTR("%s/%d/%d/%d/%d/%d"), prefix, message.sender, message.sensor, mGetCommand(message), mGetAck(message), message.type);
    // X8X22&lt;\0&gt;&lt;\n&gt;!&lt;7&gt;7AY0;255;3;0;9;TSF:MSG:READ,50-50-0,s=55,c=1,t=7,pt=1,l=1,sg=0:65&lt;\n&gt;
    // 0;255;3;0;9;Sending message on topic: domoticz/in/MyMQTT/50/55/1/0/7&lt;\n&gt;
    
    #define LAST_NODE_ID  50  // last
    #define NODE_ID       50  // sender
    #define GATEWAY_ID    0   // destination
    
                              // version_length     // 5 bit - Length of payload // 1 bit - Signed flag // 2 bit - Protocol version
                              // command_ack_payload // 3 bit - Payload data type // 1 bit - Is ack messsage - Indicator that this is the actual ack message. // 1 bit - Request an ack - Indicator that receiver should send an ack back. // 3 bit - Command type
    
    #define SENSOR_TYPE   7   // type S_HUM = 7
    #define SENSOR_ID     55  // sensor-id
    byte test[] = { LAST_NODE_ID, NODE_ID, GATEWAY_ID, 0b00010010, 0b01100001,  SENSOR_TYPE, SENSOR_ID, (uint8_t)(humidity &amp; 0x00FF), (uint8_t)((humidity &gt;&gt; 8) &amp; 0x00FF),  0x00 };
    radio.write(test,9);
}
</code></pre>
<p dir="auto">I am not quite sure yet if the message-types etc. are right but I am trying to find this out. 'A' (dec 65) is the "value" of my humidity .. next step is to make this a real value ofc.</p>
<p dir="auto">Proof at domoticz:<br />
<img src="/assets/uploads/files/1499525233088-upload-22170821-6116-4d1a-a08b-c0631b3fac15.png" alt="0_1499525234377_upload-22170821-6116-4d1a-a08b-c0631b3fac15" class=" img-fluid img-markdown" /></p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gohan" aria-label="Profile: gohan">@<bdi>gohan</bdi></a>: In the file MyConfig.h I commented this out:</p>
<pre><code>/**
 * @def MY_REGISTRATION_FEATURE
 * @brief If enabled, node has to register to gateway/controller before allowed to send sensor data.
 */
// #define MY_REGISTRATION_FEATURE
</code></pre>
<p dir="auto">This will skip the whole hasse of registering the client properly (which I can't .. remember 87% of flash is full)</p>
]]></description><link>https://forum.mysensors.org/post/70784</link><guid isPermaLink="true">https://forum.mysensors.org/post/70784</guid><dc:creator><![CDATA[cimba007]]></dc:creator><pubDate>Sat, 08 Jul 2017 17:43:48 GMT</pubDate></item><item><title><![CDATA[Reply to Cheap dirty way to send a raw-mysensors message? on Sat, 08 Jul 2017 10:26:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gohan" aria-label="Profile: gohan">@<bdi>gohan</bdi></a> Thanks for your response. The problem is that I already have 5 "chirps" and just later came up with the idea of adding nrf24 to them. I might try to add a "relay" node which will listen for "normal" rf24 packets and then send them to my gateway using the mysensors library.</p>
]]></description><link>https://forum.mysensors.org/post/70774</link><guid isPermaLink="true">https://forum.mysensors.org/post/70774</guid><dc:creator><![CDATA[cimba007]]></dc:creator><pubDate>Sat, 08 Jul 2017 10:26:05 GMT</pubDate></item><item><title><![CDATA[Reply to Cheap dirty way to send a raw-mysensors message? on Sat, 08 Jul 2017 06:33:27 GMT]]></title><description><![CDATA[<p dir="auto">The problem I think is that the gateway needs the node to register on the network so it knows what it should expect receiving, it is a 2 way communication not like those devices using RF link that only transmit and other only receives.<br />
Have you evaluated the button size node on openhardware? I think it could be an alternative for your needs</p>
]]></description><link>https://forum.mysensors.org/post/70737</link><guid isPermaLink="true">https://forum.mysensors.org/post/70737</guid><dc:creator><![CDATA[gohan]]></dc:creator><pubDate>Sat, 08 Jul 2017 06:33:27 GMT</pubDate></item></channel></rss>