├── LICENSE ├── README.md └── Somfy_Remote.ino /LICENSE: -------------------------------------------------------------------------------- 1 | Somfy Remote (c) by Nickduino 2 | 3 | Somfy Remote is licensed under a 4 | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. 5 | 6 | In short, see . 7 | 8 | Attribution-NonCommercial-ShareAlike 4.0 International 9 | 10 | ======================================================================= 11 | 12 | Creative Commons Corporation ("Creative Commons") is not a law firm and 13 | does not provide legal services or legal advice. Distribution of 14 | Creative Commons public licenses does not create a lawyer-client or 15 | other relationship. Creative Commons makes its licenses and related 16 | information available on an "as-is" basis. Creative Commons gives no 17 | warranties regarding its licenses, any material licensed under their 18 | terms and conditions, or any related information. Creative Commons 19 | disclaims all liability for damages resulting from their use to the 20 | fullest extent possible. 21 | 22 | Using Creative Commons Public Licenses 23 | 24 | Creative Commons public licenses provide a standard set of terms and 25 | conditions that creators and other rights holders may use to share 26 | original works of authorship and other material subject to copyright 27 | and certain other rights specified in the public license below. The 28 | following considerations are for informational purposes only, are not 29 | exhaustive, and do not form part of our licenses. 30 | 31 | Considerations for licensors: Our public licenses are 32 | intended for use by those authorized to give the public 33 | permission to use material in ways otherwise restricted by 34 | copyright and certain other rights. Our licenses are 35 | irrevocable. Licensors should read and understand the terms 36 | and conditions of the license they choose before applying it. 37 | Licensors should also secure all rights necessary before 38 | applying our licenses so that the public can reuse the 39 | material as expected. Licensors should clearly mark any 40 | material not subject to the license. This includes other CC- 41 | licensed material, or material used under an exception or 42 | limitation to copyright. More considerations for licensors: 43 | wiki.creativecommons.org/Considerations_for_licensors 44 | 45 | Considerations for the public: By using one of our public 46 | licenses, a licensor grants the public permission to use the 47 | licensed material under specified terms and conditions. If 48 | the licensor's permission is not necessary for any reason--for 49 | example, because of any applicable exception or limitation to 50 | copyright--then that use is not regulated by the license. Our 51 | licenses grant only permissions under copyright and certain 52 | other rights that a licensor has authority to grant. Use of 53 | the licensed material may still be restricted for other 54 | reasons, including because others have copyright or other 55 | rights in the material. A licensor may make special requests, 56 | such as asking that all changes be marked or described. 57 | Although not required by our licenses, you are encouraged to 58 | respect those requests where reasonable. More considerations 59 | for the public: 60 | wiki.creativecommons.org/Considerations_for_licensees 61 | 62 | ======================================================================= 63 | 64 | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International 65 | Public License 66 | 67 | By exercising the Licensed Rights (defined below), You accept and agree 68 | to be bound by the terms and conditions of this Creative Commons 69 | Attribution-NonCommercial-ShareAlike 4.0 International Public License 70 | ("Public License"). To the extent this Public License may be 71 | interpreted as a contract, You are granted the Licensed Rights in 72 | consideration of Your acceptance of these terms and conditions, and the 73 | Licensor grants You such rights in consideration of benefits the 74 | Licensor receives from making the Licensed Material available under 75 | these terms and conditions. 76 | 77 | 78 | Section 1 -- Definitions. 79 | 80 | a. Adapted Material means material subject to Copyright and Similar 81 | Rights that is derived from or based upon the Licensed Material 82 | and in which the Licensed Material is translated, altered, 83 | arranged, transformed, or otherwise modified in a manner requiring 84 | permission under the Copyright and Similar Rights held by the 85 | Licensor. For purposes of this Public License, where the Licensed 86 | Material is a musical work, performance, or sound recording, 87 | Adapted Material is always produced where the Licensed Material is 88 | synched in timed relation with a moving image. 89 | 90 | b. Adapter's License means the license You apply to Your Copyright 91 | and Similar Rights in Your contributions to Adapted Material in 92 | accordance with the terms and conditions of this Public License. 93 | 94 | c. BY-NC-SA Compatible License means a license listed at 95 | creativecommons.org/compatiblelicenses, approved by Creative 96 | Commons as essentially the equivalent of this Public License. 97 | 98 | d. Copyright and Similar Rights means copyright and/or similar rights 99 | closely related to copyright including, without limitation, 100 | performance, broadcast, sound recording, and Sui Generis Database 101 | Rights, without regard to how the rights are labeled or 102 | categorized. For purposes of this Public License, the rights 103 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 104 | Rights. 105 | 106 | e. Effective Technological Measures means those measures that, in the 107 | absence of proper authority, may not be circumvented under laws 108 | fulfilling obligations under Article 11 of the WIPO Copyright 109 | Treaty adopted on December 20, 1996, and/or similar international 110 | agreements. 111 | 112 | f. Exceptions and Limitations means fair use, fair dealing, and/or 113 | any other exception or limitation to Copyright and Similar Rights 114 | that applies to Your use of the Licensed Material. 115 | 116 | g. License Elements means the license attributes listed in the name 117 | of a Creative Commons Public License. The License Elements of this 118 | Public License are Attribution, NonCommercial, and ShareAlike. 119 | 120 | h. Licensed Material means the artistic or literary work, database, 121 | or other material to which the Licensor applied this Public 122 | License. 123 | 124 | i. Licensed Rights means the rights granted to You subject to the 125 | terms and conditions of this Public License, which are limited to 126 | all Copyright and Similar Rights that apply to Your use of the 127 | Licensed Material and that the Licensor has authority to license. 128 | 129 | j. Licensor means the individual(s) or entity(ies) granting rights 130 | under this Public License. 131 | 132 | k. NonCommercial means not primarily intended for or directed towards 133 | commercial advantage or monetary compensation. For purposes of 134 | this Public License, the exchange of the Licensed Material for 135 | other material subject to Copyright and Similar Rights by digital 136 | file-sharing or similar means is NonCommercial provided there is 137 | no payment of monetary compensation in connection with the 138 | exchange. 139 | 140 | l. Share means to provide material to the public by any means or 141 | process that requires permission under the Licensed Rights, such 142 | as reproduction, public display, public performance, distribution, 143 | dissemination, communication, or importation, and to make material 144 | available to the public including in ways that members of the 145 | public may access the material from a place and at a time 146 | individually chosen by them. 147 | 148 | m. Sui Generis Database Rights means rights other than copyright 149 | resulting from Directive 96/9/EC of the European Parliament and of 150 | the Council of 11 March 1996 on the legal protection of databases, 151 | as amended and/or succeeded, as well as other essentially 152 | equivalent rights anywhere in the world. 153 | 154 | n. You means the individual or entity exercising the Licensed Rights 155 | under this Public License. Your has a corresponding meaning. 156 | 157 | 158 | Section 2 -- Scope. 159 | 160 | a. License grant. 161 | 162 | 1. Subject to the terms and conditions of this Public License, 163 | the Licensor hereby grants You a worldwide, royalty-free, 164 | non-sublicensable, non-exclusive, irrevocable license to 165 | exercise the Licensed Rights in the Licensed Material to: 166 | 167 | a. reproduce and Share the Licensed Material, in whole or 168 | in part, for NonCommercial purposes only; and 169 | 170 | b. produce, reproduce, and Share Adapted Material for 171 | NonCommercial purposes only. 172 | 173 | 2. Exceptions and Limitations. For the avoidance of doubt, where 174 | Exceptions and Limitations apply to Your use, this Public 175 | License does not apply, and You do not need to comply with 176 | its terms and conditions. 177 | 178 | 3. Term. The term of this Public License is specified in Section 179 | 6(a). 180 | 181 | 4. Media and formats; technical modifications allowed. The 182 | Licensor authorizes You to exercise the Licensed Rights in 183 | all media and formats whether now known or hereafter created, 184 | and to make technical modifications necessary to do so. The 185 | Licensor waives and/or agrees not to assert any right or 186 | authority to forbid You from making technical modifications 187 | necessary to exercise the Licensed Rights, including 188 | technical modifications necessary to circumvent Effective 189 | Technological Measures. For purposes of this Public License, 190 | simply making modifications authorized by this Section 2(a) 191 | (4) never produces Adapted Material. 192 | 193 | 5. Downstream recipients. 194 | 195 | a. Offer from the Licensor -- Licensed Material. Every 196 | recipient of the Licensed Material automatically 197 | receives an offer from the Licensor to exercise the 198 | Licensed Rights under the terms and conditions of this 199 | Public License. 200 | 201 | b. Additional offer from the Licensor -- Adapted Material. 202 | Every recipient of Adapted Material from You 203 | automatically receives an offer from the Licensor to 204 | exercise the Licensed Rights in the Adapted Material 205 | under the conditions of the Adapter's License You apply. 206 | 207 | c. No downstream restrictions. You may not offer or impose 208 | any additional or different terms or conditions on, or 209 | apply any Effective Technological Measures to, the 210 | Licensed Material if doing so restricts exercise of the 211 | Licensed Rights by any recipient of the Licensed 212 | Material. 213 | 214 | 6. No endorsement. Nothing in this Public License constitutes or 215 | may be construed as permission to assert or imply that You 216 | are, or that Your use of the Licensed Material is, connected 217 | with, or sponsored, endorsed, or granted official status by, 218 | the Licensor or others designated to receive attribution as 219 | provided in Section 3(a)(1)(A)(i). 220 | 221 | b. Other rights. 222 | 223 | 1. Moral rights, such as the right of integrity, are not 224 | licensed under this Public License, nor are publicity, 225 | privacy, and/or other similar personality rights; however, to 226 | the extent possible, the Licensor waives and/or agrees not to 227 | assert any such rights held by the Licensor to the limited 228 | extent necessary to allow You to exercise the Licensed 229 | Rights, but not otherwise. 230 | 231 | 2. Patent and trademark rights are not licensed under this 232 | Public License. 233 | 234 | 3. To the extent possible, the Licensor waives any right to 235 | collect royalties from You for the exercise of the Licensed 236 | Rights, whether directly or through a collecting society 237 | under any voluntary or waivable statutory or compulsory 238 | licensing scheme. In all other cases the Licensor expressly 239 | reserves any right to collect such royalties, including when 240 | the Licensed Material is used other than for NonCommercial 241 | purposes. 242 | 243 | 244 | Section 3 -- License Conditions. 245 | 246 | Your exercise of the Licensed Rights is expressly made subject to the 247 | following conditions. 248 | 249 | a. Attribution. 250 | 251 | 1. If You Share the Licensed Material (including in modified 252 | form), You must: 253 | 254 | a. retain the following if it is supplied by the Licensor 255 | with the Licensed Material: 256 | 257 | i. identification of the creator(s) of the Licensed 258 | Material and any others designated to receive 259 | attribution, in any reasonable manner requested by 260 | the Licensor (including by pseudonym if 261 | designated); 262 | 263 | ii. a copyright notice; 264 | 265 | iii. a notice that refers to this Public License; 266 | 267 | iv. a notice that refers to the disclaimer of 268 | warranties; 269 | 270 | v. a URI or hyperlink to the Licensed Material to the 271 | extent reasonably practicable; 272 | 273 | b. indicate if You modified the Licensed Material and 274 | retain an indication of any previous modifications; and 275 | 276 | c. indicate the Licensed Material is licensed under this 277 | Public License, and include the text of, or the URI or 278 | hyperlink to, this Public License. 279 | 280 | 2. You may satisfy the conditions in Section 3(a)(1) in any 281 | reasonable manner based on the medium, means, and context in 282 | which You Share the Licensed Material. For example, it may be 283 | reasonable to satisfy the conditions by providing a URI or 284 | hyperlink to a resource that includes the required 285 | information. 286 | 3. If requested by the Licensor, You must remove any of the 287 | information required by Section 3(a)(1)(A) to the extent 288 | reasonably practicable. 289 | 290 | b. ShareAlike. 291 | 292 | In addition to the conditions in Section 3(a), if You Share 293 | Adapted Material You produce, the following conditions also apply. 294 | 295 | 1. The Adapter's License You apply must be a Creative Commons 296 | license with the same License Elements, this version or 297 | later, or a BY-NC-SA Compatible License. 298 | 299 | 2. You must include the text of, or the URI or hyperlink to, the 300 | Adapter's License You apply. You may satisfy this condition 301 | in any reasonable manner based on the medium, means, and 302 | context in which You Share Adapted Material. 303 | 304 | 3. You may not offer or impose any additional or different terms 305 | or conditions on, or apply any Effective Technological 306 | Measures to, Adapted Material that restrict exercise of the 307 | rights granted under the Adapter's License You apply. 308 | 309 | 310 | Section 4 -- Sui Generis Database Rights. 311 | 312 | Where the Licensed Rights include Sui Generis Database Rights that 313 | apply to Your use of the Licensed Material: 314 | 315 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 316 | to extract, reuse, reproduce, and Share all or a substantial 317 | portion of the contents of the database for NonCommercial purposes 318 | only; 319 | 320 | b. if You include all or a substantial portion of the database 321 | contents in a database in which You have Sui Generis Database 322 | Rights, then the database in which You have Sui Generis Database 323 | Rights (but not its individual contents) is Adapted Material, 324 | including for purposes of Section 3(b); and 325 | 326 | c. You must comply with the conditions in Section 3(a) if You Share 327 | all or a substantial portion of the contents of the database. 328 | 329 | For the avoidance of doubt, this Section 4 supplements and does not 330 | replace Your obligations under this Public License where the Licensed 331 | Rights include other Copyright and Similar Rights. 332 | 333 | 334 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 335 | 336 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 337 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 338 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 339 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 340 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 341 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 342 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 343 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 344 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 345 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 346 | 347 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 348 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 349 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 350 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 351 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 352 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 353 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 354 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 355 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 356 | 357 | c. The disclaimer of warranties and limitation of liability provided 358 | above shall be interpreted in a manner that, to the extent 359 | possible, most closely approximates an absolute disclaimer and 360 | waiver of all liability. 361 | 362 | 363 | Section 6 -- Term and Termination. 364 | 365 | a. This Public License applies for the term of the Copyright and 366 | Similar Rights licensed here. However, if You fail to comply with 367 | this Public License, then Your rights under this Public License 368 | terminate automatically. 369 | 370 | b. Where Your right to use the Licensed Material has terminated under 371 | Section 6(a), it reinstates: 372 | 373 | 1. automatically as of the date the violation is cured, provided 374 | it is cured within 30 days of Your discovery of the 375 | violation; or 376 | 377 | 2. upon express reinstatement by the Licensor. 378 | 379 | For the avoidance of doubt, this Section 6(b) does not affect any 380 | right the Licensor may have to seek remedies for Your violations 381 | of this Public License. 382 | 383 | c. For the avoidance of doubt, the Licensor may also offer the 384 | Licensed Material under separate terms or conditions or stop 385 | distributing the Licensed Material at any time; however, doing so 386 | will not terminate this Public License. 387 | 388 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 389 | License. 390 | 391 | 392 | Section 7 -- Other Terms and Conditions. 393 | 394 | a. The Licensor shall not be bound by any additional or different 395 | terms or conditions communicated by You unless expressly agreed. 396 | 397 | b. Any arrangements, understandings, or agreements regarding the 398 | Licensed Material not stated herein are separate from and 399 | independent of the terms and conditions of this Public License. 400 | 401 | 402 | Section 8 -- Interpretation. 403 | 404 | a. For the avoidance of doubt, this Public License does not, and 405 | shall not be interpreted to, reduce, limit, restrict, or impose 406 | conditions on any use of the Licensed Material that could lawfully 407 | be made without permission under this Public License. 408 | 409 | b. To the extent possible, if any provision of this Public License is 410 | deemed unenforceable, it shall be automatically reformed to the 411 | minimum extent necessary to make it enforceable. If the provision 412 | cannot be reformed, it shall be severed from this Public License 413 | without affecting the enforceability of the remaining terms and 414 | conditions. 415 | 416 | c. No term or condition of this Public License will be waived and no 417 | failure to comply consented to unless expressly agreed to by the 418 | Licensor. 419 | 420 | d. Nothing in this Public License constitutes or may be interpreted 421 | as a limitation upon, or waiver of, any privileges and immunities 422 | that apply to the Licensor or You, including from the legal 423 | processes of any jurisdiction or authority. 424 | 425 | ======================================================================= 426 | 427 | Creative Commons is not a party to its public 428 | licenses. Notwithstanding, Creative Commons may elect to apply one of 429 | its public licenses to material it publishes and in those instances 430 | will be considered the “Licensor.” The text of the Creative Commons 431 | public licenses is dedicated to the public domain under the CC0 Public 432 | Domain Dedication. Except for the limited purpose of indicating that 433 | material is shared under a Creative Commons public license or as 434 | otherwise permitted by the Creative Commons policies published at 435 | creativecommons.org/policies, Creative Commons does not authorize the 436 | use of the trademark "Creative Commons" or any other trademark or logo 437 | of Creative Commons without its prior written consent including, 438 | without limitation, in connection with any unauthorized modifications 439 | to any of its public licenses or any other arrangements, 440 | understandings, or agreements concerning use of licensed material. For 441 | the avoidance of doubt, this paragraph does not form part of the 442 | public licenses. 443 | 444 | Creative Commons may be contacted at creativecommons.org. 445 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Image of the licence](https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png) 2 | 3 | # Somfy Remote 4 | An Arduino Sketch able to emulate a Somfy remote control. 5 |


