├── Database └── absensi.sql ├── FIle Laporan.pdf ├── File Program Arduino.ino ├── File Program Website.zip ├── File Rancangan Fritzing.fzz ├── Gambar Rancangan Fritzing.png ├── Library Arduino ├── Adafruit_Unified_Sensor │ ├── Adafruit_Sensor.cpp │ ├── Adafruit_Sensor.h │ ├── LICENSE.txt │ ├── README.md │ ├── examples │ │ └── sensortest │ │ │ └── sensortest.ino │ └── library.properties ├── DHT_sensor_library │ ├── CONTRIBUTING.md │ ├── DHT.cpp │ ├── DHT.h │ ├── DHT_U.cpp │ ├── DHT_U.h │ ├── README.md │ ├── code-of-conduct.md │ ├── examples │ │ ├── DHT_Unified_Sensor │ │ │ └── DHT_Unified_Sensor.ino │ │ └── DHTtester │ │ │ └── DHTtester.ino │ ├── keywords.txt │ ├── library.properties │ └── license.txt └── rfid-master │ ├── .gitignore │ ├── .travis.yml │ ├── MFRC522.cpp │ ├── MFRC522.h │ ├── Makefile │ ├── README.rst │ ├── UNLICENSE │ ├── changes.txt │ ├── doc │ ├── fritzing │ │ ├── Arduino-Uno-r3-with-RFID-RC522.fzz │ │ ├── Arduino-Uno-r3-with-RFID-RC522.png │ │ ├── RFID-RC522 - Pin Layout.png │ │ ├── RFID-RC522-v2.fzpz │ │ └── RFID-RC522-v2.png │ ├── rfidmifare.doc │ └── rfidmifare.pdf │ ├── examples │ ├── AccessControl │ │ └── AccessControl.ino │ ├── ChangeUID │ │ └── ChangeUID.ino │ ├── DumpInfo │ │ └── DumpInfo.ino │ ├── FixBrickedUID │ │ └── FixBrickedUID.ino │ ├── MifareClassicValueBlock │ │ └── MifareClassicValueBlock.ino │ ├── MinimalInterrupt │ │ └── MinimalInterrupt.ino │ ├── Ntag216_AUTH │ │ └── Ntag216_AUTH.ino │ ├── RFID-Cloner │ │ └── RFID-Cloner.ino │ ├── ReadAndWrite │ │ └── ReadAndWrite.ino │ ├── ReadNUID │ │ └── ReadNUID.ino │ ├── ReadUidMultiReader │ │ └── ReadUidMultiReader.ino │ ├── firmware_check │ │ └── firmware_check.ino │ ├── rfid_default_keys │ │ └── rfid_default_keys.ino │ └── rfid_write_personal_data │ │ └── rfid_write_personal_data.ino │ ├── keywords.txt │ ├── library.json │ └── library.properties └── README.md /Database/absensi.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 5.1.0 3 | -- https://www.phpmyadmin.net/ 4 | -- 5 | -- Host: 127.0.0.1 6 | -- Generation Time: Jul 30, 2021 at 01:47 AM 7 | -- Server version: 10.4.19-MariaDB 8 | -- PHP Version: 7.3.28 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | START TRANSACTION; 12 | SET time_zone = "+00:00"; 13 | 14 | 15 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 16 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 17 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 18 | /*!40101 SET NAMES utf8mb4 */; 19 | 20 | -- 21 | -- Database: `absensi` 22 | -- 23 | 24 | -- -------------------------------------------------------- 25 | 26 | -- 27 | -- Table structure for table `absen` 28 | -- 29 | 30 | CREATE TABLE `absen` ( 31 | `id` int(11) NOT NULL, 32 | `uid` varchar(200) NOT NULL, 33 | `tanggal` varchar(200) NOT NULL, 34 | `jam_masuk` varchar(200) NOT NULL, 35 | `jam_pulang` varchar(200) NOT NULL, 36 | `created_at` timestamp NULL DEFAULT NULL, 37 | `updated_at` timestamp NULL DEFAULT NULL 38 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 39 | 40 | -- 41 | -- Dumping data for table `absen` 42 | -- 43 | 44 | INSERT INTO `absen` (`id`, `uid`, `tanggal`, `jam_masuk`, `jam_pulang`, `created_at`, `updated_at`) VALUES 45 | (21, '1392002428', '2021-07-22', '14:00:41', '14:01:54', '2021-07-22 07:00:41', '2021-07-22 07:01:54'); 46 | 47 | -- -------------------------------------------------------- 48 | 49 | -- 50 | -- Table structure for table `karyawan` 51 | -- 52 | 53 | CREATE TABLE `karyawan` ( 54 | `id` int(11) NOT NULL, 55 | `uid` varchar(200) NOT NULL, 56 | `nama` varchar(200) NOT NULL, 57 | `email` varchar(200) NOT NULL, 58 | `jabatan` varchar(200) NOT NULL, 59 | `created_at` timestamp NULL DEFAULT NULL, 60 | `updated_at` timestamp NULL DEFAULT NULL 61 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 62 | 63 | -- 64 | -- Dumping data for table `karyawan` 65 | -- 66 | 67 | INSERT INTO `karyawan` (`id`, `uid`, `nama`, `email`, `jabatan`, `created_at`, `updated_at`) VALUES 68 | (47, '1392002428', 'Rafy', 'rafy@gmail.com', 'programmer', '2021-07-21 23:59:27', '2021-07-21 23:59:27'); 69 | 70 | -- -------------------------------------------------------- 71 | 72 | -- 73 | -- Table structure for table `mode` 74 | -- 75 | 76 | CREATE TABLE `mode` ( 77 | `id` int(11) NOT NULL, 78 | `mode` varchar(200) NOT NULL, 79 | `created_at` timestamp NULL DEFAULT NULL, 80 | `updated_at` timestamp NULL DEFAULT NULL 81 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 82 | 83 | -- 84 | -- Dumping data for table `mode` 85 | -- 86 | 87 | INSERT INTO `mode` (`id`, `mode`, `created_at`, `updated_at`) VALUES 88 | (1, '1', '2021-06-03 14:57:31', '2021-07-22 00:03:56'); 89 | 90 | -- -------------------------------------------------------- 91 | 92 | -- 93 | -- Table structure for table `temp_rfid` 94 | -- 95 | 96 | CREATE TABLE `temp_rfid` ( 97 | `id` int(11) NOT NULL, 98 | `uid` varchar(200) NOT NULL, 99 | `created_at` timestamp NULL DEFAULT NULL, 100 | `updated_at` timestamp NULL DEFAULT NULL 101 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 102 | 103 | -- 104 | -- Indexes for dumped tables 105 | -- 106 | 107 | -- 108 | -- Indexes for table `absen` 109 | -- 110 | ALTER TABLE `absen` 111 | ADD PRIMARY KEY (`id`); 112 | 113 | -- 114 | -- Indexes for table `karyawan` 115 | -- 116 | ALTER TABLE `karyawan` 117 | ADD PRIMARY KEY (`id`); 118 | 119 | -- 120 | -- Indexes for table `mode` 121 | -- 122 | ALTER TABLE `mode` 123 | ADD PRIMARY KEY (`id`); 124 | 125 | -- 126 | -- Indexes for table `temp_rfid` 127 | -- 128 | ALTER TABLE `temp_rfid` 129 | ADD PRIMARY KEY (`id`); 130 | 131 | -- 132 | -- AUTO_INCREMENT for dumped tables 133 | -- 134 | 135 | -- 136 | -- AUTO_INCREMENT for table `absen` 137 | -- 138 | ALTER TABLE `absen` 139 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22; 140 | 141 | -- 142 | -- AUTO_INCREMENT for table `karyawan` 143 | -- 144 | ALTER TABLE `karyawan` 145 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=48; 146 | 147 | -- 148 | -- AUTO_INCREMENT for table `mode` 149 | -- 150 | ALTER TABLE `mode` 151 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; 152 | 153 | -- 154 | -- AUTO_INCREMENT for table `temp_rfid` 155 | -- 156 | ALTER TABLE `temp_rfid` 157 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; 158 | COMMIT; 159 | 160 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 161 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 162 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 163 | -------------------------------------------------------------------------------- /FIle Laporan.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RafyMrX/SISTEM-INFORMASI-ABSENSI-RFID/973ed22a30bb4ce6cd290b889b611c858bb22343/FIle Laporan.pdf -------------------------------------------------------------------------------- /File Program Arduino.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | const char* ssid = "xxx"; //ssid 7 | const char* password = "xxx"; //password wifi 8 | const char* host = ""; //ip address 9 | 10 | #define LED 15 11 | #define BZ 5 12 | #define BTN 4 13 | 14 | #define SDA 2 15 | #define RST 0 16 | 17 | MFRC522 mfrc522(SDA,RST); 18 | 19 | void setup(){ 20 | Serial.begin(115200); 21 | 22 | WiFi.hostname("NodeMCU"); 23 | WiFi.begin(ssid,password); 24 | 25 | while(WiFi.status() != WL_CONNECTED){ 26 | delay(500); 27 | Serial.print("."); 28 | } 29 | 30 | Serial.println("Wifi Terhubung"); 31 | Serial.println("Ip Address"); 32 | Serial.println(WiFi.localIP()); 33 | 34 | pinMode(LED, OUTPUT); 35 | pinMode(BZ, OUTPUT); 36 | pinMode(BTN, INPUT); 37 | noTone(BZ); 38 | SPI.begin(); 39 | mfrc522.PCD_Init(); 40 | Serial.println("Dekatkan Kartu RFID Anda ke Reader"); 41 | Serial.println(); 42 | 43 | } 44 | 45 | void loop(){ 46 | 47 | if(digitalRead(BTN)== 1){ 48 | tone(BZ, 2000); 49 | digitalWrite(LED,HIGH); 50 | delay(400); 51 | noTone(BZ); 52 | tone(BZ, 2000); 53 | delay(400); 54 | noTone(BZ); 55 | 56 | delay(2000); 57 | digitalWrite(LED,LOW); 58 | 59 | String getData, Link; 60 | HTTPClient http; 61 | WiFiClient client; 62 | // get data 63 | 64 | Link = "http://192.168.1.68:8000/mode"; 65 | http.begin(client,Link); 66 | 67 | int httpCode = http.GET(); 68 | String payload = http.getString(); 69 | Serial.println(payload); 70 | http.end(); 71 | 72 | } 73 | digitalWrite(LED,LOW); 74 | 75 | if(! mfrc522.PICC_IsNewCardPresent()) 76 | return ; 77 | 78 | if(! mfrc522.PICC_ReadCardSerial()) 79 | return ; 80 | 81 | String IDTAG = ""; 82 | for(byte i=0; i 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* Update by K. Townsend (Adafruit Industries) for lighter typedefs, and 18 | * extended sensor support to include color, voltage and current */ 19 | 20 | #ifndef _ADAFRUIT_SENSOR_H 21 | #define _ADAFRUIT_SENSOR_H 22 | 23 | #ifndef ARDUINO 24 | #include 25 | #elif ARDUINO >= 100 26 | #include "Arduino.h" 27 | #include "Print.h" 28 | #else 29 | #include "WProgram.h" 30 | #endif 31 | 32 | /* Constants */ 33 | #define SENSORS_GRAVITY_EARTH (9.80665F) /**< Earth's gravity in m/s^2 */ 34 | #define SENSORS_GRAVITY_MOON (1.6F) /**< The moon's gravity in m/s^2 */ 35 | #define SENSORS_GRAVITY_SUN (275.0F) /**< The sun's gravity in m/s^2 */ 36 | #define SENSORS_GRAVITY_STANDARD (SENSORS_GRAVITY_EARTH) 37 | #define SENSORS_MAGFIELD_EARTH_MAX \ 38 | (60.0F) /**< Maximum magnetic field on Earth's surface */ 39 | #define SENSORS_MAGFIELD_EARTH_MIN \ 40 | (30.0F) /**< Minimum magnetic field on Earth's surface */ 41 | #define SENSORS_PRESSURE_SEALEVELHPA \ 42 | (1013.25F) /**< Average sea level pressure is 1013.25 hPa */ 43 | #define SENSORS_DPS_TO_RADS \ 44 | (0.017453293F) /**< Degrees/s to rad/s multiplier \ 45 | */ 46 | #define SENSORS_RADS_TO_DPS \ 47 | (57.29577793F) /**< Rad/s to degrees/s multiplier */ 48 | #define SENSORS_GAUSS_TO_MICROTESLA \ 49 | (100) /**< Gauss to micro-Tesla multiplier */ 50 | 51 | /** Sensor types */ 52 | typedef enum { 53 | SENSOR_TYPE_ACCELEROMETER = (1), /**< Gravity + linear acceleration */ 54 | SENSOR_TYPE_MAGNETIC_FIELD = (2), 55 | SENSOR_TYPE_ORIENTATION = (3), 56 | SENSOR_TYPE_GYROSCOPE = (4), 57 | SENSOR_TYPE_LIGHT = (5), 58 | SENSOR_TYPE_PRESSURE = (6), 59 | SENSOR_TYPE_PROXIMITY = (8), 60 | SENSOR_TYPE_GRAVITY = (9), 61 | SENSOR_TYPE_LINEAR_ACCELERATION = 62 | (10), /**< Acceleration not including gravity */ 63 | SENSOR_TYPE_ROTATION_VECTOR = (11), 64 | SENSOR_TYPE_RELATIVE_HUMIDITY = (12), 65 | SENSOR_TYPE_AMBIENT_TEMPERATURE = (13), 66 | SENSOR_TYPE_OBJECT_TEMPERATURE = (14), 67 | SENSOR_TYPE_VOLTAGE = (15), 68 | SENSOR_TYPE_CURRENT = (16), 69 | SENSOR_TYPE_COLOR = (17) 70 | } sensors_type_t; 71 | 72 | /** struct sensors_vec_s is used to return a vector in a common format. */ 73 | typedef struct { 74 | union { 75 | float v[3]; ///< 3D vector elements 76 | struct { 77 | float x; ///< X component of vector 78 | float y; ///< Y component of vector 79 | float z; ///< Z component of vector 80 | }; ///< Struct for holding XYZ component 81 | /* Orientation sensors */ 82 | struct { 83 | float roll; /**< Rotation around the longitudinal axis (the plane body, 'X 84 | axis'). Roll is positive and increasing when moving 85 | downward. -90 degrees <= roll <= 90 degrees */ 86 | float pitch; /**< Rotation around the lateral axis (the wing span, 'Y 87 | axis'). Pitch is positive and increasing when moving 88 | upwards. -180 degrees <= pitch <= 180 degrees) */ 89 | float heading; /**< Angle between the longitudinal axis (the plane body) 90 | and magnetic north, measured clockwise when viewing from 91 | the top of the device. 0-359 degrees */ 92 | }; ///< Struct for holding roll/pitch/heading 93 | }; ///< Union that can hold 3D vector array, XYZ components or 94 | ///< roll/pitch/heading 95 | int8_t status; ///< Status byte 96 | uint8_t reserved[3]; ///< Reserved 97 | } sensors_vec_t; 98 | 99 | /** struct sensors_color_s is used to return color data in a common format. */ 100 | typedef struct { 101 | union { 102 | float c[3]; ///< Raw 3-element data 103 | /* RGB color space */ 104 | struct { 105 | float r; /**< Red component */ 106 | float g; /**< Green component */ 107 | float b; /**< Blue component */ 108 | }; ///< RGB data in floating point notation 109 | }; ///< Union of various ways to describe RGB colorspace 110 | uint32_t rgba; /**< 24-bit RGBA value */ 111 | } sensors_color_t; 112 | 113 | /* Sensor event (36 bytes) */ 114 | /** struct sensor_event_s is used to provide a single sensor event in a common 115 | * format. */ 116 | typedef struct { 117 | int32_t version; /**< must be sizeof(struct sensors_event_t) */ 118 | int32_t sensor_id; /**< unique sensor identifier */ 119 | int32_t type; /**< sensor type */ 120 | int32_t reserved0; /**< reserved */ 121 | int32_t timestamp; /**< time is in milliseconds */ 122 | union { 123 | float data[4]; ///< Raw data 124 | sensors_vec_t acceleration; /**< acceleration values are in meter per second 125 | per second (m/s^2) */ 126 | sensors_vec_t 127 | magnetic; /**< magnetic vector values are in micro-Tesla (uT) */ 128 | sensors_vec_t orientation; /**< orientation values are in degrees */ 129 | sensors_vec_t gyro; /**< gyroscope values are in rad/s */ 130 | float temperature; /**< temperature is in degrees centigrade (Celsius) */ 131 | float distance; /**< distance in centimeters */ 132 | float light; /**< light in SI lux units */ 133 | float pressure; /**< pressure in hectopascal (hPa) */ 134 | float relative_humidity; /**< relative humidity in percent */ 135 | float current; /**< current in milliamps (mA) */ 136 | float voltage; /**< voltage in volts (V) */ 137 | sensors_color_t color; /**< color in RGB component values */ 138 | }; ///< Union for the wide ranges of data we can carry 139 | } sensors_event_t; 140 | 141 | /* Sensor details (40 bytes) */ 142 | /** struct sensor_s is used to describe basic information about a specific 143 | * sensor. */ 144 | typedef struct { 145 | char name[12]; /**< sensor name */ 146 | int32_t version; /**< version of the hardware + driver */ 147 | int32_t sensor_id; /**< unique sensor identifier */ 148 | int32_t type; /**< this sensor's type (ex. SENSOR_TYPE_LIGHT) */ 149 | float max_value; /**< maximum value of this sensor's value in SI units */ 150 | float min_value; /**< minimum value of this sensor's value in SI units */ 151 | float resolution; /**< smallest difference between two values reported by this 152 | sensor */ 153 | int32_t min_delay; /**< min delay in microseconds between events. zero = not a 154 | constant rate */ 155 | } sensor_t; 156 | 157 | /** @brief Common sensor interface to unify various sensors. 158 | * Intentionally modeled after sensors.h in the Android API: 159 | * https://github.com/android/platform_hardware_libhardware/blob/master/include/hardware/sensors.h 160 | */ 161 | class Adafruit_Sensor { 162 | public: 163 | // Constructor(s) 164 | Adafruit_Sensor() {} 165 | virtual ~Adafruit_Sensor() {} 166 | 167 | // These must be defined by the subclass 168 | 169 | /*! @brief Whether we should automatically change the range (if possible) for 170 | higher precision 171 | @param enabled True if we will try to autorange */ 172 | virtual void enableAutoRange(bool enabled) { 173 | (void)enabled; /* suppress unused warning */ 174 | }; 175 | 176 | /*! @brief Get the latest sensor event 177 | @returns True if able to fetch an event */ 178 | virtual bool getEvent(sensors_event_t *) = 0; 179 | /*! @brief Get info about the sensor itself */ 180 | virtual void getSensor(sensor_t *) = 0; 181 | 182 | void printSensorDetails(void); 183 | 184 | private: 185 | bool _autoRange; 186 | }; 187 | 188 | #endif 189 | -------------------------------------------------------------------------------- /Library Arduino/Adafruit_Unified_Sensor/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /Library Arduino/Adafruit_Unified_Sensor/README.md: -------------------------------------------------------------------------------- 1 | # Adafruit Unified Sensor Driver # 2 | 3 | Many small embedded systems exist to collect data from sensors, analyse the data, and either take an appropriate action or send that sensor data to another system for processing. 4 | 5 | One of the many challenges of embedded systems design is the fact that parts you used today may be out of production tomorrow, or system requirements may change and you may need to choose a different sensor down the road. 6 | 7 | Creating new drivers is a relatively easy task, but integrating them into existing systems is both error prone and time consuming since sensors rarely use the exact same units of measurement. 8 | 9 | By reducing all data to a single **sensors\_event\_t** 'type' and settling on specific, **standardised SI units** for each sensor family the same sensor types return values that are comparable with any other similar sensor. This enables you to switch sensor models with very little impact on the rest of the system, which can help mitigate some of the risks and problems of sensor availability and code reuse. 10 | 11 | The unified sensor abstraction layer is also useful for data-logging and data-transmission since you only have one well-known type to log or transmit over the air or wire. 12 | 13 | ## Unified Sensor Drivers ## 14 | 15 | The following drivers are based on the Adafruit Unified Sensor Driver: 16 | 17 | **Accelerometers** 18 | - [Adafruit\_ADXL345](https://github.com/adafruit/Adafruit_ADXL345) 19 | - [Adafruit\_LSM303DLHC](https://github.com/adafruit/Adafruit_LSM303DLHC) 20 | - [Adafruit\_MMA8451\_Library](https://github.com/adafruit/Adafruit_MMA8451_Library) 21 | 22 | **Gyroscope** 23 | - [Adafruit\_L3GD20\_U](https://github.com/adafruit/Adafruit_L3GD20_U) 24 | 25 | **Light** 26 | - [Adafruit\_TSL2561](https://github.com/adafruit/Adafruit_TSL2561) 27 | - [Adafruit\_TSL2591\_Library](https://github.com/adafruit/Adafruit_TSL2591_Library) 28 | 29 | **Magnetometers** 30 | - [Adafruit\_LSM303DLHC](https://github.com/adafruit/Adafruit_LSM303DLHC) 31 | - [Adafruit\_HMC5883\_Unified](https://github.com/adafruit/Adafruit_HMC5883_Unified) 32 | 33 | **Barometric Pressure** 34 | - [Adafruit\_BMP085\_Unified](https://github.com/adafruit/Adafruit_BMP085_Unified) 35 | - [Adafruit\_BMP183\_Unified\_Library](https://github.com/adafruit/Adafruit_BMP183_Unified_Library) 36 | 37 | **Humidity & Temperature** 38 | - [DHT-sensor-library](https://github.com/adafruit/DHT-sensor-library) 39 | 40 | **Humidity, Temperature, & Barometric Pressure** 41 | - [Adafruit_BME280_Library](https://github.com/adafruit/Adafruit_BME280_Library/) 42 | 43 | **Orientation** 44 | - [Adafruit_BNO055](https://github.com/adafruit/Adafruit_BNO055) 45 | 46 | **All in one device** 47 | - [Adafruit_LSM9DS0](https://github.com/adafruit/Adafruit_LSM9DS0_Library) (accelerometer, gyroscope, magnetometer) 48 | - [Adafruit_LSM9DS1](https://github.com/adafruit/Adafruit_LSM9DS1/) (accelerometer, gyroscope, magnetometer) 49 | 50 | 51 | ## How Does it Work? ## 52 | 53 | Any driver that supports the Adafruit unified sensor abstraction layer will implement the Adafruit\_Sensor base class. There are two main typedefs and one enum defined in Adafruit_Sensor.h that are used to 'abstract' away the sensor details and values: 54 | 55 | **Sensor Types (sensors\_type\_t)** 56 | 57 | These pre-defined sensor types are used to properly handle the two related typedefs below, and allows us determine what types of units the sensor uses, etc. 58 | 59 | ```c++ 60 | /** Sensor types */ 61 | typedef enum 62 | { 63 | SENSOR_TYPE_ACCELEROMETER = (1), 64 | SENSOR_TYPE_MAGNETIC_FIELD = (2), 65 | SENSOR_TYPE_ORIENTATION = (3), 66 | SENSOR_TYPE_GYROSCOPE = (4), 67 | SENSOR_TYPE_LIGHT = (5), 68 | SENSOR_TYPE_PRESSURE = (6), 69 | SENSOR_TYPE_PROXIMITY = (8), 70 | SENSOR_TYPE_GRAVITY = (9), 71 | SENSOR_TYPE_LINEAR_ACCELERATION = (10), 72 | SENSOR_TYPE_ROTATION_VECTOR = (11), 73 | SENSOR_TYPE_RELATIVE_HUMIDITY = (12), 74 | SENSOR_TYPE_AMBIENT_TEMPERATURE = (13), 75 | SENSOR_TYPE_VOLTAGE = (15), 76 | SENSOR_TYPE_CURRENT = (16), 77 | SENSOR_TYPE_COLOR = (17) 78 | } sensors_type_t; 79 | ``` 80 | 81 | **Sensor Details (sensor\_t)** 82 | 83 | This typedef describes the specific capabilities of this sensor, and allows us to know what sensor we are using beneath the abstraction layer. 84 | 85 | ```c++ 86 | /* Sensor details (40 bytes) */ 87 | /** struct sensor_s is used to describe basic information about a specific sensor. */ 88 | typedef struct 89 | { 90 | char name[12]; 91 | int32_t version; 92 | int32_t sensor_id; 93 | int32_t type; 94 | float max_value; 95 | float min_value; 96 | float resolution; 97 | int32_t min_delay; 98 | } sensor_t; 99 | ``` 100 | 101 | The individual fields are intended to be used as follows: 102 | 103 | - **name**: The sensor name or ID, up to a maximum of twelve characters (ex. "MPL115A2") 104 | - **version**: The version of the sensor HW and the driver to allow us to differentiate versions of the board or driver 105 | - **sensor\_id**: A unique sensor identifier that is used to differentiate this specific sensor instance from any others that are present on the system or in the sensor network 106 | - **type**: The sensor type, based on **sensors\_type\_t** in sensors.h 107 | - **max\_value**: The maximum value that this sensor can return (in the appropriate SI unit) 108 | - **min\_value**: The minimum value that this sensor can return (in the appropriate SI unit) 109 | - **resolution**: The smallest difference between two values that this sensor can report (in the appropriate SI unit) 110 | - **min\_delay**: The minimum delay in microseconds between two sensor events, or '0' if there is no constant sensor rate 111 | 112 | **Sensor Data/Events (sensors\_event\_t)** 113 | 114 | This typedef is used to return sensor data from any sensor supported by the abstraction layer, using standard SI units and scales. 115 | 116 | ```c++ 117 | /* Sensor event (36 bytes) */ 118 | /** struct sensor_event_s is used to provide a single sensor event in a common format. */ 119 | typedef struct 120 | { 121 | int32_t version; 122 | int32_t sensor_id; 123 | int32_t type; 124 | int32_t reserved0; 125 | int32_t timestamp; 126 | union 127 | { 128 | float data[4]; 129 | sensors_vec_t acceleration; 130 | sensors_vec_t magnetic; 131 | sensors_vec_t orientation; 132 | sensors_vec_t gyro; 133 | float temperature; 134 | float distance; 135 | float light; 136 | float pressure; 137 | float relative_humidity; 138 | float current; 139 | float voltage; 140 | sensors_color_t color; 141 | }; 142 | } sensors_event_t; 143 | ``` 144 | It includes the following fields: 145 | 146 | - **version**: Contain 'sizeof(sensors\_event\_t)' to identify which version of the API we're using in case this changes in the future 147 | - **sensor\_id**: A unique sensor identifier that is used to differentiate this specific sensor instance from any others that are present on the system or in the sensor network (must match the sensor\_id value in the corresponding sensor\_t enum above!) 148 | - **type**: the sensor type, based on **sensors\_type\_t** in sensors.h 149 | - **timestamp**: time in milliseconds when the sensor value was read 150 | - **data[4]**: An array of four 32-bit values that allows us to encapsulate any type of sensor data via a simple union (further described below) 151 | 152 | **Required Functions** 153 | 154 | In addition to the two standard types and the sensor type enum, all drivers based on Adafruit_Sensor must also implement the following two functions: 155 | 156 | ```c++ 157 | bool getEvent(sensors_event_t*); 158 | ``` 159 | Calling this function will populate the supplied sensors\_event\_t reference with the latest available sensor data. You should call this function as often as you want to update your data. 160 | 161 | ```c++ 162 | void getSensor(sensor_t*); 163 | ``` 164 | Calling this function will provide some basic information about the sensor (the sensor name, driver version, min and max values, etc. 165 | 166 | **Standardised SI values for sensors\_event\_t** 167 | 168 | A key part of the abstraction layer is the standardisation of values on SI units of a particular scale, which is accomplished via the data[4] union in sensors\_event\_t above. This 16 byte union includes fields for each main sensor type, and uses the following SI units and scales: 169 | 170 | - **acceleration**: values are in **meter per second per second** (m/s^2) 171 | - **magnetic**: values are in **micro-Tesla** (uT) 172 | - **orientation**: values are in **degrees** 173 | - **gyro**: values are in **rad/s** 174 | - **temperature**: values in **degrees centigrade** (Celsius) 175 | - **distance**: values are in **centimeters** 176 | - **light**: values are in **SI lux** units 177 | - **pressure**: values are in **hectopascal** (hPa) 178 | - **relative\_humidity**: values are in **percent** 179 | - **current**: values are in **milliamps** (mA) 180 | - **voltage**: values are in **volts** (V) 181 | - **color**: values are in 0..1.0 RGB channel luminosity and 32-bit RGBA format 182 | 183 | ## The Unified Driver Abstraction Layer in Practice ## 184 | 185 | Using the unified sensor abstraction layer is relatively easy once a compliant driver has been created. 186 | 187 | Every compliant sensor can now be read using a single, well-known 'type' (sensors\_event\_t), and there is a standardised way of interrogating a sensor about its specific capabilities (via sensor\_t). 188 | 189 | An example of reading the [TSL2561](https://github.com/adafruit/Adafruit_TSL2561) light sensor can be seen below: 190 | 191 | ```c++ 192 | Adafruit_TSL2561 tsl = Adafruit_TSL2561(TSL2561_ADDR_FLOAT, 12345); 193 | ... 194 | /* Get a new sensor event */ 195 | sensors_event_t event; 196 | tsl.getEvent(&event); 197 | 198 | /* Display the results (light is measured in lux) */ 199 | if (event.light) 200 | { 201 | Serial.print(event.light); Serial.println(" lux"); 202 | } 203 | else 204 | { 205 | /* If event.light = 0 lux the sensor is probably saturated 206 | and no reliable data could be generated! */ 207 | Serial.println("Sensor overload"); 208 | } 209 | ``` 210 | 211 | Similarly, we can get the basic technical capabilities of this sensor with the following code: 212 | 213 | ```c++ 214 | sensor_t sensor; 215 | 216 | sensor_t sensor; 217 | tsl.getSensor(&sensor); 218 | 219 | /* Display the sensor details */ 220 | Serial.println("------------------------------------"); 221 | Serial.print ("Sensor: "); Serial.println(sensor.name); 222 | Serial.print ("Driver Ver: "); Serial.println(sensor.version); 223 | Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); 224 | Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" lux"); 225 | Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" lux"); 226 | Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" lux"); 227 | Serial.println("------------------------------------"); 228 | Serial.println(""); 229 | ``` 230 | -------------------------------------------------------------------------------- /Library Arduino/Adafruit_Unified_Sensor/examples/sensortest/sensortest.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* Assign a unique ID to this sensor at the same time */ 6 | /* Uncomment following line for default Wire bus */ 7 | Adafruit_ADXL343 accel = Adafruit_ADXL343(12345); 8 | 9 | /* NeoTrellis M4, etc. */ 10 | /* Uncomment following line for Wire1 bus */ 11 | //Adafruit_ADXL343 accel = Adafruit_ADXL343(12345, &Wire1); 12 | 13 | void displaySensorDetails(void) 14 | { 15 | sensor_t sensor; 16 | accel.getSensor(&sensor); 17 | Serial.println("------------------------------------"); 18 | Serial.print ("Sensor: "); Serial.println(sensor.name); 19 | Serial.print ("Driver Ver: "); Serial.println(sensor.version); 20 | Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); 21 | Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" m/s^2"); 22 | Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" m/s^2"); 23 | Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" m/s^2"); 24 | Serial.println("------------------------------------"); 25 | Serial.println(""); 26 | delay(500); 27 | } 28 | 29 | void displayDataRate(void) 30 | { 31 | Serial.print ("Data Rate: "); 32 | 33 | switch(accel.getDataRate()) 34 | { 35 | case ADXL343_DATARATE_3200_HZ: 36 | Serial.print ("3200 "); 37 | break; 38 | case ADXL343_DATARATE_1600_HZ: 39 | Serial.print ("1600 "); 40 | break; 41 | case ADXL343_DATARATE_800_HZ: 42 | Serial.print ("800 "); 43 | break; 44 | case ADXL343_DATARATE_400_HZ: 45 | Serial.print ("400 "); 46 | break; 47 | case ADXL343_DATARATE_200_HZ: 48 | Serial.print ("200 "); 49 | break; 50 | case ADXL343_DATARATE_100_HZ: 51 | Serial.print ("100 "); 52 | break; 53 | case ADXL343_DATARATE_50_HZ: 54 | Serial.print ("50 "); 55 | break; 56 | case ADXL343_DATARATE_25_HZ: 57 | Serial.print ("25 "); 58 | break; 59 | case ADXL343_DATARATE_12_5_HZ: 60 | Serial.print ("12.5 "); 61 | break; 62 | case ADXL343_DATARATE_6_25HZ: 63 | Serial.print ("6.25 "); 64 | break; 65 | case ADXL343_DATARATE_3_13_HZ: 66 | Serial.print ("3.13 "); 67 | break; 68 | case ADXL343_DATARATE_1_56_HZ: 69 | Serial.print ("1.56 "); 70 | break; 71 | case ADXL343_DATARATE_0_78_HZ: 72 | Serial.print ("0.78 "); 73 | break; 74 | case ADXL343_DATARATE_0_39_HZ: 75 | Serial.print ("0.39 "); 76 | break; 77 | case ADXL343_DATARATE_0_20_HZ: 78 | Serial.print ("0.20 "); 79 | break; 80 | case ADXL343_DATARATE_0_10_HZ: 81 | Serial.print ("0.10 "); 82 | break; 83 | default: 84 | Serial.print ("???? "); 85 | break; 86 | } 87 | Serial.println(" Hz"); 88 | } 89 | 90 | void displayRange(void) 91 | { 92 | Serial.print ("Range: +/- "); 93 | 94 | switch(accel.getRange()) 95 | { 96 | case ADXL343_RANGE_16_G: 97 | Serial.print ("16 "); 98 | break; 99 | case ADXL343_RANGE_8_G: 100 | Serial.print ("8 "); 101 | break; 102 | case ADXL343_RANGE_4_G: 103 | Serial.print ("4 "); 104 | break; 105 | case ADXL343_RANGE_2_G: 106 | Serial.print ("2 "); 107 | break; 108 | default: 109 | Serial.print ("?? "); 110 | break; 111 | } 112 | Serial.println(" g"); 113 | } 114 | 115 | void setup(void) 116 | { 117 | Serial.begin(9600); 118 | while (!Serial); 119 | Serial.println("Accelerometer Test"); Serial.println(""); 120 | 121 | /* Initialise the sensor */ 122 | if(!accel.begin()) 123 | { 124 | /* There was a problem detecting the ADXL343 ... check your connections */ 125 | Serial.println("Ooops, no ADXL343 detected ... Check your wiring!"); 126 | while(1); 127 | } 128 | 129 | /* Set the range to whatever is appropriate for your project */ 130 | accel.setRange(ADXL343_RANGE_16_G); 131 | // accel.setRange(ADXL343_RANGE_8_G); 132 | // accel.setRange(ADXL343_RANGE_4_G); 133 | // accel.setRange(ADXL343_RANGE_2_G); 134 | 135 | /* Display some basic information on this sensor */ 136 | displaySensorDetails(); 137 | displayDataRate(); 138 | displayRange(); 139 | Serial.println(""); 140 | } 141 | 142 | void loop(void) 143 | { 144 | /* Get a new sensor event */ 145 | sensors_event_t event; 146 | accel.getEvent(&event); 147 | 148 | /* Display the results (acceleration is measured in m/s^2) */ 149 | Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print(" "); 150 | Serial.print("Y: "); Serial.print(event.acceleration.y); Serial.print(" "); 151 | Serial.print("Z: "); Serial.print(event.acceleration.z); Serial.print(" ");Serial.println("m/s^2 "); 152 | delay(500); 153 | } 154 | -------------------------------------------------------------------------------- /Library Arduino/Adafruit_Unified_Sensor/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit Unified Sensor 2 | version=1.1.4 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Required for all Adafruit Unified Sensor based libraries. 6 | paragraph=A unified sensor abstraction layer used by many Adafruit sensor libraries. 7 | category=Sensors 8 | url=https://github.com/adafruit/Adafruit_Sensor 9 | architectures=* 10 | includes=Adafruit_Sensor.h 11 | 12 | -------------------------------------------------------------------------------- /Library Arduino/DHT_sensor_library/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidlines 2 | 3 | This library is the culmination of the expertise of many members of the open source community who have dedicated their time and hard work. The best way to ask for help or propose a new idea is to [create a new issue](https://github.com/adafruit/DHT-sensor-library/issues/new) while creating a Pull Request with your code changes allows you to share your own innovations with the rest of the community. 4 | 5 | The following are some guidelines to observe when creating issues or PRs: 6 | 7 | - Be friendly; it is important that we can all enjoy a safe space as we are all working on the same project and it is okay for people to have different ideas 8 | 9 | - [Use code blocks](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code); it helps us help you when we can read your code! On that note also refrain from pasting more than 30 lines of code in a post, instead [create a gist](https://gist.github.com/) if you need to share large snippets 10 | 11 | - Use reasonable titles; refrain from using overly long or capitalized titles as they are usually annoying and do little to encourage others to help :smile: 12 | 13 | - Be detailed; refrain from mentioning code problems without sharing your source code and always give information regarding your board and version of the library 14 | -------------------------------------------------------------------------------- /Library Arduino/DHT_sensor_library/DHT.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file DHT.cpp 3 | * 4 | * @mainpage DHT series of low cost temperature/humidity sensors. 5 | * 6 | * @section intro_sec Introduction 7 | * 8 | * This is a library for DHT series of low cost temperature/humidity sensors. 9 | * 10 | * You must have Adafruit Unified Sensor Library library installed to use this 11 | * class. 12 | * 13 | * Adafruit invests time and resources providing this open source code, 14 | * please support Adafruit andopen-source hardware by purchasing products 15 | * from Adafruit! 16 | * 17 | * @section author Author 18 | * 19 | * Written by Adafruit Industries. 20 | * 21 | * @section license License 22 | * 23 | * MIT license, all text above must be included in any redistribution 24 | */ 25 | 26 | #include "DHT.h" 27 | 28 | #define MIN_INTERVAL 2000 /**< min interval value */ 29 | #define TIMEOUT \ 30 | UINT32_MAX /**< Used programmatically for timeout. \ 31 | Not a timeout duration. Type: uint32_t. */ 32 | 33 | /*! 34 | * @brief Instantiates a new DHT class 35 | * @param pin 36 | * pin number that sensor is connected 37 | * @param type 38 | * type of sensor 39 | * @param count 40 | * number of sensors 41 | */ 42 | DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) { 43 | (void)count; // Workaround to avoid compiler warning. 44 | _pin = pin; 45 | _type = type; 46 | #ifdef __AVR 47 | _bit = digitalPinToBitMask(pin); 48 | _port = digitalPinToPort(pin); 49 | #endif 50 | _maxcycles = 51 | microsecondsToClockCycles(1000); // 1 millisecond timeout for 52 | // reading pulses from DHT sensor. 53 | // Note that count is now ignored as the DHT reading algorithm adjusts itself 54 | // based on the speed of the processor. 55 | } 56 | 57 | /*! 58 | * @brief Setup sensor pins and set pull timings 59 | * @param usec 60 | * Optionally pass pull-up time (in microseconds) before DHT reading 61 | *starts. Default is 55 (see function declaration in DHT.h). 62 | */ 63 | void DHT::begin(uint8_t usec) { 64 | // set up the pins! 65 | pinMode(_pin, INPUT_PULLUP); 66 | // Using this value makes sure that millis() - lastreadtime will be 67 | // >= MIN_INTERVAL right away. Note that this assignment wraps around, 68 | // but so will the subtraction. 69 | _lastreadtime = millis() - MIN_INTERVAL; 70 | DEBUG_PRINT("DHT max clock cycles: "); 71 | DEBUG_PRINTLN(_maxcycles, DEC); 72 | pullTime = usec; 73 | } 74 | 75 | /*! 76 | * @brief Read temperature 77 | * @param S 78 | * Scale. Boolean value: 79 | * - true = Fahrenheit 80 | * - false = Celcius 81 | * @param force 82 | * true if in force mode 83 | * @return Temperature value in selected scale 84 | */ 85 | float DHT::readTemperature(bool S, bool force) { 86 | float f = NAN; 87 | 88 | if (read(force)) { 89 | switch (_type) { 90 | case DHT11: 91 | f = data[2]; 92 | if (data[3] & 0x80) { 93 | f = -1 - f; 94 | } 95 | f += (data[3] & 0x0f) * 0.1; 96 | if (S) { 97 | f = convertCtoF(f); 98 | } 99 | break; 100 | case DHT12: 101 | f = data[2]; 102 | f += (data[3] & 0x0f) * 0.1; 103 | if (data[2] & 0x80) { 104 | f *= -1; 105 | } 106 | if (S) { 107 | f = convertCtoF(f); 108 | } 109 | break; 110 | case DHT22: 111 | case DHT21: 112 | f = ((word)(data[2] & 0x7F)) << 8 | data[3]; 113 | f *= 0.1; 114 | if (data[2] & 0x80) { 115 | f *= -1; 116 | } 117 | if (S) { 118 | f = convertCtoF(f); 119 | } 120 | break; 121 | } 122 | } 123 | return f; 124 | } 125 | 126 | /*! 127 | * @brief Converts Celcius to Fahrenheit 128 | * @param c 129 | * value in Celcius 130 | * @return float value in Fahrenheit 131 | */ 132 | float DHT::convertCtoF(float c) { return c * 1.8 + 32; } 133 | 134 | /*! 135 | * @brief Converts Fahrenheit to Celcius 136 | * @param f 137 | * value in Fahrenheit 138 | * @return float value in Celcius 139 | */ 140 | float DHT::convertFtoC(float f) { return (f - 32) * 0.55555; } 141 | 142 | /*! 143 | * @brief Read Humidity 144 | * @param force 145 | * force read mode 146 | * @return float value - humidity in percent 147 | */ 148 | float DHT::readHumidity(bool force) { 149 | float f = NAN; 150 | if (read(force)) { 151 | switch (_type) { 152 | case DHT11: 153 | case DHT12: 154 | f = data[0] + data[1] * 0.1; 155 | break; 156 | case DHT22: 157 | case DHT21: 158 | f = ((word)data[0]) << 8 | data[1]; 159 | f *= 0.1; 160 | break; 161 | } 162 | } 163 | return f; 164 | } 165 | 166 | /*! 167 | * @brief Compute Heat Index 168 | * Simplified version that reads temp and humidity from sensor 169 | * @param isFahrenheit 170 | * true if fahrenheit, false if celcius 171 | *(default true) 172 | * @return float heat index 173 | */ 174 | float DHT::computeHeatIndex(bool isFahrenheit) { 175 | float hi = computeHeatIndex(readTemperature(isFahrenheit), readHumidity(), 176 | isFahrenheit); 177 | return hi; 178 | } 179 | 180 | /*! 181 | * @brief Compute Heat Index 182 | * Using both Rothfusz and Steadman's equations 183 | * (http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml) 184 | * @param temperature 185 | * temperature in selected scale 186 | * @param percentHumidity 187 | * humidity in percent 188 | * @param isFahrenheit 189 | * true if fahrenheit, false if celcius 190 | * @return float heat index 191 | */ 192 | float DHT::computeHeatIndex(float temperature, float percentHumidity, 193 | bool isFahrenheit) { 194 | float hi; 195 | 196 | if (!isFahrenheit) 197 | temperature = convertCtoF(temperature); 198 | 199 | hi = 0.5 * (temperature + 61.0 + ((temperature - 68.0) * 1.2) + 200 | (percentHumidity * 0.094)); 201 | 202 | if (hi > 79) { 203 | hi = -42.379 + 2.04901523 * temperature + 10.14333127 * percentHumidity + 204 | -0.22475541 * temperature * percentHumidity + 205 | -0.00683783 * pow(temperature, 2) + 206 | -0.05481717 * pow(percentHumidity, 2) + 207 | 0.00122874 * pow(temperature, 2) * percentHumidity + 208 | 0.00085282 * temperature * pow(percentHumidity, 2) + 209 | -0.00000199 * pow(temperature, 2) * pow(percentHumidity, 2); 210 | 211 | if ((percentHumidity < 13) && (temperature >= 80.0) && 212 | (temperature <= 112.0)) 213 | hi -= ((13.0 - percentHumidity) * 0.25) * 214 | sqrt((17.0 - abs(temperature - 95.0)) * 0.05882); 215 | 216 | else if ((percentHumidity > 85.0) && (temperature >= 80.0) && 217 | (temperature <= 87.0)) 218 | hi += ((percentHumidity - 85.0) * 0.1) * ((87.0 - temperature) * 0.2); 219 | } 220 | 221 | return isFahrenheit ? hi : convertFtoC(hi); 222 | } 223 | 224 | /*! 225 | * @brief Read value from sensor or return last one from less than two 226 | *seconds. 227 | * @param force 228 | * true if using force mode 229 | * @return float value 230 | */ 231 | bool DHT::read(bool force) { 232 | // Check if sensor was read less than two seconds ago and return early 233 | // to use last reading. 234 | uint32_t currenttime = millis(); 235 | if (!force && ((currenttime - _lastreadtime) < MIN_INTERVAL)) { 236 | return _lastresult; // return last correct measurement 237 | } 238 | _lastreadtime = currenttime; 239 | 240 | // Reset 40 bits of received data to zero. 241 | data[0] = data[1] = data[2] = data[3] = data[4] = 0; 242 | 243 | #if defined(ESP8266) 244 | yield(); // Handle WiFi / reset software watchdog 245 | #endif 246 | 247 | // Send start signal. See DHT datasheet for full signal diagram: 248 | // http://www.adafruit.com/datasheets/Digital%20humidity%20and%20temperature%20sensor%20AM2302.pdf 249 | 250 | // Go into high impedence state to let pull-up raise data line level and 251 | // start the reading process. 252 | pinMode(_pin, INPUT_PULLUP); 253 | delay(1); 254 | 255 | // First set data line low for a period according to sensor type 256 | pinMode(_pin, OUTPUT); 257 | digitalWrite(_pin, LOW); 258 | switch (_type) { 259 | case DHT22: 260 | case DHT21: 261 | delayMicroseconds(1100); // data sheet says "at least 1ms" 262 | break; 263 | case DHT11: 264 | default: 265 | delay(20); // data sheet says at least 18ms, 20ms just to be safe 266 | break; 267 | } 268 | 269 | uint32_t cycles[80]; 270 | { 271 | // End the start signal by setting data line high for 40 microseconds. 272 | pinMode(_pin, INPUT_PULLUP); 273 | 274 | // Delay a moment to let sensor pull data line low. 275 | delayMicroseconds(pullTime); 276 | 277 | // Now start reading the data line to get the value from the DHT sensor. 278 | 279 | // Turn off interrupts temporarily because the next sections 280 | // are timing critical and we don't want any interruptions. 281 | InterruptLock lock; 282 | 283 | // First expect a low signal for ~80 microseconds followed by a high signal 284 | // for ~80 microseconds again. 285 | if (expectPulse(LOW) == TIMEOUT) { 286 | DEBUG_PRINTLN(F("DHT timeout waiting for start signal low pulse.")); 287 | _lastresult = false; 288 | return _lastresult; 289 | } 290 | if (expectPulse(HIGH) == TIMEOUT) { 291 | DEBUG_PRINTLN(F("DHT timeout waiting for start signal high pulse.")); 292 | _lastresult = false; 293 | return _lastresult; 294 | } 295 | 296 | // Now read the 40 bits sent by the sensor. Each bit is sent as a 50 297 | // microsecond low pulse followed by a variable length high pulse. If the 298 | // high pulse is ~28 microseconds then it's a 0 and if it's ~70 microseconds 299 | // then it's a 1. We measure the cycle count of the initial 50us low pulse 300 | // and use that to compare to the cycle count of the high pulse to determine 301 | // if the bit is a 0 (high state cycle count < low state cycle count), or a 302 | // 1 (high state cycle count > low state cycle count). Note that for speed 303 | // all the pulses are read into a array and then examined in a later step. 304 | for (int i = 0; i < 80; i += 2) { 305 | cycles[i] = expectPulse(LOW); 306 | cycles[i + 1] = expectPulse(HIGH); 307 | } 308 | } // Timing critical code is now complete. 309 | 310 | // Inspect pulses and determine which ones are 0 (high state cycle count < low 311 | // state cycle count), or 1 (high state cycle count > low state cycle count). 312 | for (int i = 0; i < 40; ++i) { 313 | uint32_t lowCycles = cycles[2 * i]; 314 | uint32_t highCycles = cycles[2 * i + 1]; 315 | if ((lowCycles == TIMEOUT) || (highCycles == TIMEOUT)) { 316 | DEBUG_PRINTLN(F("DHT timeout waiting for pulse.")); 317 | _lastresult = false; 318 | return _lastresult; 319 | } 320 | data[i / 8] <<= 1; 321 | // Now compare the low and high cycle times to see if the bit is a 0 or 1. 322 | if (highCycles > lowCycles) { 323 | // High cycles are greater than 50us low cycle count, must be a 1. 324 | data[i / 8] |= 1; 325 | } 326 | // Else high cycles are less than (or equal to, a weird case) the 50us low 327 | // cycle count so this must be a zero. Nothing needs to be changed in the 328 | // stored data. 329 | } 330 | 331 | DEBUG_PRINTLN(F("Received from DHT:")); 332 | DEBUG_PRINT(data[0], HEX); 333 | DEBUG_PRINT(F(", ")); 334 | DEBUG_PRINT(data[1], HEX); 335 | DEBUG_PRINT(F(", ")); 336 | DEBUG_PRINT(data[2], HEX); 337 | DEBUG_PRINT(F(", ")); 338 | DEBUG_PRINT(data[3], HEX); 339 | DEBUG_PRINT(F(", ")); 340 | DEBUG_PRINT(data[4], HEX); 341 | DEBUG_PRINT(F(" =? ")); 342 | DEBUG_PRINTLN((data[0] + data[1] + data[2] + data[3]) & 0xFF, HEX); 343 | 344 | // Check we read 40 bits and that the checksum matches. 345 | if (data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF)) { 346 | _lastresult = true; 347 | return _lastresult; 348 | } else { 349 | DEBUG_PRINTLN(F("DHT checksum failure!")); 350 | _lastresult = false; 351 | return _lastresult; 352 | } 353 | } 354 | 355 | // Expect the signal line to be at the specified level for a period of time and 356 | // return a count of loop cycles spent at that level (this cycle count can be 357 | // used to compare the relative time of two pulses). If more than a millisecond 358 | // ellapses without the level changing then the call fails with a 0 response. 359 | // This is adapted from Arduino's pulseInLong function (which is only available 360 | // in the very latest IDE versions): 361 | // https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring_pulse.c 362 | uint32_t DHT::expectPulse(bool level) { 363 | #if (F_CPU > 16000000L) 364 | uint32_t count = 0; 365 | #else 366 | uint16_t count = 0; // To work fast enough on slower AVR boards 367 | #endif 368 | // On AVR platforms use direct GPIO port access as it's much faster and better 369 | // for catching pulses that are 10's of microseconds in length: 370 | #ifdef __AVR 371 | uint8_t portState = level ? _bit : 0; 372 | while ((*portInputRegister(_port) & _bit) == portState) { 373 | if (count++ >= _maxcycles) { 374 | return TIMEOUT; // Exceeded timeout, fail. 375 | } 376 | } 377 | // Otherwise fall back to using digitalRead (this seems to be necessary on 378 | // ESP8266 right now, perhaps bugs in direct port access functions?). 379 | #else 380 | while (digitalRead(_pin) == level) { 381 | if (count++ >= _maxcycles) { 382 | return TIMEOUT; // Exceeded timeout, fail. 383 | } 384 | } 385 | #endif 386 | 387 | return count; 388 | } 389 | -------------------------------------------------------------------------------- /Library Arduino/DHT_sensor_library/DHT.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file DHT.h 3 | * 4 | * This is a library for DHT series of low cost temperature/humidity sensors. 5 | * 6 | * You must have Adafruit Unified Sensor Library library installed to use this 7 | * class. 8 | * 9 | * Adafruit invests time and resources providing this open source code, 10 | * please support Adafruit andopen-source hardware by purchasing products 11 | * from Adafruit! 12 | * 13 | * Written by Adafruit Industries. 14 | * 15 | * MIT license, all text above must be included in any redistribution 16 | */ 17 | 18 | #ifndef DHT_H 19 | #define DHT_H 20 | 21 | #include "Arduino.h" 22 | 23 | /* Uncomment to enable printing out nice debug messages. */ 24 | //#define DHT_DEBUG 25 | 26 | #define DEBUG_PRINTER \ 27 | Serial /**< Define where debug output will be printed. \ 28 | */ 29 | 30 | /* Setup debug printing macros. */ 31 | #ifdef DHT_DEBUG 32 | #define DEBUG_PRINT(...) \ 33 | { DEBUG_PRINTER.print(__VA_ARGS__); } 34 | #define DEBUG_PRINTLN(...) \ 35 | { DEBUG_PRINTER.println(__VA_ARGS__); } 36 | #else 37 | #define DEBUG_PRINT(...) \ 38 | {} /**< Debug Print Placeholder if Debug is disabled */ 39 | #define DEBUG_PRINTLN(...) \ 40 | {} /**< Debug Print Line Placeholder if Debug is disabled */ 41 | #endif 42 | 43 | /* Define types of sensors. */ 44 | #define DHT11 11 /**< DHT TYPE 11 */ 45 | #define DHT12 12 /**< DHY TYPE 12 */ 46 | #define DHT22 22 /**< DHT TYPE 22 */ 47 | #define DHT21 21 /**< DHT TYPE 21 */ 48 | #define AM2301 21 /**< AM2301 */ 49 | 50 | #if defined(TARGET_NAME) && (TARGET_NAME == ARDUINO_NANO33BLE) 51 | #ifndef microsecondsToClockCycles 52 | /*! 53 | * As of 7 Sep 2020 the Arduino Nano 33 BLE boards do not have 54 | * microsecondsToClockCycles defined. 55 | */ 56 | #define microsecondsToClockCycles(a) ((a) * (SystemCoreClock / 1000000L)) 57 | #endif 58 | #endif 59 | 60 | /*! 61 | * @brief Class that stores state and functions for DHT 62 | */ 63 | class DHT { 64 | public: 65 | DHT(uint8_t pin, uint8_t type, uint8_t count = 6); 66 | void begin(uint8_t usec = 55); 67 | float readTemperature(bool S = false, bool force = false); 68 | float convertCtoF(float); 69 | float convertFtoC(float); 70 | float computeHeatIndex(bool isFahrenheit = true); 71 | float computeHeatIndex(float temperature, float percentHumidity, 72 | bool isFahrenheit = true); 73 | float readHumidity(bool force = false); 74 | bool read(bool force = false); 75 | 76 | private: 77 | uint8_t data[5]; 78 | uint8_t _pin, _type; 79 | #ifdef __AVR 80 | // Use direct GPIO access on an 8-bit AVR so keep track of the port and 81 | // bitmask for the digital pin connected to the DHT. Other platforms will use 82 | // digitalRead. 83 | uint8_t _bit, _port; 84 | #endif 85 | uint32_t _lastreadtime, _maxcycles; 86 | bool _lastresult; 87 | uint8_t pullTime; // Time (in usec) to pull up data line before reading 88 | 89 | uint32_t expectPulse(bool level); 90 | }; 91 | 92 | /*! 93 | * @brief Class that defines Interrupt Lock Avaiability 94 | */ 95 | class InterruptLock { 96 | public: 97 | InterruptLock() { 98 | #if !defined(ARDUINO_ARCH_NRF52) 99 | noInterrupts(); 100 | #endif 101 | } 102 | ~InterruptLock() { 103 | #if !defined(ARDUINO_ARCH_NRF52) 104 | interrupts(); 105 | #endif 106 | } 107 | }; 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /Library Arduino/DHT_sensor_library/DHT_U.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file DHT_U.cpp 3 | * 4 | * Temperature & Humidity Unified Sensor Library 5 | * 6 | * This is a library for DHT series of low cost temperature/humidity sensors. 7 | * 8 | * You must have Adafruit Unified Sensor Library library installed to use this 9 | * class. 10 | * 11 | * Adafruit invests time and resources providing this open source code, 12 | * please support Adafruit andopen-source hardware by purchasing products 13 | * from Adafruit! 14 | */ 15 | #include "DHT_U.h" 16 | 17 | /*! 18 | * @brief Instantiates a new DHT_Unified class 19 | * @param pin 20 | * pin number that sensor is connected 21 | * @param type 22 | * type of sensor 23 | * @param count 24 | * number of sensors 25 | * @param tempSensorId 26 | * temperature sensor id 27 | * @param humiditySensorId 28 | * humidity sensor id 29 | */ 30 | DHT_Unified::DHT_Unified(uint8_t pin, uint8_t type, uint8_t count, 31 | int32_t tempSensorId, int32_t humiditySensorId) 32 | : _dht(pin, type, count), _type(type), _temp(this, tempSensorId), 33 | _humidity(this, humiditySensorId) {} 34 | 35 | /*! 36 | * @brief Setup sensor (calls begin on It) 37 | */ 38 | void DHT_Unified::begin() { _dht.begin(); } 39 | 40 | /*! 41 | * @brief Sets sensor name 42 | * @param sensor 43 | * Sensor that will be set 44 | */ 45 | void DHT_Unified::setName(sensor_t *sensor) { 46 | switch (_type) { 47 | case DHT11: 48 | strncpy(sensor->name, "DHT11", sizeof(sensor->name) - 1); 49 | break; 50 | case DHT12: 51 | strncpy(sensor->name, "DHT12", sizeof(sensor->name) - 1); 52 | break; 53 | case DHT21: 54 | strncpy(sensor->name, "DHT21", sizeof(sensor->name) - 1); 55 | break; 56 | case DHT22: 57 | strncpy(sensor->name, "DHT22", sizeof(sensor->name) - 1); 58 | break; 59 | default: 60 | // TODO: Perhaps this should be an error? However main DHT library doesn't 61 | // enforce restrictions on the sensor type value. Pick a generic name for 62 | // now. 63 | strncpy(sensor->name, "DHT?", sizeof(sensor->name) - 1); 64 | break; 65 | } 66 | sensor->name[sizeof(sensor->name) - 1] = 0; 67 | } 68 | 69 | /*! 70 | * @brief Sets Minimum Delay Value 71 | * @param sensor 72 | * Sensor that will be set 73 | */ 74 | void DHT_Unified::setMinDelay(sensor_t *sensor) { 75 | switch (_type) { 76 | case DHT11: 77 | sensor->min_delay = 1000000L; // 1 second (in microseconds) 78 | break; 79 | case DHT12: 80 | sensor->min_delay = 2000000L; // 2 second (in microseconds) 81 | break; 82 | case DHT21: 83 | sensor->min_delay = 2000000L; // 2 seconds (in microseconds) 84 | break; 85 | case DHT22: 86 | sensor->min_delay = 2000000L; // 2 seconds (in microseconds) 87 | break; 88 | default: 89 | // Default to slowest sample rate in case of unknown type. 90 | sensor->min_delay = 2000000L; // 2 seconds (in microseconds) 91 | break; 92 | } 93 | } 94 | 95 | /*! 96 | * @brief Instantiates a new DHT_Unified Temperature Class 97 | * @param parent 98 | * Parent Sensor 99 | * @param id 100 | * Sensor id 101 | */ 102 | DHT_Unified::Temperature::Temperature(DHT_Unified *parent, int32_t id) 103 | : _parent(parent), _id(id) {} 104 | 105 | /*! 106 | * @brief Reads the sensor and returns the data as a sensors_event_t 107 | * @param event 108 | * @return always returns true 109 | */ 110 | bool DHT_Unified::Temperature::getEvent(sensors_event_t *event) { 111 | // Clear event definition. 112 | memset(event, 0, sizeof(sensors_event_t)); 113 | // Populate sensor reading values. 114 | event->version = sizeof(sensors_event_t); 115 | event->sensor_id = _id; 116 | event->type = SENSOR_TYPE_AMBIENT_TEMPERATURE; 117 | event->timestamp = millis(); 118 | event->temperature = _parent->_dht.readTemperature(); 119 | 120 | return true; 121 | } 122 | 123 | /*! 124 | * @brief Provides the sensor_t data for this sensor 125 | * @param sensor 126 | */ 127 | void DHT_Unified::Temperature::getSensor(sensor_t *sensor) { 128 | // Clear sensor definition. 129 | memset(sensor, 0, sizeof(sensor_t)); 130 | // Set sensor name. 131 | _parent->setName(sensor); 132 | // Set version and ID 133 | sensor->version = DHT_SENSOR_VERSION; 134 | sensor->sensor_id = _id; 135 | // Set type and characteristics. 136 | sensor->type = SENSOR_TYPE_AMBIENT_TEMPERATURE; 137 | _parent->setMinDelay(sensor); 138 | switch (_parent->_type) { 139 | case DHT11: 140 | sensor->max_value = 50.0F; 141 | sensor->min_value = 0.0F; 142 | sensor->resolution = 2.0F; 143 | break; 144 | case DHT12: 145 | sensor->max_value = 60.0F; 146 | sensor->min_value = -20.0F; 147 | sensor->resolution = 0.5F; 148 | break; 149 | case DHT21: 150 | sensor->max_value = 80.0F; 151 | sensor->min_value = -40.0F; 152 | sensor->resolution = 0.1F; 153 | break; 154 | case DHT22: 155 | sensor->max_value = 125.0F; 156 | sensor->min_value = -40.0F; 157 | sensor->resolution = 0.1F; 158 | break; 159 | default: 160 | // Unknown type, default to 0. 161 | sensor->max_value = 0.0F; 162 | sensor->min_value = 0.0F; 163 | sensor->resolution = 0.0F; 164 | break; 165 | } 166 | } 167 | 168 | /*! 169 | * @brief Instantiates a new DHT_Unified Humidity Class 170 | * @param parent 171 | * Parent Sensor 172 | * @param id 173 | * Sensor id 174 | */ 175 | DHT_Unified::Humidity::Humidity(DHT_Unified *parent, int32_t id) 176 | : _parent(parent), _id(id) {} 177 | 178 | /*! 179 | * @brief Reads the sensor and returns the data as a sensors_event_t 180 | * @param event 181 | * @return always returns true 182 | */ 183 | bool DHT_Unified::Humidity::getEvent(sensors_event_t *event) { 184 | // Clear event definition. 185 | memset(event, 0, sizeof(sensors_event_t)); 186 | // Populate sensor reading values. 187 | event->version = sizeof(sensors_event_t); 188 | event->sensor_id = _id; 189 | event->type = SENSOR_TYPE_RELATIVE_HUMIDITY; 190 | event->timestamp = millis(); 191 | event->relative_humidity = _parent->_dht.readHumidity(); 192 | 193 | return true; 194 | } 195 | 196 | /*! 197 | * @brief Provides the sensor_t data for this sensor 198 | * @param sensor 199 | */ 200 | void DHT_Unified::Humidity::getSensor(sensor_t *sensor) { 201 | // Clear sensor definition. 202 | memset(sensor, 0, sizeof(sensor_t)); 203 | // Set sensor name. 204 | _parent->setName(sensor); 205 | // Set version and ID 206 | sensor->version = DHT_SENSOR_VERSION; 207 | sensor->sensor_id = _id; 208 | // Set type and characteristics. 209 | sensor->type = SENSOR_TYPE_RELATIVE_HUMIDITY; 210 | _parent->setMinDelay(sensor); 211 | switch (_parent->_type) { 212 | case DHT11: 213 | sensor->max_value = 80.0F; 214 | sensor->min_value = 20.0F; 215 | sensor->resolution = 5.0F; 216 | break; 217 | case DHT12: 218 | sensor->max_value = 95.0F; 219 | sensor->min_value = 20.0F; 220 | sensor->resolution = 5.0F; 221 | break; 222 | case DHT21: 223 | sensor->max_value = 100.0F; 224 | sensor->min_value = 0.0F; 225 | sensor->resolution = 0.1F; 226 | break; 227 | case DHT22: 228 | sensor->max_value = 100.0F; 229 | sensor->min_value = 0.0F; 230 | sensor->resolution = 0.1F; 231 | break; 232 | default: 233 | // Unknown type, default to 0. 234 | sensor->max_value = 0.0F; 235 | sensor->min_value = 0.0F; 236 | sensor->resolution = 0.0F; 237 | break; 238 | } 239 | } 240 | -------------------------------------------------------------------------------- /Library Arduino/DHT_sensor_library/DHT_U.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file DHT_U.h 3 | * 4 | * DHT Temperature & Humidity Unified Sensor Library 5 | * 6 | * Adafruit invests time and resources providing this open source code, 7 | * please support Adafruit andopen-source hardware by purchasing products 8 | * from Adafruit! 9 | * 10 | * Written by Tony DiCola (Adafruit Industries) 2014. 11 | * 12 | * MIT license, all text above must be included in any redistribution 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a copy 15 | * of this software and associated documentation files (the "Software"), to 16 | * deal in the Software without restriction, including without limitation the 17 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 18 | * sell copies of the Software, and to permit persons to whom the Software is 19 | * furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included in 22 | * all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 30 | * IN THE SOFTWARE. 31 | */ 32 | 33 | #ifndef DHT_U_H 34 | #define DHT_U_H 35 | 36 | #include 37 | #include 38 | 39 | #define DHT_SENSOR_VERSION 1 /**< Sensor Version */ 40 | 41 | /*! 42 | * @brief Class that stores state and functions for interacting with 43 | * DHT_Unified. 44 | */ 45 | class DHT_Unified { 46 | public: 47 | DHT_Unified(uint8_t pin, uint8_t type, uint8_t count = 6, 48 | int32_t tempSensorId = -1, int32_t humiditySensorId = -1); 49 | void begin(); 50 | 51 | /*! 52 | * @brief Class that stores state and functions about Temperature 53 | */ 54 | class Temperature : public Adafruit_Sensor { 55 | public: 56 | Temperature(DHT_Unified *parent, int32_t id); 57 | bool getEvent(sensors_event_t *event); 58 | void getSensor(sensor_t *sensor); 59 | 60 | private: 61 | DHT_Unified *_parent; 62 | int32_t _id; 63 | }; 64 | 65 | /*! 66 | * @brief Class that stores state and functions about Humidity 67 | */ 68 | class Humidity : public Adafruit_Sensor { 69 | public: 70 | Humidity(DHT_Unified *parent, int32_t id); 71 | bool getEvent(sensors_event_t *event); 72 | void getSensor(sensor_t *sensor); 73 | 74 | private: 75 | DHT_Unified *_parent; 76 | int32_t _id; 77 | }; 78 | 79 | /*! 80 | * @brief Returns temperature stored in _temp 81 | * @return Temperature value 82 | */ 83 | Temperature temperature() { return _temp; } 84 | 85 | /*! 86 | * @brief Returns humidity stored in _humidity 87 | * @return Humidity value 88 | */ 89 | Humidity humidity() { return _humidity; } 90 | 91 | private: 92 | DHT _dht; 93 | uint8_t _type; 94 | Temperature _temp; 95 | Humidity _humidity; 96 | 97 | void setName(sensor_t *sensor); 98 | void setMinDelay(sensor_t *sensor); 99 | }; 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /Library Arduino/DHT_sensor_library/README.md: -------------------------------------------------------------------------------- 1 | # DHT sensor library [![Build Status](https://github.com/adafruit/DHT-sensor-library/workflows/Arduino%20Library%20CI/badge.svg)](https://github.com/adafruit/DHT-sensor-library/actions) 2 | 3 | ## Description 4 | 5 | An Arduino library for the DHT series of low-cost temperature/humidity sensors. 6 | 7 | You can find DHT tutorials [here](https://learn.adafruit.com/dht). 8 | 9 | # Dependencies 10 | * [Adafruit Unified Sensor Driver](https://github.com/adafruit/Adafruit_Sensor) 11 | 12 | # Contributing 13 | 14 | Contributions are welcome! Not only you’ll encourage the development of the library, but you’ll also learn how to best use the library and probably some C++ too 15 | 16 | Please read our [Code of Conduct](https://github.com/adafruit/DHT-sensor-library/blob/master/CODE_OF_CONDUCT.md>) 17 | before contributing to help this project stay welcoming. 18 | 19 | ## Documentation and doxygen 20 | Documentation is produced by doxygen. Contributions should include documentation for any new code added. 21 | 22 | Some examples of how to use doxygen can be found in these guide pages: 23 | 24 | https://learn.adafruit.com/the-well-automated-arduino-library/doxygen 25 | 26 | https://learn.adafruit.com/the-well-automated-arduino-library/doxygen-tips 27 | 28 | Written by Adafruit Industries based on work by: 29 | 30 | * T. DiCola 31 | * P. Y. Dragon 32 | * L. Fried 33 | * J. Hoffmann 34 | * M. Kooijman 35 | * J. M. Dana 36 | * S. Conaway 37 | * S. IJskes 38 | * T. Forbes 39 | * B. C 40 | * T. J Myers 41 | * L. Sørup 42 | * per1234 43 | * O. Duffy 44 | * matthiasdanner 45 | * J. Lim 46 | * G. Ambrozio 47 | * chelmi 48 | * adams13x13 49 | * Spacefish 50 | * I. Scheller 51 | * C. Miller 52 | * 7eggert 53 | 54 | 55 | MIT license, check license.txt for more information 56 | All text above must be included in any redistribution 57 | 58 | To install, use the Arduino Library Manager and search for "DHT sensor library" and install the library. 59 | -------------------------------------------------------------------------------- /Library Arduino/DHT_sensor_library/code-of-conduct.md: -------------------------------------------------------------------------------- 1 | # Adafruit Community Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and leaders pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level or type of 9 | experience, education, socio-economic status, nationality, personal appearance, 10 | race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | We are committed to providing a friendly, safe and welcoming environment for 15 | all. 16 | 17 | Examples of behavior that contributes to creating a positive environment 18 | include: 19 | 20 | * Be kind and courteous to others 21 | * Using welcoming and inclusive language 22 | * Being respectful of differing viewpoints and experiences 23 | * Collaborating with other community members 24 | * Gracefully accepting constructive criticism 25 | * Focusing on what is best for the community 26 | * Showing empathy towards other community members 27 | 28 | Examples of unacceptable behavior by participants include: 29 | 30 | * The use of sexualized language or imagery and sexual attention or advances 31 | * The use of inappropriate images, including in a community member's avatar 32 | * The use of inappropriate language, including in a community member's nickname 33 | * Any spamming, flaming, baiting or other attention-stealing behavior 34 | * Excessive or unwelcome helping; answering outside the scope of the question 35 | asked 36 | * Trolling, insulting/derogatory comments, and personal or political attacks 37 | * Public or private harassment 38 | * Publishing others' private information, such as a physical or electronic 39 | address, without explicit permission 40 | * Other conduct which could reasonably be considered inappropriate 41 | 42 | The goal of the standards and moderation guidelines outlined here is to build 43 | and maintain a respectful community. We ask that you don’t just aim to be 44 | "technically unimpeachable", but rather try to be your best self. 45 | 46 | We value many things beyond technical expertise, including collaboration and 47 | supporting others within our community. Providing a positive experience for 48 | other community members can have a much more significant impact than simply 49 | providing the correct answer. 50 | 51 | ## Our Responsibilities 52 | 53 | Project leaders are responsible for clarifying the standards of acceptable 54 | behavior and are expected to take appropriate and fair corrective action in 55 | response to any instances of unacceptable behavior. 56 | 57 | Project leaders have the right and responsibility to remove, edit, or 58 | reject messages, comments, commits, code, issues, and other contributions 59 | that are not aligned to this Code of Conduct, or to ban temporarily or 60 | permanently any community member for other behaviors that they deem 61 | inappropriate, threatening, offensive, or harmful. 62 | 63 | ## Moderation 64 | 65 | Instances of behaviors that violate the Adafruit Community Code of Conduct 66 | may be reported by any member of the community. Community members are 67 | encouraged to report these situations, including situations they witness 68 | involving other community members. 69 | 70 | You may report in the following ways: 71 | 72 | In any situation, you may send an email to . 73 | 74 | On the Adafruit Discord, you may send an open message from any channel 75 | to all Community Helpers by tagging @community helpers. You may also send an 76 | open message from any channel, or a direct message to @kattni#1507, 77 | @tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or 78 | @Andon#8175. 79 | 80 | Email and direct message reports will be kept confidential. 81 | 82 | In situations on Discord where the issue is particularly egregious, possibly 83 | illegal, requires immediate action, or violates the Discord terms of service, 84 | you should also report the message directly to Discord. 85 | 86 | These are the steps for upholding our community’s standards of conduct. 87 | 88 | 1. Any member of the community may report any situation that violates the 89 | Adafruit Community Code of Conduct. All reports will be reviewed and 90 | investigated. 91 | 2. If the behavior is an egregious violation, the community member who 92 | committed the violation may be banned immediately, without warning. 93 | 3. Otherwise, moderators will first respond to such behavior with a warning. 94 | 4. Moderators follow a soft "three strikes" policy - the community member may 95 | be given another chance, if they are receptive to the warning and change their 96 | behavior. 97 | 5. If the community member is unreceptive or unreasonable when warned by a 98 | moderator, or the warning goes unheeded, they may be banned for a first or 99 | second offense. Repeated offenses will result in the community member being 100 | banned. 101 | 102 | ## Scope 103 | 104 | This Code of Conduct and the enforcement policies listed above apply to all 105 | Adafruit Community venues. This includes but is not limited to any community 106 | spaces (both public and private), the entire Adafruit Discord server, and 107 | Adafruit GitHub repositories. Examples of Adafruit Community spaces include 108 | but are not limited to meet-ups, audio chats on the Adafruit Discord, or 109 | interaction at a conference. 110 | 111 | This Code of Conduct applies both within project spaces and in public spaces 112 | when an individual is representing the project or its community. As a community 113 | member, you are representing our community, and are expected to behave 114 | accordingly. 115 | 116 | ## Attribution 117 | 118 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 119 | version 1.4, available at 120 | , 121 | and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html). 122 | 123 | For other projects adopting the Adafruit Community Code of 124 | Conduct, please contact the maintainers of those projects for enforcement. 125 | If you wish to use this code of conduct for your own project, consider 126 | explicitly mentioning your moderation policy or making a copy with your 127 | own moderation policy so as to avoid confusion. 128 | -------------------------------------------------------------------------------- /Library Arduino/DHT_sensor_library/examples/DHT_Unified_Sensor/DHT_Unified_Sensor.ino: -------------------------------------------------------------------------------- 1 | // DHT Temperature & Humidity Sensor 2 | // Unified Sensor Library Example 3 | // Written by Tony DiCola for Adafruit Industries 4 | // Released under an MIT license. 5 | 6 | // REQUIRES the following Arduino libraries: 7 | // - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library 8 | // - Adafruit Unified Sensor Lib: https://github.com/adafruit/Adafruit_Sensor 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #define DHTPIN 2 // Digital pin connected to the DHT sensor 15 | // Feather HUZZAH ESP8266 note: use pins 3, 4, 5, 12, 13 or 14 -- 16 | // Pin 15 can work but DHT must be disconnected during program upload. 17 | 18 | // Uncomment the type of sensor in use: 19 | //#define DHTTYPE DHT11 // DHT 11 20 | #define DHTTYPE DHT22 // DHT 22 (AM2302) 21 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 22 | 23 | // See guide for details on sensor wiring and usage: 24 | // https://learn.adafruit.com/dht/overview 25 | 26 | DHT_Unified dht(DHTPIN, DHTTYPE); 27 | 28 | uint32_t delayMS; 29 | 30 | void setup() { 31 | Serial.begin(9600); 32 | // Initialize device. 33 | dht.begin(); 34 | Serial.println(F("DHTxx Unified Sensor Example")); 35 | // Print temperature sensor details. 36 | sensor_t sensor; 37 | dht.temperature().getSensor(&sensor); 38 | Serial.println(F("------------------------------------")); 39 | Serial.println(F("Temperature Sensor")); 40 | Serial.print (F("Sensor Type: ")); Serial.println(sensor.name); 41 | Serial.print (F("Driver Ver: ")); Serial.println(sensor.version); 42 | Serial.print (F("Unique ID: ")); Serial.println(sensor.sensor_id); 43 | Serial.print (F("Max Value: ")); Serial.print(sensor.max_value); Serial.println(F("°C")); 44 | Serial.print (F("Min Value: ")); Serial.print(sensor.min_value); Serial.println(F("°C")); 45 | Serial.print (F("Resolution: ")); Serial.print(sensor.resolution); Serial.println(F("°C")); 46 | Serial.println(F("------------------------------------")); 47 | // Print humidity sensor details. 48 | dht.humidity().getSensor(&sensor); 49 | Serial.println(F("Humidity Sensor")); 50 | Serial.print (F("Sensor Type: ")); Serial.println(sensor.name); 51 | Serial.print (F("Driver Ver: ")); Serial.println(sensor.version); 52 | Serial.print (F("Unique ID: ")); Serial.println(sensor.sensor_id); 53 | Serial.print (F("Max Value: ")); Serial.print(sensor.max_value); Serial.println(F("%")); 54 | Serial.print (F("Min Value: ")); Serial.print(sensor.min_value); Serial.println(F("%")); 55 | Serial.print (F("Resolution: ")); Serial.print(sensor.resolution); Serial.println(F("%")); 56 | Serial.println(F("------------------------------------")); 57 | // Set delay between sensor readings based on sensor details. 58 | delayMS = sensor.min_delay / 1000; 59 | } 60 | 61 | void loop() { 62 | // Delay between measurements. 63 | delay(delayMS); 64 | // Get temperature event and print its value. 65 | sensors_event_t event; 66 | dht.temperature().getEvent(&event); 67 | if (isnan(event.temperature)) { 68 | Serial.println(F("Error reading temperature!")); 69 | } 70 | else { 71 | Serial.print(F("Temperature: ")); 72 | Serial.print(event.temperature); 73 | Serial.println(F("°C")); 74 | } 75 | // Get humidity event and print its value. 76 | dht.humidity().getEvent(&event); 77 | if (isnan(event.relative_humidity)) { 78 | Serial.println(F("Error reading humidity!")); 79 | } 80 | else { 81 | Serial.print(F("Humidity: ")); 82 | Serial.print(event.relative_humidity); 83 | Serial.println(F("%")); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Library Arduino/DHT_sensor_library/examples/DHTtester/DHTtester.ino: -------------------------------------------------------------------------------- 1 | // Example testing sketch for various DHT humidity/temperature sensors 2 | // Written by ladyada, public domain 3 | 4 | // REQUIRES the following Arduino libraries: 5 | // - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library 6 | // - Adafruit Unified Sensor Lib: https://github.com/adafruit/Adafruit_Sensor 7 | 8 | #include "DHT.h" 9 | 10 | #define DHTPIN 2 // Digital pin connected to the DHT sensor 11 | // Feather HUZZAH ESP8266 note: use pins 3, 4, 5, 12, 13 or 14 -- 12 | // Pin 15 can work but DHT must be disconnected during program upload. 13 | 14 | // Uncomment whatever type you're using! 15 | //#define DHTTYPE DHT11 // DHT 11 16 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 17 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 18 | 19 | // Connect pin 1 (on the left) of the sensor to +5V 20 | // NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 21 | // to 3.3V instead of 5V! 22 | // Connect pin 2 of the sensor to whatever your DHTPIN is 23 | // Connect pin 3 (on the right) of the sensor to GROUND (if your sensor has 3 pins) 24 | // Connect pin 4 (on the right) of the sensor to GROUND and leave the pin 3 EMPTY (if your sensor has 4 pins) 25 | // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor 26 | 27 | // Initialize DHT sensor. 28 | // Note that older versions of this library took an optional third parameter to 29 | // tweak the timings for faster processors. This parameter is no longer needed 30 | // as the current DHT reading algorithm adjusts itself to work on faster procs. 31 | DHT dht(DHTPIN, DHTTYPE); 32 | 33 | void setup() { 34 | Serial.begin(9600); 35 | Serial.println(F("DHTxx test!")); 36 | 37 | dht.begin(); 38 | } 39 | 40 | void loop() { 41 | // Wait a few seconds between measurements. 42 | delay(2000); 43 | 44 | // Reading temperature or humidity takes about 250 milliseconds! 45 | // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 46 | float h = dht.readHumidity(); 47 | // Read temperature as Celsius (the default) 48 | float t = dht.readTemperature(); 49 | // Read temperature as Fahrenheit (isFahrenheit = true) 50 | float f = dht.readTemperature(true); 51 | 52 | // Check if any reads failed and exit early (to try again). 53 | if (isnan(h) || isnan(t) || isnan(f)) { 54 | Serial.println(F("Failed to read from DHT sensor!")); 55 | return; 56 | } 57 | 58 | // Compute heat index in Fahrenheit (the default) 59 | float hif = dht.computeHeatIndex(f, h); 60 | // Compute heat index in Celsius (isFahreheit = false) 61 | float hic = dht.computeHeatIndex(t, h, false); 62 | 63 | Serial.print(F("Humidity: ")); 64 | Serial.print(h); 65 | Serial.print(F("% Temperature: ")); 66 | Serial.print(t); 67 | Serial.print(F("°C ")); 68 | Serial.print(f); 69 | Serial.print(F("°F Heat index: ")); 70 | Serial.print(hic); 71 | Serial.print(F("°C ")); 72 | Serial.print(hif); 73 | Serial.println(F("°F")); 74 | } 75 | -------------------------------------------------------------------------------- /Library Arduino/DHT_sensor_library/keywords.txt: -------------------------------------------------------------------------------- 1 | ########################################### 2 | # Syntax Coloring Map For DHT-sensor-library 3 | ########################################### 4 | 5 | ########################################### 6 | # Datatypes (KEYWORD1) 7 | ########################################### 8 | 9 | DHT KEYWORD1 10 | 11 | ########################################### 12 | # Methods and Functions (KEYWORD2) 13 | ########################################### 14 | 15 | begin KEYWORD2 16 | readTemperature KEYWORD2 17 | convertCtoF KEYWORD2 18 | convertFtoC KEYWORD2 19 | computeHeatIndex KEYWORD2 20 | readHumidity KEYWORD2 21 | read KEYWORD2 22 | 23 | -------------------------------------------------------------------------------- /Library Arduino/DHT_sensor_library/library.properties: -------------------------------------------------------------------------------- 1 | name=DHT sensor library 2 | version=1.4.2 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Arduino library for DHT11, DHT22, etc Temp & Humidity Sensors 6 | paragraph=Arduino library for DHT11, DHT22, etc Temp & Humidity Sensors 7 | category=Sensors 8 | url=https://github.com/adafruit/DHT-sensor-library 9 | architectures=* 10 | depends=Adafruit Unified Sensor 11 | -------------------------------------------------------------------------------- /Library Arduino/DHT_sensor_library/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 Adafruit Industries 2 | 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 20 | OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/.gitignore: -------------------------------------------------------------------------------- 1 | MFRC522.zip 2 | 3 | # ignore IDE files 4 | .idea 5 | cmake 6 | CMakeLists.txt -------------------------------------------------------------------------------- /Library Arduino/rfid-master/.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "2.7" 4 | 5 | # Cache PlatformIO packages using Travis CI container-based infrastructure 6 | sudo: false 7 | cache: 8 | directories: 9 | - "~/.platformio" 10 | 11 | env: 12 | # add examples here and define which boards should be tested (only compile test) 13 | - PLATFORMIO_CI_SRC=examples/ChangeUID/ChangeUID.ino TESTBOARD=arduino_avr,arduino_arm,teensy,esp 14 | - PLATFORMIO_CI_SRC=examples/DumpInfo/DumpInfo.ino TESTBOARD=arduino_avr,arduino_arm,teensy,esp 15 | - PLATFORMIO_CI_SRC=examples/firmware_check/firmware_check.ino TESTBOARD=arduino_avr,arduino_arm,teensy,esp 16 | - PLATFORMIO_CI_SRC=examples/FixBrickedUID/FixBrickedUID.ino TESTBOARD=arduino_avr,arduino_arm,teensy,esp 17 | - PLATFORMIO_CI_SRC=examples/MifareClassicValueBlock/MifareClassicValueBlock.ino TESTBOARD=arduino_avr,arduino_arm,teensy,esp 18 | - PLATFORMIO_CI_SRC=examples/MinimalInterrupt/MinimalInterrupt.ino TESTBOARD=arduino_avr,arduino_arm,teensy,esp 19 | - PLATFORMIO_CI_SRC=examples/ReadAndWrite/ReadAndWrite.ino TESTBOARD=arduino_avr,arduino_arm,teensy,esp 20 | - PLATFORMIO_CI_SRC=examples/ReadUidMultiReader/ReadUidMultiReader.ino TESTBOARD=arduino_avr,arduino_arm,teensy,esp 21 | - PLATFORMIO_CI_SRC=examples/rfid_default_keys/rfid_default_keys.ino TESTBOARD=arduino_avr,arduino_arm,teensy,esp 22 | - PLATFORMIO_CI_SRC=examples/rfid_write_personal_data/rfid_write_personal_data.ino TESTBOARD=arduino_avr,arduino_arm,teensy,esp 23 | - PLATFORMIO_CI_SRC=examples/Ntag216_AUTH/Ntag216_AUTH.ino TESTBOARD=arduino_avr,arduino_arm,teensy,esp 24 | - PLATFORMIO_CI_SRC=examples/ReadNUID/ReadNUID.ino TESTBOARD=arduino_avr,arduino_arm,teensy,esp 25 | - PLATFORMIO_CI_SRC=examples/AccessControl/AccessControl.ino TESTBOARD=arduino_avr,teensy 26 | - PLATFORMIO_CI_SRC=examples/RFID-Cloner/RFID-Cloner.ino TESTBOARD=arduino_avr,arduino_arm,teensy,esp 27 | 28 | install: 29 | - pip install -U platformio 30 | 31 | script: 32 | # short the string comparison 33 | - stringContain() { [ -z "${2##*$1*}" ]; } 34 | # selectable board tests @Rotzbua 35 | # prints only warnings and errors, to show all remove "1>/dev/null" 36 | - board="arduino_avr"; if stringContain "$board" "$TESTBOARD"; then echo "check board $board"; platformio ci --lib=. --board=uno --board=megaatmega1280 1>/dev/null; else echo "skip board test of $board"; fi 37 | - board="arduino_arm"; if stringContain "$board" "$TESTBOARD"; then echo "check board $board"; platformio ci --lib=. --board=due --board=zero 1>/dev/null; else echo "skip board test of $board"; fi 38 | - board="teensy"; if stringContain "$board" "$TESTBOARD"; then echo "check board $board"; platformio ci --lib=. --board=teensy20 --board=teensy31 1>/dev/null; else echo "skip board test of $board"; fi 39 | - board="esp"; if stringContain "$board" "$TESTBOARD"; then echo "check board $board"; platformio ci --lib=. --board=d1_mini 1>/dev/null; else echo "skip board test of $board"; fi 40 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for MFRC522 library 2 | # 3 | 4 | all: package 5 | 6 | help: 7 | @echo "Please use \`make ' where is one of" 8 | @echo " clean to clean the project (e.g. remove process files)" 9 | @echo " package to package the library (into a zip file)" 10 | 11 | clean: 12 | rm ./MFRC522.zip 13 | @echo 14 | @echo "Clean finished." 15 | 16 | package: 17 | zip -o ./MFRC522.zip ./MFRC522.h ./MFRC522.cpp 18 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/README.rst: -------------------------------------------------------------------------------- 1 | MFRC522 2 | ======= 3 | 4 | .. image:: https://travis-ci.org/miguelbalboa/rfid.svg?branch=master 5 | :target: https://travis-ci.org/miguelbalboa/rfid 6 | 7 | Arduino library for MFRC522 and other RFID RC522 based modules. 8 | 9 | Read and write different types of Radio-Frequency IDentification (RFID) cards 10 | on your Arduino using a RC522 based reader connected via the Serial Peripheral 11 | Interface (SPI) interface. 12 | 13 | 14 | .. _development: 15 | Development 16 | ---------- 17 | **The development by owner miguelbalboa has ended**. Further development will be done by community. This library is still maintained by miguelbalboa, so make pull request if you like some new features or fixes. Support/issues should be solved by community. 18 | 19 | 20 | .. _what works and not: 21 | What works and not? 22 | ---------- 23 | 24 | * **Works** 25 | 26 | #. Communication (Crypto1) with MIFARE Classic (1k, 4k, Mini). 27 | #. Communication (Crypto1) with MIFARE Classic compatible PICCs. 28 | #. Firmware self check of MFRC522. 29 | #. Set the UID, write to sector 0, and unbrick Chinese UID changeable MIFARE cards. 30 | 31 | * **Partial** 32 | 33 | #. Communication with MIFARE Ultralight. 34 | #. Other PICCs (Ntag216). 35 | 36 | * **Works not** 37 | 38 | #. MIFARE DESFire, MIFARE DESFire EV1/EV2, not supported by software. 39 | #. Communication with 3DES or AES, not supported by software. 40 | #. Peer-to-peer (ISO/IEC 18092), not `supported by hardware`_. 41 | #. Communication with smart phone, not `supported by hardware`_. 42 | #. Card emulation, not `supported by hardware`_. 43 | #. Use of IRQ pin. But there is a proof-of-concept example. 44 | #. With Arduino Yun like `#111 `_, not supported by software. 45 | #. Power reduction modes `#269 `_, not supported by software. 46 | #. I2C instead of SPI `#240 `_, not supported by software. 47 | 48 | * **Need more?** 49 | 50 | #. If software: code it and make a pull request. 51 | #. If hardware: buy a more expensive like PN532 (supports NFC and many more, but costs about $15). 52 | 53 | 54 | .. _compatible ide: 55 | Compatible IDE 56 | ---------- 57 | This library works with Arduino IDE 1.6, older versions are **not supported** and will cause compile errors. The built-in library manager is supported. 58 | 59 | If you use your own compiler, you have to enable ``c++11``-support. 60 | 61 | 62 | .. _compatible boards: 63 | Compatible boards 64 | ---------- 65 | 66 | **!!!Only for advanced user!!!** 67 | 68 | This library is compatible to Teensy and ESP8266, if you use board plugin of the Arduino IDE. Not all examples are available for every board. You also have to change pins, see `pin layout`_. 69 | 70 | Some user made some patches/suggestions/ports for other boards: 71 | 72 | * Linux: https://github.com/miguelbalboa/rfid/pull/216 73 | * chipKIT: https://github.com/miguelbalboa/rfid/pull/230 74 | * ESP8266 (native): https://github.com/miguelbalboa/rfid/pull/235 75 | * LPCOPen (in C): https://github.com/miguelbalboa/rfid/pull/258 76 | 77 | Note that the main target/support of library is still Arduino. 78 | 79 | .. _support issue: 80 | Support/issue 81 | ---------- 82 | 1. First checkout `what works and not`_ and `troubleshooting`_ . 83 | 84 | 2. It seems to be a hardware issue or you need support to program your project? 85 | Please ask in the official `Arduino forum`_, there you would get a much faster answer then on github. 86 | 87 | 3. It seems to be a software issue? 88 | Open an issue on github. 89 | 90 | 91 | .. _code style: 92 | Code style 93 | ---------- 94 | 95 | Please use ``fixed integers``, see `stdint.h`_. Why? This library is compatible to different boards which use different architectures (16bit vs 32bit). So unfixed ``int`` has different sizes on different environments and may cause unpredictable behaviour. 96 | 97 | 98 | .. _pin layout: 99 | Pin Layout 100 | ---------- 101 | 102 | The following table shows the typical pin layout used: 103 | 104 | +-----------+----------+---------------------------------------------------------------+--------------------------+ 105 | | | PCD | Arduino | Teensy | 106 | | +----------+-------------+---------+---------+-----------------+-----------+--------+--------+--------+ 107 | | | MFRC522 | Uno / 101 | Mega | Nano v3 |Leonardo / Micro | Pro Micro | 2.0 | ++ 2.0 | 3.1 | 108 | +-----------+----------+-------------+---------+---------+-----------------+-----------+--------+--------+--------+ 109 | | Signal | Pin | Pin | Pin | Pin | Pin | Pin | Pin | Pin | Pin | 110 | +===========+==========+=============+=========+=========+=================+===========+========+========+========+ 111 | | RST/Reset | RST | 9 [1]_ | 5 [1]_ | D9 | RESET / ICSP-5 | RST | 7 | 4 | 9 | 112 | +-----------+----------+-------------+---------+---------+-----------------+-----------+--------+--------+--------+ 113 | | SPI SS | SDA [3]_ | 10 [2]_ | 53 [2]_ | D10 | 10 | 10 | 0 | 20 | 10 | 114 | +-----------+----------+-------------+---------+---------+-----------------+-----------+--------+--------+--------+ 115 | | SPI MOSI | MOSI | 11 / ICSP-4 | 51 | D11 | ICSP-4 | 16 | 2 | 22 | 11 | 116 | +-----------+----------+-------------+---------+---------+-----------------+-----------+--------+--------+--------+ 117 | | SPI MISO | MISO | 12 / ICSP-1 | 50 | D12 | ICSP-1 | 14 | 3 | 23 | 12 | 118 | +-----------+----------+-------------+---------+---------+-----------------+-----------+--------+--------+--------+ 119 | | SPI SCK | SCK | 13 / ICSP-3 | 52 | D13 | ICSP-3 | 15 | 1 | 21 | 13 | 120 | +-----------+----------+-------------+---------+---------+-----------------+-----------+--------+--------+--------+ 121 | 122 | .. [1] Configurable, typically defined as RST_PIN in sketch/program. 123 | .. [2] Configurable, typically defined as SS_PIN in sketch/program. 124 | .. [3] The SDA pin might be labeled SS on some/older MFRC522 boards. 125 | 126 | 127 | .. _hardware: 128 | Hardware 129 | -------- 130 | 131 | There are three hardware components involved: 132 | 133 | 1. **Micro Controller**: 134 | 135 | * An `Arduino`_ or compatible executing the Sketch using this library. 136 | 137 | * Prices vary from USD 7 for clones, to USD 75 for "starter kits" (which 138 | might be a good choice if this is your first exposure to Arduino; 139 | check if such kit already includes the Arduino, Reader, and some Tags). 140 | 141 | 2. **Proximity Coupling Device (PCD)**: 142 | 143 | * The PCD is the actual RFID **Reader** based on `NXP MFRC522`_ Contactless 144 | Reader Integrated Circuit). 145 | 146 | * Readers can be found on `eBay`_ for around USD 5: search for *"rc522"*. 147 | 148 | * You can also find them at several web stores, they are often included in 149 | *"starter kits"*; so check your favourite electronics provider as well. 150 | 151 | 3. **Proximity Integrated Circuit Card (PICC)**: 152 | 153 | * The PICC is the RFID **Card** or **Tag** using the `ISO/IEC 14443A`_ 154 | interface, for example Mifare or NTAG203. 155 | 156 | * One or two might be included with the Reader or *"starter kit"* already. 157 | 158 | 159 | .. _protocol: 160 | Protocols 161 | --------- 162 | 163 | 1. The micro controller and the reader use SPI for communication. 164 | 165 | * The protocol is described in the `NXP MFRC522`_ datasheet. 166 | 167 | * See the `Pin Layout`_ section for details on connecting the pins. 168 | 169 | 2. The reader and the tags communicate using a 13.56 MHz electromagnetic field. 170 | 171 | * The protocol is defined in ISO/IEC 14443-3:2011 Part 3 Type A. 172 | 173 | * Details are found in chapter 6 *"Type A – Initialization and anticollision"*. 174 | 175 | * See http://wg8.de/wg8n1496_17n3613_Ballot_FCD14443-3.pdf for a free version 176 | of the final draft (which might be outdated in some areas). 177 | 178 | * The reader does not support ISO/IEC 14443-3 Type B. 179 | 180 | 181 | .. _security: 182 | Security 183 | ------- 184 | This library only supports crypto1-encrypted communication. Crypto1 has been known as `broken`_ for a few years, so it does NOT offer ANY security, it is virtually unencrypted communication. **Do not use it for any security related applications!** 185 | 186 | This library does not offer 3DES or AES authentication used by cards like the Mifare DESFire, it may be possible to be implemented because the datasheet says there is support. We hope for pull requests :). 187 | 188 | 189 | .. _troubleshooting: 190 | Troubleshooting 191 | ------- 192 | 193 | * **I don't get input from reader** or **WARNING: Communication failure, is the MFRC522 properly connected?** 194 | 195 | #. Check your connection, see `Pin Layout`_ . 196 | #. Check voltage. Most breakouts work with 3.3V. 197 | #. SPI only works with 3.3V, most breakouts seem 5V tollerant, but try a level shifter. 198 | #. According to reports #101, #126 and #131, there may be a problem with the soldering on the MFRC522 breakout. You could fix this on your own. 199 | 200 | 201 | * **Sometimes I get timeouts** or **sometimes tag/card does not work.** 202 | 203 | #. Try other side of the antenna. 204 | #. Try to decrease distance between MFRC522. 205 | #. Increase antenna gain per firmware: ``mfrc522.PCD_SetAntennaGain(mfrc522.RxGain_max);`` 206 | #. Use better power supply. 207 | #. Hardware may be corrupted, most products are from china and sometimes the quality is really poor. Contact your seller. 208 | 209 | 210 | * **My tag/card doesn't work.** 211 | 212 | #. Distance between antenna and token too large (>1cm). 213 | #. You got the wrong type PICC. Is it really 13.56 MHz? Is it really a Mifare Type A? 214 | #. NFC tokens are not supported. Some may work. 215 | #. Animal RFID tags are not supported. They use a different frequency (125 kHz). 216 | #. Hardware may be corrupted, most products are from china and sometimes the quality is really poor. Contact your seller. 217 | #. Newer versions of Mifare cards like DESFire/Ultralight maybe not work according to missing authentification, see `security`_ or different `protocol`_. 218 | #. Some boards bought from chinese manufactures do not use the best components and this can affect the detection of different types of tag/card. In some of these boards, the L1 and L2 inductors do not have a high enough current so the signal generated is not enough to get Ultralight C and NTAG203 tags to work, replacing those with same inductance (2.2uH) but higher operating current inductors should make things work smoothly. Also, in some of those boards the harmonic and matching circuit needs to be tuned, for this replace C4 and C5 with 33pf capacitors and you are all set. (Source: `Mikro Elektronika`_) 219 | 220 | * **My mobile phone doesn't recognize the MFRC522** or **my MFRC522 can't read data from other MFRC522** 221 | 222 | #. Card simmulation is not supported. 223 | #. Communication with mobile phones is not supported. 224 | #. Peer to peer communication is not supported. 225 | 226 | 227 | * **I need more features.** 228 | 229 | #. If software: code it and make a pull request. 230 | #. If hardware: buy a more expensive like PN532 (supports NFC and many more, but costs about $15) 231 | 232 | 233 | .. _license: 234 | License 235 | ------- 236 | This is free and unencumbered software released into the public domain. 237 | 238 | Anyone is free to copy, modify, publish, use, compile, sell, or 239 | distribute this software, either in source code form or as a compiled 240 | binary, for any purpose, commercial or non-commercial, and by any 241 | means. 242 | 243 | In jurisdictions that recognize copyright laws, the author or authors 244 | of this software dedicate any and all copyright interest in the 245 | software to the public domain. We make this dedication for the benefit 246 | of the public at large and to the detriment of our heirs and 247 | successors. We intend this dedication to be an overt act of 248 | relinquishment in perpetuity of all present and future rights to this 249 | software under copyright law. 250 | 251 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 252 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 253 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 254 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 255 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 256 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 257 | OTHER DEALINGS IN THE SOFTWARE. 258 | 259 | For more information, please refer to https://unlicense.org/ 260 | 261 | 262 | History 263 | ------- 264 | 265 | The MFRC522 library was first created in Jan 2012 by Miguel Balboa (from 266 | http://circuitito.com) based on code by Dr. Leong (from http://B2CQSHOP.com) 267 | for *"Arduino RFID module Kit 13.56 Mhz with Tags SPI W and R By COOQRobot"*. 268 | 269 | It was translated into English and rewritten/refactored in the fall of 2013 270 | by Søren Thing Andersen (from http://access.thing.dk). 271 | 272 | It has been extended with functionality to alter sector 0 on Chinese UID changeable MIFARE card in Oct 2014 by Tom Clement (from http://tomclement.nl). 273 | 274 | 275 | .. _arduino: https://arduino.cc/ 276 | .. _ebay: https://www.ebay.com/ 277 | .. _iso/iec 14443a: https://en.wikipedia.org/wiki/ISO/IEC_14443 278 | .. _iso/iec 14443-3\:2011 part 3: 279 | .. _nxp mfrc522: https://www.nxp.com/documents/data_sheet/MFRC522.pdf 280 | .. _broken: https://eprint.iacr.org/2008/166 281 | .. _supported by hardware: https://web.archive.org/web/20151210045625/http://www.nxp.com/documents/leaflet/939775017564.pdf 282 | .. _Arduino forum: https://forum.arduino.cc 283 | .. _stdint.h: https://en.wikibooks.org/wiki/C_Programming/C_Reference/stdint.h 284 | .. _Mikro Elektronika: https://forum.mikroe.com/viewtopic.php?f=147&t=64203 285 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/UNLICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to -------------------------------------------------------------------------------- /Library Arduino/rfid-master/changes.txt: -------------------------------------------------------------------------------- 1 | -- Add changes to unreleased tag until we make a release. 2 | 3 | unreleased 4 | - tba 5 | 6 | 3 Jan 2017, v1.2.0 7 | - Warning: This version introduce usage of stdint.h, usage of not well defined int types are abandoned. 8 | Interface has changed: e.g. long -> int32_t 9 | @Rotzbua 10 | - Removed problematic example examples/servo_motor/servo_motor.ino @omersiar 11 | - Added examples/AccessControl/AccessControl.ino @omersiar 12 | - Fixed minor issues reported in #211 @omersiar 13 | - Added bad components hint to README @danielcbit 14 | - Fixed selftest @surr 15 | - Fixed auth problem with long UIDs @surr 16 | 17 | 26 Aug 2016, v1.1.9 18 | - Warning: Only Arduino IDE version 1.6 is supported, please update your IDE to 1.6 to use this Library. 19 | - Added ESP8266 platform support @Rotzbua 20 | - Changed README.rst content to show more info @Rotzbua 21 | - Minor Changes to examples/ReadUidMultiReader/ReadUidMultiReader.ino example @Rotzbua 22 | 23 | 11 Feb 2016, v1.1.8 24 | - Added examples/MinimalInterrupt/MinimalInterrupt.ino example, Interrupt example @lmmeng 25 | - Added .gitignore file allows the project to be more easily used as a subproject. @BenWiederhake 26 | - Added Added Teensy 2.0 & Tensy++ 2.0 pinouts to README.rst @jkutianski 27 | 28 | 16 Jan 2016, v1.1.7 29 | - README.rst Spelling and Grammar Tweak @cuthbertnibbles 30 | - Added examples/servo_motor/servo_motor.ino example, Arduino RFID Access Control with a Servo Motor @techied 31 | - Added examples/RFID-Cloner/RFID-Cloner.ino Copy from rfid cards with standard authentication @stefanblommaert 32 | - Fix compile error at examples/RFID-Cloner/RFID-Cloner.ino, using MFRC522:::PICC_Type, @Rotzbua 33 | 34 | 06 Jan 2016, v1.1.6 35 | - Fixed compilation error for examples/ReadNUID/ReadNUID.ino example. @Rotzbua 36 | 37 | 04 Jan 2016, v1.1.5 38 | - Use settings functions on SPI libraries, setSPIConfig was deleted, now the library use SPI.beginTransaction() and SPI.endTransaction() @sophiekovalevsky 39 | - Added examples/ReadNUID/ReadNUID.ino example, showing how to read new NUID from a PICC to serial. @sophiekovalevsky 40 | 41 | 03 Jan 2016, v1.1.4 42 | - Added Authentication with Ntag 213,215,216 returns the pACK MFRC522::PCD_NTAG216_AUTH @Gargantuanman 43 | - Starting to use versions http://semver.org/ 44 | - Continuous Integration @ivankravets 45 | - functions return MFRC522::StatusCode and MFRC522::PICC_Type instead of generic byte @rotzbua 46 | - removed int-values of MFRC522::StatusCode and MFRC522::PICC_Type @rotzbua 47 | 48 | 05 Dec 2015 49 | - recognize infineon cards correctly @mayatforest 50 | - added multi reader support, see example @lmmeng 51 | 52 | 10 Nov 2014 53 | - Updated the changelog. 54 | - Added makefile. 55 | 56 | 24 Oct 2014 57 | - Added PlatformIO-based manifest file. 58 | 59 | 17 Jul 2014 60 | - Written documentation for the library. 61 | - Added rfid_default_keys example. 62 | 63 | 11 Jun 2014 64 | - Updated example: ReadAndWrite. 65 | 66 | 14 Apr 2014 67 | - Updated examples: DumpInfo, MifareClassicValueBlock, and ReadAndWrite. 68 | 69 | 12 Feb 2014 70 | - Fixed resetPowerDownPin initial state. 71 | 72 | 29 Jan 2014 73 | - Fixed chipSelectPin initial state. 74 | 75 | 30 Nov 2013 76 | - Examples put in their own folders. 77 | - Updated the keywords.txt file. 78 | 79 | 12 Nov 2013 80 | - Updated examples: DumpInfo, MifareClassicValueBlock, and ReadAndWrite. 81 | 82 | 20 Oct 2013 83 | - All constants, functions and parameters are now commented in English. 84 | - Code refactored, most function names have changed. 85 | - Support ISO-14443-3 anti collission and 4/7/10 byte UIDs (cascade levels). 86 | - Added functions for MIFARE Classic Decrement/Increment/Restore/Transfer 87 | and MIFARE Ultralight Write. 88 | - New examples written. 89 | 90 | 19 Oct 2013 91 | - Renamed library from RFID to MFRC522 (RFID seemed to generic). 92 | - Register names changed to comply with datasheet. 93 | - Global defines moved into class. 94 | 95 | 24 Sep 2013 96 | - Turn off encryption when tag is halted. 97 | 98 | 27 Jan 2013 99 | - Added README and small TODO list. 100 | - Added example to show Serial on LCD display. 101 | 102 | 09 Sep 2012 103 | - Initial commit to GitHub. 104 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/doc/fritzing/Arduino-Uno-r3-with-RFID-RC522.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RafyMrX/SISTEM-INFORMASI-ABSENSI-RFID/973ed22a30bb4ce6cd290b889b611c858bb22343/Library Arduino/rfid-master/doc/fritzing/Arduino-Uno-r3-with-RFID-RC522.fzz -------------------------------------------------------------------------------- /Library Arduino/rfid-master/doc/fritzing/Arduino-Uno-r3-with-RFID-RC522.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RafyMrX/SISTEM-INFORMASI-ABSENSI-RFID/973ed22a30bb4ce6cd290b889b611c858bb22343/Library Arduino/rfid-master/doc/fritzing/Arduino-Uno-r3-with-RFID-RC522.png -------------------------------------------------------------------------------- /Library Arduino/rfid-master/doc/fritzing/RFID-RC522 - Pin Layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RafyMrX/SISTEM-INFORMASI-ABSENSI-RFID/973ed22a30bb4ce6cd290b889b611c858bb22343/Library Arduino/rfid-master/doc/fritzing/RFID-RC522 - Pin Layout.png -------------------------------------------------------------------------------- /Library Arduino/rfid-master/doc/fritzing/RFID-RC522-v2.fzpz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RafyMrX/SISTEM-INFORMASI-ABSENSI-RFID/973ed22a30bb4ce6cd290b889b611c858bb22343/Library Arduino/rfid-master/doc/fritzing/RFID-RC522-v2.fzpz -------------------------------------------------------------------------------- /Library Arduino/rfid-master/doc/fritzing/RFID-RC522-v2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RafyMrX/SISTEM-INFORMASI-ABSENSI-RFID/973ed22a30bb4ce6cd290b889b611c858bb22343/Library Arduino/rfid-master/doc/fritzing/RFID-RC522-v2.png -------------------------------------------------------------------------------- /Library Arduino/rfid-master/doc/rfidmifare.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RafyMrX/SISTEM-INFORMASI-ABSENSI-RFID/973ed22a30bb4ce6cd290b889b611c858bb22343/Library Arduino/rfid-master/doc/rfidmifare.doc -------------------------------------------------------------------------------- /Library Arduino/rfid-master/doc/rfidmifare.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RafyMrX/SISTEM-INFORMASI-ABSENSI-RFID/973ed22a30bb4ce6cd290b889b611c858bb22343/Library Arduino/rfid-master/doc/rfidmifare.pdf -------------------------------------------------------------------------------- /Library Arduino/rfid-master/examples/ChangeUID/ChangeUID.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------------------------------------------------- 3 | * Example to change UID of changeable MIFARE card. 4 | * -------------------------------------------------------------------------------------------------------------------- 5 | * This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid 6 | * 7 | * This sample shows how to set the UID on a UID changeable MIFARE card. 8 | * NOTE: for more informations read the README.rst 9 | * 10 | * @author Tom Clement 11 | * @license Released into the public domain. 12 | * 13 | * Typical pin layout used: 14 | * ----------------------------------------------------------------------------------------- 15 | * MFRC522 Arduino Arduino Arduino Arduino Arduino 16 | * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro 17 | * Signal Pin Pin Pin Pin Pin Pin 18 | * ----------------------------------------------------------------------------------------- 19 | * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 20 | * SPI SS SDA(SS) 10 53 D10 10 10 21 | * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 22 | * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 23 | * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | #define RST_PIN 9 // Configurable, see typical pin layout above 30 | #define SS_PIN 10 // Configurable, see typical pin layout above 31 | 32 | MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance 33 | 34 | /* Set your new UID here! */ 35 | #define NEW_UID {0xDE, 0xAD, 0xBE, 0xEF} 36 | 37 | MFRC522::MIFARE_Key key; 38 | 39 | void setup() { 40 | Serial.begin(9600); // Initialize serial communications with the PC 41 | while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 42 | SPI.begin(); // Init SPI bus 43 | mfrc522.PCD_Init(); // Init MFRC522 card 44 | Serial.println(F("Warning: this example overwrites the UID of your UID changeable card, use with care!")); 45 | 46 | // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory. 47 | for (byte i = 0; i < 6; i++) { 48 | key.keyByte[i] = 0xFF; 49 | } 50 | } 51 | 52 | // Setting the UID can be as simple as this: 53 | //void loop() { 54 | // byte newUid[] = NEW_UID; 55 | // if ( mfrc522.MIFARE_SetUid(newUid, (byte)4, true) ) { 56 | // Serial.println("Wrote new UID to card."); 57 | // } 58 | // delay(1000); 59 | //} 60 | 61 | // But of course this is a more proper approach 62 | void loop() { 63 | 64 | // Look for new cards, and select one if present 65 | if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) { 66 | delay(50); 67 | return; 68 | } 69 | 70 | // Now a card is selected. The UID and SAK is in mfrc522.uid. 71 | 72 | // Dump UID 73 | Serial.print(F("Card UID:")); 74 | for (byte i = 0; i < mfrc522.uid.size; i++) { 75 | Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); 76 | Serial.print(mfrc522.uid.uidByte[i], HEX); 77 | } 78 | Serial.println(); 79 | 80 | // Dump PICC type 81 | // MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); 82 | // Serial.print(F("PICC type: ")); 83 | // Serial.print(mfrc522.PICC_GetTypeName(piccType)); 84 | // Serial.print(F(" (SAK ")); 85 | // Serial.print(mfrc522.uid.sak); 86 | // Serial.print(")\r\n"); 87 | // if ( piccType != MFRC522::PICC_TYPE_MIFARE_MINI 88 | // && piccType != MFRC522::PICC_TYPE_MIFARE_1K 89 | // && piccType != MFRC522::PICC_TYPE_MIFARE_4K) { 90 | // Serial.println(F("This sample only works with MIFARE Classic cards.")); 91 | // return; 92 | // } 93 | 94 | // Set new UID 95 | byte newUid[] = NEW_UID; 96 | if ( mfrc522.MIFARE_SetUid(newUid, (byte)4, true) ) { 97 | Serial.println(F("Wrote new UID to card.")); 98 | } 99 | 100 | // Halt PICC and re-select it so DumpToSerial doesn't get confused 101 | mfrc522.PICC_HaltA(); 102 | if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) { 103 | return; 104 | } 105 | 106 | // Dump the new memory contents 107 | Serial.println(F("New UID and contents:")); 108 | mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); 109 | 110 | delay(2000); 111 | } 112 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/examples/DumpInfo/DumpInfo.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------------------------------------------------- 3 | * Example sketch/program showing how to read data from a PICC to serial. 4 | * -------------------------------------------------------------------------------------------------------------------- 5 | * This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid 6 | * 7 | * Example sketch/program showing how to read data from a PICC (that is: a RFID Tag or Card) using a MFRC522 based RFID 8 | * Reader on the Arduino SPI interface. 9 | * 10 | * When the Arduino and the MFRC522 module are connected (see the pin layout below), load this sketch into Arduino IDE 11 | * then verify/compile and upload it. To see the output: use Tools, Serial Monitor of the IDE (hit Ctrl+Shft+M). When 12 | * you present a PICC (that is: a RFID Tag or Card) at reading distance of the MFRC522 Reader/PCD, the serial output 13 | * will show the ID/UID, type and any data blocks it can read. Note: you may see "Timeout in communication" messages 14 | * when removing the PICC from reading distance too early. 15 | * 16 | * If your reader supports it, this sketch/program will read all the PICCs presented (that is: multiple tag reading). 17 | * So if you stack two or more PICCs on top of each other and present them to the reader, it will first output all 18 | * details of the first and then the next PICC. Note that this may take some time as all data blocks are dumped, so 19 | * keep the PICCs at reading distance until complete. 20 | * 21 | * @license Released into the public domain. 22 | * 23 | * Typical pin layout used: 24 | * ----------------------------------------------------------------------------------------- 25 | * MFRC522 Arduino Arduino Arduino Arduino Arduino 26 | * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro 27 | * Signal Pin Pin Pin Pin Pin Pin 28 | * ----------------------------------------------------------------------------------------- 29 | * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 30 | * SPI SS SDA(SS) 10 53 D10 10 10 31 | * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 32 | * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 33 | * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 34 | */ 35 | 36 | #include 37 | #include 38 | 39 | #define RST_PIN 9 // Configurable, see typical pin layout above 40 | #define SS_PIN 10 // Configurable, see typical pin layout above 41 | 42 | MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance 43 | 44 | void setup() { 45 | Serial.begin(9600); // Initialize serial communications with the PC 46 | while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 47 | SPI.begin(); // Init SPI bus 48 | mfrc522.PCD_Init(); // Init MFRC522 49 | mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details 50 | Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks...")); 51 | } 52 | 53 | void loop() { 54 | // Look for new cards 55 | if ( ! mfrc522.PICC_IsNewCardPresent()) { 56 | return; 57 | } 58 | 59 | // Select one of the cards 60 | if ( ! mfrc522.PICC_ReadCardSerial()) { 61 | return; 62 | } 63 | 64 | // Dump debug info about the card; PICC_HaltA() is automatically called 65 | mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); 66 | } 67 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/examples/FixBrickedUID/FixBrickedUID.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------------------------------------------------- 3 | * Example sketch/program to fix a broken UID changeable MIFARE cards. 4 | * -------------------------------------------------------------------------------------------------------------------- 5 | * This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid 6 | * 7 | * This sample shows how to fix a broken UID changeable MIFARE cards that have a corrupted sector 0. 8 | * 9 | * @author Tom Clement 10 | * @license Released into the public domain. 11 | * 12 | * Typical pin layout used: 13 | * ----------------------------------------------------------------------------------------- 14 | * MFRC522 Arduino Arduino Arduino Arduino Arduino 15 | * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro 16 | * Signal Pin Pin Pin Pin Pin Pin 17 | * ----------------------------------------------------------------------------------------- 18 | * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 19 | * SPI SS SDA(SS) 10 53 D10 10 10 20 | * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 21 | * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 22 | * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | #define RST_PIN 9 // Configurable, see typical pin layout above 29 | #define SS_PIN 10 // Configurable, see typical pin layout above 30 | 31 | MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance 32 | 33 | MFRC522::MIFARE_Key key; 34 | 35 | void setup() { 36 | Serial.begin(9600); // Initialize serial communications with the PC 37 | while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 38 | SPI.begin(); // Init SPI bus 39 | mfrc522.PCD_Init(); // Init MFRC522 card 40 | Serial.println(F("Warning: this example clears your mifare UID, use with care!")); 41 | 42 | // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory. 43 | for (byte i = 0; i < 6; i++) { 44 | key.keyByte[i] = 0xFF; 45 | } 46 | } 47 | 48 | void loop() { 49 | if ( mfrc522.MIFARE_UnbrickUidSector(false) ) { 50 | Serial.println(F("Cleared sector 0, set UID to 1234. Card should be responsive again now.")); 51 | } 52 | delay(1000); 53 | } 54 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/examples/MifareClassicValueBlock/MifareClassicValueBlock.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * ---------------------------------------------------------------------------- 3 | * This is a MFRC522 library example; see https://github.com/miguelbalboa/rfid 4 | * for further details and other examples. 5 | * 6 | * NOTE: The library file MFRC522.h has a lot of useful info. Please read it. 7 | * 8 | * Released into the public domain. 9 | * ---------------------------------------------------------------------------- 10 | * This sample shows how to setup blocks on a MIFARE Classic PICC (= card/tag) 11 | * to be in "Value Block" mode: in this mode the operations Increment/Decrement, 12 | * Restore and Transfer can be used. 13 | * 14 | * BEWARE: Data will be written to the PICC, in sector #1 (blocks #4 to #7). 15 | * 16 | * 17 | * Typical pin layout used: 18 | * ----------------------------------------------------------------------------------------- 19 | * MFRC522 Arduino Arduino Arduino Arduino Arduino 20 | * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro 21 | * Signal Pin Pin Pin Pin Pin Pin 22 | * ----------------------------------------------------------------------------------------- 23 | * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 24 | * SPI SS SDA(SS) 10 53 D10 10 10 25 | * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 26 | * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 27 | * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 28 | * 29 | */ 30 | 31 | #include 32 | #include 33 | 34 | #define RST_PIN 9 // Configurable, see typical pin layout above 35 | #define SS_PIN 10 // Configurable, see typical pin layout above 36 | 37 | MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance. 38 | 39 | MFRC522::MIFARE_Key key; 40 | 41 | /** 42 | * Initialize. 43 | */ 44 | void setup() { 45 | Serial.begin(9600); // Initialize serial communications with the PC 46 | while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 47 | SPI.begin(); // Init SPI bus 48 | mfrc522.PCD_Init(); // Init MFRC522 card 49 | 50 | // Prepare the key (used both as key A and as key B) 51 | // using FFFFFFFFFFFFh which is the default at chip delivery from the factory 52 | for (byte i = 0; i < 6; i++) { 53 | key.keyByte[i] = 0xFF; 54 | } 55 | 56 | Serial.println(F("Scan a MIFARE Classic PICC to demonstrate Value Block mode.")); 57 | Serial.print(F("Using key (for A and B):")); 58 | dump_byte_array(key.keyByte, MFRC522::MF_KEY_SIZE); 59 | Serial.println(); 60 | 61 | Serial.println(F("BEWARE: Data will be written to the PICC, in sector #1")); 62 | } 63 | 64 | /** 65 | * Main loop. 66 | */ 67 | void loop() { 68 | // Look for new cards 69 | if ( ! mfrc522.PICC_IsNewCardPresent()) 70 | return; 71 | 72 | // Select one of the cards 73 | if ( ! mfrc522.PICC_ReadCardSerial()) 74 | return; 75 | 76 | // Show some details of the PICC (that is: the tag/card) 77 | Serial.print(F("Card UID:")); 78 | dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size); 79 | Serial.println(); 80 | Serial.print(F("PICC type: ")); 81 | MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); 82 | Serial.println(mfrc522.PICC_GetTypeName(piccType)); 83 | 84 | // Check for compatibility 85 | if ( piccType != MFRC522::PICC_TYPE_MIFARE_MINI 86 | && piccType != MFRC522::PICC_TYPE_MIFARE_1K 87 | && piccType != MFRC522::PICC_TYPE_MIFARE_4K) { 88 | Serial.println(F("This sample only works with MIFARE Classic cards.")); 89 | return; 90 | } 91 | 92 | // In this sample we use the second sector, 93 | // that is: sector #1, covering block #4 up to and including block #7 94 | byte sector = 1; 95 | byte valueBlockA = 5; 96 | byte valueBlockB = 6; 97 | byte trailerBlock = 7; 98 | MFRC522::StatusCode status; 99 | byte buffer[18]; 100 | byte size = sizeof(buffer); 101 | int32_t value; 102 | 103 | // Authenticate using key A 104 | Serial.println(F("Authenticating using key A...")); 105 | status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &key, &(mfrc522.uid)); 106 | if (status != MFRC522::STATUS_OK) { 107 | Serial.print(F("PCD_Authenticate() failed: ")); 108 | Serial.println(mfrc522.GetStatusCodeName(status)); 109 | return; 110 | } 111 | 112 | // Show the whole sector as it currently is 113 | Serial.println(F("Current data in sector:")); 114 | mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector); 115 | Serial.println(); 116 | 117 | // We need a sector trailer that defines blocks 5 and 6 as Value Blocks and enables key B 118 | // The last block in a sector (block #3 for Mifare Classic 1K) is the Sector Trailer. 119 | // See http://www.nxp.com/documents/data_sheet/MF1S503x.pdf sections 8.6 and 8.7: 120 | // Bytes 0-5: Key A 121 | // Bytes 6-8: Access Bits 122 | // Bytes 9: User data 123 | // Bytes 10-15: Key B (or user data) 124 | byte trailerBuffer[] = { 125 | 255, 255, 255, 255, 255, 255, // Keep default key A 126 | 0, 0, 0, 127 | 0, 128 | 255, 255, 255, 255, 255, 255}; // Keep default key B 129 | // The access bits are stored in a peculiar fashion. 130 | // There are four groups: 131 | // g[0] Access bits for block 0 (for sectors 0-31) 132 | // or blocks 0-4 (for sectors 32-39) 133 | // g[1] Access bits for block 1 (for sectors 0-31) 134 | // or blocks 5-9 (for sectors 32-39) 135 | // g[2] Access bits for block 2 (for sectors 0-31) 136 | // or blocks 10-14 (for sectors 32-39) 137 | // g[3] Access bits for the Sector Trailer: block 3 (for sectors 0-31) 138 | // or block 15 (for sectors 32-39) 139 | // Each group has access bits [C1 C2 C3], in this code C1 is MSB and C3 is LSB. 140 | // Determine the bit pattern needed using MIFARE_SetAccessBits: 141 | // g0=0 access bits for block 0 (of this sector) using [0 0 0] = 000b = 0 142 | // which means key A|B have r/w for block 0 of this sector 143 | // which (in this example) translates to block #4 within sector #1; 144 | // this is the transport configuration (at factory delivery). 145 | // g1=6 access bits for block 1 (of this sector) using [1 1 0] = 110b = 6 146 | // which means block 1 (of this sector) is used as a value block, 147 | // which (in this example) translates to block #5 within sector #1; 148 | // where key A|B have r, key B has w, key B can increment, 149 | // and key A|B can decrement, transfer, and restore. 150 | // g2=6 same thing for block 2 (of this sector): set it to a value block; 151 | // which (in this example) translates to block #6 within sector #1; 152 | // g3=3 access bits for block 3 (of this sector): the Sector Trailer here; 153 | // using [0 1 1] = 011b = 3 which means only key B has r/w access 154 | // to the Sector Trailer (block 3 of this sector) from now on 155 | // which (in this example) translates to block #7 within sector #1; 156 | mfrc522.MIFARE_SetAccessBits(&trailerBuffer[6], 0, 6, 6, 3); 157 | 158 | // Read the sector trailer as it is currently stored on the PICC 159 | Serial.println(F("Reading sector trailer...")); 160 | status = mfrc522.MIFARE_Read(trailerBlock, buffer, &size); 161 | if (status != MFRC522::STATUS_OK) { 162 | Serial.print(F("MIFARE_Read() failed: ")); 163 | Serial.println(mfrc522.GetStatusCodeName(status)); 164 | return; 165 | } 166 | // Check if it matches the desired access pattern already; 167 | // because if it does, we don't need to write it again... 168 | if ( buffer[6] != trailerBuffer[6] 169 | || buffer[7] != trailerBuffer[7] 170 | || buffer[8] != trailerBuffer[8]) { 171 | // They don't match (yet), so write it to the PICC 172 | Serial.println(F("Writing new sector trailer...")); 173 | status = mfrc522.MIFARE_Write(trailerBlock, trailerBuffer, 16); 174 | if (status != MFRC522::STATUS_OK) { 175 | Serial.print(F("MIFARE_Write() failed: ")); 176 | Serial.println(mfrc522.GetStatusCodeName(status)); 177 | return; 178 | } 179 | } 180 | 181 | // Authenticate using key B 182 | Serial.println(F("Authenticating again using key B...")); 183 | status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_B, trailerBlock, &key, &(mfrc522.uid)); 184 | if (status != MFRC522::STATUS_OK) { 185 | Serial.print(F("PCD_Authenticate() failed: ")); 186 | Serial.println(mfrc522.GetStatusCodeName(status)); 187 | return; 188 | } 189 | 190 | // A value block has a 32 bit signed value stored three times 191 | // and an 8 bit address stored 4 times. Make sure that valueBlockA 192 | // and valueBlockB have that format (note that it will only format 193 | // the block when it doesn't comply to the expected format already). 194 | formatValueBlock(valueBlockA); 195 | formatValueBlock(valueBlockB); 196 | 197 | // Add 1 to the value of valueBlockA and store the result in valueBlockA. 198 | Serial.print("Adding 1 to value of block "); Serial.println(valueBlockA); 199 | status = mfrc522.MIFARE_Increment(valueBlockA, 1); 200 | if (status != MFRC522::STATUS_OK) { 201 | Serial.print(F("MIFARE_Increment() failed: ")); 202 | Serial.println(mfrc522.GetStatusCodeName(status)); 203 | return; 204 | } 205 | status = mfrc522.MIFARE_Transfer(valueBlockA); 206 | if (status != MFRC522::STATUS_OK) { 207 | Serial.print(F("MIFARE_Transfer() failed: ")); 208 | Serial.println(mfrc522.GetStatusCodeName(status)); 209 | return; 210 | } 211 | // Show the new value of valueBlockA 212 | status = mfrc522.MIFARE_GetValue(valueBlockA, &value); 213 | if (status != MFRC522::STATUS_OK) { 214 | Serial.print(F("mifare_GetValue() failed: ")); 215 | Serial.println(mfrc522.GetStatusCodeName(status)); 216 | return; 217 | } 218 | Serial.print("New value of value block "); Serial.print(valueBlockA); 219 | Serial.print(" = "); Serial.println(value); 220 | 221 | // Decrement 10 from the value of valueBlockB and store the result in valueBlockB. 222 | Serial.print("Subtracting 10 from value of block "); Serial.println(valueBlockB); 223 | status = mfrc522.MIFARE_Decrement(valueBlockB, 10); 224 | if (status != MFRC522::STATUS_OK) { 225 | Serial.print(F("MIFARE_Decrement() failed: ")); 226 | Serial.println(mfrc522.GetStatusCodeName(status)); 227 | return; 228 | } 229 | status = mfrc522.MIFARE_Transfer(valueBlockB); 230 | if (status != MFRC522::STATUS_OK) { 231 | Serial.print(F("MIFARE_Transfer() failed: ")); 232 | Serial.println(mfrc522.GetStatusCodeName(status)); 233 | return; 234 | } 235 | // Show the new value of valueBlockB 236 | status = mfrc522.MIFARE_GetValue(valueBlockB, &value); 237 | if (status != MFRC522::STATUS_OK) { 238 | Serial.print(F("mifare_GetValue() failed: ")); 239 | Serial.println(mfrc522.GetStatusCodeName(status)); 240 | return; 241 | } 242 | Serial.print(F("New value of value block ")); Serial.print(valueBlockB); 243 | Serial.print(F(" = ")); Serial.println(value); 244 | // Check some boundary... 245 | if (value <= -100) { 246 | Serial.println(F("Below -100, so resetting it to 255 = 0xFF just for fun...")); 247 | status = mfrc522.MIFARE_SetValue(valueBlockB, 255); 248 | if (status != MFRC522::STATUS_OK) { 249 | Serial.print(F("mifare_SetValue() failed: ")); 250 | Serial.println(mfrc522.GetStatusCodeName(status)); 251 | return; 252 | } 253 | } 254 | 255 | // Dump the sector data 256 | mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector); 257 | Serial.println(); 258 | 259 | // Halt PICC 260 | mfrc522.PICC_HaltA(); 261 | // Stop encryption on PCD 262 | mfrc522.PCD_StopCrypto1(); 263 | } 264 | 265 | /** 266 | * Helper routine to dump a byte array as hex values to Serial. 267 | */ 268 | void dump_byte_array(byte *buffer, byte bufferSize) { 269 | for (byte i = 0; i < bufferSize; i++) { 270 | Serial.print(buffer[i] < 0x10 ? " 0" : " "); 271 | Serial.print(buffer[i], HEX); 272 | } 273 | } 274 | 275 | /** 276 | * Ensure that a given block is formatted as a Value Block. 277 | */ 278 | void formatValueBlock(byte blockAddr) { 279 | byte buffer[18]; 280 | byte size = sizeof(buffer); 281 | MFRC522::StatusCode status; 282 | 283 | Serial.print(F("Reading block ")); Serial.println(blockAddr); 284 | status = mfrc522.MIFARE_Read(blockAddr, buffer, &size); 285 | if (status != MFRC522::STATUS_OK) { 286 | Serial.print(F("MIFARE_Read() failed: ")); 287 | Serial.println(mfrc522.GetStatusCodeName(status)); 288 | return; 289 | } 290 | 291 | if ( (buffer[0] == (byte)~buffer[4]) 292 | && (buffer[1] == (byte)~buffer[5]) 293 | && (buffer[2] == (byte)~buffer[6]) 294 | && (buffer[3] == (byte)~buffer[7]) 295 | 296 | && (buffer[0] == buffer[8]) 297 | && (buffer[1] == buffer[9]) 298 | && (buffer[2] == buffer[10]) 299 | && (buffer[3] == buffer[11]) 300 | 301 | && (buffer[12] == (byte)~buffer[13]) 302 | && (buffer[12] == buffer[14]) 303 | && (buffer[12] == (byte)~buffer[15])) { 304 | Serial.println(F("Block has correct Value Block format.")); 305 | } 306 | else { 307 | Serial.println(F("Formatting as Value Block...")); 308 | byte valueBlock[] = { 309 | 0, 0, 0, 0, 310 | 255, 255, 255, 255, 311 | 0, 0, 0, 0, 312 | blockAddr, ~blockAddr, blockAddr, ~blockAddr }; 313 | status = mfrc522.MIFARE_Write(blockAddr, valueBlock, 16); 314 | if (status != MFRC522::STATUS_OK) { 315 | Serial.print(F("MIFARE_Write() failed: ")); 316 | Serial.println(mfrc522.GetStatusCodeName(status)); 317 | } 318 | } 319 | } 320 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/examples/MinimalInterrupt/MinimalInterrupt.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * ---------------------------------------------------------------------------- 3 | * This is a MFRC522 library example; see https://github.com/miguelbalboa/rfid 4 | * for further details and other examples. 5 | * 6 | * NOTE: The library file MFRC522.h has a lot of useful info. Please read it. 7 | * 8 | * Released into the public domain. 9 | * ---------------------------------------------------------------------------- 10 | * Minimal example how to use the interrupts to read the UID of a MIFARE Classic PICC 11 | * (= card/tag). 12 | * 13 | * 14 | * Typical pin layout used: 15 | * ----------------------------------------------------------------------------------------- 16 | * MFRC522 Arduino Arduino Arduino Arduino Arduino 17 | * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro 18 | * Signal Pin Pin Pin Pin Pin Pin 19 | * ----------------------------------------------------------------------------------------- 20 | * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 21 | * SPI SS SDA(SS) 10 53 D10 3 10 22 | * IRQ ? ? ? ? 2 10 23 | * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 24 | * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 25 | * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 26 | * 27 | */ 28 | 29 | #include 30 | #include 31 | 32 | #define RST_PIN 9 // Configurable, see typical pin layout above 33 | #define SS_PIN 3 // Configurable, see typical pin layout above 34 | #define IRQ_PIN 2 // Configurable, depends on hardware 35 | 36 | MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance. 37 | 38 | MFRC522::MIFARE_Key key; 39 | 40 | volatile boolean bNewInt = false; 41 | byte regVal = 0x7F; 42 | void activateRec(MFRC522 mfrc522); 43 | void clearInt(MFRC522 mfrc522); 44 | 45 | /** 46 | * Initialize. 47 | */ 48 | void setup() { 49 | Serial.begin(115200); // Initialize serial communications with the PC 50 | while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 51 | SPI.begin(); // Init SPI bus 52 | 53 | mfrc522.PCD_Init(); // Init MFRC522 card 54 | 55 | /* read and printout the MFRC522 version (valid values 0x91 & 0x92)*/ 56 | Serial.print(F("Ver: 0x")); 57 | byte readReg = mfrc522.PCD_ReadRegister(mfrc522.VersionReg); 58 | Serial.println(readReg, HEX); 59 | 60 | /* setup the IRQ pin*/ 61 | pinMode(IRQ_PIN, INPUT_PULLUP); 62 | 63 | /* 64 | * Allow the ... irq to be propagated to the IRQ pin 65 | * For test purposes propagate the IdleIrq and loAlert 66 | */ 67 | regVal = 0xA0; //rx irq 68 | mfrc522.PCD_WriteRegister(mfrc522.ComIEnReg, regVal); 69 | 70 | bNewInt = false; //interrupt flag 71 | 72 | /*Activate the interrupt*/ 73 | attachInterrupt(digitalPinToInterrupt(IRQ_PIN), readCard, FALLING); 74 | 75 | do { //clear a spourious interrupt at start 76 | ; 77 | } while (!bNewInt); 78 | bNewInt = false; 79 | 80 | Serial.println(F("End setup")); 81 | } 82 | 83 | /** 84 | * Main loop. 85 | */ 86 | void loop() { 87 | if (bNewInt) { //new read interrupt 88 | Serial.print(F("Interrupt. ")); 89 | mfrc522.PICC_ReadCardSerial(); //read the tag data 90 | // Show some details of the PICC (that is: the tag/card) 91 | Serial.print(F("Card UID:")); 92 | dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size); 93 | Serial.println(); 94 | 95 | clearInt(mfrc522); 96 | mfrc522.PICC_HaltA(); 97 | bNewInt = false; 98 | } 99 | 100 | // The receiving block needs regular retriggering (tell the tag it should transmit??) 101 | // (mfrc522.PCD_WriteRegister(mfrc522.FIFODataReg,mfrc522.PICC_CMD_REQA);) 102 | activateRec(mfrc522); 103 | delay(100); 104 | } //loop() 105 | 106 | /** 107 | * Helper routine to dump a byte array as hex values to Serial. 108 | */ 109 | void dump_byte_array(byte *buffer, byte bufferSize) { 110 | for (byte i = 0; i < bufferSize; i++) { 111 | Serial.print(buffer[i] < 0x10 ? " 0" : " "); 112 | Serial.print(buffer[i], HEX); 113 | } 114 | } 115 | /** 116 | * MFRC522 interrupt serving routine 117 | */ 118 | void readCard() { 119 | bNewInt = true; 120 | } 121 | 122 | /* 123 | * The function sending to the MFRC522 the needed commands to activate the reception 124 | */ 125 | void activateRec(MFRC522 mfrc522) { 126 | mfrc522.PCD_WriteRegister(mfrc522.FIFODataReg, mfrc522.PICC_CMD_REQA); 127 | mfrc522.PCD_WriteRegister(mfrc522.CommandReg, mfrc522.PCD_Transceive); 128 | mfrc522.PCD_WriteRegister(mfrc522.BitFramingReg, 0x87); 129 | } 130 | 131 | /* 132 | * The function to clear the pending interrupt bits after interrupt serving routine 133 | */ 134 | void clearInt(MFRC522 mfrc522) { 135 | mfrc522.PCD_WriteRegister(mfrc522.ComIrqReg, 0x7F); 136 | } 137 | 138 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/examples/Ntag216_AUTH/Ntag216_AUTH.ino: -------------------------------------------------------------------------------- 1 | //This example show how you can get Authenticated by the NTAG213,215,216 by default the tags are unprotected in order to protect them we need to write 4 different values: 2 | // Using mfrc522.MIFARE_Ultralight_Write(PageNum, Data, #Databytes)) 3 | //1.- we need to write the 32bit passWord to page 0xE5 !for ntag 213 and 215 page is different refer to nxp documentation! 4 | //2.- Now Write the 16 bits pACK to the page 0xE6 use the 2 high bytes like this: pACKH + pACKL + 00 + 00 after an authentication the tag will return this secret bytes 5 | //3.- Now we need to write the first page we want to protect this is a 1 byte data in page 0xE3 we need to write 00 + 00 + 00 + firstPage all pages after this one are write protected 6 | // Now WRITE protection is ACTIVATED so we need to get authenticated in order to write the last data 7 | //4.- Finally we need to write an access record in order to READ protect the card this step is optional only if you want to read protect also write 80 + 00 + 00 + 00 to 0xE4 8 | //After completeing all these steps you will nee to authentiate first in order to read or write ant page after the first page you selected to protect 9 | //To disengage proection just write the page (0xE3) to 00 + 00 + 00 + FF that going to remove all protection 10 | //Made by GARGANTUA from RoboCreators.com & paradoxalabs.com 11 | 12 | #include 13 | #include 14 | 15 | #define RST_PIN 9 // 16 | #define SS_PIN 10 // 17 | 18 | MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance 19 | 20 | void setup() { 21 | Serial.begin(9600); // Initialize serial communications with the PC 22 | while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 23 | SPI.begin(); // Init SPI bus 24 | mfrc522.PCD_Init(); // Init MFRC522 25 | Serial.println(F("Scan PICC to see UID, type, and data blocks...")); 26 | } 27 | 28 | void loop() { 29 | // Look for new cards 30 | if ( ! mfrc522.PICC_IsNewCardPresent()) { 31 | return; 32 | } 33 | 34 | // Select one of the cards 35 | if ( ! mfrc522.PICC_ReadCardSerial()) { 36 | return; 37 | } 38 | 39 | byte PSWBuff[] = {0xFF, 0xFF, 0xFF, 0xFF}; //32 bit PassWord default FFFFFFFF 40 | byte pACK[] = {0, 0}; //16 bit PassWord ACK returned by the NFCtag 41 | 42 | Serial.print("Auth: "); 43 | Serial.println(mfrc522.PCD_NTAG216_AUTH(&PSWBuff[0], pACK)); //Request Authentification if return STATUS_OK we are good 44 | 45 | //Print PassWordACK 46 | Serial.print(pACK[0], HEX); 47 | Serial.println(pACK[1], HEX); 48 | 49 | byte WBuff[] = {0x00, 0x00, 0x00, 0x04}; 50 | byte RBuff[18]; 51 | 52 | //Serial.print("CHG BLK: "); 53 | //Serial.println(mfrc522.MIFARE_Ultralight_Write(0xE3, WBuff, 4)); //How to write to a page 54 | 55 | mfrc522.PICC_DumpMifareUltralightToSerial(); //This is a modifier dunp just cghange the for cicle to < 232 instead of < 16 in order to see all the pages on NTAG216 56 | 57 | delay(3000); 58 | } -------------------------------------------------------------------------------- /Library Arduino/rfid-master/examples/RFID-Cloner/RFID-Cloner.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Copy the RFID card data into variables and then 3 | * scan the second empty card to copy all the date 4 | * ---------------------------------------------------------------------------- 5 | * Example sketch/program which will try the most used default keys listed in 6 | * https://code.google.com/p/mfcuk/wiki/MifareClassicDefaultKeys to dump the 7 | * block 0 of a MIFARE RFID card using a RFID-RC522 reader. 8 | * 9 | * Typical pin layout used: 10 | * ----------------------------------------------------------------------------------------- 11 | * MFRC522 Arduino Arduino Arduino Arduino Arduino 12 | * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro 13 | * Signal Pin Pin Pin Pin Pin Pin 14 | * ----------------------------------------------------------------------------------------- 15 | * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 16 | * SPI SS SDA(SS) 10 53 D10 10 10 17 | * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 18 | * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 19 | * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 20 | * 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #define RST_PIN 9 // Configurable, see typical pin layout above 27 | #define SS_PIN 10 // Configurable, see typical pin layout above 28 | 29 | MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance. 30 | 31 | byte buffer[18]; 32 | byte block; 33 | byte waarde[64][16]; 34 | MFRC522::StatusCode status; 35 | 36 | MFRC522::MIFARE_Key key; 37 | 38 | // Number of known default keys (hard-coded) 39 | // NOTE: Synchronize the NR_KNOWN_KEYS define with the defaultKeys[] array 40 | #define NR_KNOWN_KEYS 8 41 | // Known keys, see: https://code.google.com/p/mfcuk/wiki/MifareClassicDefaultKeys 42 | byte knownKeys[NR_KNOWN_KEYS][MFRC522::MF_KEY_SIZE] = { 43 | {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // FF FF FF FF FF FF = factory default 44 | {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5}, // A0 A1 A2 A3 A4 A5 45 | {0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5}, // B0 B1 B2 B3 B4 B5 46 | {0x4d, 0x3a, 0x99, 0xc3, 0x51, 0xdd}, // 4D 3A 99 C3 51 DD 47 | {0x1a, 0x98, 0x2c, 0x7e, 0x45, 0x9a}, // 1A 98 2C 7E 45 9A 48 | {0xd3, 0xf7, 0xd3, 0xf7, 0xd3, 0xf7}, // D3 F7 D3 F7 D3 F7 49 | {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, // AA BB CC DD EE FF 50 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // 00 00 00 00 00 00 51 | }; 52 | 53 | char choice; 54 | /* 55 | * Initialize. 56 | */ 57 | void setup() { 58 | Serial.begin(9600); // Initialize serial communications with the PC 59 | while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 60 | SPI.begin(); // Init SPI bus 61 | mfrc522.PCD_Init(); // Init MFRC522 card 62 | Serial.println(F("Try the most used default keys to print block 0 to 63 of a MIFARE PICC.")); 63 | Serial.println("1.Read card \n2.Write to card \n3.Copy the data."); 64 | 65 | for (byte i = 0; i < 6; i++) { 66 | key.keyByte[i] = 0xFF; 67 | } 68 | } 69 | 70 | 71 | 72 | //Via seriele monitor de bytes uitlezen in hexadecimaal 73 | 74 | void dump_byte_array(byte *buffer, byte bufferSize) { 75 | for (byte i = 0; i < bufferSize; i++) { 76 | Serial.print(buffer[i] < 0x10 ? " 0" : " "); 77 | Serial.print(buffer[i], HEX); 78 | } 79 | } 80 | //Via seriele monitor de bytes uitlezen in ASCI 81 | 82 | void dump_byte_array1(byte *buffer, byte bufferSize) { 83 | for (byte i = 0; i < bufferSize; i++) { 84 | Serial.print(buffer[i] < 0x10 ? " 0" : " "); 85 | Serial.write(buffer[i]); 86 | } 87 | } 88 | 89 | /* 90 | * Try using the PICC (the tag/card) with the given key to access block 0 to 63. 91 | * On success, it will show the key details, and dump the block data on Serial. 92 | * 93 | * @return true when the given key worked, false otherwise. 94 | */ 95 | 96 | boolean try_key(MFRC522::MIFARE_Key *key) 97 | { 98 | boolean result = false; 99 | 100 | for(byte block = 0; block < 64; block++){ 101 | 102 | // Serial.println(F("Authenticating using key A...")); 103 | status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, key, &(mfrc522.uid)); 104 | if (status != MFRC522::STATUS_OK) { 105 | Serial.print(F("PCD_Authenticate() failed: ")); 106 | Serial.println(mfrc522.GetStatusCodeName(status)); 107 | return false; 108 | } 109 | 110 | // Read block 111 | byte byteCount = sizeof(buffer); 112 | status = mfrc522.MIFARE_Read(block, buffer, &byteCount); 113 | if (status != MFRC522::STATUS_OK) { 114 | Serial.print(F("MIFARE_Read() failed: ")); 115 | Serial.println(mfrc522.GetStatusCodeName(status)); 116 | } 117 | else { 118 | // Successful read 119 | result = true; 120 | Serial.print(F("Success with key:")); 121 | dump_byte_array((*key).keyByte, MFRC522::MF_KEY_SIZE); 122 | Serial.println(); 123 | 124 | // Dump block data 125 | Serial.print(F("Block ")); Serial.print(block); Serial.print(F(":")); 126 | dump_byte_array1(buffer, 16); //omzetten van hex naar ASCI 127 | Serial.println(); 128 | 129 | for (int p = 0; p < 16; p++) //De 16 bits uit de block uitlezen 130 | { 131 | waarde [block][p] = buffer[p]; 132 | Serial.print(waarde[block][p]); 133 | Serial.print(" "); 134 | } 135 | 136 | } 137 | } 138 | Serial.println(); 139 | 140 | Serial.println("1.Read card \n2.Write to card \n3.Copy the data."); 141 | 142 | mfrc522.PICC_HaltA(); // Halt PICC 143 | mfrc522.PCD_StopCrypto1(); // Stop encryption on PCD 144 | return result; 145 | 146 | start(); 147 | } 148 | 149 | /* 150 | * Main loop. 151 | */ 152 | void loop() { 153 | start(); 154 | 155 | } 156 | 157 | void start(){ 158 | choice = Serial.read(); 159 | 160 | if(choice == '1') 161 | { 162 | Serial.println("Read the card"); 163 | keuze1(); 164 | 165 | } 166 | else if(choice == '2') 167 | { 168 | Serial.println("See what is in the variables"); 169 | keuze2(); 170 | } 171 | else if(choice == '3') 172 | { 173 | Serial.println("Copying the data on to the new card"); 174 | keuze3(); 175 | } 176 | } 177 | 178 | void keuze2(){ //Test waardes in blokken 179 | 180 | for(block = 4; block <= 62; block++){ 181 | if(block == 7 || block == 11 || block == 15 || block == 19 || block == 23 || block == 27 || block == 31 || block == 35 || block == 39 || block == 43 || block == 47 || block == 51 || block == 55 || block == 59){ 182 | block ++; 183 | } 184 | 185 | Serial.print(F("Writing data into block ")); 186 | Serial.print(block); 187 | Serial.println("\n"); 188 | 189 | for(int j = 0; j < 16; j++){ 190 | Serial.print(waarde[block][j]); 191 | Serial.print(" "); 192 | } 193 | Serial.println("\n"); 194 | 195 | } 196 | 197 | Serial.println("1.Read card \n2.Write to card \n3.Copy the data."); 198 | start(); 199 | } 200 | 201 | void keuze3(){ //Copy the data in the new card 202 | Serial.println("Insert new card..."); 203 | // Look for new cards 204 | if ( ! mfrc522.PICC_IsNewCardPresent()) 205 | return; 206 | 207 | // Select one of the cards 208 | if ( ! mfrc522.PICC_ReadCardSerial()) 209 | return; 210 | 211 | // Show some details of the PICC (that is: the tag/card) 212 | Serial.print(F("Card UID:")); 213 | dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size); 214 | Serial.println(); 215 | Serial.print(F("PICC type: ")); 216 | MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); 217 | Serial.println(mfrc522.PICC_GetTypeName(piccType)); 218 | 219 | // Try the known default keys 220 | /*MFRC522::MIFARE_Key key; 221 | for (byte k = 0; k < NR_KNOWN_KEYS; k++) { 222 | // Copy the known key into the MIFARE_Key structure 223 | for (byte i = 0; i < MFRC522::MF_KEY_SIZE; i++) { 224 | key.keyByte[i] = knownKeys[k][i]; 225 | } 226 | }*/ 227 | for (byte i = 0; i < 6; i++) { 228 | key.keyByte[i] = 0xFF; 229 | } 230 | 231 | for(int i = 4; i <= 62; i++){ //De blocken 4 tot 62 kopieren, behalve al deze onderstaande blocken (omdat deze de authenticatie blokken zijn) 232 | if(i == 7 || i == 11 || i == 15 || i == 19 || i == 23 || i == 27 || i == 31 || i == 35 || i == 39 || i == 43 || i == 47 || i == 51 || i == 55 || i == 59){ 233 | i++; 234 | } 235 | block = i; 236 | 237 | // Authenticate using key A 238 | Serial.println(F("Authenticating using key A...")); 239 | status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, &key, &(mfrc522.uid)); 240 | if (status != MFRC522::STATUS_OK) { 241 | Serial.print(F("PCD_Authenticate() failed: ")); 242 | Serial.println(mfrc522.GetStatusCodeName(status)); 243 | return; 244 | } 245 | 246 | // Authenticate using key B 247 | Serial.println(F("Authenticating again using key B...")); 248 | status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_B, block, &key, &(mfrc522.uid)); 249 | if (status != MFRC522::STATUS_OK) { 250 | Serial.print(F("PCD_Authenticate() failed: ")); 251 | Serial.println(mfrc522.GetStatusCodeName(status)); 252 | return; 253 | } 254 | 255 | // Write data to the block 256 | Serial.print(F("Writing data into block ")); 257 | Serial.print(block); 258 | Serial.println("\n"); 259 | 260 | dump_byte_array(waarde[block], 16); 261 | 262 | 263 | status = (MFRC522::StatusCode) mfrc522.MIFARE_Write(block, waarde[block], 16); 264 | if (status != MFRC522::STATUS_OK) { 265 | Serial.print(F("MIFARE_Write() failed: ")); 266 | Serial.println(mfrc522.GetStatusCodeName(status)); 267 | } 268 | 269 | 270 | Serial.println("\n"); 271 | 272 | } 273 | mfrc522.PICC_HaltA(); // Halt PICC 274 | mfrc522.PCD_StopCrypto1(); // Stop encryption on PCD 275 | 276 | Serial.println("1.Read card \n2.Write to card \n3.Copy the data."); 277 | start(); 278 | } 279 | 280 | void keuze1(){ //Read card 281 | Serial.println("Insert card..."); 282 | // Look for new cards 283 | if ( ! mfrc522.PICC_IsNewCardPresent()) 284 | return; 285 | 286 | // Select one of the cards 287 | if ( ! mfrc522.PICC_ReadCardSerial()) 288 | return; 289 | 290 | // Show some details of the PICC (that is: the tag/card) 291 | Serial.print(F("Card UID:")); 292 | dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size); 293 | Serial.println(); 294 | Serial.print(F("PICC type: ")); 295 | MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); 296 | Serial.println(mfrc522.PICC_GetTypeName(piccType)); 297 | 298 | // Try the known default keys 299 | MFRC522::MIFARE_Key key; 300 | for (byte k = 0; k < NR_KNOWN_KEYS; k++) { 301 | // Copy the known key into the MIFARE_Key structure 302 | for (byte i = 0; i < MFRC522::MF_KEY_SIZE; i++) { 303 | key.keyByte[i] = knownKeys[k][i]; 304 | } 305 | // Try the key 306 | if (try_key(&key)) { 307 | // Found and reported on the key and block, 308 | // no need to try other keys for this PICC 309 | break; 310 | } 311 | } 312 | } 313 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/examples/ReadAndWrite/ReadAndWrite.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * ---------------------------------------------------------------------------- 3 | * This is a MFRC522 library example; see https://github.com/miguelbalboa/rfid 4 | * for further details and other examples. 5 | * 6 | * NOTE: The library file MFRC522.h has a lot of useful info. Please read it. 7 | * 8 | * Released into the public domain. 9 | * ---------------------------------------------------------------------------- 10 | * This sample shows how to read and write data blocks on a MIFARE Classic PICC 11 | * (= card/tag). 12 | * 13 | * BEWARE: Data will be written to the PICC, in sector #1 (blocks #4 to #7). 14 | * 15 | * 16 | * Typical pin layout used: 17 | * ----------------------------------------------------------------------------------------- 18 | * MFRC522 Arduino Arduino Arduino Arduino Arduino 19 | * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro 20 | * Signal Pin Pin Pin Pin Pin Pin 21 | * ----------------------------------------------------------------------------------------- 22 | * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 23 | * SPI SS SDA(SS) 10 53 D10 10 10 24 | * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 25 | * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 26 | * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 27 | * 28 | */ 29 | 30 | #include 31 | #include 32 | 33 | #define RST_PIN 9 // Configurable, see typical pin layout above 34 | #define SS_PIN 10 // Configurable, see typical pin layout above 35 | 36 | MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance. 37 | 38 | MFRC522::MIFARE_Key key; 39 | 40 | /** 41 | * Initialize. 42 | */ 43 | void setup() { 44 | Serial.begin(9600); // Initialize serial communications with the PC 45 | while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 46 | SPI.begin(); // Init SPI bus 47 | mfrc522.PCD_Init(); // Init MFRC522 card 48 | 49 | // Prepare the key (used both as key A and as key B) 50 | // using FFFFFFFFFFFFh which is the default at chip delivery from the factory 51 | for (byte i = 0; i < 6; i++) { 52 | key.keyByte[i] = 0xFF; 53 | } 54 | 55 | Serial.println(F("Scan a MIFARE Classic PICC to demonstrate read and write.")); 56 | Serial.print(F("Using key (for A and B):")); 57 | dump_byte_array(key.keyByte, MFRC522::MF_KEY_SIZE); 58 | Serial.println(); 59 | 60 | Serial.println(F("BEWARE: Data will be written to the PICC, in sector #1")); 61 | } 62 | 63 | /** 64 | * Main loop. 65 | */ 66 | void loop() { 67 | // Look for new cards 68 | if ( ! mfrc522.PICC_IsNewCardPresent()) 69 | return; 70 | 71 | // Select one of the cards 72 | if ( ! mfrc522.PICC_ReadCardSerial()) 73 | return; 74 | 75 | // Show some details of the PICC (that is: the tag/card) 76 | Serial.print(F("Card UID:")); 77 | dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size); 78 | Serial.println(); 79 | Serial.print(F("PICC type: ")); 80 | MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); 81 | Serial.println(mfrc522.PICC_GetTypeName(piccType)); 82 | 83 | // Check for compatibility 84 | if ( piccType != MFRC522::PICC_TYPE_MIFARE_MINI 85 | && piccType != MFRC522::PICC_TYPE_MIFARE_1K 86 | && piccType != MFRC522::PICC_TYPE_MIFARE_4K) { 87 | Serial.println(F("This sample only works with MIFARE Classic cards.")); 88 | return; 89 | } 90 | 91 | // In this sample we use the second sector, 92 | // that is: sector #1, covering block #4 up to and including block #7 93 | byte sector = 1; 94 | byte blockAddr = 4; 95 | byte dataBlock[] = { 96 | 0x01, 0x02, 0x03, 0x04, // 1, 2, 3, 4, 97 | 0x05, 0x06, 0x07, 0x08, // 5, 6, 7, 8, 98 | 0x08, 0x09, 0xff, 0x0b, // 9, 10, 255, 12, 99 | 0x0c, 0x0d, 0x0e, 0x0f // 13, 14, 15, 16 100 | }; 101 | byte trailerBlock = 7; 102 | MFRC522::StatusCode status; 103 | byte buffer[18]; 104 | byte size = sizeof(buffer); 105 | 106 | // Authenticate using key A 107 | Serial.println(F("Authenticating using key A...")); 108 | status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &key, &(mfrc522.uid)); 109 | if (status != MFRC522::STATUS_OK) { 110 | Serial.print(F("PCD_Authenticate() failed: ")); 111 | Serial.println(mfrc522.GetStatusCodeName(status)); 112 | return; 113 | } 114 | 115 | // Show the whole sector as it currently is 116 | Serial.println(F("Current data in sector:")); 117 | mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector); 118 | Serial.println(); 119 | 120 | // Read data from the block 121 | Serial.print(F("Reading data from block ")); Serial.print(blockAddr); 122 | Serial.println(F(" ...")); 123 | status = (MFRC522::StatusCode) mfrc522.MIFARE_Read(blockAddr, buffer, &size); 124 | if (status != MFRC522::STATUS_OK) { 125 | Serial.print(F("MIFARE_Read() failed: ")); 126 | Serial.println(mfrc522.GetStatusCodeName(status)); 127 | } 128 | Serial.print(F("Data in block ")); Serial.print(blockAddr); Serial.println(F(":")); 129 | dump_byte_array(buffer, 16); Serial.println(); 130 | Serial.println(); 131 | 132 | // Authenticate using key B 133 | Serial.println(F("Authenticating again using key B...")); 134 | status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_B, trailerBlock, &key, &(mfrc522.uid)); 135 | if (status != MFRC522::STATUS_OK) { 136 | Serial.print(F("PCD_Authenticate() failed: ")); 137 | Serial.println(mfrc522.GetStatusCodeName(status)); 138 | return; 139 | } 140 | 141 | // Write data to the block 142 | Serial.print(F("Writing data into block ")); Serial.print(blockAddr); 143 | Serial.println(F(" ...")); 144 | dump_byte_array(dataBlock, 16); Serial.println(); 145 | status = (MFRC522::StatusCode) mfrc522.MIFARE_Write(blockAddr, dataBlock, 16); 146 | if (status != MFRC522::STATUS_OK) { 147 | Serial.print(F("MIFARE_Write() failed: ")); 148 | Serial.println(mfrc522.GetStatusCodeName(status)); 149 | } 150 | Serial.println(); 151 | 152 | // Read data from the block (again, should now be what we have written) 153 | Serial.print(F("Reading data from block ")); Serial.print(blockAddr); 154 | Serial.println(F(" ...")); 155 | status = (MFRC522::StatusCode) mfrc522.MIFARE_Read(blockAddr, buffer, &size); 156 | if (status != MFRC522::STATUS_OK) { 157 | Serial.print(F("MIFARE_Read() failed: ")); 158 | Serial.println(mfrc522.GetStatusCodeName(status)); 159 | } 160 | Serial.print(F("Data in block ")); Serial.print(blockAddr); Serial.println(F(":")); 161 | dump_byte_array(buffer, 16); Serial.println(); 162 | 163 | // Check that data in block is what we have written 164 | // by counting the number of bytes that are equal 165 | Serial.println(F("Checking result...")); 166 | byte count = 0; 167 | for (byte i = 0; i < 16; i++) { 168 | // Compare buffer (= what we've read) with dataBlock (= what we've written) 169 | if (buffer[i] == dataBlock[i]) 170 | count++; 171 | } 172 | Serial.print(F("Number of bytes that match = ")); Serial.println(count); 173 | if (count == 16) { 174 | Serial.println(F("Success :-)")); 175 | } else { 176 | Serial.println(F("Failure, no match :-(")); 177 | Serial.println(F(" perhaps the write didn't work properly...")); 178 | } 179 | Serial.println(); 180 | 181 | // Dump the sector data 182 | Serial.println(F("Current data in sector:")); 183 | mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector); 184 | Serial.println(); 185 | 186 | // Halt PICC 187 | mfrc522.PICC_HaltA(); 188 | // Stop encryption on PCD 189 | mfrc522.PCD_StopCrypto1(); 190 | } 191 | 192 | /** 193 | * Helper routine to dump a byte array as hex values to Serial. 194 | */ 195 | void dump_byte_array(byte *buffer, byte bufferSize) { 196 | for (byte i = 0; i < bufferSize; i++) { 197 | Serial.print(buffer[i] < 0x10 ? " 0" : " "); 198 | Serial.print(buffer[i], HEX); 199 | } 200 | } 201 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/examples/ReadNUID/ReadNUID.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------------------------------------------------- 3 | * Example sketch/program showing how to read new NUID from a PICC to serial. 4 | * -------------------------------------------------------------------------------------------------------------------- 5 | * This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid 6 | * 7 | * Example sketch/program showing how to the read data from a PICC (that is: a RFID Tag or Card) using a MFRC522 based RFID 8 | * Reader on the Arduino SPI interface. 9 | * 10 | * When the Arduino and the MFRC522 module are connected (see the pin layout below), load this sketch into Arduino IDE 11 | * then verify/compile and upload it. To see the output: use Tools, Serial Monitor of the IDE (hit Ctrl+Shft+M). When 12 | * you present a PICC (that is: a RFID Tag or Card) at reading distance of the MFRC522 Reader/PCD, the serial output 13 | * will show the type, and the NUID if a new card has been detected. Note: you may see "Timeout in communication" messages 14 | * when removing the PICC from reading distance too early. 15 | * 16 | * @license Released into the public domain. 17 | * 18 | * Typical pin layout used: 19 | * ----------------------------------------------------------------------------------------- 20 | * MFRC522 Arduino Arduino Arduino Arduino Arduino 21 | * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro 22 | * Signal Pin Pin Pin Pin Pin Pin 23 | * ----------------------------------------------------------------------------------------- 24 | * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 25 | * SPI SS SDA(SS) 10 53 D10 10 10 26 | * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 27 | * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 28 | * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 29 | */ 30 | 31 | #include 32 | #include 33 | 34 | #define SS_PIN 10 35 | #define RST_PIN 9 36 | 37 | MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class 38 | 39 | MFRC522::MIFARE_Key key; 40 | 41 | // Init array that will store new NUID 42 | byte nuidPICC[4]; 43 | 44 | void setup() { 45 | Serial.begin(9600); 46 | SPI.begin(); // Init SPI bus 47 | rfid.PCD_Init(); // Init MFRC522 48 | 49 | for (byte i = 0; i < 6; i++) { 50 | key.keyByte[i] = 0xFF; 51 | } 52 | 53 | Serial.println(F("This code scan the MIFARE Classsic NUID.")); 54 | Serial.print(F("Using the following key:")); 55 | printHex(key.keyByte, MFRC522::MF_KEY_SIZE); 56 | } 57 | 58 | void loop() { 59 | 60 | // Look for new cards 61 | if ( ! rfid.PICC_IsNewCardPresent()) 62 | return; 63 | 64 | // Verify if the NUID has been readed 65 | if ( ! rfid.PICC_ReadCardSerial()) 66 | return; 67 | 68 | Serial.print(F("PICC type: ")); 69 | MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak); 70 | Serial.println(rfid.PICC_GetTypeName(piccType)); 71 | 72 | // Check is the PICC of Classic MIFARE type 73 | if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI && 74 | piccType != MFRC522::PICC_TYPE_MIFARE_1K && 75 | piccType != MFRC522::PICC_TYPE_MIFARE_4K) { 76 | Serial.println(F("Your tag is not of type MIFARE Classic.")); 77 | return; 78 | } 79 | 80 | if (rfid.uid.uidByte[0] != nuidPICC[0] || 81 | rfid.uid.uidByte[1] != nuidPICC[1] || 82 | rfid.uid.uidByte[2] != nuidPICC[2] || 83 | rfid.uid.uidByte[3] != nuidPICC[3] ) { 84 | Serial.println(F("A new card has been detected.")); 85 | 86 | // Store NUID into nuidPICC array 87 | for (byte i = 0; i < 4; i++) { 88 | nuidPICC[i] = rfid.uid.uidByte[i]; 89 | } 90 | 91 | Serial.println(F("The NUID tag is:")); 92 | Serial.print(F("In hex: ")); 93 | printHex(rfid.uid.uidByte, rfid.uid.size); 94 | Serial.println(); 95 | Serial.print(F("In dec: ")); 96 | printDec(rfid.uid.uidByte, rfid.uid.size); 97 | Serial.println(); 98 | } 99 | else Serial.println(F("Card read previously.")); 100 | 101 | // Halt PICC 102 | rfid.PICC_HaltA(); 103 | 104 | // Stop encryption on PCD 105 | rfid.PCD_StopCrypto1(); 106 | } 107 | 108 | 109 | /** 110 | * Helper routine to dump a byte array as hex values to Serial. 111 | */ 112 | void printHex(byte *buffer, byte bufferSize) { 113 | for (byte i = 0; i < bufferSize; i++) { 114 | Serial.print(buffer[i] < 0x10 ? " 0" : " "); 115 | Serial.print(buffer[i], HEX); 116 | } 117 | } 118 | 119 | /** 120 | * Helper routine to dump a byte array as dec values to Serial. 121 | */ 122 | void printDec(byte *buffer, byte bufferSize) { 123 | for (byte i = 0; i < bufferSize; i++) { 124 | Serial.print(buffer[i] < 0x10 ? " 0" : " "); 125 | Serial.print(buffer[i], DEC); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/examples/ReadUidMultiReader/ReadUidMultiReader.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * ---------------------------------------------------------------------------- 3 | * This is a MFRC522 library example; see https://github.com/miguelbalboa/rfid 4 | * for further details and other examples. 5 | * 6 | * NOTE: The library file MFRC522.h has a lot of useful info. Please read it. 7 | * 8 | * Released into the public domain. 9 | * ---------------------------------------------------------------------------- 10 | * This sample shows how to read and write data blocks on a MIFARE Classic PICC 11 | * (= card/tag). 12 | * 13 | * BEWARE: Data will be written to the PICC, in sector #1 (blocks #4 to #7). 14 | * 15 | * 16 | * Typical pin layout used: 17 | * ----------------------------------------------------------------------------------------- 18 | * MFRC522 Arduino Arduino Arduino Arduino Arduino 19 | * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro 20 | * Signal Pin Pin Pin Pin Pin Pin 21 | * ----------------------------------------------------------------------------------------- 22 | * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 23 | * SPI SS 1 SDA(SS) ** custom, take a unused pin, only HIGH/LOW required ** 24 | * SPI SS 2 SDA(SS) ** custom, take a unused pin, only HIGH/LOW required ** 25 | * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 26 | * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 27 | * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 28 | * 29 | */ 30 | 31 | #include 32 | #include 33 | 34 | #define RST_PIN 9 // Configurable, see typical pin layout above 35 | #define SS_1_PIN 10 // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 2 36 | #define SS_2_PIN 8 // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 1 37 | 38 | #define NR_OF_READERS 2 39 | 40 | byte ssPins[] = {SS_1_PIN, SS_2_PIN}; 41 | 42 | MFRC522 mfrc522[NR_OF_READERS]; // Create MFRC522 instance. 43 | 44 | /** 45 | * Initialize. 46 | */ 47 | void setup() { 48 | 49 | Serial.begin(9600); // Initialize serial communications with the PC 50 | while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 51 | 52 | SPI.begin(); // Init SPI bus 53 | 54 | for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) { 55 | mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN); // Init each MFRC522 card 56 | Serial.print(F("Reader ")); 57 | Serial.print(reader); 58 | Serial.print(F(": ")); 59 | mfrc522[reader].PCD_DumpVersionToSerial(); 60 | } 61 | } 62 | 63 | /** 64 | * Main loop. 65 | */ 66 | void loop() { 67 | 68 | for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) { 69 | // Look for new cards 70 | 71 | if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) { 72 | Serial.print(F("Reader ")); 73 | Serial.print(reader); 74 | // Show some details of the PICC (that is: the tag/card) 75 | Serial.print(F(": Card UID:")); 76 | dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size); 77 | Serial.println(); 78 | Serial.print(F("PICC type: ")); 79 | MFRC522::PICC_Type piccType = mfrc522[reader].PICC_GetType(mfrc522[reader].uid.sak); 80 | Serial.println(mfrc522[reader].PICC_GetTypeName(piccType)); 81 | 82 | // Halt PICC 83 | mfrc522[reader].PICC_HaltA(); 84 | // Stop encryption on PCD 85 | mfrc522[reader].PCD_StopCrypto1(); 86 | } //if (mfrc522[reader].PICC_IsNewC 87 | } //for(uint8_t reader 88 | } 89 | 90 | /** 91 | * Helper routine to dump a byte array as hex values to Serial. 92 | */ 93 | void dump_byte_array(byte *buffer, byte bufferSize) { 94 | for (byte i = 0; i < bufferSize; i++) { 95 | Serial.print(buffer[i] < 0x10 ? " 0" : " "); 96 | Serial.print(buffer[i], HEX); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/examples/firmware_check/firmware_check.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------------------------------------------------------- 3 | * Example sketch/program to test your firmware. 4 | * -------------------------------------------------------------------------------------------------------------------- 5 | * This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid 6 | * 7 | * This example test the firmware of your MFRC522 reader module, only known version can be checked. If the test passed 8 | * it do not mean that your module is faultless! Some modules have bad or broken antennas or the PICC is broken. 9 | * NOTE: for more informations read the README.rst 10 | * 11 | * @author Rotzbua 12 | * @license Released into the public domain. 13 | * 14 | * Typical pin layout used: 15 | * ----------------------------------------------------------------------------------------- 16 | * MFRC522 Arduino Arduino Arduino Arduino Arduino 17 | * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro 18 | * Signal Pin Pin Pin Pin Pin Pin 19 | * ----------------------------------------------------------------------------------------- 20 | * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 21 | * SPI SS SDA(SS) 10 53 D10 10 10 22 | * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 23 | * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 24 | * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | #define RST_PIN 9 // Configurable, see typical pin layout above 31 | #define SS_PIN 10 // Configurable, see typical pin layout above 32 | 33 | MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance 34 | 35 | /** 36 | * Check firmware only once at startup 37 | */ 38 | void setup() { 39 | Serial.begin(9600); // Initialize serial communications with the PC 40 | while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 41 | SPI.begin(); // Init SPI bus 42 | mfrc522.PCD_Init(); // Init MFRC522 module 43 | 44 | Serial.println(F("*****************************")); 45 | Serial.println(F("MFRC522 Digital self test")); 46 | Serial.println(F("*****************************")); 47 | mfrc522.PCD_DumpVersionToSerial(); // Show version of PCD - MFRC522 Card Reader 48 | Serial.println(F("-----------------------------")); 49 | Serial.println(F("Only known versions supported")); 50 | Serial.println(F("-----------------------------")); 51 | Serial.println(F("Performing test...")); 52 | bool result = mfrc522.PCD_PerformSelfTest(); // perform the test 53 | Serial.println(F("-----------------------------")); 54 | Serial.print(F("Result: ")); 55 | if (result) 56 | Serial.println(F("OK")); 57 | else 58 | Serial.println(F("DEFECT or UNKNOWN")); 59 | Serial.println(); 60 | } 61 | 62 | void loop() {} // nothing to do 63 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/examples/rfid_default_keys/rfid_default_keys.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * ---------------------------------------------------------------------------- 3 | * This is a MFRC522 library example; see https://github.com/miguelbalboa/rfid 4 | * for further details and other examples. 5 | * 6 | * NOTE: The library file MFRC522.h has a lot of useful info. Please read it. 7 | * 8 | * Released into the public domain. 9 | * ---------------------------------------------------------------------------- 10 | * Example sketch/program which will try the most used default keys listed in 11 | * https://code.google.com/p/mfcuk/wiki/MifareClassicDefaultKeys to dump the 12 | * block 0 of a MIFARE RFID card using a RFID-RC522 reader. 13 | * 14 | * Typical pin layout used: 15 | * ----------------------------------------------------------------------------------------- 16 | * MFRC522 Arduino Arduino Arduino Arduino Arduino 17 | * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro 18 | * Signal Pin Pin Pin Pin Pin Pin 19 | * ----------------------------------------------------------------------------------------- 20 | * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 21 | * SPI SS SDA(SS) 10 53 D10 10 10 22 | * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 23 | * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 24 | * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 25 | * 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | #define RST_PIN 9 // Configurable, see typical pin layout above 32 | #define SS_PIN 10 // Configurable, see typical pin layout above 33 | 34 | MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance. 35 | 36 | // Number of known default keys (hard-coded) 37 | // NOTE: Synchronize the NR_KNOWN_KEYS define with the defaultKeys[] array 38 | #define NR_KNOWN_KEYS 8 39 | // Known keys, see: https://code.google.com/p/mfcuk/wiki/MifareClassicDefaultKeys 40 | byte knownKeys[NR_KNOWN_KEYS][MFRC522::MF_KEY_SIZE] = { 41 | {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // FF FF FF FF FF FF = factory default 42 | {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5}, // A0 A1 A2 A3 A4 A5 43 | {0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5}, // B0 B1 B2 B3 B4 B5 44 | {0x4d, 0x3a, 0x99, 0xc3, 0x51, 0xdd}, // 4D 3A 99 C3 51 DD 45 | {0x1a, 0x98, 0x2c, 0x7e, 0x45, 0x9a}, // 1A 98 2C 7E 45 9A 46 | {0xd3, 0xf7, 0xd3, 0xf7, 0xd3, 0xf7}, // D3 F7 D3 F7 D3 F7 47 | {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, // AA BB CC DD EE FF 48 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // 00 00 00 00 00 00 49 | }; 50 | 51 | /* 52 | * Initialize. 53 | */ 54 | void setup() { 55 | Serial.begin(9600); // Initialize serial communications with the PC 56 | while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) 57 | SPI.begin(); // Init SPI bus 58 | mfrc522.PCD_Init(); // Init MFRC522 card 59 | Serial.println(F("Try the most used default keys to print block 0 of a MIFARE PICC.")); 60 | } 61 | 62 | /* 63 | * Helper routine to dump a byte array as hex values to Serial. 64 | */ 65 | void dump_byte_array(byte *buffer, byte bufferSize) { 66 | for (byte i = 0; i < bufferSize; i++) { 67 | Serial.print(buffer[i] < 0x10 ? " 0" : " "); 68 | Serial.print(buffer[i], HEX); 69 | } 70 | } 71 | 72 | /* 73 | * Try using the PICC (the tag/card) with the given key to access block 0. 74 | * On success, it will show the key details, and dump the block data on Serial. 75 | * 76 | * @return true when the given key worked, false otherwise. 77 | */ 78 | boolean try_key(MFRC522::MIFARE_Key *key) 79 | { 80 | boolean result = false; 81 | byte buffer[18]; 82 | byte block = 0; 83 | MFRC522::StatusCode status; 84 | 85 | // http://arduino.stackexchange.com/a/14316 86 | if ( ! mfrc522.PICC_IsNewCardPresent()) 87 | return false; 88 | if ( ! mfrc522.PICC_ReadCardSerial()) 89 | return false; 90 | // Serial.println(F("Authenticating using key A...")); 91 | status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, key, &(mfrc522.uid)); 92 | if (status != MFRC522::STATUS_OK) { 93 | // Serial.print(F("PCD_Authenticate() failed: ")); 94 | // Serial.println(mfrc522.GetStatusCodeName(status)); 95 | return false; 96 | } 97 | 98 | // Read block 99 | byte byteCount = sizeof(buffer); 100 | status = mfrc522.MIFARE_Read(block, buffer, &byteCount); 101 | if (status != MFRC522::STATUS_OK) { 102 | // Serial.print(F("MIFARE_Read() failed: ")); 103 | // Serial.println(mfrc522.GetStatusCodeName(status)); 104 | } 105 | else { 106 | // Successful read 107 | result = true; 108 | Serial.print(F("Success with key:")); 109 | dump_byte_array((*key).keyByte, MFRC522::MF_KEY_SIZE); 110 | Serial.println(); 111 | // Dump block data 112 | Serial.print(F("Block ")); Serial.print(block); Serial.print(F(":")); 113 | dump_byte_array(buffer, 16); 114 | Serial.println(); 115 | } 116 | Serial.println(); 117 | 118 | mfrc522.PICC_HaltA(); // Halt PICC 119 | mfrc522.PCD_StopCrypto1(); // Stop encryption on PCD 120 | return result; 121 | } 122 | 123 | /* 124 | * Main loop. 125 | */ 126 | void loop() { 127 | // Look for new cards 128 | if ( ! mfrc522.PICC_IsNewCardPresent()) 129 | return; 130 | 131 | // Select one of the cards 132 | if ( ! mfrc522.PICC_ReadCardSerial()) 133 | return; 134 | 135 | // Show some details of the PICC (that is: the tag/card) 136 | Serial.print(F("Card UID:")); 137 | dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size); 138 | Serial.println(); 139 | Serial.print(F("PICC type: ")); 140 | MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); 141 | Serial.println(mfrc522.PICC_GetTypeName(piccType)); 142 | 143 | // Try the known default keys 144 | MFRC522::MIFARE_Key key; 145 | for (byte k = 0; k < NR_KNOWN_KEYS; k++) { 146 | // Copy the known key into the MIFARE_Key structure 147 | for (byte i = 0; i < MFRC522::MF_KEY_SIZE; i++) { 148 | key.keyByte[i] = knownKeys[k][i]; 149 | } 150 | // Try the key 151 | if (try_key(&key)) { 152 | // Found and reported on the key and block, 153 | // no need to try other keys for this PICC 154 | break; 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/examples/rfid_write_personal_data/rfid_write_personal_data.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Write personal data of a MIFARE RFID card using a RFID-RC522 reader 3 | * Uses MFRC522 - Library to use ARDUINO RFID MODULE KIT 13.56 MHZ WITH TAGS SPI W AND R BY COOQROBOT. 4 | * ----------------------------------------------------------------------------------------- 5 | * MFRC522 Arduino Arduino Arduino Arduino Arduino 6 | * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro 7 | * Signal Pin Pin Pin Pin Pin Pin 8 | * ----------------------------------------------------------------------------------------- 9 | * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 10 | * SPI SS SDA(SS) 10 53 D10 10 10 11 | * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 12 | * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 13 | * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 14 | * 15 | * Hardware required: 16 | * Arduino 17 | * PCD (Proximity Coupling Device): NXP MFRC522 Contactless Reader IC 18 | * PICC (Proximity Integrated Circuit Card): A card or tag using the ISO 14443A interface, eg Mifare or NTAG203. 19 | * The reader can be found on eBay for around 5 dollars. Search for "mf-rc522" on ebay.com. 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #define RST_PIN 9 // Configurable, see typical pin layout above 26 | #define SS_PIN 10 // Configurable, see typical pin layout above 27 | 28 | MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance 29 | 30 | void setup() { 31 | Serial.begin(9600); // Initialize serial communications with the PC 32 | SPI.begin(); // Init SPI bus 33 | mfrc522.PCD_Init(); // Init MFRC522 card 34 | Serial.println(F("Write personal data on a MIFARE PICC ")); 35 | } 36 | 37 | void loop() { 38 | 39 | // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory. 40 | MFRC522::MIFARE_Key key; 41 | for (byte i = 0; i < 6; i++) key.keyByte[i] = 0xFF; 42 | 43 | // Look for new cards 44 | if ( ! mfrc522.PICC_IsNewCardPresent()) { 45 | return; 46 | } 47 | 48 | // Select one of the cards 49 | if ( ! mfrc522.PICC_ReadCardSerial()) return; 50 | 51 | Serial.print(F("Card UID:")); //Dump UID 52 | for (byte i = 0; i < mfrc522.uid.size; i++) { 53 | Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); 54 | Serial.print(mfrc522.uid.uidByte[i], HEX); 55 | } 56 | Serial.print(F(" PICC type: ")); // Dump PICC type 57 | MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); 58 | Serial.println(mfrc522.PICC_GetTypeName(piccType)); 59 | 60 | byte buffer[34]; 61 | byte block; 62 | MFRC522::StatusCode status; 63 | byte len; 64 | 65 | Serial.setTimeout(20000L) ; // wait until 20 seconds for input from serial 66 | // Ask personal data: Family name 67 | Serial.println(F("Type Family name, ending with #")); 68 | len=Serial.readBytesUntil('#', (char *) buffer, 30) ; // read family name from serial 69 | for (byte i = len; i < 30; i++) buffer[i] = ' '; // pad with spaces 70 | 71 | block = 1; 72 | //Serial.println(F("Authenticating using key A...")); 73 | status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, &key, &(mfrc522.uid)); 74 | if (status != MFRC522::STATUS_OK) { 75 | Serial.print(F("PCD_Authenticate() failed: ")); 76 | Serial.println(mfrc522.GetStatusCodeName(status)); 77 | return; 78 | } 79 | else Serial.println(F("PCD_Authenticate() success: ")); 80 | 81 | // Write block 82 | status = mfrc522.MIFARE_Write(block, buffer, 16); 83 | if (status != MFRC522::STATUS_OK) { 84 | Serial.print(F("MIFARE_Write() failed: ")); 85 | Serial.println(mfrc522.GetStatusCodeName(status)); 86 | return; 87 | } 88 | else Serial.println(F("MIFARE_Write() success: ")); 89 | 90 | block = 2; 91 | //Serial.println(F("Authenticating using key A...")); 92 | status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, &key, &(mfrc522.uid)); 93 | if (status != MFRC522::STATUS_OK) { 94 | Serial.print(F("PCD_Authenticate() failed: ")); 95 | Serial.println(mfrc522.GetStatusCodeName(status)); 96 | return; 97 | } 98 | 99 | // Write block 100 | status = mfrc522.MIFARE_Write(block, &buffer[16], 16); 101 | if (status != MFRC522::STATUS_OK) { 102 | Serial.print(F("MIFARE_Write() failed: ")); 103 | Serial.println(mfrc522.GetStatusCodeName(status)); 104 | return; 105 | } 106 | else Serial.println(F("MIFARE_Write() success: ")); 107 | 108 | // Ask personal data: First name 109 | Serial.println(F("Type First name, ending with #")); 110 | len=Serial.readBytesUntil('#', (char *) buffer, 20) ; // read first name from serial 111 | for (byte i = len; i < 20; i++) buffer[i] = ' '; // pad with spaces 112 | 113 | block = 4; 114 | //Serial.println(F("Authenticating using key A...")); 115 | status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, &key, &(mfrc522.uid)); 116 | if (status != MFRC522::STATUS_OK) { 117 | Serial.print(F("PCD_Authenticate() failed: ")); 118 | Serial.println(mfrc522.GetStatusCodeName(status)); 119 | return; 120 | } 121 | 122 | // Write block 123 | status = mfrc522.MIFARE_Write(block, buffer, 16); 124 | if (status != MFRC522::STATUS_OK) { 125 | Serial.print(F("MIFARE_Write() failed: ")); 126 | Serial.println(mfrc522.GetStatusCodeName(status)); 127 | return; 128 | } 129 | else Serial.println(F("MIFARE_Write() success: ")); 130 | 131 | block = 5; 132 | //Serial.println(F("Authenticating using key A...")); 133 | status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, &key, &(mfrc522.uid)); 134 | if (status != MFRC522::STATUS_OK) { 135 | Serial.print(F("PCD_Authenticate() failed: ")); 136 | Serial.println(mfrc522.GetStatusCodeName(status)); 137 | return; 138 | } 139 | 140 | // Write block 141 | status = mfrc522.MIFARE_Write(block, &buffer[16], 16); 142 | if (status != MFRC522::STATUS_OK) { 143 | Serial.print(F("MIFARE_Write() failed: ")); 144 | Serial.println(mfrc522.GetStatusCodeName(status)); 145 | return; 146 | } 147 | else Serial.println(F("MIFARE_Write() success: ")); 148 | 149 | 150 | Serial.println(" "); 151 | mfrc522.PICC_HaltA(); // Halt PICC 152 | mfrc522.PCD_StopCrypto1(); // Stop encryption on PCD 153 | 154 | } 155 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map for library MFRC522 3 | ####################################### 4 | 5 | ####################################### 6 | # KEYWORD1 Classes, datatypes, and C++ keywords 7 | ####################################### 8 | MFRC522 KEYWORD1 9 | PCD_Register KEYWORD1 10 | PCD_Command KEYWORD1 11 | PCD_RxGain KEYWORD1 12 | PICC_Command KEYWORD1 13 | MIFARE_Misc KEYWORD1 14 | PICC_Type KEYWORD1 15 | StatusCode KEYWORD1 16 | Uid KEYWORD1 17 | MIFARE_Key KEYWORD1 18 | 19 | ####################################### 20 | # KEYWORD2 Methods and functions 21 | ####################################### 22 | 23 | # Basic interface functions for communicating with the MFRC522 24 | PCD_WriteRegister KEYWORD2 25 | PCD_WriteRegister KEYWORD2 26 | PCD_ReadRegister KEYWORD2 27 | PCD_ReadRegister KEYWORD2 28 | setBitMask KEYWORD2 29 | PCD_SetRegisterBitMask KEYWORD2 30 | PCD_ClearRegisterBitMask KEYWORD2 31 | PCD_CalculateCRC KEYWORD2 32 | 33 | # Functions for manipulating the MFRC522 34 | PCD_Init KEYWORD2 35 | PCD_Reset KEYWORD2 36 | PCD_AntennaOn KEYWORD2 37 | PCD_AntennaOff KEYWORD2 38 | PCD_GetAntennaGain KEYWORD2 39 | PCD_SetAntennaGain KEYWORD2 40 | PCD_PerformSelfTest KEYWORD2 41 | 42 | # Functions for communicating with PICCs 43 | PCD_TransceiveData KEYWORD2 44 | PCD_CommunicateWithPICC KEYWORD2 45 | PICC_RequestA KEYWORD2 46 | PICC_WakeupA KEYWORD2 47 | PICC_REQA_or_WUPA KEYWORD2 48 | PICC_Select KEYWORD2 49 | PICC_HaltA KEYWORD2 50 | 51 | # Functions for communicating with MIFARE PICCs 52 | PCD_Authenticate KEYWORD2 53 | PCD_StopCrypto1 KEYWORD2 54 | MIFARE_Read KEYWORD2 55 | MIFARE_Write KEYWORD2 56 | MIFARE_Increment KEYWORD2 57 | MIFARE_Ultralight_Write KEYWORD2 58 | MIFARE_GetValue KEYWORD2 59 | MIFARE_SetValue KEYWORD2 60 | PCD_NTAG216_AUTH KEYWORD2 61 | 62 | # Support functions 63 | PCD_MIFARE_Transceive KEYWORD2 64 | GetStatusCodeName KEYWORD2 65 | PICC_GetType KEYWORD2 66 | PICC_GetTypeName KEYWORD2 67 | 68 | # Support functions for debuging 69 | PCD_DumpVersionToSerial KEYWORD2 70 | PICC_DumpToSerial KEYWORD2 71 | PICC_DumpDetailsToSerial KEYWORD2 72 | PICC_DumpMifareClassicToSerial KEYWORD2 73 | PICC_DumpMifareClassicSectorToSerial KEYWORD2 74 | PICC_DumpMifareUltralightToSerial KEYWORD2 75 | 76 | # Advanced functions for MIFARE 77 | MIFARE_SetAccessBits KEYWORD2 78 | MIFARE_OpenUidBackdoor KEYWORD2 79 | MIFARE_SetUid KEYWORD2 80 | MIFARE_UnbrickUidSector KEYWORD2 81 | 82 | # Convenience functions - does not add extra functionality 83 | PICC_IsNewCardPresent KEYWORD2 84 | PICC_ReadCardSerial KEYWORD2 85 | 86 | ####################################### 87 | # KEYWORD3 setup and loop functions, as well as the Serial keywords 88 | ####################################### 89 | 90 | ####################################### 91 | LITERAL1 Constants 92 | ####################################### 93 | CommandReg LITERAL1 94 | ComIEnReg LITERAL1 95 | DivIEnReg LITERAL1 96 | ComIrqReg LITERAL1 97 | DivIrqReg LITERAL1 98 | ErrorReg LITERAL1 99 | Status1Reg LITERAL1 100 | Status2Reg LITERAL1 101 | FIFODataReg LITERAL1 102 | FIFOLevelReg LITERAL1 103 | WaterLevelReg LITERAL1 104 | ControlReg LITERAL1 105 | BitFramingReg LITERAL1 106 | CollReg LITERAL1 107 | ModeReg LITERAL1 108 | TxModeReg LITERAL1 109 | RxModeReg LITERAL1 110 | TxControlReg LITERAL1 111 | TxASKReg LITERAL1 112 | TxSelReg LITERAL1 113 | RxSelReg LITERAL1 114 | RxThresholdReg LITERAL1 115 | DemodReg LITERAL1 116 | MfTxReg LITERAL1 117 | MfRxReg LITERAL1 118 | SerialSpeedReg LITERAL1 119 | CRCResultRegH LITERAL1 120 | CRCResultRegL LITERAL1 121 | ModWidthReg LITERAL1 122 | RFCfgReg LITERAL1 123 | GsNReg LITERAL1 124 | CWGsPReg LITERAL1 125 | ModGsPReg LITERAL1 126 | TModeReg LITERAL1 127 | TPrescalerReg LITERAL1 128 | TReloadRegH LITERAL1 129 | TReloadRegL LITERAL1 130 | TCounterValueRegH LITERAL1 131 | TCounterValueRegL LITERAL1 132 | TestSel1Reg LITERAL1 133 | TestSel2Reg LITERAL1 134 | TestPinEnReg LITERAL1 135 | TestPinValueReg LITERAL1 136 | TestBusReg LITERAL1 137 | AutoTestReg LITERAL1 138 | VersionReg LITERAL1 139 | AnalogTestReg LITERAL1 140 | TestDAC1Reg LITERAL1 141 | TestDAC2Reg LITERAL1 142 | TestADCReg LITERAL1 143 | PCD_Idle LITERAL1 144 | PCD_Mem LITERAL1 145 | PCD_GenerateRandomID LITERAL1 146 | PCD_CalcCRC LITERAL1 147 | PCD_Transmit LITERAL1 148 | PCD_NoCmdChange LITERAL1 149 | PCD_Receive LITERAL1 150 | PCD_Transceive LITERAL1 151 | PCD_MFAuthent LITERAL1 152 | PCD_SoftReset LITERAL1 153 | RxGain_18dB LITERAL1 154 | RxGain_23dB LITERAL1 155 | RxGain_18dB_2 LITERAL1 156 | RxGain_23dB_2 LITERAL1 157 | RxGain_33dB LITERAL1 158 | RxGain_38dB LITERAL1 159 | RxGain_43dB LITERAL1 160 | RxGain_48dB LITERAL1 161 | RxGain_min LITERAL1 162 | RxGain_avg LITERAL1 163 | RxGain_max LITERAL1 164 | PICC_CMD_REQA LITERAL1 165 | PICC_CMD_WUPA LITERAL1 166 | PICC_CMD_CT LITERAL1 167 | PICC_CMD_SEL_CL1 LITERAL1 168 | PICC_CMD_SEL_CL2 LITERAL1 169 | PICC_CMD_SEL_CL3 LITERAL1 170 | PICC_CMD_HLTA LITERAL1 171 | PICC_CMD_MF_AUTH_KEY_A LITERAL1 172 | PICC_CMD_MF_AUTH_KEY_B LITERAL1 173 | PICC_CMD_MF_READ LITERAL1 174 | PICC_CMD_MF_WRITE LITERAL1 175 | PICC_CMD_MF_DECREMENT LITERAL1 176 | PICC_CMD_MF_INCREMENT LITERAL1 177 | PICC_CMD_MF_RESTORE LITERAL1 178 | PICC_CMD_MF_TRANSFER LITERAL1 179 | PICC_CMD_UL_WRITE LITERAL1 180 | MF_ACK LITERAL1 181 | MF_KEY_SIZE LITERAL1 182 | PICC_TYPE_UNKNOWN LITERAL1 183 | PICC_TYPE_ISO_14443_4 LITERAL1 184 | PICC_TYPE_ISO_18092 LITERAL1 185 | PICC_TYPE_MIFARE_MINI LITERAL1 186 | PICC_TYPE_MIFARE_1K LITERAL1 187 | PICC_TYPE_MIFARE_4K LITERAL1 188 | PICC_TYPE_MIFARE_UL LITERAL1 189 | PICC_TYPE_MIFARE_PLUS LITERAL1 190 | PICC_TYPE_TNP3XXX LITERAL1 191 | PICC_TYPE_NOT_COMPLETE LITERAL1 192 | STATUS_OK LITERAL1 193 | STATUS_ERROR LITERAL1 194 | STATUS_COLLISION LITERAL1 195 | STATUS_TIMEOUT LITERAL1 196 | STATUS_NO_ROOM LITERAL1 197 | STATUS_INTERNAL_ERROR LITERAL1 198 | STATUS_INVALID LITERAL1 199 | STATUS_CRC_WRONG LITERAL1 200 | STATUS_MIFARE_NACK LITERAL1 201 | FIFO_SIZE LITERAL1 202 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MFRC522", 3 | "keywords": "rfid, spi", 4 | "description": "Read a card using a MFRC522 reader on your SPI interface", 5 | "repository": 6 | { 7 | "type": "git", 8 | "url": "https://github.com/miguelbalboa/rfid.git" 9 | }, 10 | "version": "1.2.0", 11 | "exclude": "doc", 12 | "frameworks": "arduino", 13 | "platforms": ["atmelavr", "ststm32", "teensy", "espressif8266"] 14 | } 15 | -------------------------------------------------------------------------------- /Library Arduino/rfid-master/library.properties: -------------------------------------------------------------------------------- 1 | name=MFRC522 2 | version=1.2.0 3 | author=GithubCommunity 4 | maintainer=miguelbalboa 5 | sentence=Arduino RFID Library for MFRC522 (SPI) 6 | paragraph=Read/Write a RFID Card or Tag using the ISO/IEC 14443A/MIFARE interface. 7 | category=Communication 8 | url=https://github.com/miguelbalboa/rfid 9 | architectures=avr,STM32F1,teensy 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SISTEM-INFORMASI-ABSENSI-RFID-IOT- 2 | --------------------------------------------------------------------------------