├── .gitattributes
├── .gitignore
├── Hardware
├── SparkFun_ACS712LowCurrentSensorBoard.brd
└── SparkFun_ACS712LowCurrentSensorBoard.sch
├── LICENSE.md
├── Production
└── SparkFun_ACS712_Low_Current_Sensor_Panel_v14.brd
├── README.md
└── Software
└── SparkFun_ACS712_Demo
└── SparkFun_ACS712_Demo.ino
/.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 |
--------------------------------------------------------------------------------
/Hardware/SparkFun_ACS712LowCurrentSensorBoard.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 | GND
124 | Vo
125 | 5V
126 | GAIN
127 | Vref
128 | IP+
129 | IP-
130 | ACS712 Low Current
131 | Sensor Board v1
132 | v14
133 | IP-
134 | IP+
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 | >NAME
148 | >VALUE
149 |
150 |
151 | <b>CAPACITOR</b><p>
152 | chip
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 | >NAME
162 | >VALUE
163 |
164 |
165 |
166 |
167 |
168 |
169 | <b>CAPACITOR</b><p>
170 | chip
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 | >NAME
181 | >VALUE
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 | >NAME
211 | >VALUE
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 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 | <b>Small Outline Package</b> Fits JEDEC packages (narrow SOIC-8)
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 | >VALUE
751 | >NAME
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 | <b>Small Outline Transistor</b>
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 | >NAME
776 | >VALUE
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 | >NAME
786 | >VALUE
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 | >NAME
799 | >VALUE
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 | <b>EAGLE Design Rules</b>
815 | <p>
816 | The default Design Rules have been set to cover
817 | a wide range of applications. Your particular design
818 | may have different requirements, so please make the
819 | necessary adjustments and save your customized
820 | design rules under a new name.
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 |
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
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 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | SparkFun License Information
2 | ============================
3 |
4 | SparkFun uses two different licenses for our files — one for hardware and one for code.
5 |
6 | Hardware
7 | ---------
8 |
9 | **SparkFun hardware is released under [Creative Commons Share-alike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/).**
10 |
11 | Note: This is a human-readable summary of (and not a substitute for) the [license](http://creativecommons.org/licenses/by-sa/4.0/legalcode).
12 |
13 | You are free to:
14 |
15 | Share — copy and redistribute the material in any medium or format
16 | Adapt — remix, transform, and build upon the material
17 | for any purpose, even commercially.
18 | The licensor cannot revoke these freedoms as long as you follow the license terms.
19 | Under the following terms:
20 |
21 | Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
22 | ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
23 | No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
24 | Notices:
25 |
26 | You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
27 | No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.
28 |
29 |
30 | Code
31 | --------
32 |
33 | **SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).**
34 |
35 | The MIT License (MIT)
36 |
37 | Copyright (c) 2016 SparkFun Electronics
38 |
39 | Permission is hereby granted, free of charge, to any person obtaining a copy
40 | of this software and associated documentation files (the "Software"), to deal
41 | in the Software without restriction, including without limitation the rights
42 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
43 | copies of the Software, and to permit persons to whom the Software is
44 | furnished to do so, subject to the following conditions:
45 |
46 | The above copyright notice and this permission notice shall be included in all
47 | copies or substantial portions of the Software.
48 |
49 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
50 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
51 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
52 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
53 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
54 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
55 | SOFTWARE.
56 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **NOTE:** *This product has been retired from our catalog. There is an updated drop-in replacement with the ACS723 available: [SEN-14544](https://github.com/sparkfun/Current_Sensor_Breakout-ACS723-Low_Current). 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 version.*
2 |
3 | * *[SparkFun Forum](https://forum.sparkfun.com/)*
4 | * *[Comments Here on GitHub](https://github.com/sparkfun/Low_Current_Sensor_Breakout-ACS712/issues)*
5 | * *[IRC Channel](https://www.sparkfun.com/news/263)*
6 |
7 | SparkFun Low Current Sensor Breakout Board - ACS712
8 | ======================================================
9 |
10 | 
11 |
12 | [*SparkFun Low Current Sensor Breakout Board - ACS712 (SEN-08883)*](https://www.sparkfun.com/products/8883)
13 |
14 | This current sensor gives precise current measurement for both AC and DC signals.
15 | These are good sensors for metering and measuring overall power consumption of systems.
16 | The ACS712 Low Current Sensor Breakout outputs an analog voltage that varies linearly with sensed current.
17 |
18 | Repository Contents
19 | -------------------
20 | * **/Hardware** - All Eagle design files (.brd, .sch)
21 |
22 | Documentation
23 | --------------
24 | * **[Hookup Guide](https://learn.sparkfun.com/tutorials/acs712-low-current-sensor-hookup-guide)** - Basic hookup guide for the ACS712.
25 |
26 | Product Versions
27 | ----------------
28 |
29 | * [SEN-08883 (RETIRED)](https://www.sparkfun.com/products/8883)- Initial release; ACS712 Version of this Board
30 |
31 | License Information
32 | -------------------
33 |
34 | This product is _**open source**_!
35 |
36 | Please review the LICENSE.md file for license information.
37 |
38 | If you have any questions or concerns on licensing, please contact techsupport@sparkfun.com.
39 |
40 | Distributed as-is; no warranty is given.
41 |
42 | - Your friends at SparkFun.
43 |
44 | __
45 |
--------------------------------------------------------------------------------
/Software/SparkFun_ACS712_Demo/SparkFun_ACS712_Demo.ino:
--------------------------------------------------------------------------------
1 | /* SparkFun ACS712 Demo
2 | Created by George Beckstein for SparkFun
3 | 4/30/2017
4 |
5 | Uses an Arduino to set up the ACS712 Current Sensor
6 | See the product page at: https://www.sparkfun.com/products/8883
7 |
8 | Parts you may need:
9 | - 100 Ohm, 1/2W or greater resistor OR two 220 Ohm 1/4 resistors in parallel
10 | - ACS712 Breakout with on-board amplifier
11 |
12 | Optional equipment:
13 | - Oscilloscope
14 | - Multimeter (or two)
15 | - A power supply with current limiting/constant current would be handy to calibrate the device without using resistors
16 | */
17 |
18 | const int analogInPin = A0;
19 |
20 | // Number of samples to average the reading over
21 | // Change this to make the reading smoother... but beware of buffer overflows!
22 | const int avgSamples = 10;
23 |
24 | int sensorValue = 0;
25 |
26 | float sensitivity = 100.0 / 500.0; //100mA per 500mV = 0.2
27 | float Vref = 2500; // Output voltage with no current: ~ 2500mV or 2.5V
28 |
29 | void setup() {
30 | // initialize serial communications at 9600 bps:
31 | Serial.begin(9600);
32 | }
33 |
34 | void loop() {
35 | // read the analog in value:
36 | for (int i = 0; i < avgSamples; i++)
37 | {
38 | sensorValue += analogRead(analogInPin);
39 |
40 | // wait 2 milliseconds before the next loop
41 | // for the analog-to-digital converter to settle
42 | // after the last reading:
43 | delay(2);
44 |
45 | }
46 |
47 | sensorValue = sensorValue / avgSamples;
48 |
49 | // The on-board ADC is 10-bits -> 2^10 = 1024 -> 5V / 1024 ~= 4.88mV
50 | // The voltage is in millivolts
51 | float voltage = 4.88 * sensorValue;
52 |
53 | // This will calculate the actual current (in mA)
54 | // Using the Vref and sensitivity settings you configure
55 | float current = (voltage - Vref) * sensitivity;
56 |
57 | // This is the raw sensor value, not very useful without some calculations
58 | //Serial.print(sensorValue);
59 |
60 | /*************************************************************************************
61 | * Step 1.)
62 | * Uncomment and run the following code to set up the baseline voltage
63 | * (the voltage with 0 current flowing through the device).
64 | * Make sure no current is flowing through the IP+ and IP- terminals during this part!
65 | *
66 | * The output units are in millivolts. Use the Arduino IDE's Tools->Serial Plotter
67 | * To see a plot of the output. Adjust the Vref potentiometer to set the reference
68 | * voltage. This allows the sensor to output positive and negative currents!
69 | *************************************************************************************/
70 |
71 | Serial.print(voltage);
72 | //Serial.print("mV");
73 |
74 | /*************************************************************************************
75 | * Step 2.)
76 | * Keep running the same code as above to set up the sensitivity
77 | * (how many millivolts are output per Amp of current.
78 | *
79 | * This time, use a known load current (measure this with a multimeter)
80 | * to give a constant output voltage. Adjust the sensitivity by turning the
81 | * gain potentiometer.
82 | *
83 | * The sensitivity will be (Vreading - Vref)/(known current).
84 | *************************************************************************************/
85 |
86 | /*************************************************************************************
87 | * Step 3.)
88 | * Comment out the code used for the last two parts and uncomment the following code.
89 | * When you have performed the calibration steps above, make sure to change the
90 | * global variables "sensitivity" and "Vref" to what you have set up.
91 | *
92 | * This next line of code will print out the calculated current from these parameters.
93 | * The output is in mA
94 | *************************************************************************************/
95 |
96 | //Serial.print(current);
97 | //Serial.print("mA");
98 |
99 |
100 | // -- DO NOT UNCOMMENT BELOW THIS LINE --
101 | Serial.print("\n");
102 |
103 | // Reset the sensor value for the next reading
104 | sensorValue = 0;
105 | }
106 |
--------------------------------------------------------------------------------