├── .gitattributes ├── .gitignore ├── Documentation └── TSL256x.pdf ├── Hardware ├── README.md ├── SparkFun_TSL2561_Sensor_Breakout.brd └── SparkFun_TSL2561_Sensor_Breakout.sch ├── LICENSE.md ├── Libraries ├── Arduino │ ├── LICENSE.md │ ├── README.md │ ├── examples │ │ └── SparkFunTSL2561Example │ │ │ └── SparkFunTSL2561Example.ino │ ├── library.properties │ └── src │ │ ├── SparkFunTSL2561.cpp │ │ └── SparkFunTSL2561.h └── README.md ├── Production ├── README.md └── TSL2561_Luminosity_Sensor_BOB-Panel-v10.brd └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## SparkFun Useful stuff 3 | ################# 4 | 5 | ## AVR Development 6 | *.eep 7 | *.elf 8 | *.lst 9 | *.lss 10 | *.sym 11 | *.d 12 | *.o 13 | *.srec 14 | *.map 15 | 16 | ## Notepad++ backup files 17 | *.bak 18 | 19 | ## BOM files 20 | *bom* 21 | 22 | ################# 23 | ## Eclipse 24 | ################# 25 | 26 | *.pydevproject 27 | .project 28 | .metadata 29 | bin/ 30 | tmp/ 31 | *.tmp 32 | *.bak 33 | *.swp 34 | *~.nib 35 | local.properties 36 | .classpath 37 | .settings/ 38 | .loadpath 39 | 40 | # External tool builders 41 | .externalToolBuilders/ 42 | 43 | # Locally stored "Eclipse launch configurations" 44 | *.launch 45 | 46 | # CDT-specific 47 | .cproject 48 | 49 | # PDT-specific 50 | .buildpath 51 | 52 | 53 | ############# 54 | ## Eagle 55 | ############# 56 | 57 | # Ignore the board and schematic backup files 58 | *.b#? 59 | *.s#? 60 | 61 | 62 | ################# 63 | ## Visual Studio 64 | ################# 65 | 66 | ## Ignore Visual Studio temporary files, build results, and 67 | ## files generated by popular Visual Studio add-ons. 68 | 69 | # User-specific files 70 | *.suo 71 | *.user 72 | *.sln.docstates 73 | 74 | # Build results 75 | [Dd]ebug/ 76 | [Rr]elease/ 77 | *_i.c 78 | *_p.c 79 | *.ilk 80 | *.meta 81 | *.obj 82 | *.pch 83 | *.pdb 84 | *.pgc 85 | *.pgd 86 | *.rsp 87 | *.sbr 88 | *.tlb 89 | *.tli 90 | *.tlh 91 | *.tmp 92 | *.vspscc 93 | .builds 94 | *.dotCover 95 | 96 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 97 | #packages/ 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opensdf 104 | *.sdf 105 | 106 | # Visual Studio profiler 107 | *.psess 108 | *.vsp 109 | 110 | # ReSharper is a .NET coding add-in 111 | _ReSharper* 112 | 113 | # Installshield output folder 114 | [Ee]xpress 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish 128 | 129 | # Others 130 | [Bb]in 131 | [Oo]bj 132 | sql 133 | TestResults 134 | *.Cache 135 | ClientBin 136 | stylecop.* 137 | ~$* 138 | *.dbmdl 139 | Generated_Code #added for RIA/Silverlight projects 140 | 141 | # Backup & report files from converting an old project file to a newer 142 | # Visual Studio version. Backup files are not needed, because we have git ;-) 143 | _UpgradeReport_Files/ 144 | Backup*/ 145 | UpgradeLog*.XML 146 | 147 | 148 | ############ 149 | ## Windows 150 | ############ 151 | 152 | # Windows image file caches 153 | Thumbs.db 154 | 155 | # Folder config file 156 | Desktop.ini 157 | 158 | 159 | ############# 160 | ## Python 161 | ############# 162 | 163 | *.py[co] 164 | 165 | # Packages 166 | *.egg 167 | *.egg-info 168 | dist 169 | build 170 | eggs 171 | parts 172 | bin 173 | var 174 | sdist 175 | develop-eggs 176 | .installed.cfg 177 | 178 | # Installer logs 179 | pip-log.txt 180 | 181 | # Unit test / coverage reports 182 | .coverage 183 | .tox 184 | 185 | #Translations 186 | *.mo 187 | 188 | #Mr Developer 189 | .mr.developer.cfg 190 | 191 | # Mac crap 192 | .DS_Store 193 | -------------------------------------------------------------------------------- /Documentation/TSL256x.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/TSL2561_Luminosity_Sensor_BOB/e2fbe173be2ccb2f266d7aa7585b99362578fbc6/Documentation/TSL256x.pdf -------------------------------------------------------------------------------- /Hardware/README.md: -------------------------------------------------------------------------------- 1 | SparkFun Design Files 2 | ===================================== 3 | 4 | The .sch and .brd files hare are Eagle CAD schematic and PCB design files from SparkFun Electronics. 5 | A freeware version of Eagle can be found [here](http://www.cadsoftusa.com/download-eagle/freeware/). 6 | 7 | 8 | License 9 | --------- 10 | This product is open source! 11 | The hardware is released under [Creative Commons ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). 12 | 13 | Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license. 14 | 15 | Distributed as-is; no warranty is given. 16 | 17 | - Your friends at SparkFun. -------------------------------------------------------------------------------- /Hardware/SparkFun_TSL2561_Sensor_Breakout.brd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | PU 159 | 10 160 | ADDR 161 | INT 162 | GND 163 | 3V3 164 | SCL 165 | SDA 166 | INT 167 | GND 168 | 3V3 169 | SCL 170 | SDA 171 | TSL2561 172 | Luminosity 173 | Sensor 174 | V10 175 | M Grusin 176 | 177 | 178 | 179 | 180 | 181 | 0.125 x 2 182 | 183 | 184 | 185 | <h3>SparkFun Electronics' preferred foot prints</h3> 186 | In this library you'll find non-functional items- supply symbols, logos, notations, frame blocks, etc.<br><br> 187 | We've spent an enormous amount of time creating and checking these footprints and parts, but it is the end user's responsibility to ensure correctness and suitablity for a given componet or application. If you enjoy using this library, please buy one of our products at www.sparkfun.com. 188 | <br><br> 189 | <b>Licensing:</b> CC v3.0 Share-Alike You are welcome to use this library for commercial purposes. For attribution, we ask that when you begin to sell your device using our footprint, you email us with a link to the product being sold. We want bragging rights that we helped (in a very small part) to create your 8th world wonder. We would like the opportunity to feature your device on our homepage. 190 | 191 | 192 | Released under the Creative Commons Attribution Share-Alike 3.0 License 193 | http://creativecommons.org/licenses/by-sa/3.0 194 | Designed by: 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | >NAME 705 | >VALUE 706 | >VALUE 707 | 708 | 709 | 710 | 711 | <h3>SparkFun Electronics' preferred foot prints</h3> 712 | In this library you'll find resistors, capacitors, inductors, test points, jumper pads, etc.<br><br> 713 | We've spent an enormous amount of time creating and checking these footprints and parts, but it is the end user's responsibility to ensure correctness and suitablity for a given componet or application. If you enjoy using this library, please buy one of our products at www.sparkfun.com. 714 | <br><br> 715 | <b>Licensing:</b> CC v3.0 Share-Alike You are welcome to use this library for commercial purposes. For attribution, we ask that when you begin to sell your device using our footprint, you email us with a link to the product being sold. We want bragging rights that we helped (in a very small part) to create your 8th world wonder. We would like the opportunity to feature your device on our homepage. 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | >NAME 727 | >VALUE 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | <h3>SparkFun Electronics' preferred foot prints</h3> 737 | In this library you'll find resistors, capacitors, inductors, test points, jumper pads, etc.<br><br> 738 | We've spent an enormous amount of time creating and checking these footprints and parts, but it is the end user's responsibility to ensure correctness and suitablity for a given componet or application. If you enjoy using this library, please buy one of our products at www.sparkfun.com. 739 | <br><br> 740 | <b>Licensing:</b> CC v3.0 Share-Alike You are welcome to use this library for commercial purposes. For attribution, we ask that when you begin to sell your device using our footprint, you email us with a link to the product being sold. We want bragging rights that we helped (in a very small part) to create your 8th world wonder. We would like the opportunity to feature your device on our homepage. 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | >NAME 753 | >VALUE 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | <h3>SparkFun Electronics' preferred foot prints</h3> 762 | In this library you'll find anything that moves- switches, relays, buttons, potentiometers. Also, anything that goes on a board but isn't electrical in nature- screws, standoffs, etc.<br><br> 763 | We've spent an enormous amount of time creating and checking these footprints and parts, but it is the end user's responsibility to ensure correctness and suitablity for a given componet or application. If you enjoy using this library, please buy one of our products at www.sparkfun.com. 764 | <br><br> 765 | <b>Licensing:</b> CC v3.0 Share-Alike You are welcome to use this library for commercial purposes. For attribution, we ask that when you begin to sell your device using our footprint, you email us with a link to the product being sold. We want bragging rights that we helped (in a very small part) to create your 8th world wonder. We would like the opportunity to feature your device on our homepage. 766 | 767 | 768 | <b>Stand Off</b><p> 769 | This is the mechanical footprint for a #4 phillips button head screw. Use the keepout ring to avoid running the screw head into surrounding components. SKU : PRT-00447 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | <h3>SparkFun Electronics' preferred foot prints</h3> 781 | In this library you'll find all manner of digital ICs- microcontrollers, memory chips, logic chips, FPGAs, etc.<br><br> 782 | We've spent an enormous amount of time creating and checking these footprints and parts, but it is the end user's responsibility to ensure correctness and suitablity for a given componet or application. If you enjoy using this library, please buy one of our products at www.sparkfun.com. 783 | <br><br> 784 | <b>Licensing:</b> Creative Commons ShareAlike 4.0 International - https://creativecommons.org/licenses/by-sa/4.0/ 785 | <br><br> 786 | You are welcome to use this library for commercial purposes. For attribution, we ask that when you begin to sell your device using our footprint, you email us with a link to the product being sold. We want bragging rights that we helped (in a very small part) to create your 8th world wonder. We would like the opportunity to feature your device on our homepage. 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | >NAME 804 | >VALUE 805 | 806 | 807 | 808 | 809 | <h3>SparkFun Electronics' preferred foot prints</h3> 810 | In this library you'll find connectors and sockets- basically anything that can be plugged into or onto.<br><br> 811 | We've spent an enormous amount of time creating and checking these footprints and parts, but it is the end user's responsibility to ensure correctness and suitablity for a given componet or application. If you enjoy using this library, please buy one of our products at www.sparkfun.com. 812 | <br><br> 813 | <b>Licensing:</b> Creative Commons ShareAlike 4.0 International - https://creativecommons.org/licenses/by-sa/4.0/ 814 | <br><br> 815 | You are welcome to use this library for commercial purposes. For attribution, we ask that when you begin to sell your device using our footprint, you email us with a link to the product being sold. We want bragging rights that we helped (in a very small part) to create your 8th world wonder. We would like the opportunity to feature your device on our homepage. 816 | 817 | 818 | No outline in silkscreen 819 | 820 | 821 | 822 | 823 | 824 | >NAME 825 | >VALUE 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | <h3>SparkFun Electronics' preferred foot prints</h3> 836 | In this library you'll find resistors, capacitors, inductors, test points, jumper pads, etc.<br><br> 837 | We've spent an enormous amount of time creating and checking these footprints and parts, but it is the end user's responsibility to ensure correctness and suitablity for a given componet or application. If you enjoy using this library, please buy one of our products at www.sparkfun.com. 838 | <br><br> 839 | <b>Licensing:</b> Creative Commons ShareAlike 4.0 International - https://creativecommons.org/licenses/by-sa/4.0/ 840 | <br><br> 841 | You are welcome to use this library for commercial purposes. For attribution, we ask that when you begin to sell your device using our footprint, you email us with a link to the product being sold. We want bragging rights that we helped (in a very small part) to create your 8th world wonder. We would like the opportunity to feature your device on our homepage. 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | >NAME 860 | >VALUE 861 | PASTE 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | <b>EAGLE Design Rules</b> 877 | <p> 878 | The default Design Rules have been set to cover 879 | a wide range of applications. Your particular design 880 | may have different requirements, so please make the 881 | necessary adjustments and save your customized 882 | design rules under a new name. 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 | 954 | 955 | 956 | 957 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 | 985 | 986 | 987 | 988 | 989 | 990 | 991 | 992 | 993 | 994 | 995 | 996 | 997 | 998 | 999 | 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 | 1009 | 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 1016 | 1017 | 1018 | 1019 | 1020 | 1021 | 1022 | 1023 | 1024 | 1025 | 1026 | 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | 1048 | 1049 | 1050 | 1051 | 1052 | 1053 | 1054 | 1055 | 1056 | 1057 | 1058 | 1059 | 1060 | 1061 | 1062 | 1063 | 1064 | 1065 | 1066 | 1067 | 1068 | 1069 | 1070 | 1071 | 1072 | 1073 | 1074 | 1075 | 1076 | 1077 | 1078 | 1079 | 1080 | 1081 | 1082 | 1083 | 1084 | 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1092 | 1093 | 1094 | 1095 | 1096 | 1097 | 1098 | 1099 | 1100 | 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | 1110 | 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | 1117 | 1118 | 1119 | 1120 | 1121 | 1122 | 1123 | 1124 | 1125 | 1126 | 1127 | 1128 | 1129 | 1130 | 1131 | 1132 | 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1155 | 1156 | 1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1164 | 1165 | 1166 | 1167 | 1168 | 1169 | 1170 | 1171 | 1172 | 1173 | 1174 | 1175 | 1176 | 1177 | 1178 | 1179 | 1180 | 1181 | 1182 | 1183 | 1184 | 1185 | 1186 | 1187 | 1188 | 1189 | 1190 | 1191 | 1192 | 1193 | 1194 | 1195 | 1196 | 1197 | 1198 | 1199 | 1200 | 1201 | 1202 | 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | 1221 | 1222 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | License Information 3 | ------------------- 4 | 5 | The hardware is released under [Creative Commons Share-alike 3.0](http://creativecommons.org/licenses/by-sa/3.0/). 6 | 7 | All other code is open source so please feel free to do anything you want with it; you buy me a beer if you use this and we meet someday ([Beerware license](http://en.wikipedia.org/wiki/Beerware)). 8 | 9 | 10 | -------------------------------------------------------------------------------- /Libraries/Arduino/LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | License Information 3 | ------------------- 4 | 5 | The hardware is released under [Creative Commons Share-alike 3.0](http://creativecommons.org/licenses/by-sa/3.0/). 6 | 7 | All other code is open source so please feel free to do anything you want with it; you buy me a beer if you use this and we meet someday ([Beerware license](http://en.wikipedia.org/wiki/Beerware)). 8 | 9 | 10 | -------------------------------------------------------------------------------- /Libraries/Arduino/README.md: -------------------------------------------------------------------------------- 1 | SparkFun TSL2561 Arduino Library 2 | ======================================== 3 | ![TSL2561 Luminosity Sensor Breakout](https://dlnmh9ip6v2uc.cloudfront.net//images/products/1/2/0/5/5/12055-01.jpg)](https://www.sparkfun.com/products/12055) 4 | 5 | [TSL2561 Luminosity Sensor Breakout (SEN-12055)](https://www.sparkfun.com/products/12055) 6 | 7 | This is a Arduino Library for the AMS/TAOS TSL2561 Luminiosity sensor. 8 | This illumination sensor has a flat response across most of the visible spectrum and has an adjustable integration time. 9 | It communicates via I2C and runs at 3.3V. 10 | 11 | Repository Contents 12 | ------------------- 13 | 14 | * **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE. 15 | * **/src** - Source files for the library (.cpp, .h). 16 | * **library.properties** - General library properties for the Arduino package manager. 17 | 18 | Documentation 19 | -------------- 20 | 21 | * **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library. 22 | * **[Product Repository](https://github.com/sparkfun/TSL2561_Luminosity_Sensor_BOB/)** - Main repository (including hardware files) for the TSL2561 Luminosity Sensor. 23 | * **[Hookup Guide](https://learn.sparkfun.com/tutorials/tsl2561-luminosity-sensor-hookup-guide)** - Basic hookup guide for the TSL2561 Luminosity Sensor. 24 | 25 | Products that use this Library 26 | --------------------------------- 27 | 28 | * [SEN-12055](Shttps://www.sparkfun.com/products/12055)- TSL2561 Luminosity Sensor. 29 | 30 | 31 | 32 | License Information 33 | ------------------- 34 | 35 | This product is _**open source**_! 36 | 37 | The **code** is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round! 38 | 39 | Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license. 40 | 41 | Distributed as-is; no warranty is given. 42 | 43 | - Your friends at SparkFun. 44 | -------------------------------------------------------------------------------- /Libraries/Arduino/examples/SparkFunTSL2561Example/SparkFunTSL2561Example.ino: -------------------------------------------------------------------------------- 1 | /* SparkFun TSL2561 library example sketch 2 | 3 | This sketch shows how to use the SparkFunTSL2561 4 | library to read the AMS/TAOS TSL2561 5 | light sensor. 6 | 7 | Product page: https://www.sparkfun.com/products/11824 8 | Hook-up guide: https://learn.sparkfun.com/tutorials/getting-started-with-the-tsl2561-luminosity-sensor 9 | 10 | Hardware connections: 11 | 12 | 3V3 to 3.3V 13 | GND to GND 14 | 15 | (WARNING: do not connect 3V3 to 5V 16 | or the sensor will be damaged!) 17 | 18 | You will also need to connect the I2C pins (SCL and SDA) to your Arduino. 19 | The pins are different on different Arduinos: 20 | 21 | SDA SCL 22 | Any Arduino "SDA" "SCL" 23 | Uno, Redboard, Pro A4 A5 24 | Mega2560, Due 20 21 25 | Leonardo 2 3 26 | 27 | You do not need to connect the INT (interrupt) pin 28 | for basic operation. 29 | 30 | Operation: 31 | 32 | Upload this sketch to your Arduino, and open the 33 | Serial Monitor window to 9600 baud. 34 | 35 | Have fun! -Your friends at SparkFun. 36 | 37 | Our example code uses the "beerware" license. 38 | You can do anything you like with this code. 39 | No really, anything. If you find it useful, 40 | buy me a beer someday. 41 | 42 | V10 Mike Grusin, SparkFun Electronics 12/26/2013 43 | Updated to Arduino 1.6.4 5/2015 44 | */ 45 | 46 | // Your sketch must #include this library, and the Wire library 47 | // (Wire is a standard library included with Arduino): 48 | 49 | #include 50 | #include 51 | 52 | // Create an SFE_TSL2561 object, here called "light": 53 | 54 | SFE_TSL2561 light; 55 | 56 | // Global variables: 57 | 58 | boolean gain; // Gain setting, 0 = X1, 1 = X16; 59 | unsigned int ms; // Integration ("shutter") time in milliseconds 60 | 61 | void setup() 62 | { 63 | // Initialize the Serial port: 64 | 65 | Serial.begin(9600); 66 | Serial.println("TSL2561 example sketch"); 67 | 68 | // Initialize the SFE_TSL2561 library 69 | 70 | // You can pass nothing to light.begin() for the default I2C address (0x39), 71 | // or use one of the following presets if you have changed 72 | // the ADDR jumper on the board: 73 | 74 | // TSL2561_ADDR_0 address with '0' shorted on board (0x29) 75 | // TSL2561_ADDR default address (0x39) 76 | // TSL2561_ADDR_1 address with '1' shorted on board (0x49) 77 | 78 | // For more information see the hookup guide at: https://learn.sparkfun.com/tutorials/getting-started-with-the-tsl2561-luminosity-sensor 79 | 80 | light.begin(); 81 | 82 | // Get factory ID from sensor: 83 | // (Just for fun, you don't need to do this to operate the sensor) 84 | 85 | unsigned char ID; 86 | 87 | if (light.getID(ID)) 88 | { 89 | Serial.print("Got factory ID: 0X"); 90 | Serial.print(ID,HEX); 91 | Serial.println(", should be 0X5X"); 92 | } 93 | // Most library commands will return true if communications was successful, 94 | // and false if there was a problem. You can ignore this returned value, 95 | // or check whether a command worked correctly and retrieve an error code: 96 | else 97 | { 98 | byte error = light.getError(); 99 | printError(error); 100 | } 101 | 102 | // The light sensor has a default integration time of 402ms, 103 | // and a default gain of low (1X). 104 | 105 | // If you would like to change either of these, you can 106 | // do so using the setTiming() command. 107 | 108 | // If gain = false (0), device is set to low gain (1X) 109 | // If gain = high (1), device is set to high gain (16X) 110 | 111 | gain = 0; 112 | 113 | // If time = 0, integration will be 13.7ms 114 | // If time = 1, integration will be 101ms 115 | // If time = 2, integration will be 402ms 116 | // If time = 3, use manual start / stop to perform your own integration 117 | 118 | unsigned char time = 2; 119 | 120 | // setTiming() will set the third parameter (ms) to the 121 | // requested integration time in ms (this will be useful later): 122 | 123 | Serial.println("Set timing..."); 124 | light.setTiming(gain,time,ms); 125 | 126 | // To start taking measurements, power up the sensor: 127 | 128 | Serial.println("Powerup..."); 129 | light.setPowerUp(); 130 | 131 | // The sensor will now gather light during the integration time. 132 | // After the specified time, you can retrieve the result from the sensor. 133 | // Once a measurement occurs, another integration period will start. 134 | } 135 | 136 | void loop() 137 | { 138 | // Wait between measurements before retrieving the result 139 | // (You can also configure the sensor to issue an interrupt 140 | // when measurements are complete) 141 | 142 | // This sketch uses the TSL2561's built-in integration timer. 143 | // You can also perform your own manual integration timing 144 | // by setting "time" to 3 (manual) in setTiming(), 145 | // then performing a manualStart() and a manualStop() as in the below 146 | // commented statements: 147 | 148 | // ms = 1000; 149 | // light.manualStart(); 150 | delay(ms); 151 | // light.manualStop(); 152 | 153 | // Once integration is complete, we'll retrieve the data. 154 | 155 | // There are two light sensors on the device, one for visible light 156 | // and one for infrared. Both sensors are needed for lux calculations. 157 | 158 | // Retrieve the data from the device: 159 | 160 | unsigned int data0, data1; 161 | 162 | if (light.getData(data0,data1)) 163 | { 164 | // getData() returned true, communication was successful 165 | 166 | Serial.print("data0: "); 167 | Serial.print(data0); 168 | Serial.print(" data1: "); 169 | Serial.print(data1); 170 | 171 | // To calculate lux, pass all your settings and readings 172 | // to the getLux() function. 173 | 174 | // The getLux() function will return 1 if the calculation 175 | // was successful, or 0 if one or both of the sensors was 176 | // saturated (too much light). If this happens, you can 177 | // reduce the integration time and/or gain. 178 | // For more information see the hookup guide at: https://learn.sparkfun.com/tutorials/getting-started-with-the-tsl2561-luminosity-sensor 179 | 180 | double lux; // Resulting lux value 181 | boolean good; // True if neither sensor is saturated 182 | 183 | // Perform lux calculation: 184 | 185 | good = light.getLux(gain,ms,data0,data1,lux); 186 | 187 | // Print out the results: 188 | 189 | Serial.print(" lux: "); 190 | Serial.print(lux); 191 | if (good) Serial.println(" (good)"); else Serial.println(" (BAD)"); 192 | } 193 | else 194 | { 195 | // getData() returned false because of an I2C error, inform the user. 196 | 197 | byte error = light.getError(); 198 | printError(error); 199 | } 200 | } 201 | 202 | void printError(byte error) 203 | // If there's an I2C error, this function will 204 | // print out an explanation. 205 | { 206 | Serial.print("I2C error: "); 207 | Serial.print(error,DEC); 208 | Serial.print(", "); 209 | 210 | switch(error) 211 | { 212 | case 0: 213 | Serial.println("success"); 214 | break; 215 | case 1: 216 | Serial.println("data too long for transmit buffer"); 217 | break; 218 | case 2: 219 | Serial.println("received NACK on address (disconnected?)"); 220 | break; 221 | case 3: 222 | Serial.println("received NACK on data"); 223 | break; 224 | case 4: 225 | Serial.println("other error"); 226 | break; 227 | default: 228 | Serial.println("unknown error"); 229 | } 230 | } 231 | 232 | -------------------------------------------------------------------------------- /Libraries/Arduino/library.properties: -------------------------------------------------------------------------------- 1 | name=SparkFun TSL2561 2 | version=1.1.0 3 | author=Mike Grusin@SparkFun Electronics 4 | maintainer=SparkFun Electronics 5 | sentence=An Arduino Library for the TSL2561 Luminosity Sensor Breakout from SparkFun Electronics. 6 | paragraph=Via I2C communication, the sensor conducts specific light ranges from 0.1-40k+ Lux. 7 | category=Sensors 8 | url=https://github.com/sparkfun/SparkFun_TSL2561_Arduino_Library 9 | architectures=* -------------------------------------------------------------------------------- /Libraries/Arduino/src/SparkFunTSL2561.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | SFE_TSL2561 illumination sensor library for Arduino 3 | Mike Grusin, SparkFun Electronics 4 | 5 | This library provides functions to access the TAOS TSL2561 6 | Illumination Sensor. 7 | 8 | Our example code uses the "beerware" license. You can do anything 9 | you like with this code. No really, anything. If you find it useful, 10 | buy me a beer someday. 11 | 12 | version 1.0 2013/09/20 MDG initial version 13 | Updated to Arduino 1.6.4 5/2015 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | 20 | SFE_TSL2561::SFE_TSL2561(void) 21 | // SFE_TSL2561 object 22 | {} 23 | 24 | 25 | boolean SFE_TSL2561::begin(void) 26 | // Initialize TSL2561 library with default address (0x39) 27 | // Always returns true 28 | { 29 | return(begin(TSL2561_ADDR)); 30 | } 31 | 32 | 33 | boolean SFE_TSL2561::begin(char i2c_address) 34 | // Initialize TSL2561 library to arbitrary address or: 35 | // TSL2561_ADDR_0 (0x29 address with '0' shorted on board) 36 | // TSL2561_ADDR (0x39 default address) 37 | // TSL2561_ADDR_1 (0x49 address with '1' shorted on board) 38 | // Always returns true 39 | { 40 | _i2c_address = i2c_address; 41 | Wire.begin(); 42 | return(true); 43 | } 44 | 45 | 46 | boolean SFE_TSL2561::setPowerUp(void) 47 | // Turn on TSL2561, begin integrations 48 | // Returns true (1) if successful, false (0) if there was an I2C error 49 | // (Also see getError() below) 50 | { 51 | // Write 0x03 to command byte (power on) 52 | return(writeByte(TSL2561_REG_CONTROL,0x03)); 53 | } 54 | 55 | 56 | boolean SFE_TSL2561::setPowerDown(void) 57 | // Turn off TSL2561 58 | // Returns true (1) if successful, false (0) if there was an I2C error 59 | // (Also see getError() below) 60 | { 61 | // Clear command byte (power off) 62 | return(writeByte(TSL2561_REG_CONTROL,0x00)); 63 | } 64 | 65 | 66 | boolean SFE_TSL2561::setTiming(boolean gain, unsigned char time) 67 | // If gain = false (0), device is set to low gain (1X) 68 | // If gain = high (1), device is set to high gain (16X) 69 | // If time = 0, integration will be 13.7ms 70 | // If time = 1, integration will be 101ms 71 | // If time = 2, integration will be 402ms 72 | // If time = 3, use manual start / stop 73 | // Returns true (1) if successful, false (0) if there was an I2C error 74 | // (Also see getError() below) 75 | { 76 | unsigned char timing; 77 | 78 | // Get timing byte 79 | if (readByte(TSL2561_REG_TIMING,timing)) 80 | { 81 | // Set gain (0 or 1) 82 | if (gain) 83 | timing |= 0x10; 84 | else 85 | timing &= ~0x10; 86 | 87 | // Set integration time (0 to 3) 88 | timing &= ~0x03; 89 | timing |= (time & 0x03); 90 | 91 | // Write modified timing byte back to device 92 | if (writeByte(TSL2561_REG_TIMING,timing)) 93 | return(true); 94 | } 95 | return(false); 96 | } 97 | 98 | 99 | boolean SFE_TSL2561::setTiming(boolean gain, unsigned char time, unsigned int &ms) 100 | // If gain = false (0), device is set to low gain (1X) 101 | // If gain = high (1), device is set to high gain (16X) 102 | // If time = 0, integration will be 13.7ms 103 | // If time = 1, integration will be 101ms 104 | // If time = 2, integration will be 402ms 105 | // If time = 3, use manual start / stop (ms = 0) 106 | // ms will be set to integration time 107 | // Returns true (1) if successful, false (0) if there was an I2C error 108 | // (Also see getError() below) 109 | { 110 | // Calculate ms for user 111 | switch (time) 112 | { 113 | case 0: ms = 14; break; 114 | case 1: ms = 101; break; 115 | case 2: ms = 402; break; 116 | default: ms = 0; 117 | } 118 | // Set integration using base function 119 | return(setTiming(gain,time)); 120 | } 121 | 122 | 123 | boolean SFE_TSL2561::manualStart(void) 124 | // Starts a manual integration period 125 | // After running this command, you must manually stop integration with manualStop() 126 | // Internally sets integration time to 3 for manual integration (gain is unchanged) 127 | // Returns true (1) if successful, false (0) if there was an I2C error 128 | // (Also see getError() below) 129 | { 130 | unsigned char timing; 131 | 132 | // Get timing byte 133 | if (readByte(TSL2561_REG_TIMING,timing)) 134 | { 135 | // Set integration time to 3 (manual integration) 136 | timing |= 0x03; 137 | 138 | if (writeByte(TSL2561_REG_TIMING,timing)) 139 | { 140 | // Begin manual integration 141 | timing |= 0x08; 142 | 143 | // Write modified timing byte back to device 144 | if (writeByte(TSL2561_REG_TIMING,timing)) 145 | return(true); 146 | } 147 | } 148 | return(false); 149 | } 150 | 151 | 152 | boolean SFE_TSL2561::manualStop(void) 153 | // Stops a manual integration period 154 | // Returns true (1) if successful, false (0) if there was an I2C error 155 | // (Also see getError() below) 156 | { 157 | unsigned char timing; 158 | 159 | // Get timing byte 160 | if (readByte(TSL2561_REG_TIMING,timing)) 161 | { 162 | // Stop manual integration 163 | timing &= ~0x08; 164 | 165 | // Write modified timing byte back to device 166 | if (writeByte(TSL2561_REG_TIMING,timing)) 167 | return(true); 168 | } 169 | return(false); 170 | } 171 | 172 | 173 | boolean SFE_TSL2561::getData(unsigned int &data0, unsigned int &data1) 174 | // Retrieve raw integration results 175 | // data0 and data1 will be set to integration results 176 | // Returns true (1) if successful, false (0) if there was an I2C error 177 | // (Also see getError() below) 178 | { 179 | // Get data0 and data1 out of result registers 180 | if (readUInt(TSL2561_REG_DATA_0,data0) && readUInt(TSL2561_REG_DATA_1,data1)) 181 | return(true); 182 | 183 | return(false); 184 | } 185 | 186 | 187 | boolean SFE_TSL2561::getLux(unsigned char gain, unsigned int ms, unsigned int CH0, unsigned int CH1, double &lux) 188 | // Convert raw data to lux 189 | // gain: 0 (1X) or 1 (16X), see setTiming() 190 | // ms: integration time in ms, from setTiming() or from manual integration 191 | // CH0, CH1: results from getData() 192 | // lux will be set to resulting lux calculation 193 | // returns true (1) if calculation was successful 194 | // RETURNS false (0) AND lux = 0.0 IF EITHER SENSOR WAS SATURATED (0XFFFF) 195 | { 196 | double ratio, d0, d1; 197 | 198 | // Determine if either sensor saturated (0xFFFF) 199 | // If so, abandon ship (calculation will not be accurate) 200 | if ((CH0 == 0xFFFF) || (CH1 == 0xFFFF)) 201 | { 202 | lux = 0.0; 203 | return(false); 204 | } 205 | 206 | // Convert from unsigned integer to floating point 207 | d0 = CH0; d1 = CH1; 208 | 209 | // We will need the ratio for subsequent calculations 210 | ratio = d1 / d0; 211 | 212 | // Normalize for integration time 213 | d0 *= (402.0/ms); 214 | d1 *= (402.0/ms); 215 | 216 | // Normalize for gain 217 | if (!gain) 218 | { 219 | d0 *= 16; 220 | d1 *= 16; 221 | } 222 | 223 | // Determine lux per datasheet equations: 224 | 225 | if (ratio < 0.5) 226 | { 227 | lux = 0.0304 * d0 - 0.062 * d0 * pow(ratio,1.4); 228 | return(true); 229 | } 230 | 231 | if (ratio < 0.61) 232 | { 233 | lux = 0.0224 * d0 - 0.031 * d1; 234 | return(true); 235 | } 236 | 237 | if (ratio < 0.80) 238 | { 239 | lux = 0.0128 * d0 - 0.0153 * d1; 240 | return(true); 241 | } 242 | 243 | if (ratio < 1.30) 244 | { 245 | lux = 0.00146 * d0 - 0.00112 * d1; 246 | return(true); 247 | } 248 | 249 | // if (ratio > 1.30) 250 | lux = 0.0; 251 | return(true); 252 | } 253 | 254 | 255 | boolean SFE_TSL2561::setInterruptControl(unsigned char control, unsigned char persist) 256 | // Sets up interrupt operations 257 | // If control = 0, interrupt output disabled 258 | // If control = 1, use level interrupt, see setInterruptThreshold() 259 | // If persist = 0, every integration cycle generates an interrupt 260 | // If persist = 1, any value outside of threshold generates an interrupt 261 | // If persist = 2 to 15, value must be outside of threshold for 2 to 15 integration cycles 262 | // Returns true (1) if successful, false (0) if there was an I2C error 263 | // (Also see getError() below) 264 | { 265 | // Place control and persist bits into proper location in interrupt control register 266 | if (writeByte(TSL2561_REG_INTCTL,((control & 0B00000011) << 4) | (persist & 0B00001111))) 267 | return(true); 268 | 269 | return(false); 270 | } 271 | 272 | 273 | boolean SFE_TSL2561::setInterruptThreshold(unsigned int low, unsigned int high) 274 | // Set interrupt thresholds (channel 0 only) 275 | // low, high: 16-bit threshold values 276 | // Returns true (1) if successful, false (0) if there was an I2C error 277 | // (Also see getError() below) 278 | { 279 | // Write low and high threshold values 280 | if (writeUInt(TSL2561_REG_THRESH_L,low) && writeUInt(TSL2561_REG_THRESH_H,high)) 281 | return(true); 282 | 283 | return(false); 284 | } 285 | 286 | 287 | boolean SFE_TSL2561::clearInterrupt(void) 288 | // Clears an active interrupt 289 | // Returns true (1) if successful, false (0) if there was an I2C error 290 | // (Also see getError() below) 291 | { 292 | // Set up command byte for interrupt clear 293 | Wire.beginTransmission(_i2c_address); 294 | Wire.write(TSL2561_CMD_CLEAR); 295 | _error = Wire.endTransmission(); 296 | if (_error == 0) 297 | return(true); 298 | 299 | return(false); 300 | } 301 | 302 | 303 | boolean SFE_TSL2561::getID(unsigned char &ID) 304 | // Retrieves part and revision code from TSL2561 305 | // Sets ID to part ID (see datasheet) 306 | // Returns true (1) if successful, false (0) if there was an I2C error 307 | // (Also see getError() below) 308 | { 309 | // Get ID byte from ID register 310 | if (readByte(TSL2561_REG_ID,ID)) 311 | return(true); 312 | 313 | return(false); 314 | } 315 | 316 | 317 | byte SFE_TSL2561::getError(void) 318 | // If any library command fails, you can retrieve an extended 319 | // error code using this command. Errors are from the wire library: 320 | // 0 = Success 321 | // 1 = Data too long to fit in transmit buffer 322 | // 2 = Received NACK on transmit of address 323 | // 3 = Received NACK on transmit of data 324 | // 4 = Other error 325 | { 326 | return(_error); 327 | } 328 | 329 | // Private functions: 330 | 331 | boolean SFE_TSL2561::readByte(unsigned char address, unsigned char &value) 332 | // Reads a byte from a TSL2561 address 333 | // Address: TSL2561 address (0 to 15) 334 | // Value will be set to stored byte 335 | // Returns true (1) if successful, false (0) if there was an I2C error 336 | // (Also see getError() above) 337 | { 338 | // Set up command byte for read 339 | Wire.beginTransmission(_i2c_address); 340 | Wire.write((address & 0x0F) | TSL2561_CMD); 341 | _error = Wire.endTransmission(); 342 | 343 | // Read requested byte 344 | if (_error == 0) 345 | { 346 | Wire.requestFrom(_i2c_address,1); 347 | if (Wire.available() == 1) 348 | { 349 | value = Wire.read(); 350 | return(true); 351 | } 352 | } 353 | return(false); 354 | } 355 | 356 | 357 | boolean SFE_TSL2561::writeByte(unsigned char address, unsigned char value) 358 | // Write a byte to a TSL2561 address 359 | // Address: TSL2561 address (0 to 15) 360 | // Value: byte to write to address 361 | // Returns true (1) if successful, false (0) if there was an I2C error 362 | // (Also see getError() above) 363 | { 364 | // Set up command byte for write 365 | Wire.beginTransmission(_i2c_address); 366 | Wire.write((address & 0x0F) | TSL2561_CMD); 367 | // Write byte 368 | Wire.write(value); 369 | _error = Wire.endTransmission(); 370 | if (_error == 0) 371 | return(true); 372 | 373 | return(false); 374 | } 375 | 376 | 377 | boolean SFE_TSL2561::readUInt(unsigned char address, unsigned int &value) 378 | // Reads an unsigned integer (16 bits) from a TSL2561 address (low byte first) 379 | // Address: TSL2561 address (0 to 15), low byte first 380 | // Value will be set to stored unsigned integer 381 | // Returns true (1) if successful, false (0) if there was an I2C error 382 | // (Also see getError() above) 383 | { 384 | char high, low; 385 | 386 | // Set up command byte for read 387 | Wire.beginTransmission(_i2c_address); 388 | Wire.write((address & 0x0F) | TSL2561_CMD); 389 | _error = Wire.endTransmission(); 390 | 391 | // Read two bytes (low and high) 392 | if (_error == 0) 393 | { 394 | Wire.requestFrom(_i2c_address,2); 395 | if (Wire.available() == 2) 396 | { 397 | low = Wire.read(); 398 | high = Wire.read(); 399 | // Combine bytes into unsigned int 400 | value = word(high,low); 401 | return(true); 402 | } 403 | } 404 | return(false); 405 | } 406 | 407 | 408 | boolean SFE_TSL2561::writeUInt(unsigned char address, unsigned int value) 409 | // Write an unsigned integer (16 bits) to a TSL2561 address (low byte first) 410 | // Address: TSL2561 address (0 to 15), low byte first 411 | // Value: unsigned int to write to address 412 | // Returns true (1) if successful, false (0) if there was an I2C error 413 | // (Also see getError() above) 414 | { 415 | // Split int into lower and upper bytes, write each byte 416 | if (writeByte(address,lowByte(value)) 417 | && writeByte(address + 1,highByte(value))) 418 | return(true); 419 | 420 | return(false); 421 | } 422 | -------------------------------------------------------------------------------- /Libraries/Arduino/src/SparkFunTSL2561.h: -------------------------------------------------------------------------------- 1 | /* 2 | SFE_TSL2561 illumination sensor library for Arduino 3 | Mike Grusin, SparkFun Electronics 4 | 5 | This library provides functions to access the TAOS TSL2561 6 | Illumination Sensor. 7 | 8 | Our example code uses the "beerware" license. You can do anything 9 | you like with this code. No really, anything. If you find it useful, 10 | buy me a beer someday. 11 | 12 | version 1.0 2013/09/20 MDG initial version 13 | Updated to Arduino 1.6.4 5/2015 14 | */ 15 | 16 | #ifndef SparkFunTSL2561_h 17 | #define SparkFunTSL2561_h 18 | 19 | #include "Arduino.h" 20 | 21 | class SFE_TSL2561 22 | { 23 | public: 24 | SFE_TSL2561(void); 25 | // SFE_TSL2561 object 26 | 27 | boolean begin(void); 28 | // Initialize TSL2561 library with default address (0x39) 29 | // Always returns true 30 | 31 | boolean begin(char i2c_address); 32 | // Initialize TSL2561 library to arbitrary address or: 33 | // TSL2561_ADDR_0 (0x29 address with '0' shorted on board) 34 | // TSL2561_ADDR (0x39 default address) 35 | // TSL2561_ADDR_1 (0x49 address with '1' shorted on board) 36 | // Always returns true 37 | 38 | boolean setPowerUp(void); 39 | // Turn on TSL2561, begin integration 40 | // Returns true (1) if successful, false (0) if there was an I2C error 41 | // (Also see getError() below) 42 | 43 | boolean setPowerDown(void); 44 | // Turn off TSL2561 45 | // Returns true (1) if successful, false (0) if there was an I2C error 46 | // (Also see getError() below) 47 | 48 | boolean setTiming(boolean gain, unsigned char time); 49 | // If gain = false (0), device is set to low gain (1X) 50 | // If gain = high (1), device is set to high gain (16X) 51 | // If time = 0, integration will be 13.7ms 52 | // If time = 1, integration will be 101ms 53 | // If time = 2, integration will be 402ms 54 | // If time = 3, use manual start / stop 55 | // Returns true (1) if successful, false (0) if there was an I2C error 56 | // (Also see getError() below) 57 | 58 | boolean setTiming(boolean gain, unsigned char time, unsigned int &ms); 59 | // Identical to above command, except ms is set to selected integration time 60 | // If gain = false (0), device is set to low gain (1X) 61 | // If gain = high (1), device is set to high gain (16X) 62 | // If time = 0, integration will be 13.7ms 63 | // If time = 1, integration will be 101ms 64 | // If time = 2, integration will be 402ms 65 | // If time = 3, use manual start / stop (ms = 0) 66 | // ms will be set to requested integration time 67 | // Returns true (1) if successful, false (0) if there was an I2C error 68 | // (Also see getError() below) 69 | 70 | boolean manualStart(void); 71 | // Starts a manual integration period 72 | // After running this command, you must manually stop integration with manualStop() 73 | // Internally sets integration time to 3 for manual integration (gain is unchanged) 74 | // Returns true (1) if successful, false (0) if there was an I2C error 75 | // (Also see getError() below) 76 | 77 | boolean manualStop(void); 78 | // Stops a manual integration period 79 | // Returns true (1) if successful, false (0) if there was an I2C error 80 | // (Also see getError() below) 81 | 82 | boolean getData(unsigned int &CH0, unsigned int &CH1); 83 | // Retrieve raw integration results 84 | // data0 and data1 will be set to integration results 85 | // Returns true (1) if successful, false (0) if there was an I2C error 86 | // (Also see getError() below) 87 | 88 | boolean getLux(unsigned char gain, unsigned int ms, unsigned int CH0, unsigned int CH1, double &lux); 89 | // Convert raw data to lux 90 | // gain: 0 (1X) or 1 (16X), see setTiming() 91 | // ms: integration time in ms, from setTiming() or from manual integration 92 | // CH0, CH1: results from getData() 93 | // lux will be set to resulting lux calculation 94 | // returns true (1) if calculation was successful 95 | // RETURNS false (0) AND lux = 0.0 IF EITHER SENSOR WAS SATURATED (0XFFFF) 96 | 97 | boolean setInterruptControl(unsigned char control, unsigned char persist); 98 | // Sets up interrupt operations 99 | // If control = 0, interrupt output disabled 100 | // If control = 1, use level interrupt, see setInterruptThreshold() 101 | // If persist = 0, every integration cycle generates an interrupt 102 | // If persist = 1, any value outside of threshold generates an interrupt 103 | // If persist = 2 to 15, value must be outside of threshold for 2 to 15 integration cycles 104 | // Returns true (1) if successful, false (0) if there was an I2C error 105 | // (Also see getError() below) 106 | 107 | boolean setInterruptThreshold(unsigned int low, unsigned int high); 108 | // Set interrupt thresholds (channel 0 only) 109 | // low, high: 16-bit threshold values 110 | // Returns true (1) if successful, false (0) if there was an I2C error 111 | // (Also see getError() below) 112 | 113 | boolean clearInterrupt(void); 114 | // Clears an active interrupt 115 | // Returns true (1) if successful, false (0) if there was an I2C error 116 | // (Also see getError() below) 117 | 118 | boolean getID(unsigned char &ID); 119 | // Retrieves part and revision code from TSL2561 120 | // Sets ID to part ID (see datasheet) 121 | // Returns true (1) if successful, false (0) if there was an I2C error 122 | // (Also see getError() below) 123 | 124 | byte getError(void); 125 | // If any library command fails, you can retrieve an extended 126 | // error code using this command. Errors are from the wire library: 127 | // 0 = Success 128 | // 1 = Data too long to fit in transmit buffer 129 | // 2 = Received NACK on transmit of address 130 | // 3 = Received NACK on transmit of data 131 | // 4 = Other error 132 | 133 | // private: 134 | 135 | boolean readByte(unsigned char address, unsigned char &value); 136 | // Reads a byte from a TSL2561 address 137 | // Address: TSL2561 address (0 to 15) 138 | // Value will be set to stored byte 139 | // Returns true (1) if successful, false (0) if there was an I2C error 140 | // (Also see getError() above) 141 | 142 | boolean writeByte(unsigned char address, unsigned char value); 143 | // Write a byte to a TSL2561 address 144 | // Address: TSL2561 address (0 to 15) 145 | // Value: byte to write to address 146 | // Returns true (1) if successful, false (0) if there was an I2C error 147 | // (Also see getError() above) 148 | 149 | boolean readUInt(unsigned char address, unsigned int &value); 150 | // Reads an unsigned integer (16 bits) from a TSL2561 address (low byte first) 151 | // Address: TSL2561 address (0 to 15), low byte first 152 | // Value will be set to stored unsigned integer 153 | // Returns true (1) if successful, false (0) if there was an I2C error 154 | // (Also see getError() above) 155 | 156 | boolean writeUInt(unsigned char address, unsigned int value); 157 | // Write an unsigned integer (16 bits) to a TSL2561 address (low byte first) 158 | // Address: TSL2561 address (0 to 15), low byte first 159 | // Value: unsigned int to write to address 160 | // Returns true (1) if successful, false (0) if there was an I2C error 161 | // (Also see getError() above) 162 | 163 | char _i2c_address; 164 | byte _error; 165 | }; 166 | 167 | #define TSL2561_ADDR_0 0x29 // address with '0' shorted on board 168 | #define TSL2561_ADDR 0x39 // default address 169 | #define TSL2561_ADDR_1 0x49 // address with '1' shorted on board 170 | 171 | // TSL2561 registers 172 | 173 | #define TSL2561_CMD 0x80 174 | #define TSL2561_CMD_CLEAR 0xC0 175 | #define TSL2561_REG_CONTROL 0x00 176 | #define TSL2561_REG_TIMING 0x01 177 | #define TSL2561_REG_THRESH_L 0x02 178 | #define TSL2561_REG_THRESH_H 0x04 179 | #define TSL2561_REG_INTCTL 0x06 180 | #define TSL2561_REG_ID 0x0A 181 | #define TSL2561_REG_DATA_0 0x0C 182 | #define TSL2561_REG_DATA_1 0x0E 183 | 184 | #endif 185 | -------------------------------------------------------------------------------- /Libraries/README.md: -------------------------------------------------------------------------------- 1 | SparkFun TSL2561 Libraries 2 | ================================= 3 | 4 | Libraries for use in different environments. 5 | 6 | 7 | Directory Contents 8 | ------------------- 9 | * **/Arduino** - [Arduino IDE](http://www.arduino.cc/en/Main/Software) libraries 10 | 11 | 12 | License Information 13 | ------------------- 14 | This product is open source! 15 | The code is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round! 16 | Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license. 17 | 18 | Distributed as-is; no warranty is given. 19 | 20 | - Your friends at SparkFun. 21 | 22 | 23 | Update Library Instructions: 24 | ---------------------------- 25 | To get the most up-to-date version of the library, you must run the following git subtree commands. 26 | 27 | $git subtree pull -P Libraries/Arduino --squash https://github.com/sparkfun/SparkFun_TSL2561_Arduino_Library.git master -------------------------------------------------------------------------------- /Production/README.md: -------------------------------------------------------------------------------- 1 | SparkFun Production Files 2 | ========================================= 3 | 4 | 5 | These are the production files SparkFun uses for printing PCBs. 6 | 7 | 8 | License Information 9 | ------------------- 10 | This product is open source! 11 | 12 | The hardware is released under [Creative Commons ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). 13 | 14 | Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license. 15 | 16 | Distributed as-is; no warranty is given. 17 | 18 | - Your friends at SparkFun. 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **NOTE:** *This product has been retired from our catalog. If you are looking for more up-to-date info, please check out some of these resources to see how other users are still hacking and improving on this product.* 2 | * *[SparkFun Forum](https://forum.sparkfun.com/)* 3 | * *[Comments Here on GitHub](https://github.com/sparkfun/SparkFun_TSL2561_Arduino_Library/issues)* 4 | * *[IRC Channel](https://www.sparkfun.com/news/263)* 5 | 6 | SparkFun TSL2561 Luminosity Sensor Breakout Board 7 | ============================================ 8 | 9 | ![TSL2561 Luminosity Sensor Breakout](https://dlnmh9ip6v2uc.cloudfront.net//images/products/1/2/0/5/5/12055-01.jpg) 10 | 11 | [*TSL2561 Luminosity Sensor Breakout (SEN-12055)*](https://www.sparkfun.com/products/12055) 12 | 13 | This is a breakout board for the AMS/TAOS TSL2561 Luminosity sensor. 14 | This illumination sensor has a flat response across most of the visible spectrum and has an adjustable integration time. 15 | It communicates via I2C and runs at 3.3V. 16 | 17 | Repository Contents 18 | ------------------- 19 | * **/Documentation** - Datasheets and additional information 20 | * **/Hardware** - Eagle design files (.brd, .sch) 21 | * **/Libraries** - Libraries for use with the TSL2561 22 | * **/Production** - Production panel files (.brd) 23 | 24 | Documentation 25 | -------------- 26 | * **[Library](https://github.com/sparkfun/SparkFun_TSL2561_Arduino_Library)** - Arduino library for the TSL2561. 27 | * **[Hookup Guide](https://learn.sparkfun.com/tutorials/tsl2561-luminosity-sensor-hookup-guide)** - Basic hookup guide for the TSL2561 Breakout. 28 | * **[SparkFun Fritzing repo](https://github.com/sparkfun/Fritzing_Parts)** - Fritzing diagrams for SparkFun products. 29 | * **[SparkFun 3D Model repo](https://github.com/sparkfun/3D_Models)** - 3D models of SparkFun products. 30 | 31 | License Information 32 | ------------------- 33 | This product is _**open source**_! 34 | 35 | The **hardware** is released under [Creative Commons ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). 36 | 37 | The **code** is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round! 38 | 39 | Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license. 40 | 41 | Distributed as-is; no warranty is given. 42 | 43 | - Your friends at SparkFun. 44 | --------------------------------------------------------------------------------