6 | If you want to learn more about the Somfy RTS protocol, check out [Pushtack](https://pushstack.wordpress.com/somfy-rts-protocol/). 7 | 8 | If you want to see it in action, MakerMeik made [a great video](https://youtu.be/9RhHrYqp9FU) about his port to an ESP8266 9 |



10 | 11 | **How the hardware works:** 12 | Connect a *433.42 Mhz* RF transmitter to Arduino Pin 5 (or change the pin in the sketch). I couldn't find a 433.*42* MHz transmitter so I hacked a remote to send my signals. I then ordered 433.42 MHz crystals to change the regular 433.92 MHz ones I have on my transmitters: that's the cheapest way to do it. Other option would be to use a tunable transmitter like the CC1101 (but that hardly looks like the easy way and I'm not a ham radio, so...). 13 | 14 | 15 | **How the software works:** 16 | What you really want to keep here are the BuildFrame() and SendCommand() procedures. Input the *remote address* and the *rolling code* value and you have a remote. With the sketch, you can send the command through serial line but that would be easily modified to button press or whatever (I plan on running it on an internet-connected ESP8266 to shut the blinds at sunset every day). 17 | 18 | 19 | The rolling code value is stored in the EEPROM, so that you don't loose count of your rolling code after a reset. 20 | 21 |
22 |
23 |
24 | 25 | **If you want more functionality** or simply better instructions, check out the [Python version](https://github.com/Nickduino/Pi-Somfy) 26 | -------------------------------------------------------------------------------- /Somfy_Remote.ino: -------------------------------------------------------------------------------- 1 | /* This sketch allows you to emulate a Somfy RTS or Simu HZ remote. 2 | If you want to learn more about the Somfy RTS protocol, check out https://pushstack.wordpress.com/somfy-rts-protocol/ 3 | 4 | The rolling code will be stored in EEPROM, so that you can power the Arduino off. 5 | 6 | Easiest way to make it work for you: 7 | - Choose a remote number 8 | - Choose a starting point for the rolling code. Any unsigned int works, 1 is a good start 9 | - Upload the sketch 10 | - Long-press the program button of YOUR ACTUAL REMOTE until your blind goes up and down slightly 11 | - send 'p' to the serial terminal 12 | To make a group command, just repeat the last two steps with another blind (one by one) 13 | 14 | Then: 15 | - m, u or h will make it to go up 16 | - s make it stop 17 | - b, or d will make it to go down 18 | - you can also send a HEX number directly for any weird command you (0x9 for the sun and wind detector for instance) 19 | */ 20 | 21 | #include 22 | #define PORT_TX 5 //5 of PORTD = DigitalPin 5 23 | 24 | #define SYMBOL 640 25 | #define HAUT 0x2 26 | #define STOP 0x1 27 | #define BAS 0x4 28 | #define PROG 0x8 29 | #define EEPROM_ADDRESS 0 30 | 31 | #define REMOTE 0x121300 //<-- Change it! 32 | 33 | unsigned int newRollingCode = 101; //<-- Change it! 34 | unsigned int rollingCode = 0; 35 | byte frame[7]; 36 | byte checksum; 37 | 38 | void BuildFrame(byte *frame, byte button); 39 | void SendCommand(byte *frame, byte sync); 40 | 41 | 42 | void setup() { 43 | Serial.begin(115200); 44 | DDRD |= 1< 0) { 56 | char serie = (char)Serial.read(); 57 | Serial.println(""); 58 | // Serial.print("Remote : "); Serial.println(REMOTE, HEX); 59 | if(serie == 'm'||serie == 'u'||serie == 'h') { 60 | Serial.println("Monte"); // Somfy is a French company, after all. 61 | BuildFrame(frame, HAUT); 62 | } 63 | else if(serie == 's') { 64 | Serial.println("Stop"); 65 | BuildFrame(frame, STOP); 66 | } 67 | else if(serie == 'b'||serie == 'd') { 68 | Serial.println("Descend"); 69 | BuildFrame(frame, BAS); 70 | } 71 | else if(serie == 'p') { 72 | Serial.println("Prog"); 73 | BuildFrame(frame, PROG); 74 | } 75 | else { 76 | Serial.println("Custom code"); 77 | BuildFrame(frame, serie); 78 | } 79 | 80 | Serial.println(""); 81 | SendCommand(frame, 2); 82 | for(int i = 0; i<2; i++) { 83 | SendCommand(frame, 7); 84 | } 85 | } 86 | } 87 | 88 | 89 | void BuildFrame(byte *frame, byte button) { 90 | unsigned int code; 91 | EEPROM.get(EEPROM_ADDRESS, code); 92 | frame[0] = 0xA7; // Encryption key. Doesn't matter much 93 | frame[1] = button << 4; // Which button did you press? The 4 LSB will be the checksum 94 | frame[2] = code >> 8; // Rolling code (big endian) 95 | frame[3] = code; // Rolling code 96 | frame[4] = REMOTE >> 16; // Remote address 97 | frame[5] = REMOTE >> 8; // Remote address 98 | frame[6] = REMOTE; // Remote address 99 | 100 | Serial.print("Frame : "); 101 | for(byte i = 0; i < 7; i++) { 102 | if(frame[i] >> 4 == 0) { // Displays leading zero in case the most significant 103 | Serial.print("0"); // nibble is a 0. 104 | } 105 | Serial.print(frame[i],HEX); Serial.print(" "); 106 | } 107 | 108 | // Checksum calculation: a XOR of all the nibbles 109 | checksum = 0; 110 | for(byte i = 0; i < 7; i++) { 111 | checksum = checksum ^ frame[i] ^ (frame[i] >> 4); 112 | } 113 | checksum &= 0b1111; // We keep the last 4 bits only 114 | 115 | 116 | //Checksum integration 117 | frame[1] |= checksum; // If a XOR of all the nibbles is equal to 0, the blinds will 118 | // consider the checksum ok. 119 | 120 | Serial.println(""); Serial.print("With checksum : "); 121 | for(byte i = 0; i < 7; i++) { 122 | if(frame[i] >> 4 == 0) { 123 | Serial.print("0"); 124 | } 125 | Serial.print(frame[i],HEX); Serial.print(" "); 126 | } 127 | 128 | 129 | // Obfuscation: a XOR of all the bytes 130 | for(byte i = 1; i < 7; i++) { 131 | frame[i] ^= frame[i-1]; 132 | } 133 | 134 | Serial.println(""); Serial.print("Obfuscated : "); 135 | for(byte i = 0; i < 7; i++) { 136 | if(frame[i] >> 4 == 0) { 137 | Serial.print("0"); 138 | } 139 | Serial.print(frame[i],HEX); Serial.print(" "); 140 | } 141 | Serial.println(""); 142 | Serial.print("Rolling Code : "); Serial.println(code); 143 | EEPROM.put(EEPROM_ADDRESS, code + 1); // We store the value of the rolling code in the 144 | // EEPROM. It should take up to 2 adresses but the 145 | // Arduino function takes care of it. 146 | } 147 | 148 | void SendCommand(byte *frame, byte sync) { 149 | if(sync == 2) { // Only with the first frame. 150 | //Wake-up pulse & Silence 151 | PORTD |= 1<> (7 - (i%8))) & 1) == 1) { 175 | PORTD &= !(1<