├── 180815 LCD.zip ├── Adafruit_BNO055-master.zip ├── Frekuensi Arduino 40KHz ├── Book1.xlsx ├── Presentation1.pptx ├── Untitled.png ├── fsa.txt ├── sketch_jul16b_LCD │ └── sketch_jul16b_LCD.ino └── sketch_jul19a │ └── sketch_jul19a.ino ├── HX711 ├── Calibration │ └── Calibration.ino ├── HX711_ADC-master.zip ├── New Microsoft PowerPoint Presentation.pptx ├── Testing │ └── Testing.ino ├── hx711.jpg ├── hx711d.jpg └── main_hx_blynk_rpm │ └── main_hx_blynk_rpm.ino ├── I2c_scanner.zip ├── MPU2 ├── All File.zip ├── I2C_scanner │ └── I2C_scanner.ino ├── lib │ ├── Arduino-MPU6050-master │ │ ├── CHANGELOG │ │ ├── LICENSE │ │ ├── MPU6050.cpp │ │ ├── MPU6050.h │ │ ├── MPU6050_accel_pitch_roll │ │ │ └── MPU6050_accel_pitch_roll.ino │ │ ├── MPU6050_accel_simple │ │ │ └── MPU6050_accel_simple.ino │ │ ├── MPU6050_free_fall │ │ │ └── MPU6050_free_fall.ino │ │ ├── MPU6050_gyro_pitch_roll_yaw │ │ │ └── MPU6050_gyro_pitch_roll_yaw.ino │ │ ├── MPU6050_gyro_simple │ │ │ └── MPU6050_gyro_simple.ino │ │ ├── MPU6050_motion │ │ │ └── MPU6050_motion.ino │ │ ├── MPU6050_temperature │ │ │ └── MPU6050_temperature.ino │ │ └── README.md │ └── MPU6050_tockn-master │ │ ├── README.md │ │ ├── examples │ │ ├── GetAllData │ │ │ └── GetAllData.ino │ │ └── GetAngle │ │ │ └── GetAngle.ino │ │ ├── library.properties │ │ └── src │ │ ├── MPU6050_tockn.cpp │ │ └── MPU6050_tockn.h └── sketch_aug01a │ └── sketch_aug01a.ino ├── Sensor AD8232 ├── Blog AD8232 KEYES ESP32.docx └── main6_MAV │ └── main6_MAV.ino ├── SuhuKelembapanDHT22 ├── DHT_sensor_library.zip ├── dht22.jpg └── suhu_dht22 │ ├── dh22.ino │ └── suhu_dht22.ino ├── bts7960 ├── btsservo.jpg └── data bts7960.xlsx ├── dimmerPWM ├── RBDDimmer-master.zip ├── SerialMonitorDim │ └── SerialMonitorDim.ino ├── dimmer nano.jpg └── esp32 │ ├── SerialMonitorDim_ESP │ └── SerialMonitorDim_ESP.ino │ └── dimmer esp.jpg ├── epever ├── ModbusMaster-master │ ├── .github │ │ ├── ISSUE_TEMPLATE.md │ │ └── PULL_REQUEST_TEMPLATE.md │ ├── .github_changelog_generator │ ├── .gitignore │ ├── .ruby-gemset │ ├── .ruby-version │ ├── .travis.yml │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── Gemfile │ ├── Gemfile.lock │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── Rakefile │ ├── STYLE.md │ ├── VERSION │ ├── examples │ │ ├── Basic │ │ │ └── Basic.pde │ │ ├── PhoenixContact_nanoLC │ │ │ └── PhoenixContact_nanoLC.pde │ │ └── RS485_HalfDuplex │ │ │ └── RS485_HalfDuplex.ino │ ├── extras │ │ ├── ModbusMaster reference-2.0.1.pdf │ │ └── README.txt │ ├── keywords.txt │ ├── library.properties │ └── src │ │ ├── ModbusMaster.cpp │ │ ├── ModbusMaster.h │ │ └── util │ │ ├── crc16.h │ │ └── word.h ├── Screenshot (18).png └── no_blynk_serial_2 │ └── no_blynk_serial_2.ino ├── esp32_firebase └── firebase_legacy.zip ├── esp32_ps3 ├── esp32-ps3-master.zip └── esp32_ps3 │ └── esp32_ps3.ino ├── esp32bt ├── bt2legacyv2 │ └── bt2legacyv2.ino └── btblev2 │ └── btblev2.ino ├── floatsprintf └── floatsprintf.ino ├── gps10zubx ├── Presentation1.pptx ├── RANGKUMAN protocol UBX.txt ├── UBX10Z.zip └── u-blox8-M8_ReceiverDescrProtSpec_UBX-13003221.pdf ├── konten_us_SMA └── konten_us.ino ├── labview └── 190613_mesin.vi ├── library ├── Adafruit_GPS-master.zip └── Mecha_QMC5883L-master.zip ├── logger └── logger.ino ├── main_tombol.zip ├── multi_plotter └── multi_plotter.ino ├── nokia_tune └── nokia_tune.ino ├── nrf_remote ├── JoystickShield-master.zip ├── RF24-master.zip ├── main │ └── main.ino └── main_remot │ └── main_remot.ino ├── ph_arduino ├── ph kalibrasi.xlsx └── ph_arduino.ino ├── project ├── Brangkas_SIM_CAM-VC0706-master.zip └── Kursi Bayi │ ├── BukuPA2_1110195022_Sayuna Ulfa Yakin.pdf │ └── File Lain.zip ├── random_number └── random_number.ino ├── rsa_edit ├── 17.K1.0007-MICHAEL VALENTINO-LAMP_a.pdf ├── rsa.ino └── rsa_edit.ino ├── scrolllcd ├── left │ └── left.ino └── right │ └── right.ino ├── sensor_getar └── sensor_getar.ino └── tayo ├── i_sensor.ino ├── o_motor.ino └── tayo.ino /180815 LCD.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/180815 LCD.zip -------------------------------------------------------------------------------- /Adafruit_BNO055-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/Adafruit_BNO055-master.zip -------------------------------------------------------------------------------- /Frekuensi Arduino 40KHz/Book1.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/Frekuensi Arduino 40KHz/Book1.xlsx -------------------------------------------------------------------------------- /Frekuensi Arduino 40KHz/Presentation1.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/Frekuensi Arduino 40KHz/Presentation1.pptx -------------------------------------------------------------------------------- /Frekuensi Arduino 40KHz/Untitled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/Frekuensi Arduino 40KHz/Untitled.png -------------------------------------------------------------------------------- /Frekuensi Arduino 40KHz/fsa.txt: -------------------------------------------------------------------------------- 1 | fSOC frekuensi crystal system yaitu 16Mhz atau 16.000.000 Hz -------------------------------------------------------------------------------- /Frekuensi Arduino 40KHz/sketch_jul16b_LCD/sketch_jul16b_LCD.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | LiquidCrystal_I2C lcd(0x3F,20,4); 4 | 5 | 6 | int hitung_icr, frekuensi, duty_cycle, dataf ; 7 | void setup() { 8 | Serial.begin(9600); 9 | lcd.init(); 10 | lcd.backlight(); 11 | pinMode(11, OUTPUT); 12 | // Timer/Counter 1 initialization 13 | TCCR1A = 0xA2; 14 | TCCR1B = 0x19; 15 | TCNT1H = 0x00; 16 | TCNT1L = 0x00; 17 | 18 | duty_cycle = 60; //0-100 19 | hitung_icr = 399; //lihat tabel 20 | frekuensi = 16000 / (1 + hitung_icr); 21 | 22 | Serial.print("D(%) = "); Serial.println(duty_cycle); 23 | Serial.print("ICR (D)= "); Serial.println(hitung_icr); 24 | Serial.print("F(kHz) = "); Serial.println(frekuensi); 25 | 26 | lcd.setCursor(0,0); 27 | lcd.print("Function Generator"); 28 | lcd.setCursor(0,1); 29 | lcd.print("D = "); lcd.print(duty_cycle); lcd.print(" % "); 30 | lcd.setCursor(0,2); 31 | lcd.print("F = "); lcd.print(frekuensi); lcd.print(" kHz "); 32 | lcd.setCursor(0,3); 33 | lcd.print("P = 11"); 34 | 35 | 36 | 37 | ICR1H = hitung_icr >> 8; 38 | ICR1L = hitung_icr & 0x00ff; 39 | // Register atur Duty Clycle 40 | OCR1A = hitung_icr * (duty_cycle / 100.0); 41 | 42 | } 43 | 44 | void loop() { 45 | // put your main code here, to run repeatedly: 46 | 47 | } 48 | -------------------------------------------------------------------------------- /Frekuensi Arduino 40KHz/sketch_jul19a/sketch_jul19a.ino: -------------------------------------------------------------------------------- 1 | int hitung_icr, frekuensi, duty_cycle, dataf ; 2 | void setup() { 3 | Serial.begin(9600); 4 | pinMode(11, OUTPUT); 5 | 6 | // Timer/Counter 1 initialization 7 | TCCR1A = 0xA2; 8 | TCCR1B = 0x19; 9 | TCNT1H = 0x00; 10 | TCNT1L = 0x00; 11 | 12 | duty_cycle = 30; //0-100 13 | hitung_icr = 199; //lihat tabel 14 | frekuensi = 16000 / (1 + hitung_icr); 15 | 16 | Serial.print("D(%) = "); Serial.println(duty_cycle); 17 | Serial.print("ICR (D)= "); Serial.println(hitung_icr); 18 | Serial.print("F(kHz) = "); Serial.println(frekuensi); 19 | 20 | ICR1H = hitung_icr >> 8; 21 | ICR1L = hitung_icr & 0x00ff; 22 | // Register atur Duty Clycle 23 | OCR1A = hitung_icr * (duty_cycle / 100.0); 24 | } 25 | 26 | void loop() { 27 | // put your main code here, to run repeatedly: 28 | } 29 | -------------------------------------------------------------------------------- /HX711/Calibration/Calibration.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------------------- 3 | HX711_ADC 4 | Arduino library for HX711 24-Bit Analog-to-Digital Converter for Weight Scales 5 | Olav Kallhovd sept2017 6 | ------------------------------------------------------------------------------------- 7 | */ 8 | 9 | /* 10 | This example file shows how to calibrate the load cell and optionally store the calibration 11 | value in EEPROM, and also how to change the value manually. 12 | The result value can then later be included in your project sketch or fetched from EEPROM. 13 | 14 | To implement calibration in your project sketch the simplified procedure is as follow: 15 | LoadCell.tare(); 16 | //place known mass 17 | LoadCell.refreshDataSet(); 18 | float newCalibrationValue = LoadCell.getNewCalibration(known_mass); 19 | */ 20 | 21 | #include 22 | #if defined(ESP8266)|| defined(ESP32) || defined(AVR) 23 | #include 24 | #endif 25 | 26 | //pins: 27 | const int HX711_dout = 15; //mcu > HX711 dout pin 28 | const int HX711_sck = 5; //mcu > HX711 sck pin 29 | 30 | //HX711 constructor: 31 | HX711_ADC LoadCell(HX711_dout, HX711_sck); 32 | 33 | const int calVal_eepromAdress = 0; 34 | unsigned long t = 0; 35 | 36 | void setup() { 37 | Serial.begin(9600); delay(10); 38 | Serial.println(); 39 | Serial.println("Starting..."); 40 | 41 | LoadCell.begin(); 42 | //LoadCell.setReverseOutput(); //uncomment to turn a negative output value to positive 43 | unsigned long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time 44 | boolean _tare = true; //set this to false if you don't want tare to be performed in the next step 45 | LoadCell.start(stabilizingtime, _tare); 46 | 47 | //gk berguna di esp32 tapi di mega berfungsi 48 | if (LoadCell.getTareTimeoutFlag() || LoadCell.getSignalTimeoutFlag()) { 49 | Serial.println("Timeout, check MCU>HX711 wiring and pin designations"); 50 | while (1); 51 | } 52 | else { 53 | LoadCell.setCalFactor(1.0); // user set calibration value (float), initial value 1.0 may be used for this sketch 54 | Serial.println("Startup is complete"); 55 | } 56 | while (!LoadCell.update()); 57 | Serial.print("Calibration value: "); 58 | Serial.println(LoadCell.getCalFactor()); 59 | Serial.print("HX711 measured conversion time ms: "); 60 | Serial.println(LoadCell.getConversionTime()); 61 | Serial.print("HX711 measured sampling rate HZ: "); 62 | Serial.println(LoadCell.getSPS()); 63 | Serial.print("HX711 measured settlingtime ms: "); 64 | Serial.println(LoadCell.getSettlingTime()); 65 | Serial.println("Note that the settling time may increase significantly if you use delay() in your sketch!"); 66 | if (LoadCell.getSPS() < 7 || LoadCell.getSPS() > 100 ) { 67 | Serial.println("HX711 not found."); 68 | while(1); 69 | } 70 | calibrate(); //start calibration procedure 71 | } 72 | 73 | void loop() { 74 | static boolean newDataReady = 0; 75 | const int serialPrintInterval = 0; //increase value to slow down serial print activity 76 | 77 | // check for new data/start next conversion: 78 | if (LoadCell.update()) newDataReady = true; 79 | 80 | // get smoothed value from the dataset: 81 | if (newDataReady) { 82 | if (millis() > t + serialPrintInterval) { 83 | float i = LoadCell.getData(); 84 | Serial.print("Load_cell output val: "); 85 | Serial.println(i); 86 | newDataReady = 0; 87 | t = millis(); 88 | } 89 | } 90 | 91 | // receive command from serial terminal 92 | if (Serial.available() > 0) { 93 | char inByte = Serial.read(); 94 | if (inByte == 't') LoadCell.tareNoDelay(); //tare 95 | else if (inByte == 'r') calibrate(); //calibrate 96 | else if (inByte == 'c') changeSavedCalFactor(); //edit calibration value manually 97 | } 98 | 99 | // check if last tare operation is complete 100 | if (LoadCell.getTareStatus() == true) { 101 | Serial.println("Tare complete"); 102 | } 103 | 104 | } 105 | 106 | void calibrate() { 107 | Serial.println("***"); 108 | Serial.println("Start calibration:"); 109 | Serial.println("Place the load cell an a level stable surface."); 110 | Serial.println("Remove any load applied to the load cell."); 111 | Serial.println("Send 't' from serial monitor to set the tare offset."); 112 | 113 | boolean _resume = false; 114 | while (_resume == false) { 115 | LoadCell.update(); 116 | if (Serial.available() > 0) { 117 | if (Serial.available() > 0) { 118 | char inByte = Serial.read(); 119 | if (inByte == 't') LoadCell.tareNoDelay(); 120 | } 121 | } 122 | if (LoadCell.getTareStatus() == true) { 123 | Serial.println("Tare complete"); 124 | _resume = true; 125 | } 126 | } 127 | 128 | Serial.println("Now, place your known mass on the loadcell."); 129 | Serial.println("Then send the weight of this mass (i.e. 100.0) from serial monitor."); 130 | 131 | float known_mass = 0; 132 | _resume = false; 133 | while (_resume == false) { 134 | LoadCell.update(); 135 | if (Serial.available() > 0) { 136 | known_mass = Serial.parseFloat(); 137 | if (known_mass != 0) { 138 | Serial.print("Known mass is: "); 139 | Serial.println(known_mass); 140 | _resume = true; 141 | } 142 | } 143 | } 144 | 145 | LoadCell.refreshDataSet(); //refresh the dataset to be sure that the known mass is measured correct 146 | float newCalibrationValue = LoadCell.getNewCalibration(known_mass); //get the new calibration value 147 | 148 | Serial.print("New calibration value has been set to: "); 149 | Serial.print(newCalibrationValue); 150 | Serial.println(", use this as calibration value (calFactor) in your project sketch."); 151 | Serial.print("Save this value to EEPROM adress "); 152 | Serial.print(calVal_eepromAdress); 153 | Serial.println("? y/n"); 154 | 155 | _resume = false; 156 | while (_resume == false) { 157 | if (Serial.available() > 0) { 158 | char inByte = Serial.read(); 159 | if (inByte == 'y') { 160 | #if defined(ESP8266)|| defined(ESP32) 161 | EEPROM.begin(512); 162 | #endif 163 | EEPROM.put(calVal_eepromAdress, newCalibrationValue); 164 | #if defined(ESP8266)|| defined(ESP32) 165 | EEPROM.commit(); 166 | #endif 167 | EEPROM.get(calVal_eepromAdress, newCalibrationValue); 168 | Serial.print("Value "); 169 | Serial.print(newCalibrationValue); 170 | Serial.print(" saved to EEPROM address: "); 171 | Serial.println(calVal_eepromAdress); 172 | _resume = true; 173 | 174 | } 175 | else if (inByte == 'n') { 176 | Serial.println("Value not saved to EEPROM"); 177 | _resume = true; 178 | } 179 | } 180 | } 181 | 182 | Serial.println("End calibration"); 183 | Serial.println("***"); 184 | Serial.println("To re-calibrate, send 'r' from serial monitor."); 185 | Serial.println("For manual edit of the calibration value, send 'c' from serial monitor."); 186 | Serial.println("***"); 187 | } 188 | 189 | void changeSavedCalFactor() { 190 | float oldCalibrationValue = LoadCell.getCalFactor(); 191 | boolean _resume = false; 192 | Serial.println("***"); 193 | Serial.print("Current value is: "); 194 | Serial.println(oldCalibrationValue); 195 | Serial.println("Now, send the new value from serial monitor, i.e. 696.0"); 196 | float newCalibrationValue; 197 | while (_resume == false) { 198 | if (Serial.available() > 0) { 199 | newCalibrationValue = Serial.parseFloat(); 200 | if (newCalibrationValue != 0) { 201 | Serial.print("New calibration value is: "); 202 | Serial.println(newCalibrationValue); 203 | LoadCell.setCalFactor(newCalibrationValue); 204 | _resume = true; 205 | } 206 | } 207 | } 208 | _resume = false; 209 | Serial.print("Save this value to EEPROM adress "); 210 | Serial.print(calVal_eepromAdress); 211 | Serial.println("? y/n"); 212 | while (_resume == false) { 213 | if (Serial.available() > 0) { 214 | char inByte = Serial.read(); 215 | if (inByte == 'y') { 216 | #if defined(ESP8266)|| defined(ESP32) 217 | EEPROM.begin(512); 218 | #endif 219 | EEPROM.put(calVal_eepromAdress, newCalibrationValue); 220 | #if defined(ESP8266)|| defined(ESP32) 221 | EEPROM.commit(); 222 | #endif 223 | EEPROM.get(calVal_eepromAdress, newCalibrationValue); 224 | Serial.print("Value "); 225 | Serial.print(newCalibrationValue); 226 | Serial.print(" saved to EEPROM address: "); 227 | Serial.println(calVal_eepromAdress); 228 | _resume = true; 229 | } 230 | else if (inByte == 'n') { 231 | Serial.println("Value not saved to EEPROM"); 232 | _resume = true; 233 | } 234 | } 235 | } 236 | Serial.println("End change calibration value"); 237 | Serial.println("***"); 238 | } 239 | -------------------------------------------------------------------------------- /HX711/HX711_ADC-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/HX711/HX711_ADC-master.zip -------------------------------------------------------------------------------- /HX711/New Microsoft PowerPoint Presentation.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/HX711/New Microsoft PowerPoint Presentation.pptx -------------------------------------------------------------------------------- /HX711/Testing/Testing.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------------------- 3 | HX711_ADC 4 | Arduino library for HX711 24-Bit Analog-to-Digital Converter for Weight Scales 5 | Olav Kallhovd sept2017 6 | ------------------------------------------------------------------------------------- 7 | */ 8 | 9 | /* 10 | Settling time (number of samples) and data filtering can be adjusted in the config.h file 11 | For calibration and storing the calibration value in eeprom, see example file "Calibration.ino" 12 | 13 | The update() function checks for new data and starts the next conversion. In order to acheive maximum effective 14 | sample rate, update() should be called at least as often as the HX711 sample rate; >10Hz@10SPS, >80Hz@80SPS. 15 | If you have other time consuming code running (i.e. a graphical LCD), consider calling update() from an interrupt routine, 16 | see example file "Read_1x_load_cell_interrupt_driven.ino". 17 | 18 | This is an example sketch on how to use this library 19 | */ 20 | 21 | #include 22 | #if defined(ESP8266)|| defined(ESP32) || defined(AVR) 23 | #include 24 | #endif 25 | 26 | //pins: 27 | const int HX711_dout = 15; //mcu > HX711 dout pin 28 | const int HX711_sck = 5; //mcu > HX711 sck pin 29 | 30 | //HX711 constructor: 31 | HX711_ADC LoadCell(HX711_dout, HX711_sck); 32 | 33 | const int calVal_eepromAdress = 0; 34 | unsigned long t = 0; 35 | 36 | void setup() { 37 | Serial.begin(9600); delay(10); 38 | Serial.println(); 39 | Serial.println("Starting..."); 40 | 41 | float calibrationValue; // calibration value 42 | 43 | #if defined(ESP8266) || defined(ESP32) 44 | EEPROM.begin(512); // uncomment this if you use ESP8266 and want to fetch this value from eeprom 45 | #endif 46 | EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch this value from eeprom 47 | 48 | LoadCell.begin(); 49 | //LoadCell.setReverseOutput(); 50 | unsigned long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time 51 | boolean _tare = true; //set this to false if you don't want tare to be performed in the next step 52 | LoadCell.start(stabilizingtime, _tare); 53 | if (LoadCell.getTareTimeoutFlag()) { 54 | Serial.println("Timeout, check MCU>HX711 wiring and pin designations"); 55 | } 56 | else { 57 | LoadCell.setCalFactor(calibrationValue); // set calibration factor (float) 58 | Serial.println("Startup is complete"); 59 | } 60 | while (!LoadCell.update()); 61 | Serial.print("Calibration value: "); 62 | Serial.println(LoadCell.getCalFactor()); 63 | Serial.print("HX711 measured conversion time ms: "); 64 | Serial.println(LoadCell.getConversionTime()); 65 | Serial.print("HX711 measured sampling rate HZ: "); 66 | Serial.println(LoadCell.getSPS()); 67 | Serial.print("HX711 measured settlingtime ms: "); 68 | Serial.println(LoadCell.getSettlingTime()); 69 | Serial.println("Note that the settling time may increase significantly if you use delay() in your sketch!"); 70 | if (LoadCell.getSPS() < 7 || LoadCell.getSPS() > 100 ) { 71 | Serial.println("HX711 not found."); 72 | while(1){} 73 | } 74 | } 75 | 76 | void loop() { 77 | static boolean newDataReady = 0; 78 | const int serialPrintInterval = 500; //increase value to slow down serial print activity 79 | 80 | // check for new data/start next conversion: 81 | if (LoadCell.update()) newDataReady = true; 82 | 83 | // get smoothed value from the dataset: 84 | if (newDataReady) { 85 | if (millis() > t + serialPrintInterval) { 86 | float i = LoadCell.getData(); 87 | 88 | if(i<0) 89 | i=0; 90 | Serial.print("Load_cell output val: "); 91 | Serial.println(i); 92 | newDataReady = 0; 93 | t = millis(); 94 | } 95 | } 96 | 97 | // receive command from serial terminal, send 't' to initiate tare operation: 98 | if (Serial.available() > 0) { 99 | char inByte = Serial.read(); 100 | if (inByte == 't') LoadCell.tareNoDelay(); 101 | } 102 | 103 | // check if last tare operation is complete: 104 | if (LoadCell.getTareStatus() == true) { 105 | Serial.println("Tare complete"); 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /HX711/hx711.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/HX711/hx711.jpg -------------------------------------------------------------------------------- /HX711/hx711d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/HX711/hx711d.jpg -------------------------------------------------------------------------------- /I2c_scanner.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/I2c_scanner.zip -------------------------------------------------------------------------------- /MPU2/All File.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/MPU2/All File.zip -------------------------------------------------------------------------------- /MPU2/I2C_scanner/I2C_scanner.ino: -------------------------------------------------------------------------------- 1 | // -------------------------------------- 2 | // i2c_scanner 3 | // 4 | // Version 1 5 | // This program (or code that looks like it) 6 | // can be found in many places. 7 | // For example on the Arduino.cc forum. 8 | // The original author is not know. 9 | // Version 2, Juni 2012, Using Arduino 1.0.1 10 | // Adapted to be as simple as possible by Arduino.cc user Krodal 11 | // Version 3, Feb 26 2013 12 | // V3 by louarnold 13 | // Version 4, March 3, 2013, Using Arduino 1.0.3 14 | // by Arduino.cc user Krodal. 15 | // Changes by louarnold removed. 16 | // Scanning addresses changed from 0...127 to 1...119, 17 | // according to the i2c scanner by Nick Gammon 18 | // http://www.gammon.com.au/forum/?id=10896 19 | // Version 5, March 28, 2013 20 | // As version 4, but address scans now to 127. 21 | // A sensor seems to use address 120. 22 | // Version 6, November 27, 2015. 23 | // Added waiting for the Leonardo serial communication. 24 | // 25 | // 26 | // This sketch tests the standard 7-bit addresses 27 | // Devices with higher bit address might not be seen properly. 28 | // 29 | 30 | #include 31 | 32 | 33 | void setup() 34 | { 35 | Wire.begin(); 36 | 37 | Serial.begin(115200); 38 | while (!Serial); // Leonardo: wait for serial monitor 39 | Serial.println("\nI2C Scanner"); 40 | } 41 | 42 | 43 | void loop() 44 | { 45 | byte error, address; 46 | int nDevices; 47 | 48 | Serial.println("Scanning..."); 49 | 50 | nDevices = 0; 51 | for(address = 1; address < 127; address++ ) 52 | { 53 | // The i2c_scanner uses the return value of 54 | // the Write.endTransmisstion to see if 55 | // a device did acknowledge to the address. 56 | Wire.beginTransmission(address); 57 | error = Wire.endTransmission(); 58 | 59 | if (error == 0) 60 | { 61 | Serial.print("I2C device found at address 0x"); 62 | if (address<16) 63 | Serial.print("0"); 64 | Serial.print(address,HEX); 65 | Serial.println(" !"); 66 | 67 | nDevices++; 68 | } 69 | else if (error==4) 70 | { 71 | Serial.print("Unknown error at address 0x"); 72 | if (address<16) 73 | Serial.print("0"); 74 | Serial.println(address,HEX); 75 | } 76 | } 77 | if (nDevices == 0) 78 | Serial.println("No I2C devices found\n"); 79 | else 80 | Serial.println("done\n"); 81 | 82 | delay(5000); // wait 5 seconds for next scan 83 | } 84 | -------------------------------------------------------------------------------- /MPU2/lib/Arduino-MPU6050-master/CHANGELOG: -------------------------------------------------------------------------------- 1 | MPU6050 Arduino Library 1.0.3 / 03.03.2015 2 | ====================================================================== 3 | 4 | * Added setDLPFMode(mpu6050_dlpf_t dlpf) function 5 | MPU6050_DLPF_0...6 (see datatsheet) 6 | 7 | MPU6050 Arduino Library 1.0.2 / 10.02.2015 8 | ====================================================================== 9 | 10 | * Adjustable i2c address 11 | mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G) - default 0x68 12 | mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G, 0x69) - use 0x69 13 | 14 | MPU6050 Arduino Library 1.0.1 / 26.10.2014 15 | ====================================================================== 16 | 17 | * Removing examples for Kalman Filter. Moved to KalmanFilter Git repo 18 | * Removing examples for HMC5883L. Moved to HMC5833L Git repo 19 | 20 | MPU6050 Arduino Library 1.0.0 / 20.10.2014 21 | ====================================================================== 22 | 23 | * First release 24 | -------------------------------------------------------------------------------- /MPU2/lib/Arduino-MPU6050-master/MPU6050.h: -------------------------------------------------------------------------------- 1 | /* 2 | MPU6050.h - Header file for the MPU6050 Triple Axis Gyroscope & Accelerometer Arduino Library. 3 | 4 | Version: 1.0.3 5 | (c) 2014-2015 Korneliusz Jarzebski 6 | www.jarzebski.pl 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the version 3 GNU General Public License as 10 | published by the Free Software Foundation. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | #ifndef MPU6050_h 22 | #define MPU6050_h 23 | 24 | #if ARDUINO >= 100 25 | #include "Arduino.h" 26 | #else 27 | #include "WProgram.h" 28 | #endif 29 | 30 | #define MPU6050_ADDRESS (0x68) // 0x69 when AD0 pin to Vcc 31 | 32 | #define MPU6050_REG_ACCEL_XOFFS_H (0x06) 33 | #define MPU6050_REG_ACCEL_XOFFS_L (0x07) 34 | #define MPU6050_REG_ACCEL_YOFFS_H (0x08) 35 | #define MPU6050_REG_ACCEL_YOFFS_L (0x09) 36 | #define MPU6050_REG_ACCEL_ZOFFS_H (0x0A) 37 | #define MPU6050_REG_ACCEL_ZOFFS_L (0x0B) 38 | #define MPU6050_REG_GYRO_XOFFS_H (0x13) 39 | #define MPU6050_REG_GYRO_XOFFS_L (0x14) 40 | #define MPU6050_REG_GYRO_YOFFS_H (0x15) 41 | #define MPU6050_REG_GYRO_YOFFS_L (0x16) 42 | #define MPU6050_REG_GYRO_ZOFFS_H (0x17) 43 | #define MPU6050_REG_GYRO_ZOFFS_L (0x18) 44 | #define MPU6050_REG_CONFIG (0x1A) 45 | #define MPU6050_REG_GYRO_CONFIG (0x1B) // Gyroscope Configuration 46 | #define MPU6050_REG_ACCEL_CONFIG (0x1C) // Accelerometer Configuration 47 | #define MPU6050_REG_FF_THRESHOLD (0x1D) 48 | #define MPU6050_REG_FF_DURATION (0x1E) 49 | #define MPU6050_REG_MOT_THRESHOLD (0x1F) 50 | #define MPU6050_REG_MOT_DURATION (0x20) 51 | #define MPU6050_REG_ZMOT_THRESHOLD (0x21) 52 | #define MPU6050_REG_ZMOT_DURATION (0x22) 53 | #define MPU6050_REG_INT_PIN_CFG (0x37) // INT Pin. Bypass Enable Configuration 54 | #define MPU6050_REG_INT_ENABLE (0x38) // INT Enable 55 | #define MPU6050_REG_INT_STATUS (0x3A) 56 | #define MPU6050_REG_ACCEL_XOUT_H (0x3B) 57 | #define MPU6050_REG_ACCEL_XOUT_L (0x3C) 58 | #define MPU6050_REG_ACCEL_YOUT_H (0x3D) 59 | #define MPU6050_REG_ACCEL_YOUT_L (0x3E) 60 | #define MPU6050_REG_ACCEL_ZOUT_H (0x3F) 61 | #define MPU6050_REG_ACCEL_ZOUT_L (0x40) 62 | #define MPU6050_REG_TEMP_OUT_H (0x41) 63 | #define MPU6050_REG_TEMP_OUT_L (0x42) 64 | #define MPU6050_REG_GYRO_XOUT_H (0x43) 65 | #define MPU6050_REG_GYRO_XOUT_L (0x44) 66 | #define MPU6050_REG_GYRO_YOUT_H (0x45) 67 | #define MPU6050_REG_GYRO_YOUT_L (0x46) 68 | #define MPU6050_REG_GYRO_ZOUT_H (0x47) 69 | #define MPU6050_REG_GYRO_ZOUT_L (0x48) 70 | #define MPU6050_REG_MOT_DETECT_STATUS (0x61) 71 | #define MPU6050_REG_MOT_DETECT_CTRL (0x69) 72 | #define MPU6050_REG_USER_CTRL (0x6A) // User Control 73 | #define MPU6050_REG_PWR_MGMT_1 (0x6B) // Power Management 1 74 | #define MPU6050_REG_WHO_AM_I (0x75) // Who Am I 75 | 76 | #ifndef VECTOR_STRUCT_H 77 | #define VECTOR_STRUCT_H 78 | struct Vector 79 | { 80 | float XAxis; 81 | float YAxis; 82 | float ZAxis; 83 | }; 84 | #endif 85 | 86 | struct Activites 87 | { 88 | bool isOverflow; 89 | bool isFreeFall; 90 | bool isInactivity; 91 | bool isActivity; 92 | bool isPosActivityOnX; 93 | bool isPosActivityOnY; 94 | bool isPosActivityOnZ; 95 | bool isNegActivityOnX; 96 | bool isNegActivityOnY; 97 | bool isNegActivityOnZ; 98 | bool isDataReady; 99 | }; 100 | 101 | typedef enum 102 | { 103 | MPU6050_CLOCK_KEEP_RESET = 0b111, 104 | MPU6050_CLOCK_EXTERNAL_19MHZ = 0b101, 105 | MPU6050_CLOCK_EXTERNAL_32KHZ = 0b100, 106 | MPU6050_CLOCK_PLL_ZGYRO = 0b011, 107 | MPU6050_CLOCK_PLL_YGYRO = 0b010, 108 | MPU6050_CLOCK_PLL_XGYRO = 0b001, 109 | MPU6050_CLOCK_INTERNAL_8MHZ = 0b000 110 | } mpu6050_clockSource_t; 111 | 112 | typedef enum 113 | { 114 | MPU6050_SCALE_2000DPS = 0b11, 115 | MPU6050_SCALE_1000DPS = 0b10, 116 | MPU6050_SCALE_500DPS = 0b01, 117 | MPU6050_SCALE_250DPS = 0b00 118 | } mpu6050_dps_t; 119 | 120 | typedef enum 121 | { 122 | MPU6050_RANGE_16G = 0b11, 123 | MPU6050_RANGE_8G = 0b10, 124 | MPU6050_RANGE_4G = 0b01, 125 | MPU6050_RANGE_2G = 0b00, 126 | } mpu6050_range_t; 127 | 128 | typedef enum 129 | { 130 | MPU6050_DELAY_3MS = 0b11, 131 | MPU6050_DELAY_2MS = 0b10, 132 | MPU6050_DELAY_1MS = 0b01, 133 | MPU6050_NO_DELAY = 0b00, 134 | } mpu6050_onDelay_t; 135 | 136 | typedef enum 137 | { 138 | MPU6050_DHPF_HOLD = 0b111, 139 | MPU6050_DHPF_0_63HZ = 0b100, 140 | MPU6050_DHPF_1_25HZ = 0b011, 141 | MPU6050_DHPF_2_5HZ = 0b010, 142 | MPU6050_DHPF_5HZ = 0b001, 143 | MPU6050_DHPF_RESET = 0b000, 144 | } mpu6050_dhpf_t; 145 | 146 | typedef enum 147 | { 148 | MPU6050_DLPF_6 = 0b110, 149 | MPU6050_DLPF_5 = 0b101, 150 | MPU6050_DLPF_4 = 0b100, 151 | MPU6050_DLPF_3 = 0b011, 152 | MPU6050_DLPF_2 = 0b010, 153 | MPU6050_DLPF_1 = 0b001, 154 | MPU6050_DLPF_0 = 0b000, 155 | } mpu6050_dlpf_t; 156 | 157 | class MPU6050 158 | { 159 | public: 160 | 161 | bool begin(mpu6050_dps_t scale = MPU6050_SCALE_2000DPS, mpu6050_range_t range = MPU6050_RANGE_2G, int mpua = MPU6050_ADDRESS); 162 | 163 | void setClockSource(mpu6050_clockSource_t source); 164 | void setScale(mpu6050_dps_t scale); 165 | void setRange(mpu6050_range_t range); 166 | mpu6050_clockSource_t getClockSource(void); 167 | mpu6050_dps_t getScale(void); 168 | mpu6050_range_t getRange(void); 169 | void setDHPFMode(mpu6050_dhpf_t dhpf); 170 | void setDLPFMode(mpu6050_dlpf_t dlpf); 171 | mpu6050_onDelay_t getAccelPowerOnDelay(); 172 | void setAccelPowerOnDelay(mpu6050_onDelay_t delay); 173 | 174 | uint8_t getIntStatus(void); 175 | 176 | bool getIntZeroMotionEnabled(void); 177 | void setIntZeroMotionEnabled(bool state); 178 | bool getIntMotionEnabled(void); 179 | void setIntMotionEnabled(bool state); 180 | bool getIntFreeFallEnabled(void); 181 | void setIntFreeFallEnabled(bool state); 182 | 183 | uint8_t getMotionDetectionThreshold(void); 184 | void setMotionDetectionThreshold(uint8_t threshold); 185 | uint8_t getMotionDetectionDuration(void); 186 | void setMotionDetectionDuration(uint8_t duration); 187 | 188 | uint8_t getZeroMotionDetectionThreshold(void); 189 | void setZeroMotionDetectionThreshold(uint8_t threshold); 190 | uint8_t getZeroMotionDetectionDuration(void); 191 | void setZeroMotionDetectionDuration(uint8_t duration); 192 | 193 | uint8_t getFreeFallDetectionThreshold(void); 194 | void setFreeFallDetectionThreshold(uint8_t threshold); 195 | uint8_t getFreeFallDetectionDuration(void); 196 | void setFreeFallDetectionDuration(uint8_t duration); 197 | 198 | bool getSleepEnabled(void); 199 | void setSleepEnabled(bool state); 200 | bool getI2CMasterModeEnabled(void); 201 | void setI2CMasterModeEnabled(bool state); 202 | bool getI2CBypassEnabled(void); 203 | void setI2CBypassEnabled(bool state); 204 | 205 | float readTemperature(void); 206 | Activites readActivites(void); 207 | 208 | int16_t getGyroOffsetX(void); 209 | void setGyroOffsetX(int16_t offset); 210 | int16_t getGyroOffsetY(void); 211 | void setGyroOffsetY(int16_t offset); 212 | int16_t getGyroOffsetZ(void); 213 | void setGyroOffsetZ(int16_t offset); 214 | 215 | int16_t getAccelOffsetX(void); 216 | void setAccelOffsetX(int16_t offset); 217 | int16_t getAccelOffsetY(void); 218 | void setAccelOffsetY(int16_t offset); 219 | int16_t getAccelOffsetZ(void); 220 | void setAccelOffsetZ(int16_t offset); 221 | 222 | void calibrateGyro(uint8_t samples = 50); 223 | void setThreshold(uint8_t multiple = 1); 224 | uint8_t getThreshold(void); 225 | 226 | Vector readRawGyro(void); 227 | Vector readNormalizeGyro(void); 228 | 229 | Vector readRawAccel(void); 230 | Vector readNormalizeAccel(void); 231 | Vector readScaledAccel(void); 232 | 233 | private: 234 | Vector ra, rg; // Raw vectors 235 | Vector na, ng; // Normalized vectors 236 | Vector tg, dg; // Threshold and Delta for Gyro 237 | Vector th; // Threshold 238 | Activites a; // Activities 239 | 240 | float dpsPerDigit, rangePerDigit; 241 | float actualThreshold; 242 | bool useCalibrate; 243 | int mpuAddress; 244 | 245 | uint8_t fastRegister8(uint8_t reg); 246 | 247 | uint8_t readRegister8(uint8_t reg); 248 | void writeRegister8(uint8_t reg, uint8_t value); 249 | 250 | int16_t readRegister16(uint8_t reg); 251 | void writeRegister16(uint8_t reg, int16_t value); 252 | 253 | bool readRegisterBit(uint8_t reg, uint8_t pos); 254 | void writeRegisterBit(uint8_t reg, uint8_t pos, bool state); 255 | 256 | }; 257 | 258 | #endif 259 | -------------------------------------------------------------------------------- /MPU2/lib/Arduino-MPU6050-master/MPU6050_accel_pitch_roll/MPU6050_accel_pitch_roll.ino: -------------------------------------------------------------------------------- 1 | /* 2 | MPU6050 Triple Axis Gyroscope & Accelerometer. Pitch & Roll Accelerometer Example. 3 | Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-zyroskop-i-akcelerometr-mpu6050.html 4 | GIT: https://github.com/jarzebski/Arduino-MPU6050 5 | Web: http://www.jarzebski.pl 6 | (c) 2014 by Korneliusz Jarzebski 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | MPU6050 mpu; 13 | 14 | void setup() 15 | { 16 | Serial.begin(115200); 17 | 18 | Serial.println("Initialize MPU6050"); 19 | 20 | while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) 21 | { 22 | Serial.println("Could not find a valid MPU6050 sensor, check wiring!"); 23 | delay(500); 24 | } 25 | } 26 | 27 | void loop() 28 | { 29 | // Read normalized values 30 | Vector normAccel = mpu.readNormalizeAccel(); 31 | 32 | // Calculate Pitch & Roll 33 | int pitch = -(atan2(normAccel.XAxis, sqrt(normAccel.YAxis*normAccel.YAxis + normAccel.ZAxis*normAccel.ZAxis))*180.0)/M_PI; 34 | int roll = (atan2(normAccel.YAxis, normAccel.ZAxis)*180.0)/M_PI; 35 | 36 | // Output 37 | Serial.print(" Pitch = "); 38 | Serial.print(pitch); 39 | Serial.print(" Roll = "); 40 | Serial.print(roll); 41 | 42 | Serial.println(); 43 | 44 | delay(10); 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /MPU2/lib/Arduino-MPU6050-master/MPU6050_accel_simple/MPU6050_accel_simple.ino: -------------------------------------------------------------------------------- 1 | /* 2 | MPU6050 Triple Axis Gyroscope & Accelerometer. Simple Accelerometer Example. 3 | Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-zyroskop-i-akcelerometr-mpu6050.html 4 | GIT: https://github.com/jarzebski/Arduino-MPU6050 5 | Web: http://www.jarzebski.pl 6 | (c) 2014 by Korneliusz Jarzebski 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | MPU6050 mpu; 13 | 14 | void setup() 15 | { 16 | Serial.begin(115200); 17 | 18 | Serial.println("Initialize MPU6050"); 19 | 20 | while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) 21 | { 22 | Serial.println("Could not find a valid MPU6050 sensor, check wiring!"); 23 | delay(500); 24 | } 25 | 26 | // If you want, you can set accelerometer offsets 27 | // mpu.setAccelOffsetX(); 28 | // mpu.setAccelOffsetY(); 29 | // mpu.setAccelOffsetZ(); 30 | 31 | checkSettings(); 32 | } 33 | 34 | void checkSettings() 35 | { 36 | Serial.println(); 37 | 38 | Serial.print(" * Sleep Mode: "); 39 | Serial.println(mpu.getSleepEnabled() ? "Enabled" : "Disabled"); 40 | 41 | Serial.print(" * Clock Source: "); 42 | switch(mpu.getClockSource()) 43 | { 44 | case MPU6050_CLOCK_KEEP_RESET: Serial.println("Stops the clock and keeps the timing generator in reset"); break; 45 | case MPU6050_CLOCK_EXTERNAL_19MHZ: Serial.println("PLL with external 19.2MHz reference"); break; 46 | case MPU6050_CLOCK_EXTERNAL_32KHZ: Serial.println("PLL with external 32.768kHz reference"); break; 47 | case MPU6050_CLOCK_PLL_ZGYRO: Serial.println("PLL with Z axis gyroscope reference"); break; 48 | case MPU6050_CLOCK_PLL_YGYRO: Serial.println("PLL with Y axis gyroscope reference"); break; 49 | case MPU6050_CLOCK_PLL_XGYRO: Serial.println("PLL with X axis gyroscope reference"); break; 50 | case MPU6050_CLOCK_INTERNAL_8MHZ: Serial.println("Internal 8MHz oscillator"); break; 51 | } 52 | 53 | Serial.print(" * Accelerometer: "); 54 | switch(mpu.getRange()) 55 | { 56 | case MPU6050_RANGE_16G: Serial.println("+/- 16 g"); break; 57 | case MPU6050_RANGE_8G: Serial.println("+/- 8 g"); break; 58 | case MPU6050_RANGE_4G: Serial.println("+/- 4 g"); break; 59 | case MPU6050_RANGE_2G: Serial.println("+/- 2 g"); break; 60 | } 61 | 62 | Serial.print(" * Accelerometer offsets: "); 63 | Serial.print(mpu.getAccelOffsetX()); 64 | Serial.print(" / "); 65 | Serial.print(mpu.getAccelOffsetY()); 66 | Serial.print(" / "); 67 | Serial.println(mpu.getAccelOffsetZ()); 68 | 69 | Serial.println(); 70 | } 71 | 72 | void loop() 73 | { 74 | Vector rawAccel = mpu.readRawAccel(); 75 | Vector normAccel = mpu.readNormalizeAccel(); 76 | 77 | Serial.print(" Xraw = "); 78 | Serial.print(rawAccel.XAxis); 79 | Serial.print(" Yraw = "); 80 | Serial.print(rawAccel.YAxis); 81 | Serial.print(" Zraw = "); 82 | 83 | Serial.println(rawAccel.ZAxis); 84 | Serial.print(" Xnorm = "); 85 | Serial.print(normAccel.XAxis); 86 | Serial.print(" Ynorm = "); 87 | Serial.print(normAccel.YAxis); 88 | Serial.print(" Znorm = "); 89 | Serial.println(normAccel.ZAxis); 90 | 91 | delay(10); 92 | } 93 | 94 | 95 | -------------------------------------------------------------------------------- /MPU2/lib/Arduino-MPU6050-master/MPU6050_free_fall/MPU6050_free_fall.ino: -------------------------------------------------------------------------------- 1 | /* 2 | MPU6050 Triple Axis Gyroscope & Accelerometer. Free fall detection. 3 | Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-zyroskop-i-akcelerometr-mpu6050.html 4 | GIT: https://github.com/jarzebski/Arduino-MPU6050 5 | Web: http://www.jarzebski.pl 6 | (c) 2014 by Korneliusz Jarzebski 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | MPU6050 mpu; 13 | 14 | boolean ledState = false; 15 | boolean freefallDetected = false; 16 | int freefallBlinkCount = 0; 17 | 18 | void setup() 19 | { 20 | Serial.begin(115200); 21 | 22 | Serial.println("Initialize MPU6050"); 23 | 24 | while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_16G)) 25 | { 26 | Serial.println("Could not find a valid MPU6050 sensor, check wiring!"); 27 | delay(500); 28 | } 29 | 30 | mpu.setAccelPowerOnDelay(MPU6050_DELAY_3MS); 31 | 32 | mpu.setIntFreeFallEnabled(true); 33 | mpu.setIntZeroMotionEnabled(false); 34 | mpu.setIntMotionEnabled(false); 35 | 36 | mpu.setDHPFMode(MPU6050_DHPF_5HZ); 37 | 38 | mpu.setFreeFallDetectionThreshold(17); 39 | mpu.setFreeFallDetectionDuration(2); 40 | 41 | checkSettings(); 42 | 43 | pinMode(4, OUTPUT); 44 | digitalWrite(4, LOW); 45 | 46 | attachInterrupt(0, doInt, RISING); 47 | } 48 | 49 | void doInt() 50 | { 51 | freefallBlinkCount = 0; 52 | freefallDetected = true; 53 | } 54 | 55 | void checkSettings() 56 | { 57 | Serial.println(); 58 | 59 | Serial.print(" * Sleep Mode: "); 60 | Serial.println(mpu.getSleepEnabled() ? "Enabled" : "Disabled"); 61 | 62 | Serial.print(" * Motion Interrupt: "); 63 | Serial.println(mpu.getIntMotionEnabled() ? "Enabled" : "Disabled"); 64 | 65 | Serial.print(" * Zero Motion Interrupt: "); 66 | Serial.println(mpu.getIntZeroMotionEnabled() ? "Enabled" : "Disabled"); 67 | 68 | Serial.print(" * Free Fall Interrupt: "); 69 | Serial.println(mpu.getIntFreeFallEnabled() ? "Enabled" : "Disabled"); 70 | 71 | Serial.print(" * Free Fal Threshold: "); 72 | Serial.println(mpu.getFreeFallDetectionThreshold()); 73 | 74 | Serial.print(" * Free FallDuration: "); 75 | Serial.println(mpu.getFreeFallDetectionDuration()); 76 | 77 | Serial.print(" * Clock Source: "); 78 | switch(mpu.getClockSource()) 79 | { 80 | case MPU6050_CLOCK_KEEP_RESET: Serial.println("Stops the clock and keeps the timing generator in reset"); break; 81 | case MPU6050_CLOCK_EXTERNAL_19MHZ: Serial.println("PLL with external 19.2MHz reference"); break; 82 | case MPU6050_CLOCK_EXTERNAL_32KHZ: Serial.println("PLL with external 32.768kHz reference"); break; 83 | case MPU6050_CLOCK_PLL_ZGYRO: Serial.println("PLL with Z axis gyroscope reference"); break; 84 | case MPU6050_CLOCK_PLL_YGYRO: Serial.println("PLL with Y axis gyroscope reference"); break; 85 | case MPU6050_CLOCK_PLL_XGYRO: Serial.println("PLL with X axis gyroscope reference"); break; 86 | case MPU6050_CLOCK_INTERNAL_8MHZ: Serial.println("Internal 8MHz oscillator"); break; 87 | } 88 | 89 | Serial.print(" * Accelerometer: "); 90 | switch(mpu.getRange()) 91 | { 92 | case MPU6050_RANGE_16G: Serial.println("+/- 16 g"); break; 93 | case MPU6050_RANGE_8G: Serial.println("+/- 8 g"); break; 94 | case MPU6050_RANGE_4G: Serial.println("+/- 4 g"); break; 95 | case MPU6050_RANGE_2G: Serial.println("+/- 2 g"); break; 96 | } 97 | 98 | Serial.print(" * Accelerometer offsets: "); 99 | Serial.print(mpu.getAccelOffsetX()); 100 | Serial.print(" / "); 101 | Serial.print(mpu.getAccelOffsetY()); 102 | Serial.print(" / "); 103 | Serial.println(mpu.getAccelOffsetZ()); 104 | 105 | Serial.print(" * Accelerometer power delay: "); 106 | switch(mpu.getAccelPowerOnDelay()) 107 | { 108 | case MPU6050_DELAY_3MS: Serial.println("3ms"); break; 109 | case MPU6050_DELAY_2MS: Serial.println("2ms"); break; 110 | case MPU6050_DELAY_1MS: Serial.println("1ms"); break; 111 | case MPU6050_NO_DELAY: Serial.println("0ms"); break; 112 | } 113 | 114 | Serial.println(); 115 | } 116 | 117 | void loop() 118 | { 119 | Vector rawAccel = mpu.readRawAccel(); 120 | Activites act = mpu.readActivites(); 121 | 122 | Serial.print(act.isFreeFall); 123 | Serial.print("\n"); 124 | 125 | if (freefallDetected) 126 | { 127 | ledState = !ledState; 128 | 129 | digitalWrite(4, ledState); 130 | 131 | freefallBlinkCount++; 132 | 133 | if (freefallBlinkCount == 20) 134 | { 135 | freefallDetected = false; 136 | ledState = false; 137 | digitalWrite(4, ledState); 138 | } 139 | } 140 | 141 | delay(100); 142 | 143 | } 144 | -------------------------------------------------------------------------------- /MPU2/lib/Arduino-MPU6050-master/MPU6050_gyro_pitch_roll_yaw/MPU6050_gyro_pitch_roll_yaw.ino: -------------------------------------------------------------------------------- 1 | /* 2 | MPU6050 Triple Axis Gyroscope & Accelerometer. Pitch & Roll & Yaw Gyroscope Example. 3 | Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-zyroskop-i-akcelerometr-mpu6050.html 4 | GIT: https://github.com/jarzebski/Arduino-MPU6050 5 | Web: http://www.jarzebski.pl 6 | (c) 2014 by Korneliusz Jarzebski 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | MPU6050 mpu; 13 | 14 | // Timers 15 | unsigned long timer = 0; 16 | float timeStep = 0.01; 17 | 18 | // Pitch, Roll and Yaw values 19 | float pitch = 0; 20 | float roll = 0; 21 | float yaw = 0; 22 | 23 | void setup() 24 | { 25 | Serial.begin(115200); 26 | 27 | // Initialize MPU6050 28 | while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) 29 | { 30 | Serial.println("Could not find a valid MPU6050 sensor, check wiring!"); 31 | delay(500); 32 | } 33 | 34 | // Calibrate gyroscope. The calibration must be at rest. 35 | // If you don't want calibrate, comment this line. 36 | mpu.calibrateGyro(); 37 | 38 | // Set threshold sensivty. Default 3. 39 | // If you don't want use threshold, comment this line or set 0. 40 | mpu.setThreshold(3); 41 | } 42 | 43 | void loop() 44 | { 45 | timer = millis(); 46 | 47 | // Read normalized values 48 | Vector norm = mpu.readNormalizeGyro(); 49 | 50 | // Calculate Pitch, Roll and Yaw 51 | pitch = pitch + norm.YAxis * timeStep; 52 | roll = roll + norm.XAxis * timeStep; 53 | yaw = yaw + norm.ZAxis * timeStep; 54 | 55 | // Output raw 56 | Serial.print(" Pitch = "); 57 | Serial.print(pitch); 58 | Serial.print(" Roll = "); 59 | Serial.print(roll); 60 | Serial.print(" Yaw = "); 61 | Serial.println(yaw); 62 | 63 | // Wait to full timeStep period 64 | delay((timeStep*1000) - (millis() - timer)); 65 | } 66 | -------------------------------------------------------------------------------- /MPU2/lib/Arduino-MPU6050-master/MPU6050_gyro_simple/MPU6050_gyro_simple.ino: -------------------------------------------------------------------------------- 1 | /* 2 | MPU6050 Triple Axis Gyroscope & Accelerometer. Simple Gyroscope Example. 3 | Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-zyroskop-i-akcelerometr-mpu6050.html 4 | GIT: https://github.com/jarzebski/Arduino-MPU6050 5 | Web: http://www.jarzebski.pl 6 | (c) 2014 by Korneliusz Jarzebski 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | MPU6050 mpu; 13 | 14 | void setup() 15 | { 16 | Serial.begin(115200); 17 | 18 | // Initialize MPU6050 19 | Serial.println("Initialize MPU6050"); 20 | while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) 21 | { 22 | Serial.println("Could not find a valid MPU6050 sensor, check wiring!"); 23 | delay(500); 24 | } 25 | 26 | // If you want, you can set gyroscope offsets 27 | // mpu.setGyroOffsetX(155); 28 | // mpu.setGyroOffsetY(15); 29 | // mpu.setGyroOffsetZ(15); 30 | 31 | // Calibrate gyroscope. The calibration must be at rest. 32 | // If you don't want calibrate, comment this line. 33 | mpu.calibrateGyro(); 34 | 35 | // Set threshold sensivty. Default 3. 36 | // If you don't want use threshold, comment this line or set 0. 37 | mpu.setThreshold(3); 38 | 39 | // Check settings 40 | checkSettings(); 41 | } 42 | 43 | void checkSettings() 44 | { 45 | Serial.println(); 46 | 47 | Serial.print(" * Sleep Mode: "); 48 | Serial.println(mpu.getSleepEnabled() ? "Enabled" : "Disabled"); 49 | 50 | Serial.print(" * Clock Source: "); 51 | switch(mpu.getClockSource()) 52 | { 53 | case MPU6050_CLOCK_KEEP_RESET: Serial.println("Stops the clock and keeps the timing generator in reset"); break; 54 | case MPU6050_CLOCK_EXTERNAL_19MHZ: Serial.println("PLL with external 19.2MHz reference"); break; 55 | case MPU6050_CLOCK_EXTERNAL_32KHZ: Serial.println("PLL with external 32.768kHz reference"); break; 56 | case MPU6050_CLOCK_PLL_ZGYRO: Serial.println("PLL with Z axis gyroscope reference"); break; 57 | case MPU6050_CLOCK_PLL_YGYRO: Serial.println("PLL with Y axis gyroscope reference"); break; 58 | case MPU6050_CLOCK_PLL_XGYRO: Serial.println("PLL with X axis gyroscope reference"); break; 59 | case MPU6050_CLOCK_INTERNAL_8MHZ: Serial.println("Internal 8MHz oscillator"); break; 60 | } 61 | 62 | Serial.print(" * Gyroscope: "); 63 | switch(mpu.getScale()) 64 | { 65 | case MPU6050_SCALE_2000DPS: Serial.println("2000 dps"); break; 66 | case MPU6050_SCALE_1000DPS: Serial.println("1000 dps"); break; 67 | case MPU6050_SCALE_500DPS: Serial.println("500 dps"); break; 68 | case MPU6050_SCALE_250DPS: Serial.println("250 dps"); break; 69 | } 70 | 71 | Serial.print(" * Gyroscope offsets: "); 72 | Serial.print(mpu.getGyroOffsetX()); 73 | Serial.print(" / "); 74 | Serial.print(mpu.getGyroOffsetY()); 75 | Serial.print(" / "); 76 | Serial.println(mpu.getGyroOffsetZ()); 77 | 78 | Serial.println(); 79 | } 80 | 81 | void loop() 82 | { 83 | Vector rawGyro = mpu.readRawGyro(); 84 | Vector normGyro = mpu.readNormalizeGyro(); 85 | 86 | Serial.print(" Xraw = "); 87 | Serial.print(rawGyro.XAxis); 88 | Serial.print(" Yraw = "); 89 | Serial.print(rawGyro.YAxis); 90 | Serial.print(" Zraw = "); 91 | Serial.println(rawGyro.ZAxis); 92 | 93 | Serial.print(" Xnorm = "); 94 | Serial.print(normGyro.XAxis); 95 | Serial.print(" Ynorm = "); 96 | Serial.print(normGyro.YAxis); 97 | Serial.print(" Znorm = "); 98 | Serial.println(normGyro.ZAxis); 99 | 100 | delay(10); 101 | } 102 | 103 | 104 | -------------------------------------------------------------------------------- /MPU2/lib/Arduino-MPU6050-master/MPU6050_motion/MPU6050_motion.ino: -------------------------------------------------------------------------------- 1 | /* 2 | MPU6050 Triple Axis Gyroscope & Accelerometer. Motion detection. 3 | Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-zyroskop-i-akcelerometr-mpu6050.html 4 | GIT: https://github.com/jarzebski/Arduino-MPU6050 5 | Web: http://www.jarzebski.pl 6 | (c) 2014 by Korneliusz Jarzebski 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | MPU6050 mpu; 13 | 14 | void setup() 15 | { 16 | Serial.begin(115200); 17 | 18 | Serial.println("Initialize MPU6050"); 19 | 20 | while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_16G)) 21 | { 22 | Serial.println("Could not find a valid MPU6050 sensor, check wiring!"); 23 | delay(500); 24 | } 25 | 26 | mpu.setAccelPowerOnDelay(MPU6050_DELAY_3MS); 27 | 28 | mpu.setIntFreeFallEnabled(false); 29 | mpu.setIntZeroMotionEnabled(false); 30 | mpu.setIntMotionEnabled(false); 31 | 32 | mpu.setDHPFMode(MPU6050_DHPF_5HZ); 33 | 34 | mpu.setMotionDetectionThreshold(2); 35 | mpu.setMotionDetectionDuration(5); 36 | 37 | mpu.setZeroMotionDetectionThreshold(4); 38 | mpu.setZeroMotionDetectionDuration(2); 39 | 40 | checkSettings(); 41 | 42 | pinMode(4, OUTPUT); 43 | digitalWrite(4, LOW); 44 | 45 | pinMode(7, OUTPUT); 46 | digitalWrite(7, LOW); 47 | } 48 | 49 | void checkSettings() 50 | { 51 | Serial.println(); 52 | 53 | Serial.print(" * Sleep Mode: "); 54 | Serial.println(mpu.getSleepEnabled() ? "Enabled" : "Disabled"); 55 | 56 | Serial.print(" * Motion Interrupt: "); 57 | Serial.println(mpu.getIntMotionEnabled() ? "Enabled" : "Disabled"); 58 | 59 | Serial.print(" * Zero Motion Interrupt: "); 60 | Serial.println(mpu.getIntZeroMotionEnabled() ? "Enabled" : "Disabled"); 61 | 62 | Serial.print(" * Free Fall Interrupt: "); 63 | Serial.println(mpu.getIntFreeFallEnabled() ? "Enabled" : "Disabled"); 64 | 65 | Serial.print(" * Motion Threshold: "); 66 | Serial.println(mpu.getMotionDetectionThreshold()); 67 | 68 | Serial.print(" * Motion Duration: "); 69 | Serial.println(mpu.getMotionDetectionDuration()); 70 | 71 | Serial.print(" * Zero Motion Threshold: "); 72 | Serial.println(mpu.getZeroMotionDetectionThreshold()); 73 | 74 | Serial.print(" * Zero Motion Duration: "); 75 | Serial.println(mpu.getZeroMotionDetectionDuration()); 76 | 77 | Serial.print(" * Clock Source: "); 78 | switch(mpu.getClockSource()) 79 | { 80 | case MPU6050_CLOCK_KEEP_RESET: Serial.println("Stops the clock and keeps the timing generator in reset"); break; 81 | case MPU6050_CLOCK_EXTERNAL_19MHZ: Serial.println("PLL with external 19.2MHz reference"); break; 82 | case MPU6050_CLOCK_EXTERNAL_32KHZ: Serial.println("PLL with external 32.768kHz reference"); break; 83 | case MPU6050_CLOCK_PLL_ZGYRO: Serial.println("PLL with Z axis gyroscope reference"); break; 84 | case MPU6050_CLOCK_PLL_YGYRO: Serial.println("PLL with Y axis gyroscope reference"); break; 85 | case MPU6050_CLOCK_PLL_XGYRO: Serial.println("PLL with X axis gyroscope reference"); break; 86 | case MPU6050_CLOCK_INTERNAL_8MHZ: Serial.println("Internal 8MHz oscillator"); break; 87 | } 88 | 89 | Serial.print(" * Accelerometer: "); 90 | switch(mpu.getRange()) 91 | { 92 | case MPU6050_RANGE_16G: Serial.println("+/- 16 g"); break; 93 | case MPU6050_RANGE_8G: Serial.println("+/- 8 g"); break; 94 | case MPU6050_RANGE_4G: Serial.println("+/- 4 g"); break; 95 | case MPU6050_RANGE_2G: Serial.println("+/- 2 g"); break; 96 | } 97 | 98 | Serial.print(" * Accelerometer offsets: "); 99 | Serial.print(mpu.getAccelOffsetX()); 100 | Serial.print(" / "); 101 | Serial.print(mpu.getAccelOffsetY()); 102 | Serial.print(" / "); 103 | Serial.println(mpu.getAccelOffsetZ()); 104 | 105 | Serial.print(" * Accelerometer power delay: "); 106 | switch(mpu.getAccelPowerOnDelay()) 107 | { 108 | case MPU6050_DELAY_3MS: Serial.println("3ms"); break; 109 | case MPU6050_DELAY_2MS: Serial.println("2ms"); break; 110 | case MPU6050_DELAY_1MS: Serial.println("1ms"); break; 111 | case MPU6050_NO_DELAY: Serial.println("0ms"); break; 112 | } 113 | 114 | Serial.println(); 115 | } 116 | 117 | void loop() 118 | { 119 | Vector rawAccel = mpu.readRawAccel(); 120 | Activites act = mpu.readActivites(); 121 | 122 | if (act.isActivity) 123 | { 124 | digitalWrite(4, HIGH); 125 | } else 126 | { 127 | digitalWrite(4, LOW); 128 | } 129 | 130 | if (act.isInactivity) 131 | { 132 | digitalWrite(7, HIGH); 133 | } else 134 | { 135 | digitalWrite(7, LOW); 136 | } 137 | 138 | Serial.print(act.isActivity); 139 | Serial.print(act.isInactivity); 140 | 141 | Serial.print(" "); 142 | Serial.print(act.isPosActivityOnX); 143 | Serial.print(act.isNegActivityOnX); 144 | Serial.print(" "); 145 | 146 | Serial.print(act.isPosActivityOnY); 147 | Serial.print(act.isNegActivityOnY); 148 | Serial.print(" "); 149 | 150 | Serial.print(act.isPosActivityOnZ); 151 | Serial.print(act.isNegActivityOnZ); 152 | Serial.print("\n"); 153 | delay(50); 154 | } 155 | 156 | 157 | -------------------------------------------------------------------------------- /MPU2/lib/Arduino-MPU6050-master/MPU6050_temperature/MPU6050_temperature.ino: -------------------------------------------------------------------------------- 1 | /* 2 | MPU6050 Triple Axis Gyroscope & Accelerometer. Temperature Example. 3 | Read more: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-zyroskop-i-akcelerometr-mpu6050.html 4 | GIT: https://github.com/jarzebski/Arduino-MPU6050 5 | Web: http://www.jarzebski.pl 6 | (c) 2014 by Korneliusz Jarzebski 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | MPU6050 mpu; 13 | 14 | void setup() 15 | { 16 | Serial.begin(115200); 17 | 18 | Serial.println("Initialize MPU6050"); 19 | 20 | while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) 21 | { 22 | Serial.println("Could not find a valid MPU6050 sensor, check wiring!"); 23 | delay(500); 24 | } 25 | } 26 | 27 | void loop() 28 | { 29 | float temp = mpu.readTemperature(); 30 | 31 | Serial.print(" Temp = "); 32 | Serial.print(temp); 33 | Serial.println(" *C"); 34 | 35 | delay(500); 36 | } 37 | 38 | 39 | -------------------------------------------------------------------------------- /MPU2/lib/Arduino-MPU6050-master/README.md: -------------------------------------------------------------------------------- 1 | Arduino-MPU6050 2 | =============== 3 | 4 | MPU6050 Triple Axis Gyroscope & Accelerometer Arduino Library. 5 | 6 | ![MPU6050 Processing](http://www.jarzebski.pl/media/zoom/publish/2014/10/mpu6050-processing-2.png "MPU6050 Processing") 7 | 8 | Tutorials: http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-zyroskop-i-akcelerometr-mpu6050.html 9 | 10 | This library use I2C to communicate, 2 pins are required to interface 11 | 12 | I need your help 13 | ---------------- 14 | 15 | July 31, 2017 16 | 17 | In the near future I plan to refactoring the libraries. The main goal is to improve code quality, new features and add support for different versions of Arduino boards like Uno, Mega and Zero. 18 | 19 | For this purpose I need to buy modules, Arduino Boards and lot of beer. 20 | 21 | If you want to support the further and long-term development of libraries, please help. 22 | 23 | You can do this by transferring any amount to my PayPal account: paypal@jarzebski.pl 24 | 25 | Thanks! 26 | -------------------------------------------------------------------------------- /MPU2/lib/MPU6050_tockn-master/README.md: -------------------------------------------------------------------------------- 1 | # MPU6050_tockn 2 | Arduino library for easy communicating with the MPU6050 3 | ## Usage 4 | You can see [example sketch.](https://github.com/Tockn/MPU6050_tockn/tree/master/examples) 5 | 6 | If you want to get data of MPU6050, you must execute `update()` method before get method. 7 | `update()` will get all data of MPU6050, and calculating angle by accelerometer, gyroscope and complementary filter. 8 | 9 | ### Complementary filter 10 | `update()` method calculate angle by accelerometer and gyroscope using complementary filter. 11 | Those two coefficients determined by constructor. 12 | Default coefficient of accelerometer is 0.02, gyroscope is 0.98. 13 | `filtered_angle = (0.02 * accel) + (0.98 * gyro)` 14 | #### example 15 | If you want to set 0.1 to accelerometer coefficient and 0.9 to gyroscope coefficient, your code is 16 | ```MPU6050 mpu6050(Wire, 0.1, 0.9);``` 17 | 18 | 19 | ### Auto calibration 20 | If you use `calcGyroOffsets()` in `setup()`, it will calculate calibration of the gyroscope, and the value of the gyroscope will calibrated. 21 | ⚠DO NOT MOVE MPU6050 during calculating.⚠ 22 | ``` 23 | #include 24 | #include 25 | 26 | MPU6050 mpu6050(Wire); 27 | 28 | void setup(){ 29 | Wire.begin(); 30 | mpu6050.begin(); 31 | mpu6050.calcGyroOffsets(); 32 | } 33 | 34 | ``` 35 | 36 | If you use `calcGyroOffsets(true)` in `setup()`, you can see state of calculating calibration in serial monitor. 37 | ``` 38 | #include 39 | #include 40 | 41 | MPU6050 mpu6050(Wire); 42 | 43 | void setup(){ 44 | Serial.begin(9600); 45 | Wire.begin(); 46 | mpu6050.begin(); 47 | mpu6050.calcGyroOffsets(true); 48 | } 49 | ``` 50 | Serial monitor: 51 | ``` 52 | Calculate gyro offsets 53 | DO NOT MOVE MPU6050..... 54 | Done! 55 | X : 1.45 56 | Y : 1.23 57 | Z : -1.32 58 | Program will start after 3 seconds 59 | ``` 60 | 61 | If you know offsets of gyroscope, you can set them by `setGyroOffsets()`, and you don't have to execute `calcGyroOffsets()`, so you can launch program quickly. 62 | #### example 63 | ``` 64 | #include 65 | #include 66 | 67 | MPU6050 mpu6050(Wire); 68 | 69 | void setup(){ 70 | Serial.begin(9600); 71 | Wire.begin(); 72 | mpu6050.begin(); 73 | mpu6050.setGyroOffsets(1.45, 1.23, -1.32); 74 | } 75 | ``` 76 | ## Licence 77 | MIT 78 | ## Author 79 | 80 | [tockn](https://github.com/tockn) 81 | -------------------------------------------------------------------------------- /MPU2/lib/MPU6050_tockn-master/examples/GetAllData/GetAllData.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | MPU6050 mpu6050(Wire); 6 | 7 | long timer = 0; 8 | 9 | void setup() { 10 | Serial.begin(9600); 11 | Wire.begin(); 12 | mpu6050.begin(); 13 | mpu6050.calcGyroOffsets(true); 14 | } 15 | 16 | void loop() { 17 | mpu6050.update(); 18 | 19 | if(millis() - timer > 1000){ 20 | 21 | Serial.println("======================================================="); 22 | Serial.print("temp : ");Serial.println(mpu6050.getTemp()); 23 | Serial.print("accX : ");Serial.print(mpu6050.getAccX()); 24 | Serial.print("\taccY : ");Serial.print(mpu6050.getAccY()); 25 | Serial.print("\taccZ : ");Serial.println(mpu6050.getAccZ()); 26 | 27 | Serial.print("gyroX : ");Serial.print(mpu6050.getGyroX()); 28 | Serial.print("\tgyroY : ");Serial.print(mpu6050.getGyroY()); 29 | Serial.print("\tgyroZ : ");Serial.println(mpu6050.getGyroZ()); 30 | 31 | Serial.print("accAngleX : ");Serial.print(mpu6050.getAccAngleX()); 32 | Serial.print("\taccAngleY : ");Serial.println(mpu6050.getAccAngleY()); 33 | 34 | Serial.print("gyroAngleX : ");Serial.print(mpu6050.getGyroAngleX()); 35 | Serial.print("\tgyroAngleY : ");Serial.print(mpu6050.getGyroAngleY()); 36 | Serial.print("\tgyroAngleZ : ");Serial.println(mpu6050.getGyroAngleZ()); 37 | 38 | Serial.print("angleX : ");Serial.print(mpu6050.getAngleX()); 39 | Serial.print("\tangleY : ");Serial.print(mpu6050.getAngleY()); 40 | Serial.print("\tangleZ : ");Serial.println(mpu6050.getAngleZ()); 41 | Serial.println("=======================================================\n"); 42 | timer = millis(); 43 | 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /MPU2/lib/MPU6050_tockn-master/examples/GetAngle/GetAngle.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | MPU6050 mpu6050(Wire); 6 | 7 | void setup() { 8 | Serial.begin(9600); 9 | Wire.begin(); 10 | mpu6050.begin(); 11 | mpu6050.calcGyroOffsets(true); 12 | } 13 | 14 | void loop() { 15 | mpu6050.update(); 16 | Serial.print("angleX : "); 17 | Serial.print(mpu6050.getAngleX()); 18 | Serial.print("\tangleY : "); 19 | Serial.print(mpu6050.getAngleY()); 20 | Serial.print("\tangleZ : "); 21 | Serial.println(mpu6050.getAngleZ()); 22 | } 23 | -------------------------------------------------------------------------------- /MPU2/lib/MPU6050_tockn-master/library.properties: -------------------------------------------------------------------------------- 1 | name=MPU6050_tockn 2 | version=1.5.2 3 | author=tockn 4 | maintainer=tockn 5 | sentence=Arduino library for easy communicating with the MPU6050. 6 | paragraph=It can get accel, gyro, and angle data. 7 | category=Sensors 8 | url=https://github.com/Tockn/MPU6050_tockn 9 | architectures=* 10 | -------------------------------------------------------------------------------- /MPU2/lib/MPU6050_tockn-master/src/MPU6050_tockn.cpp: -------------------------------------------------------------------------------- 1 | #include "MPU6050_tockn.h" 2 | #include "Arduino.h" 3 | 4 | MPU6050_tockn::MPU6050_tockn(TwoWire &w){ 5 | wire = &w; 6 | accCoef = 0.02f; 7 | gyroCoef = 0.98f; 8 | } 9 | 10 | MPU6050_tockn::MPU6050_tockn(TwoWire &w, float aC, float gC){ 11 | wire = &w; 12 | accCoef = aC; 13 | gyroCoef = gC; 14 | } 15 | 16 | void MPU6050_tockn::begin(){ 17 | writeMPU6050(MPU6050_SMPLRT_DIV, 0x00); 18 | writeMPU6050(MPU6050_CONFIG, 0x00); 19 | writeMPU6050(MPU6050_GYRO_CONFIG, 0x08); 20 | writeMPU6050(MPU6050_ACCEL_CONFIG, 0x00); 21 | writeMPU6050(MPU6050_PWR_MGMT_1, 0x01); 22 | this->update(); 23 | angleGyroX = 0; 24 | angleGyroY = 0; 25 | angleX = this->getAccAngleX(); 26 | angleY = this->getAccAngleY(); 27 | preInterval = millis(); 28 | } 29 | 30 | void MPU6050_tockn::writeMPU6050(byte reg, byte data){ 31 | wire->beginTransmission(MPU6050_ADDR); 32 | wire->write(reg); 33 | wire->write(data); 34 | wire->endTransmission(); 35 | } 36 | 37 | byte MPU6050_tockn::readMPU6050(byte reg) { 38 | wire->beginTransmission(MPU6050_ADDR); 39 | wire->write(reg); 40 | wire->endTransmission(true); 41 | wire->requestFrom(MPU6050_ADDR, 1); 42 | byte data = wire->read(); 43 | return data; 44 | } 45 | 46 | void MPU6050_tockn::setGyroOffsets(float x, float y, float z){ 47 | gyroXoffset = x; 48 | gyroYoffset = y; 49 | gyroZoffset = z; 50 | } 51 | 52 | void MPU6050_tockn::calcGyroOffsets(bool console, uint16_t delayBefore, uint16_t delayAfter){ 53 | float x = 0, y = 0, z = 0; 54 | int16_t rx, ry, rz; 55 | 56 | delay(delayBefore); 57 | if(console){ 58 | Serial.println(); 59 | Serial.println("========================================"); 60 | Serial.println("Calculating gyro offsets"); 61 | Serial.print("DO NOT MOVE MPU6050"); 62 | } 63 | for(int i = 0; i < 3000; i++){ 64 | if(console && i % 1000 == 0){ 65 | Serial.print("."); 66 | } 67 | wire->beginTransmission(MPU6050_ADDR); 68 | wire->write(0x43); 69 | wire->endTransmission(false); 70 | wire->requestFrom((int)MPU6050_ADDR, 6); 71 | 72 | rx = wire->read() << 8 | wire->read(); 73 | ry = wire->read() << 8 | wire->read(); 74 | rz = wire->read() << 8 | wire->read(); 75 | 76 | x += ((float)rx) / 65.5; 77 | y += ((float)ry) / 65.5; 78 | z += ((float)rz) / 65.5; 79 | } 80 | gyroXoffset = x / 3000; 81 | gyroYoffset = y / 3000; 82 | gyroZoffset = z / 3000; 83 | 84 | if(console){ 85 | Serial.println(); 86 | Serial.println("Done!"); 87 | Serial.print("X : ");Serial.println(gyroXoffset); 88 | Serial.print("Y : ");Serial.println(gyroYoffset); 89 | Serial.print("Z : ");Serial.println(gyroZoffset); 90 | Serial.println("Program will start after 3 seconds"); 91 | Serial.print("========================================"); 92 | delay(delayAfter); 93 | } 94 | } 95 | 96 | void MPU6050_tockn::update(){ 97 | wire->beginTransmission(MPU6050_ADDR); 98 | wire->write(0x3B); 99 | wire->endTransmission(false); 100 | wire->requestFrom((int)MPU6050_ADDR, 14); 101 | 102 | rawAccX = wire->read() << 8 | wire->read(); 103 | rawAccY = wire->read() << 8 | wire->read(); 104 | rawAccZ = wire->read() << 8 | wire->read(); 105 | rawTemp = wire->read() << 8 | wire->read(); 106 | rawGyroX = wire->read() << 8 | wire->read(); 107 | rawGyroY = wire->read() << 8 | wire->read(); 108 | rawGyroZ = wire->read() << 8 | wire->read(); 109 | 110 | temp = (rawTemp + 12412.0) / 340.0; 111 | 112 | accX = ((float)rawAccX) / 16384.0; 113 | accY = ((float)rawAccY) / 16384.0; 114 | accZ = ((float)rawAccZ) / 16384.0; 115 | 116 | angleAccX = atan2(accY, sqrt(accZ * accZ + accX * accX)) * 360 / 2.0 / PI; 117 | angleAccY = atan2(accX, sqrt(accZ * accZ + accY * accY)) * 360 / -2.0 / PI; 118 | 119 | gyroX = ((float)rawGyroX) / 65.5; 120 | gyroY = ((float)rawGyroY) / 65.5; 121 | gyroZ = ((float)rawGyroZ) / 65.5; 122 | 123 | gyroX -= gyroXoffset; 124 | gyroY -= gyroYoffset; 125 | gyroZ -= gyroZoffset; 126 | 127 | interval = (millis() - preInterval) * 0.001; 128 | 129 | angleGyroX += gyroX * interval; 130 | angleGyroY += gyroY * interval; 131 | angleGyroZ += gyroZ * interval; 132 | 133 | angleX = (gyroCoef * (angleX + gyroX * interval)) + (accCoef * angleAccX); 134 | angleY = (gyroCoef * (angleY + gyroY * interval)) + (accCoef * angleAccY); 135 | angleZ = angleGyroZ; 136 | 137 | preInterval = millis(); 138 | 139 | } 140 | -------------------------------------------------------------------------------- /MPU2/lib/MPU6050_tockn-master/src/MPU6050_tockn.h: -------------------------------------------------------------------------------- 1 | #ifndef MPU6050_TOCKN_H 2 | #define MPU6050_TOCKN_H 3 | 4 | #include "Arduino.h" 5 | #include "Wire.h" 6 | 7 | #define MPU6050_ADDR 0x69 8 | #define MPU6050_SMPLRT_DIV 0x19 9 | #define MPU6050_CONFIG 0x1a 10 | #define MPU6050_GYRO_CONFIG 0x1b 11 | #define MPU6050_ACCEL_CONFIG 0x1c 12 | #define MPU6050_WHO_AM_I 0x75 13 | #define MPU6050_PWR_MGMT_1 0x6b 14 | #define MPU6050_TEMP_H 0x41 15 | #define MPU6050_TEMP_L 0x42 16 | 17 | class MPU6050_tockn{ 18 | public: 19 | 20 | MPU6050_tockn(TwoWire &w); 21 | MPU6050_tockn(TwoWire &w, float aC, float gC); 22 | 23 | void begin(); 24 | 25 | void setGyroOffsets(float x, float y, float z); 26 | 27 | void writeMPU6050(byte reg, byte data); 28 | byte readMPU6050(byte reg); 29 | 30 | int16_t getRawAccX(){ return rawAccX; }; 31 | int16_t getRawAccY(){ return rawAccY; }; 32 | int16_t getRawAccZ(){ return rawAccZ; }; 33 | 34 | int16_t getRawTemp(){ return rawTemp; }; 35 | 36 | int16_t getRawGyroX(){ return rawGyroX; }; 37 | int16_t getRawGyroY(){ return rawGyroY; }; 38 | int16_t getRawGyroZ(){ return rawGyroZ; }; 39 | 40 | float getTemp(){ return temp; }; 41 | 42 | float getAccX(){ return accX; }; 43 | float getAccY(){ return accY; }; 44 | float getAccZ(){ return accZ; }; 45 | 46 | float getGyroX(){ return gyroX; }; 47 | float getGyroY(){ return gyroY; }; 48 | float getGyroZ(){ return gyroZ; }; 49 | 50 | void calcGyroOffsets(bool console = false, uint16_t delayBefore = 1000, uint16_t delayAfter = 3000); 51 | 52 | float getGyroXoffset(){ return gyroXoffset; }; 53 | float getGyroYoffset(){ return gyroYoffset; }; 54 | float getGyroZoffset(){ return gyroZoffset; }; 55 | 56 | void update(); 57 | 58 | float getAccAngleX(){ return angleAccX; }; 59 | float getAccAngleY(){ return angleAccY; }; 60 | 61 | float getGyroAngleX(){ return angleGyroX; }; 62 | float getGyroAngleY(){ return angleGyroY; }; 63 | float getGyroAngleZ(){ return angleGyroZ; }; 64 | 65 | float getAngleX(){ return angleX; }; 66 | float getAngleY(){ return angleY; }; 67 | float getAngleZ(){ return angleZ; }; 68 | 69 | private: 70 | 71 | TwoWire *wire; 72 | 73 | int16_t rawAccX, rawAccY, rawAccZ, rawTemp, 74 | rawGyroX, rawGyroY, rawGyroZ; 75 | 76 | float gyroXoffset, gyroYoffset, gyroZoffset; 77 | 78 | float temp, accX, accY, accZ, gyroX, gyroY, gyroZ; 79 | 80 | float angleGyroX, angleGyroY, angleGyroZ, 81 | angleAccX, angleAccY, angleAccZ; 82 | 83 | float angleX, angleY, angleZ; 84 | 85 | float interval; 86 | long preInterval; 87 | 88 | float accCoef, gyroCoef; 89 | }; 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /MPU2/sketch_aug01a/sketch_aug01a.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | MPU6050_tockn mpu6050_1(Wire); 5 | 6 | #include 7 | MPU6050 mpu6050_2; 8 | unsigned long timer = 0; 9 | float timeStep = 0.01; 10 | 11 | void setup() { 12 | Serial.begin(115200); 13 | Wire.begin(); 14 | mpu6050_1.begin(); 15 | mpu6050_1.calcGyroOffsets(true); 16 | 17 | 18 | while (!mpu6050_2.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) 19 | { 20 | Serial.println("Could not find a valid MPU6050 sensor, check wiring!"); 21 | delay(500); 22 | } 23 | 24 | } 25 | 26 | void loop() { 27 | 28 | //MPU 1 29 | mpu6050_1.update(); 30 | // Serial.print("aX "); Serial.print(mpu6050_1.getAccX()); 31 | // Serial.print(" aY "); Serial.print(mpu6050_1.getAccY()); 32 | // Serial.print(" aZ "); Serial.print(mpu6050_1.getAccZ()); 33 | // 34 | // Serial.print(" gX "); Serial.print(mpu6050_1.getGyroX()); 35 | // Serial.print(" gY "); Serial.print(mpu6050_1.getGyroY()); 36 | // Serial.print(" gZ "); Serial.print(mpu6050_1.getGyroZ()); 37 | // 38 | // Serial.print(" X "); Serial.print(mpu6050_1.getAngleX()); 39 | // Serial.print(" Y "); Serial.print(mpu6050_1.getAngleY()); 40 | // Serial.print(" Z "); Serial.print(mpu6050_1.getAngleZ()); 41 | 42 | 43 | //--------------------MPU 2 44 | Vector normAccel = mpu6050_2.readNormalizeAccel(); 45 | Vector normGyro = mpu6050_2.readNormalizeGyro(); 46 | 47 | int pitch = -(atan2(normAccel.XAxis, sqrt(normAccel.YAxis*normAccel.YAxis + normAccel.ZAxis*normAccel.ZAxis))*180.0)/M_PI; 48 | int roll = (atan2(normAccel.YAxis, normAccel.ZAxis)*180.0)/M_PI; 49 | int yaw = yaw + normGyro.ZAxis * timeStep; 50 | 51 | // Serial.print("aX "); 52 | // Serial.print(normAccel.XAxis); 53 | // Serial.print(" aY "); 54 | // Serial.print(normAccel.YAxis); 55 | // Serial.print(" aZ "); 56 | // Serial.s(normAccel.ZAxis); 57 | // 58 | // Serial.print(" gX "); 59 | // Serial.print(normGyro.XAxis); 60 | // Serial.print(" gY "); 61 | // Serial.print(normGyro.YAxis); 62 | // Serial.print(" gZ "); 63 | // Serial.print(normGyro.ZAxis); 64 | // 65 | // Serial.print(" X "); Serial.print(pitch); 66 | // Serial.print(" Y "); Serial.println(roll); 67 | 68 | //Serial Plotter 69 | Serial.print(mpu6050_1.getAngleX()); Serial.print(" "); 70 | Serial.print(mpu6050_1.getAngleY()); Serial.print(" "); 71 | Serial.print(pitch); Serial.print(" "); 72 | Serial.print(roll); Serial.println(" "); 73 | 74 | delay(100); 75 | } 76 | -------------------------------------------------------------------------------- /Sensor AD8232/Blog AD8232 KEYES ESP32.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/Sensor AD8232/Blog AD8232 KEYES ESP32.docx -------------------------------------------------------------------------------- /Sensor AD8232/main6_MAV/main6_MAV.ino: -------------------------------------------------------------------------------- 1 | #define piLOplus_LAYellow 32 //LO+ RX2 Konek 0 DC 1 2 | #define piLOmin_RARed 33 //LO- TX2 Konek 0 DC 1 3 | #define paOutput 36 //LO- TX2 4 | #define poLEDtick LED_BUILTIN 5 | unsigned char dLOplus_LAYellow; 6 | unsigned char dLOmin_RARed; 7 | int dOutput = 0; 8 | 9 | #define tresholdSinyal 3000 10 | 11 | 12 | void setup() 13 | { 14 | Serial.begin(115200); 15 | pinMode(piLOplus_LAYellow, INPUT_PULLUP); 16 | pinMode(piLOmin_RARed, INPUT_PULLUP); 17 | pinMode(poLEDtick, OUTPUT); 18 | 19 | my_moving_ave_clear(); 20 | } 21 | 22 | 23 | int ledState = LOW; 24 | unsigned long previousMillis = 0; 25 | const long interval = 1 ; //1000Hz 26 | float BPM = 0; 27 | int mavBPM = 0; 28 | int error = 0; //untuk kalibrasi 29 | int msBPM; 30 | 31 | int flagBPM = 0; 32 | void loop() 33 | { 34 | 35 | unsigned long currentMillis = millis(); 36 | if (currentMillis - previousMillis >= interval) 37 | { 38 | previousMillis = currentMillis; 39 | 40 | dLOmin_RARed = digitalRead(piLOmin_RARed); 41 | dLOplus_LAYellow = digitalRead(piLOplus_LAYellow); 42 | dOutput = analogRead(paOutput); 43 | 44 | //dataLOPrint(); 45 | //dataSignalPrint(); 46 | 47 | 48 | // LEAD TIDAK TERHUBUNG 49 | // LED NYALA 50 | if (dLOmin_RARed == HIGH || dLOplus_LAYellow == HIGH) { 51 | digitalWrite(poLEDtick, HIGH); //NYALA 52 | msBPM = 0; 53 | } 54 | 55 | 56 | // LEAD TERHUBUNG 57 | // LED KEDIP 58 | else { 59 | 60 | 61 | if (dOutput > tresholdSinyal && flagBPM == 0) { 62 | 63 | flagBPM = 1; 64 | digitalWrite(poLEDtick, HIGH); 65 | 66 | 67 | if (msBPM > 525) 68 | { 69 | BPM = 60000.0 / msBPM; 70 | mavBPM = my_moving_average(BPM, 0); 71 | mavBPM -= error; 72 | //Serial.print(BPM); Serial.print(" "); 73 | Serial.println(mavBPM); 74 | } 75 | 76 | 77 | 78 | msBPM = 0; 79 | 80 | } 81 | else if (dOutput < tresholdSinyal) { 82 | flagBPM = 0; 83 | digitalWrite(poLEDtick, LOW); 84 | msBPM++; 85 | } 86 | } 87 | } 88 | } 89 | 90 | void dataPrint() { 91 | //Serial.print(dLOplus); Serial.print("+"); 92 | //Serial.print(dLOmin); Serial.print("-"); 93 | Serial.print(dOutput); 94 | Serial.println(); 95 | } 96 | 97 | 98 | 99 | 100 | void dataLOPrint() { 101 | Serial.print(dLOplus_LAYellow); Serial.print("LA"); 102 | Serial.print(dLOmin_RARed); Serial.print("RA"); 103 | Serial.println(); 104 | } 105 | 106 | void dataSignalPrint() { 107 | Serial.print(dOutput); 108 | Serial.println(); 109 | } 110 | 111 | 112 | 113 | //--------------------------------#MY AVERAGE 114 | #define n_my_data 5 115 | float my_data[n_my_data]; 116 | int i_my_data = 0; 117 | 118 | float my_moving_average(float in_data, int debug) 119 | { 120 | float my_ave; 121 | float my_sum; 122 | 123 | my_data[i_my_data] = in_data; 124 | 125 | if (my_data[n_my_data - 1] == 0) 126 | { 127 | my_sum = 0; 128 | 129 | for (int i = 0; i <= i_my_data; i++) 130 | { 131 | my_sum += my_data[i]; 132 | } 133 | my_ave = my_sum / (i_my_data + 1); 134 | } 135 | else 136 | { 137 | my_sum = 0; 138 | for (int i = 0; i < n_my_data; i++) 139 | { 140 | my_sum += my_data[i]; 141 | } 142 | my_ave = my_sum / n_my_data; 143 | } 144 | 145 | 146 | //#Debug 147 | if (debug) 148 | { 149 | for (int i = 0; i < n_my_data; i++) 150 | { 151 | Serial.print(i); Serial.print(" "); Serial.println(my_data[i]); 152 | } 153 | Serial.print("i"); Serial.print(" "); Serial.println(i_my_data); 154 | Serial.print("Last"); Serial.print(" "); Serial.println(my_data[n_my_data - 1]); 155 | 156 | Serial.print("Sum"); Serial.print(" "); Serial.println(my_sum); 157 | Serial.print("Ave"); Serial.print(" "); Serial.println(my_ave); 158 | Serial.println(); 159 | } 160 | 161 | 162 | 163 | i_my_data++; 164 | if (i_my_data >= n_my_data) 165 | i_my_data = 0; 166 | 167 | return my_ave; 168 | } 169 | 170 | void my_moving_ave_clear() 171 | { 172 | //Make sure All Array is 0 173 | for (int i = 0; i < n_my_data; i++) 174 | { 175 | my_data[i] = 0; 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /SuhuKelembapanDHT22/DHT_sensor_library.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/SuhuKelembapanDHT22/DHT_sensor_library.zip -------------------------------------------------------------------------------- /SuhuKelembapanDHT22/dht22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/SuhuKelembapanDHT22/dht22.jpg -------------------------------------------------------------------------------- /SuhuKelembapanDHT22/suhu_dht22/dh22.ino: -------------------------------------------------------------------------------- 1 | #include "DHT.h" 2 | // Reading temperature or humidity takes about 250 milliseconds! 3 | // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 4 | 5 | 6 | #define DHTPIN 4 // Digital pin connected to the DHT sensor 7 | // Feather HUZZAH ESP8266 note: use pins 3, 4, 5, 12, 13 or 14 -- 8 | // Pin 15 can work but DHT must be disconnected during program upload. 9 | 10 | #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 11 | 12 | // Connect pin 1 (on the left) of the sensor to +5V 13 | // NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 14 | // to 3.3V instead of 5V! 15 | // Connect pin 2 of the sensor to whatever your DHTPIN is 16 | // Connect pin 4 (on the right) of the sensor to GROUND 17 | // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor 18 | 19 | DHT dht(DHTPIN, DHTTYPE); 20 | float suhuF, suhuC, kelembapan; 21 | 22 | void setupDHT22() { 23 | Serial.println(F("DHTxx test!")); 24 | dht.begin(); 25 | } 26 | 27 | int timeoutNodata; 28 | void getDHT22() { 29 | // Reading temperature or humidity takes about 250 milliseconds! 30 | // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 31 | float h = dht.readHumidity(); 32 | // Read temperature as Celsius (the default) 33 | float t = dht.readTemperature(); 34 | // Read temperature as Fahrenheit (isFahrenheit = true) 35 | float f = dht.readTemperature(true); 36 | 37 | // Check if any reads failed and exit early (to try again). 38 | if (isnan(h) || isnan(t) || isnan(f)) { 39 | suhuF = suhuF; 40 | suhuC = suhuC; 41 | kelembapan = kelembapan; 42 | 43 | timeoutNodata++; 44 | if (timeoutNodata >= 5) { 45 | Serial.println(F("Failed to read from DHT sensor!")); 46 | return; 47 | } 48 | 49 | } 50 | else { 51 | suhuF = f; 52 | suhuC = t; 53 | kelembapan = h; 54 | timeoutNodata = 0; 55 | } 56 | 57 | // Compute heat index in Fahrenheit (the default) 58 | float hif = dht.computeHeatIndex(f, h); 59 | // Compute heat index in Celsius (isFahreheit = false) 60 | float hic = dht.computeHeatIndex(t, h, false); 61 | 62 | Serial.print(F("Humidity: ")); 63 | Serial.print(kelembapan); 64 | Serial.print(F("% Temperature: ")); 65 | Serial.print(suhuC); 66 | Serial.print(F("°C ")); 67 | Serial.print(suhuF); 68 | Serial.print(F("°F Heat index: ")); 69 | Serial.print(hic); 70 | Serial.print(F("°C ")); 71 | Serial.print(hif); 72 | Serial.println(F("°F")); 73 | } 74 | -------------------------------------------------------------------------------- /SuhuKelembapanDHT22/suhu_dht22/suhu_dht22.ino: -------------------------------------------------------------------------------- 1 | void setup() { 2 | Serial.begin(9600); 3 | setupDHT22(); 4 | } 5 | 6 | 7 | void loop() { 8 | if(taskTimer1s()){ 9 | getDHT22(); 10 | } 11 | } 12 | 13 | 14 | unsigned long previousMillis = 0; 15 | const long interval = 1000; 16 | boolean taskTimer1s() { 17 | unsigned long currentMillis = millis(); 18 | if (currentMillis - previousMillis >= interval) 19 | { 20 | previousMillis = currentMillis; 21 | return true; 22 | } 23 | else return false; 24 | } 25 | -------------------------------------------------------------------------------- /bts7960/btsservo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/bts7960/btsservo.jpg -------------------------------------------------------------------------------- /bts7960/data bts7960.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/bts7960/data bts7960.xlsx -------------------------------------------------------------------------------- /dimmerPWM/RBDDimmer-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/dimmerPWM/RBDDimmer-master.zip -------------------------------------------------------------------------------- /dimmerPWM/SerialMonitorDim/SerialMonitorDim.ino: -------------------------------------------------------------------------------- 1 | /************** 2 | * RobotDyn 3 | * Dimmer Library 4 | * ************** 5 | * 6 | * The following sketch is meant to define the dimming value through the serial port of the controller, 7 | * using USE_SERIAL.begin 8 | * void printSpace() function is used for adding of space after functional data 9 | * void loop() serial port evaluator, used to register and define values in dimmer.setPower(outVal); 10 | * 11 | * 12 | * ---------------------- OUTPUT & INPUT Pin table --------------------- 13 | * +---------------+-------------------------+-------------------------+ 14 | * | Board | INPUT Pin | OUTPUT Pin | 15 | * | | Zero-Cross | | 16 | * +---------------+-------------------------+-------------------------+ 17 | * | Lenardo | D7 (NOT CHANGABLE) | D0-D6, D8-D13 | 18 | * +---------------+-------------------------+-------------------------+ 19 | * | Mega | D2 (NOT CHANGABLE) | D0-D1, D3-D70 | 20 | * +---------------+-------------------------+-------------------------+ 21 | * | Uno | D2 (NOT CHANGABLE) | D0-D1, D3-D20 | 22 | * +---------------+-------------------------+-------------------------+ 23 | * | ESP8266 | D1(IO5), D2(IO4), | D0(IO16), D1(IO5), | 24 | * | | D5(IO14), D6(IO12), | D2(IO4), D5(IO14), | 25 | * | | D7(IO13), D8(IO15), | D6(IO12), D7(IO13), | 26 | * | | | D8(IO15) | 27 | * +---------------+-------------------------+-------------------------+ 28 | * | ESP32 | 4(GPI36), 6(GPI34), | 8(GPO32), 9(GP033), | 29 | * | | 5(GPI39), 7(GPI35), | 10(GPIO25), 11(GPIO26), | 30 | * | | 8(GPO32), 9(GP033), | 12(GPIO27), 13(GPIO14), | 31 | * | | 10(GPI025), 11(GPIO26), | 14(GPIO12), 16(GPIO13), | 32 | * | | 12(GPIO27), 13(GPIO14), | 23(GPIO15), 24(GPIO2), | 33 | * | | 14(GPIO12), 16(GPIO13), | 25(GPIO0), 26(GPIO4), | 34 | * | | 21(GPIO7), 23(GPIO15), | 27(GPIO16), 28(GPIO17), | 35 | * | | 24(GPIO2), 25(GPIO0), | 29(GPIO5), 30(GPIO18), | 36 | * | | 26(GPIO4), 27(GPIO16), | 31(GPIO19), 33(GPIO21), | 37 | * | | 28(GPIO17), 29(GPIO5), | 34(GPIO3), 35(GPIO1), | 38 | * | | 30(GPIO18), 31(GPIO19), | 36(GPIO22), 37(GPIO23), | 39 | * | | 33(GPIO21), 35(GPIO1), | | 40 | * | | 36(GPIO22), 37(GPIO23), | | 41 | * +---------------+-------------------------+-------------------------+ 42 | * | Arduino M0 | D7 (NOT CHANGABLE) | D0-D6, D8-D13 | 43 | * | Arduino Zero | | | 44 | * +---------------+-------------------------+-------------------------+ 45 | * | Arduino Due | D0-D53 | D0-D53 | 46 | * +---------------+-------------------------+-------------------------+ 47 | * | STM32 | PA0-PA15,PB0-PB15 | PA0-PA15,PB0-PB15 | 48 | * | Black Pill | PC13-PC15 | PC13-PC15 | 49 | * | BluePill | | | 50 | * | Etc... | | | 51 | * +---------------+-------------------------+-------------------------+ 52 | */ 53 | 54 | #include // 55 | 56 | //#define USE_SERIAL SerialUSB //Serial for boards whith USB serial port 57 | #define USE_SERIAL Serial 58 | #define outputPin 9 59 | #define zerocross 2 // for boards with CHANGEBLE input pins 60 | 61 | //dimmerLamp dimmer(outputPin, zerocross); //initialase port for dimmer for ESP8266, ESP32, Arduino due boards 62 | dimmerLamp dimmer(outputPin); //initialase port for dimmer for MEGA, Leonardo, UNO, Arduino M0, Arduino Zero 63 | 64 | int outVal = 0; 65 | 66 | void setup() { 67 | USE_SERIAL.begin(9600); 68 | dimmer.begin(NORMAL_MODE, ON); //dimmer initialisation: name.begin(MODE, STATE) 69 | USE_SERIAL.println("Dimmer Program is starting..."); 70 | USE_SERIAL.println("Set value"); 71 | } 72 | 73 | void printSpace(int val) 74 | { 75 | if ((val / 100) == 0) USE_SERIAL.print(" "); 76 | if ((val / 10) == 0) USE_SERIAL.print(" "); 77 | } 78 | 79 | void loop() { 80 | int preVal = outVal; 81 | 82 | if (USE_SERIAL.available()) 83 | { 84 | int buf = USE_SERIAL.parseInt(); 85 | if (buf != 0) outVal = buf; 86 | delay(200); 87 | } 88 | dimmer.setPower(outVal); // setPower(0-100%); 89 | 90 | if (preVal != outVal) 91 | { 92 | USE_SERIAL.print("lampValue -> "); 93 | printSpace(dimmer.getPower()); 94 | USE_SERIAL.print(dimmer.getPower()); 95 | USE_SERIAL.println("%"); 96 | 97 | } 98 | delay(50); 99 | 100 | } 101 | -------------------------------------------------------------------------------- /dimmerPWM/dimmer nano.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/dimmerPWM/dimmer nano.jpg -------------------------------------------------------------------------------- /dimmerPWM/esp32/SerialMonitorDim_ESP/SerialMonitorDim_ESP.ino: -------------------------------------------------------------------------------- 1 | /************** 2 | * RobotDyn 3 | * Dimmer Library 4 | * ************** 5 | * 6 | * The following sketch is meant to define the dimming value through the serial port of the controller, 7 | * using USE_SERIAL.begin 8 | * void printSpace() function is used for adding of space after functional data 9 | * void loop() serial port evaluator, used to register and define values in dimmer.setPower(outVal); 10 | * 11 | * 12 | * ---------------------- OUTPUT & INPUT Pin table --------------------- 13 | * +---------------+-------------------------+-------------------------+ 14 | * | Board | INPUT Pin | OUTPUT Pin | 15 | * | | Zero-Cross | | 16 | * +---------------+-------------------------+-------------------------+ 17 | * | Lenardo | D7 (NOT CHANGABLE) | D0-D6, D8-D13 | 18 | * +---------------+-------------------------+-------------------------+ 19 | * | Mega | D2 (NOT CHANGABLE) | D0-D1, D3-D70 | 20 | * +---------------+-------------------------+-------------------------+ 21 | * | Uno | D2 (NOT CHANGABLE) | D0-D1, D3-D20 | 22 | * +---------------+-------------------------+-------------------------+ 23 | * | ESP8266 | D1(IO5), D2(IO4), | D0(IO16), D1(IO5), | 24 | * | | D5(IO14), D6(IO12), | D2(IO4), D5(IO14), | 25 | * | | D7(IO13), D8(IO15), | D6(IO12), D7(IO13), | 26 | * | | | D8(IO15) | 27 | * +---------------+-------------------------+-------------------------+ 28 | * | ESP32 | 4(GPI36), 6(GPI34), | 8(GPO32), 9(GP033), | 29 | * | | 5(GPI39), 7(GPI35), | 10(GPIO25), 11(GPIO26), | 30 | * | | 8(GPO32), 9(GP033), | 12(GPIO27), 13(GPIO14), | 31 | * | | 10(GPI025), 11(GPIO26), | 14(GPIO12), 16(GPIO13), | 32 | * | | 12(GPIO27), 13(GPIO14), | 23(GPIO15), 24(GPIO2), | 33 | * | | 14(GPIO12), 16(GPIO13), | 25(GPIO0), 26(GPIO4), | 34 | * | | 21(GPIO7), 23(GPIO15), | 27(GPIO16), 28(GPIO17), | 35 | * | | 24(GPIO2), 25(GPIO0), | 29(GPIO5), 30(GPIO18), | 36 | * | | 26(GPIO4), 27(GPIO16), | 31(GPIO19), 33(GPIO21), | 37 | * | | 28(GPIO17), 29(GPIO5), | 34(GPIO3), 35(GPIO1), | 38 | * | | 30(GPIO18), 31(GPIO19), | 36(GPIO22), 37(GPIO23), | 39 | * | | 33(GPIO21), 35(GPIO1), | | 40 | * | | 36(GPIO22), 37(GPIO23), | | 41 | * +---------------+-------------------------+-------------------------+ 42 | * | Arduino M0 | D7 (NOT CHANGABLE) | D0-D6, D8-D13 | 43 | * | Arduino Zero | | | 44 | * +---------------+-------------------------+-------------------------+ 45 | * | Arduino Due | D0-D53 | D0-D53 | 46 | * +---------------+-------------------------+-------------------------+ 47 | * | STM32 | PA0-PA15,PB0-PB15 | PA0-PA15,PB0-PB15 | 48 | * | Black Pill | PC13-PC15 | PC13-PC15 | 49 | * | BluePill | | | 50 | * | Etc... | | | 51 | * +---------------+-------------------------+-------------------------+ 52 | */ 53 | 54 | #include // 55 | 56 | //#define USE_SERIAL SerialUSB //Serial for boards whith USB serial port 57 | #define USE_SERIAL Serial 58 | #define outputPin 14 59 | #define zerocross 27 // for boards with CHANGEBLE input pins 60 | 61 | dimmerLamp dimmer(outputPin, zerocross); //initialase port for dimmer for ESP8266, ESP32, Arduino due boards 62 | //dimmerLamp dimmer(outputPin); //initialase port for dimmer for MEGA, Leonardo, UNO, Arduino M0, Arduino Zero 63 | 64 | int outVal = 0; 65 | 66 | void setup() { 67 | USE_SERIAL.begin(9600); 68 | dimmer.begin(NORMAL_MODE, ON); //dimmer initialisation: name.begin(MODE, STATE) 69 | USE_SERIAL.println("Dimmer Program is starting..."); 70 | USE_SERIAL.println("Set value"); 71 | } 72 | 73 | void printSpace(int val) 74 | { 75 | if ((val / 100) == 0) USE_SERIAL.print(" "); 76 | if ((val / 10) == 0) USE_SERIAL.print(" "); 77 | } 78 | 79 | void loop() { 80 | int preVal = outVal; 81 | 82 | if (USE_SERIAL.available()) 83 | { 84 | int buf = USE_SERIAL.parseInt(); 85 | if (buf != 0) outVal = buf; 86 | delay(200); 87 | } 88 | dimmer.setPower(outVal); // setPower(0-100%); 89 | 90 | if (preVal != outVal) 91 | { 92 | USE_SERIAL.print("lampValue -> "); 93 | printSpace(dimmer.getPower()); 94 | USE_SERIAL.print(dimmer.getPower()); 95 | USE_SERIAL.println("%"); 96 | 97 | } 98 | delay(50); 99 | 100 | } 101 | -------------------------------------------------------------------------------- /dimmerPWM/esp32/dimmer esp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/dimmerPWM/esp32/dimmer esp.jpg -------------------------------------------------------------------------------- /epever/ModbusMaster-master/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | ### ModbusMaster version 13 | [Version of the project where you are encountering the issue] 14 | 15 | ### Arduino IDE version 16 | [Version of Arduino IDE in your environment] 17 | 18 | ### Arduino Hardware 19 | [Hardware information, including board and processor] 20 | 21 | ### Platform Details 22 | [Operating system distribution and release version] 23 | 24 | --- 25 | 28 | ### Scenario: 29 | [What you are trying to achieve and you can't?] 30 | 31 | ### Steps to Reproduce: 32 | [If you are filing an issue what are the things we need to do in order to repro your problem? How are you using this project or any resources it includes?] 33 | 34 | ### Expected Result: 35 | [What are you expecting to happen as the consequence of above reproduction steps?] 36 | 37 | ### Actual Result: 38 | [What actually happens after the reproduction steps? Include the error output or a link to a gist if possible.] 39 | 40 | --- 41 | 45 | ### Feature Request 46 | 47 | #### Narrative: 48 | 49 | ```` text 50 | As a [role] 51 | I want [feature] 52 | So that [benefit] 53 | ```` 54 | 55 | #### Acceptance Criteria: 56 | 59 | ```` text 60 | Scenario 1: Title 61 | Given [context] 62 | And [some more context]... 63 | When [event] 64 | Then [outcome] 65 | And [another outcome]... 66 | ```` 67 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 8 | ### Description 9 | [Describe what this change achieves] 10 | 11 | ### Issues Resolved 12 | [List any existing issues this PR resolves; include Fixes #xxx or Closes #xxx (where xxx is issue number)] 13 | 14 | ### Check List 15 | 16 | General 17 | 18 | - [ ] Code follows coding style defined in STYLE.md 19 | - [ ] Doxygen comments are included inline with code 20 | - [ ] No unnecessary whitespace; check with `git diff --check` before committing. 21 | 22 | The following have been modified to reflect new features, if warranted 23 | 24 | - [ ] README.md 25 | - [ ] keywords.txt (use tabs as whitespace separators) 26 | - [ ] library.properties 27 | - [ ] examples/ - update or create new ones, as warranted 28 | 29 | The following have **NOT** been modified 30 | 31 | - [ ] doc/ - will be updated upon versioned release 32 | - [ ] .ruby-gemset 33 | - [ ] .ruby-version 34 | - [ ] CHANGELOG.md - will be updated upon versioned release (HISTORY.md is deprecated) 35 | - [ ] Gemfile 36 | - [ ] LICENSE 37 | - [ ] VERSION - will be updated upon versioned release 38 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/.github_changelog_generator: -------------------------------------------------------------------------------- 1 | add_issues_wo_labels=false 2 | add_pr_wo_labels=false 3 | enhancement-labels=Type: Enhancement 4 | bug-labels=Type: Bug 5 | exclude-labels=Type: Question 6 | header=# ModbusMaster CHANGELOG 7 | include-labels=Type: Bug,Type: Enhancement,Type: Feature Request,Type: Maintenance 8 | future-release=Unreleased 9 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/.gitignore: -------------------------------------------------------------------------------- 1 | #---------------------------------------------------------------- ModbusMaster 2 | doc/html/ 3 | doc/latex/ 4 | 5 | 6 | #-------------- https://github.com/github/gitignore/blob/master/Ruby.gitignore 7 | *.gem 8 | *.rbc 9 | /.config 10 | /coverage/ 11 | /InstalledFiles 12 | /pkg/ 13 | /spec/reports/ 14 | /spec/examples.txt 15 | /test/tmp/ 16 | /test/version_tmp/ 17 | /tmp/ 18 | 19 | # Used by dotenv library to load environment variables. 20 | # .env 21 | 22 | ## Specific to RubyMotion: 23 | .dat* 24 | .repl_history 25 | build/ 26 | *.bridgesupport 27 | build-iPhoneOS/ 28 | build-iPhoneSimulator/ 29 | 30 | ## Specific to RubyMotion (use of CocoaPods): 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # vendor/Pods/ 37 | 38 | ## Documentation cache and generated files: 39 | /.yardoc/ 40 | /_yardoc/ 41 | /doc/ 42 | /rdoc/ 43 | 44 | ## Environment normalization: 45 | /.bundle/ 46 | /vendor/bundle 47 | /lib/bundler/man/ 48 | 49 | # for a library or gem, you might want to ignore these files since the code is 50 | # intended to run in multiple environments; otherwise, check them in: 51 | # Gemfile.lock 52 | # .ruby-version 53 | # .ruby-gemset 54 | 55 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 56 | .rvmrc 57 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/.ruby-gemset: -------------------------------------------------------------------------------- 1 | global 2 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/.ruby-version: -------------------------------------------------------------------------------- 1 | 2.3.1 2 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | python: 4 | - 2.7 5 | 6 | sudo: false 7 | 8 | cache: 9 | directories: 10 | - ~/.platformio 11 | 12 | # update Makefile if target boards added 13 | env: 14 | - PLATFORMIO_BOARD=uno 15 | - PLATFORMIO_BOARD=due 16 | - PLATFORMIO_BOARD=huzzah 17 | - PLATFORMIO_BOARD=genuino101 18 | - PLATFORMIO_BOARD=teensy31 19 | 20 | install: 21 | - pip install -U platformio 22 | 23 | before_script: 24 | - env 25 | - echo $HOME 26 | - echo $TRAVIS_BUILD_DIR 27 | - ls -al $PWD 28 | 29 | script: 30 | - make build 31 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # ModbusMaster CHANGELOG 2 | 3 | ## [v2.0.0](https://github.com/4-20ma/ModbusMaster/tree/v2.0.0) (2016-09-24) 4 | [Full Changelog](https://github.com/4-20ma/ModbusMaster/compare/v1.0.0...v2.0.0) 5 | 6 | **Implemented enhancements:** 7 | 8 | - BREAK: Update library to match IDE 1.5 spec v2.1 [\#81](https://github.com/4-20ma/ModbusMaster/pull/81) ([4-20ma](https://github.com/4-20ma)) 9 | - Use platformio to build multiple boards [\#79](https://github.com/4-20ma/ModbusMaster/pull/79) ([4-20ma](https://github.com/4-20ma)) 10 | 11 | **Closed issues:** 12 | 13 | - Use platformio to build against multiple boards [\#78](https://github.com/4-20ma/ModbusMaster/issues/78) 14 | - Add ruby files to .gitignore [\#75](https://github.com/4-20ma/ModbusMaster/issues/75) 15 | - Reorder Installation section of README [\#73](https://github.com/4-20ma/ModbusMaster/issues/73) 16 | - Update README [\#71](https://github.com/4-20ma/ModbusMaster/issues/71) 17 | - Rename HISTORY to CHANGELOG [\#47](https://github.com/4-20ma/ModbusMaster/issues/47) 18 | - Update library to match 1.5 specification [\#14](https://github.com/4-20ma/ModbusMaster/issues/14) 19 | 20 | **Merged pull requests:** 21 | 22 | - Use relative path to examples [\#80](https://github.com/4-20ma/ModbusMaster/pull/80) ([4-20ma](https://github.com/4-20ma)) 23 | - Add files to .gitignore [\#76](https://github.com/4-20ma/ModbusMaster/pull/76) ([4-20ma](https://github.com/4-20ma)) 24 | - Reorder installation section of README [\#74](https://github.com/4-20ma/ModbusMaster/pull/74) ([4-20ma](https://github.com/4-20ma)) 25 | - Update README [\#72](https://github.com/4-20ma/ModbusMaster/pull/72) ([4-20ma](https://github.com/4-20ma)) 26 | - Automate CHANGELOG generation [\#68](https://github.com/4-20ma/ModbusMaster/pull/68) ([4-20ma](https://github.com/4-20ma)) 27 | 28 | ## [v1.0.0](https://github.com/4-20ma/ModbusMaster/tree/v1.0.0) (2016-09-12) 29 | [Full Changelog](https://github.com/4-20ma/ModbusMaster/compare/v0.11.0...v1.0.0) 30 | 31 | **Implemented enhancements:** 32 | 33 | - Add LICENSE, convert project to Apache 2.0 [\#67](https://github.com/4-20ma/ModbusMaster/pull/67) ([4-20ma](https://github.com/4-20ma)) 34 | - Add example sketch for half-duplex RS485 [\#66](https://github.com/4-20ma/ModbusMaster/pull/66) ([kintel](https://github.com/kintel)) 35 | - Add continuous integration testing with Travis CI [\#63](https://github.com/4-20ma/ModbusMaster/pull/63) ([4-20ma](https://github.com/4-20ma)) 36 | - Disable \_\_MODBUSMASTER\_DEBUG\_\_ mode by default [\#43](https://github.com/4-20ma/ModbusMaster/pull/43) ([kintel](https://github.com/kintel)) 37 | 38 | **Closed issues:** 39 | 40 | - Fix documentation references in ModbusMaster.h, .cpp [\#69](https://github.com/4-20ma/ModbusMaster/issues/69) 41 | - Clean up template wording [\#64](https://github.com/4-20ma/ModbusMaster/issues/64) 42 | - Add Label section to CONTRIBUTING [\#60](https://github.com/4-20ma/ModbusMaster/issues/60) 43 | - Update README contact information [\#58](https://github.com/4-20ma/ModbusMaster/issues/58) 44 | - Add continuous integration testing with travis [\#55](https://github.com/4-20ma/ModbusMaster/issues/55) 45 | - Add Code of Conduct [\#54](https://github.com/4-20ma/ModbusMaster/issues/54) 46 | - Create PULL\_REQUEST\_TEMPLATE [\#49](https://github.com/4-20ma/ModbusMaster/issues/49) 47 | - Create ISSUE\_TEMPLATE [\#48](https://github.com/4-20ma/ModbusMaster/issues/48) 48 | - Change license to Apache 2.0 [\#45](https://github.com/4-20ma/ModbusMaster/issues/45) 49 | - Set \_\_MODBUSMASTER\_DEBUG\_\_ to 0 by default [\#35](https://github.com/4-20ma/ModbusMaster/issues/35) 50 | - Pass Stream object instead of integer reference [\#17](https://github.com/4-20ma/ModbusMaster/issues/17) 51 | 52 | **Merged pull requests:** 53 | 54 | - Add documentation cross-references [\#70](https://github.com/4-20ma/ModbusMaster/pull/70) ([4-20ma](https://github.com/4-20ma)) 55 | - Clean up ISSUE/PULL\_REQUEST templates [\#65](https://github.com/4-20ma/ModbusMaster/pull/65) ([4-20ma](https://github.com/4-20ma)) 56 | - Add initial .travis.yml configuration [\#62](https://github.com/4-20ma/ModbusMaster/pull/62) ([4-20ma](https://github.com/4-20ma)) 57 | - Add label guidance to CONTRIBUTING [\#61](https://github.com/4-20ma/ModbusMaster/pull/61) ([4-20ma](https://github.com/4-20ma)) 58 | - Update README contact information [\#59](https://github.com/4-20ma/ModbusMaster/pull/59) ([4-20ma](https://github.com/4-20ma)) 59 | - Add email address to CODE\_OF\_CONDUCT [\#57](https://github.com/4-20ma/ModbusMaster/pull/57) ([4-20ma](https://github.com/4-20ma)) 60 | - Add CODE\_OF\_CONDUCT [\#56](https://github.com/4-20ma/ModbusMaster/pull/56) ([4-20ma](https://github.com/4-20ma)) 61 | - Add initial PULL\_REQUEST\_TEMPLATE [\#53](https://github.com/4-20ma/ModbusMaster/pull/53) ([4-20ma](https://github.com/4-20ma)) 62 | - Clarify instructions in ISSUE\_TEMPLATE [\#52](https://github.com/4-20ma/ModbusMaster/pull/52) ([4-20ma](https://github.com/4-20ma)) 63 | - Add ISSUE\_TEMPLATE title reqs, separator lines [\#51](https://github.com/4-20ma/ModbusMaster/pull/51) ([4-20ma](https://github.com/4-20ma)) 64 | - Add initial ISSUE\_TEMPLATE [\#50](https://github.com/4-20ma/ModbusMaster/pull/50) ([4-20ma](https://github.com/4-20ma)) 65 | - Add preTransmission\(\), postTransmission\(\) for half-duplex [\#44](https://github.com/4-20ma/ModbusMaster/pull/44) ([kintel](https://github.com/kintel)) 66 | - Add STYLE coding style guide [\#29](https://github.com/4-20ma/ModbusMaster/pull/29) ([4-20ma](https://github.com/4-20ma)) 67 | 68 | ## [v0.11.0](https://github.com/4-20ma/ModbusMaster/tree/v0.11.0) (2015-05-22) 69 | [Full Changelog](https://github.com/4-20ma/ModbusMaster/compare/v0.10.3...v0.11.0) 70 | 71 | **Implemented enhancements:** 72 | 73 | - Update architecture switch [\#28](https://github.com/4-20ma/ModbusMaster/pull/28) ([4-20ma](https://github.com/4-20ma)) 74 | 75 | **Closed issues:** 76 | 77 | - Update architecture switch to match Arduino convention [\#27](https://github.com/4-20ma/ModbusMaster/issues/27) 78 | - Request timeout is impatient [\#3](https://github.com/4-20ma/ModbusMaster/issues/3) 79 | 80 | ## [v0.10.3](https://github.com/4-20ma/ModbusMaster/tree/v0.10.3) (2015-05-22) 81 | [Full Changelog](https://github.com/4-20ma/ModbusMaster/compare/v0.10.2...v0.10.3) 82 | 83 | **Closed issues:** 84 | 85 | - Inconsistent Doxygen comments [\#25](https://github.com/4-20ma/ModbusMaster/issues/25) 86 | - Replace C macros with inline functions [\#18](https://github.com/4-20ma/ModbusMaster/issues/18) 87 | 88 | **Merged pull requests:** 89 | 90 | - Adjust doxygen comments to be consistent [\#26](https://github.com/4-20ma/ModbusMaster/pull/26) ([4-20ma](https://github.com/4-20ma)) 91 | - Replace C macros w/inline functions [\#24](https://github.com/4-20ma/ModbusMaster/pull/24) ([4-20ma](https://github.com/4-20ma)) 92 | 93 | ## [v0.10.2](https://github.com/4-20ma/ModbusMaster/tree/v0.10.2) (2015-05-22) 94 | [Full Changelog](https://github.com/4-20ma/ModbusMaster/compare/v0.9.1...v0.10.2) 95 | 96 | **Implemented enhancements:** 97 | 98 | - Implement CRC16 for SAM3X8E microprocessor [\#11](https://github.com/4-20ma/ModbusMaster/pull/11) ([4-20ma](https://github.com/4-20ma)) 99 | - Add rx flush, change response timeout to 2000 ms [\#10](https://github.com/4-20ma/ModbusMaster/pull/10) ([agprimatic](https://github.com/agprimatic)) 100 | 101 | **Fixed bugs:** 102 | 103 | - Fix documentation build error [\#23](https://github.com/4-20ma/ModbusMaster/pull/23) ([4-20ma](https://github.com/4-20ma)) 104 | - Work around HardwareSerial for SAM3 micro [\#12](https://github.com/4-20ma/ModbusMaster/pull/12) ([4-20ma](https://github.com/4-20ma)) 105 | 106 | **Merged pull requests:** 107 | 108 | - Update pointers to match C++ convention [\#22](https://github.com/4-20ma/ModbusMaster/pull/22) ([4-20ma](https://github.com/4-20ma)) 109 | - Rename markdown file extensions [\#21](https://github.com/4-20ma/ModbusMaster/pull/21) ([4-20ma](https://github.com/4-20ma)) 110 | 111 | ## [v0.9.1](https://github.com/4-20ma/ModbusMaster/tree/v0.9.1) (2013-01-02) 112 | [Full Changelog](https://github.com/4-20ma/ModbusMaster/compare/v0.9...v0.9.1) 113 | 114 | ## [v0.9](https://github.com/4-20ma/ModbusMaster/tree/v0.9) (2011-12-27) 115 | [Full Changelog](https://github.com/4-20ma/ModbusMaster/compare/v0.8...v0.9) 116 | 117 | ## [v0.8](https://github.com/4-20ma/ModbusMaster/tree/v0.8) (2011-11-09) 118 | [Full Changelog](https://github.com/4-20ma/ModbusMaster/compare/v0.7...v0.8) 119 | 120 | ## [v0.7](https://github.com/4-20ma/ModbusMaster/tree/v0.7) (2010-02-10) 121 | [Full Changelog](https://github.com/4-20ma/ModbusMaster/compare/v0.6...v0.7) 122 | 123 | ## [v0.6](https://github.com/4-20ma/ModbusMaster/tree/v0.6) (2010-02-05) 124 | [Full Changelog](https://github.com/4-20ma/ModbusMaster/compare/v0.5...v0.6) 125 | 126 | ## [v0.5](https://github.com/4-20ma/ModbusMaster/tree/v0.5) (2010-01-30) 127 | [Full Changelog](https://github.com/4-20ma/ModbusMaster/compare/v0.4...v0.5) 128 | 129 | ## [v0.4](https://github.com/4-20ma/ModbusMaster/tree/v0.4) (2010-01-30) 130 | [Full Changelog](https://github.com/4-20ma/ModbusMaster/compare/v0.3...v0.4) 131 | 132 | ## [v0.3](https://github.com/4-20ma/ModbusMaster/tree/v0.3) (2010-01-29) 133 | [Full Changelog](https://github.com/4-20ma/ModbusMaster/compare/v0.2...v0.3) 134 | 135 | ## [v0.2](https://github.com/4-20ma/ModbusMaster/tree/v0.2) (2010-01-26) 136 | [Full Changelog](https://github.com/4-20ma/ModbusMaster/compare/v0.1...v0.2) 137 | 138 | ## [v0.1](https://github.com/4-20ma/ModbusMaster/tree/v0.1) (2010-01-25) 139 | 140 | 141 | \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* -------------------------------------------------------------------------------- /epever/ModbusMaster-master/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers 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 of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project owner at 4-20ma@wvfans.net. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Project Maintainers 69 | 70 | - Doc Walker <<4-20ma@wvfans.net>> 71 | 72 | ## Attribution 73 | 74 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 75 | available at [http://contributor-covenant.org/version/1/4][version] 76 | 77 | [homepage]: http://contributor-covenant.org 78 | [version]: http://contributor-covenant.org/version/1/4/ 79 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 4 | - Fork, then clone the repo: 5 | ```` 6 | git clone git@github.com:your_username/ModbusMaster.git 7 | ```` 8 | 9 | - Create a topic branch from where you want to base your work 10 | - This is usually the master branch 11 | - Only target release branches if you are certain your fix must be on that branch 12 | - To quickly create a topic branch based on master; `git checkout -b fix/master/my_contribution master`. Please avoid working directly on the `master` branch. 13 | 14 | - Follow the [style guide](https://github.com/4-20ma/ModbusMaster/blob/master/STYLE.md) 15 | 16 | - Test your change 17 | 18 | ```` bash 19 | $ make 20 | ```` 21 | 22 | Project must build successfully using `make` in order for contribution to be considered. 23 | 24 | - Make commits of logical units 25 | - Check for unnecessary whitespace with `git diff --check` before committing 26 | - Each commit should represent one atomic change and should stand on its own 27 | - Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) 28 | 29 | - Push to your fork and [submit a pull request](https://github.com/4-20ma/ModbusMaster/compare/) 30 | - [Code of conduct](https://github.com/4-20ma/ModbusMaster/blob/master/CODE_OF_CONDUCT.md) 31 | 32 | ### Labels 33 | 34 | Project maintainers assign labels to Issues and Pull Requests (PRs) to categorize, prioritize, and provide status. The following guidelines and conventions are used in this project: 35 | 36 | #### Type 37 | 38 | - `Bug` - existing code does not behave as described in the project documentation; _requires_ clear test case and be _reproducible_ by project maintainer 39 | - `Enhancement` - improvement to an existing feature (Issue or Pull Request) 40 | - `Feature Requst` - new functionality; _requires_ a well-written, clear user story (Issue) 41 | - `Maintenance` - minor administrative change that does not provide enhancement or introduce new feature 42 | - `Question` - self-explanatory 43 | 44 | #### Priority 45 | 46 | - `Low` - default priority; new issues generally start here 47 | - `Medium` - issues are escalated, depending on severity of the issue 48 | - `High` - issues are escalated, depending on severity of the issue 49 | - `Critical` - these issues are to be resolved ahead of any other 50 | 51 | #### Status 52 | 53 | - `Abandoned` - issue/PR closed due to inactivity 54 | - `Blocked` - issue/PR will not be resolved/merged (some projects label these items as `wontfix`; include explanation in issue/PR) 55 | - `In Progress` - issue has been assigned and is actively being addressed; re-label issue `On Hold` with explanation if there will be a significant delay 56 | - `Maintainer Review Needed` - last step prior to merge; PR passes continuous integration tests and is able to be cleanly merged - awaiting review for style, code cleanliness, etc. 57 | - `On Hold` - implementation delayed; provide explanation in issue/PR 58 | - `Pending Contributor Response` - issue/PR closed after 14 days of inactivity (re-label `Abandoned` at closure) 59 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/Gemfile: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | # Gemfile style guide derived from: 3 | # http://mcdowall.info/posts/gemfile-best-practices-and-discourse/ 4 | 5 | # Use `bundle install` after changing this file 6 | # `bundle update [gemname]` to force update of gem 7 | # `bundle show [gemname]` to see where a bundled gem is installed 8 | # `bundle open [gemname]` to edit a bundled gem 9 | # `bundle package` to add gem to vendor/cache 10 | 11 | source 'https://rubygems.org' 12 | 13 | 14 | # place gems sourced from github.com in this section _________________________ 15 | 16 | 17 | # place gems sourced from a project path in this section _____________________ 18 | 19 | 20 | # place general project gems in this section (alphabetical order) ____________ 21 | gem 'git', '~> 1.3.0' # git management 22 | gem 'github_changelog_generator', '~> 1.13.1' 23 | gem 'rake', '~> 11.2.2' 24 | gem 'version', '~> 1.0.0' # version management gem 25 | 26 | 27 | # place gems related to test/specs in this section (alphabetical order) ______ 28 | 29 | 30 | # place gems related to development in this section (alphabetical order) _____ 31 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | addressable (2.4.0) 5 | colorize (0.8.1) 6 | descendants_tracker (0.0.4) 7 | thread_safe (~> 0.3, >= 0.3.1) 8 | faraday (0.9.2) 9 | multipart-post (>= 1.2, < 3) 10 | git (1.3.0) 11 | github_api (0.14.5) 12 | addressable (~> 2.4.0) 13 | descendants_tracker (~> 0.0.4) 14 | faraday (~> 0.8, < 0.10) 15 | hashie (>= 3.4) 16 | oauth2 (~> 1.0) 17 | github_changelog_generator (1.13.1) 18 | colorize (~> 0.7) 19 | github_api (~> 0.12) 20 | rake (>= 10.0) 21 | hashie (3.4.4) 22 | jwt (1.5.4) 23 | multi_json (1.12.1) 24 | multi_xml (0.5.5) 25 | multipart-post (2.0.0) 26 | oauth2 (1.2.0) 27 | faraday (>= 0.8, < 0.10) 28 | jwt (~> 1.0) 29 | multi_json (~> 1.3) 30 | multi_xml (~> 0.5) 31 | rack (>= 1.2, < 3) 32 | rack (2.0.1) 33 | rake (11.2.2) 34 | thread_safe (0.3.5) 35 | version (1.0.0) 36 | 37 | PLATFORMS 38 | ruby 39 | 40 | DEPENDENCIES 41 | git (~> 1.3.0) 42 | github_changelog_generator (~> 1.13.1) 43 | rake (~> 11.2.2) 44 | version (~> 1.0.0) 45 | 46 | BUNDLED WITH 47 | 1.12.1 48 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/Makefile: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- settings 2 | FIND := find 3 | DIR := examples 4 | CRITERIA := \( -name "*.ino" -o -name "*.pde" \) 5 | EACH_EXAMPLE := $(FIND) $(DIR) $(CRITERIA) -exec 6 | BUILD := platformio ci 7 | LIB := src 8 | 9 | #--------------------------------------------------------------------- targets 10 | # update .travis.yml if target boards added 11 | all: uno due huzzah genuino101 teensy31 12 | 13 | uno due huzzah genuino101 teensy31: 14 | PLATFORMIO_BOARD=$@ $(MAKE) build 15 | 16 | build: 17 | $(EACH_EXAMPLE) $(BUILD) --board=$(PLATFORMIO_BOARD) --lib=$(LIB) {} \; 18 | 19 | .PHONY: all uno due huzzah genuino101 teensy31 build 20 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/README.md: -------------------------------------------------------------------------------- 1 | # ModbusMaster 2 | [![GitHub release](https://img.shields.io/github/release/4-20ma/ModbusMaster.svg?maxAge=3600)][GitHub release] 3 | [![Travis](https://img.shields.io/travis/4-20ma/ModbusMaster.svg?maxAge=3600)][Travis] 4 | [![license](https://img.shields.io/github/license/4-20ma/ModbusMaster.svg?maxAge=3600)][license] 5 | [![code of conduct](https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-blue.svg?maxAge=3600)][code of conduct] 6 | 7 | [GitHub release]: https://github.com/4-20ma/ModbusMaster 8 | [Travis]: https://travis-ci.org/4-20ma/ModbusMaster 9 | [license]: LICENSE 10 | [code of conduct]: CODE_OF_CONDUCT.md 11 | 12 | 13 | ## Overview 14 | This is an Arduino library for communicating with Modbus slaves over RS232/485 (via RTU protocol). 15 | 16 | 17 | ## Features 18 | The following Modbus functions are available: 19 | 20 | Discrete Coils/Flags 21 | 22 | - 0x01 - Read Coils 23 | - 0x02 - Read Discrete Inputs 24 | - 0x05 - Write Single Coil 25 | - 0x0F - Write Multiple Coils 26 | 27 | Registers 28 | 29 | - 0x03 - Read Holding Registers 30 | - 0x04 - Read Input Registers 31 | - 0x06 - Write Single Register 32 | - 0x10 - Write Multiple Registers 33 | - 0x16 - Mask Write Register 34 | - 0x17 - Read Write Multiple Registers 35 | 36 | Both full-duplex and half-duplex RS232/485 transceivers are supported. Callback functions are provided to toggle Data Enable (DE) and Receiver Enable (/RE) pins. 37 | 38 | 39 | ## Installation 40 | 41 | #### Library Manager 42 | Install the library into your Arduino IDE using the Library Manager (available from IDE version 1.6.2). Open the IDE and click Sketch > Include Library > Manage Libraries… 43 | 44 | Scroll or search for `ModbusMaster`, then select the version of the library you want to install. Quit/re-launch the IDE to refresh the list; new versions are automatically added to the list, once released on GitHub. 45 | 46 | Refer to Arduino Tutorials > Libraries [Using the Library Manager](https://www.arduino.cc/en/Guide/Libraries#toc3). 47 | 48 | #### Zip Library 49 | Refer to Arduino Tutorials > Libraries [Importing a .zip Library](https://www.arduino.cc/en/Guide/Libraries#toc4). 50 | 51 | #### Manual 52 | Refer to Arduino Tutorials > Libraries [Manual Installation](https://www.arduino.cc/en/Guide/Libraries#toc5). 53 | 54 | 55 | ## Hardware 56 | This library has been tested with an Arduino [Duemilanove](http://www.arduino.cc/en/Main/ArduinoBoardDuemilanove), PHOENIX CONTACT [nanoLine](https://www.phoenixcontact.com/online/portal/us?1dmy&urile=wcm%3apath%3a/usen/web/main/products/subcategory_pages/standard_logic_modules_p-21-03-03/3329dd38-7c6a-46e1-8260-b9208235d6fe/3329dd38-7c6a-46e1-8260-b9208235d6fe) controller, connected via RS485 using a Maxim [MAX488EPA](http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1111) transceiver. 57 | 58 | 59 | ## Caveats 60 | Conforms to Arduino IDE 1.5 Library Specification v2.1 which requires Arduino IDE >= 1.5. 61 | 62 | Arduinos prior to the Mega have one serial port which must be connected to USB (FTDI) for uploading sketches and to the RS232/485 device/network for running sketches. You will need to disconnect pin 0 (RX) while uploading sketches. After a successful upload, you can reconnect pin 0. 63 | 64 | 65 | ## Support 66 | Please [submit an issue](https://github.com/4-20ma/ModbusMaster/issues) for all questions, bug reports, and feature requests. Email requests will be politely redirected to the issue tracker so others may contribute to the discussion and requestors get a more timely response. 67 | 68 | 69 | ## Example 70 | The library contains a few sketches that demonstrate use of the `ModbusMaster` library. You can find these in the [examples](https://github.com/4-20ma/ModbusMaster/tree/master/examples) folder. 71 | 72 | ``` cpp 73 | /* 74 | 75 | Basic.pde - example using ModbusMaster library 76 | 77 | Library:: ModbusMaster 78 | Author:: Doc Walker <4-20ma@wvfans.net> 79 | 80 | Copyright:: 2009-2016 Doc Walker 81 | 82 | Licensed under the Apache License, Version 2.0 (the "License"); 83 | you may not use this file except in compliance with the License. 84 | You may obtain a copy of the License at 85 | 86 | http://www.apache.org/licenses/LICENSE-2.0 87 | 88 | Unless required by applicable law or agreed to in writing, software 89 | distributed under the License is distributed on an "AS IS" BASIS, 90 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 91 | See the License for the specific language governing permissions and 92 | limitations under the License. 93 | 94 | */ 95 | 96 | #include 97 | 98 | 99 | // instantiate ModbusMaster object 100 | ModbusMaster node; 101 | 102 | 103 | void setup() 104 | { 105 | // use Serial (port 0); initialize Modbus communication baud rate 106 | Serial.begin(19200); 107 | 108 | // communicate with Modbus slave ID 2 over Serial (port 0) 109 | node.begin(2, Serial); 110 | } 111 | 112 | 113 | void loop() 114 | { 115 | static uint32_t i; 116 | uint8_t j, result; 117 | uint16_t data[6]; 118 | 119 | i++; 120 | 121 | // set word 0 of TX buffer to least-significant word of counter (bits 15..0) 122 | node.setTransmitBuffer(0, lowWord(i)); 123 | 124 | // set word 1 of TX buffer to most-significant word of counter (bits 31..16) 125 | node.setTransmitBuffer(1, highWord(i)); 126 | 127 | // slave: write TX buffer to (2) 16-bit registers starting at register 0 128 | result = node.writeMultipleRegisters(0, 2); 129 | 130 | // slave: read (6) 16-bit registers starting at register 2 to RX buffer 131 | result = node.readHoldingRegisters(2, 6); 132 | 133 | // do something with data if read is successful 134 | if (result == node.ku8MBSuccess) 135 | { 136 | for (j = 0; j < 6; j++) 137 | { 138 | data[j] = node.getResponseBuffer(j); 139 | } 140 | } 141 | } 142 | ``` 143 | 144 | _Project inspired by [Arduino Modbus Master](http://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-master)._ 145 | 146 | 147 | ## License & Authors 148 | 149 | - Author:: Doc Walker ([4-20ma@wvfans.net](mailto:4-20ma@wvfans.net)) 150 | - Author:: Ag Primatic ([agprimatic@gmail.com](mailto:agprimatic@gmail.com)) 151 | - Author:: Marius Kintel ([marius@kintel.net](mailto:marius@kintel.net)) 152 | 153 | ``` 154 | Copyright:: 2009-2016 Doc Walker 155 | 156 | Licensed under the Apache License, Version 2.0 (the "License"); 157 | you may not use this file except in compliance with the License. 158 | You may obtain a copy of the License at 159 | 160 | http://www.apache.org/licenses/LICENSE-2.0 161 | 162 | Unless required by applicable law or agreed to in writing, software 163 | distributed under the License is distributed on an "AS IS" BASIS, 164 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 165 | See the License for the specific language governing permissions and 166 | limitations under the License. 167 | ``` 168 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/Rakefile: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | # 3 | # Copyright:: 2009-2016 Doc Walker 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | require 'git' 19 | require 'github_changelog_generator/task' 20 | require 'rake' 21 | require 'rubygems' 22 | require 'rake/version_task' # gem install version 23 | require 'version' 24 | 25 | # requires additional packages on MacOS (including Homebrew): 26 | # $ /usr/bin/ruby -e "$(curl -fsSL \ 27 | # https://raw.githubusercontent.com/Homebrew/install/master/install)" 28 | # $ brew install doxygen # generates documentation from source code 29 | # $ brew cask install mactex # MacTeX 30 | 31 | Rake::VersionTask.new do |task| 32 | # prevent auto-commit on version bump 33 | task.with_git = false 34 | end 35 | 36 | # adjust as appropriate 37 | CWD = File.expand_path(File.dirname(__FILE__)) 38 | DOXYFILE = 'Doxyfile' 39 | GITHUB_USERNAME = '4-20ma' 40 | GITHUB_REPO = 'ModbusMaster' 41 | HEADER_FILE = "#{GITHUB_REPO}.h" 42 | CHANGELOG_FILE = 'CHANGELOG.md' 43 | PROPERTIES_FILE = 'library.properties' 44 | VERSION_FILE = Version.version_file('').basename.to_s 45 | 46 | 47 | task :default => :info 48 | 49 | desc 'Display instructions for public release' 50 | task :info do 51 | puts <<-EOF.gsub(/^\s{2}/, '') 52 | 53 | Instructions for public release 54 | 55 | - Update version, as appropriate: 56 | 57 | $ rake version:bump # or 58 | $ rake version:bump:minor # or 59 | $ rake version:bump:major # or 60 | edit 'VERSION' file directly 61 | 62 | - Prepare release date, 'CHANGELOG.md' file, documentation: 63 | 64 | $ rake prepare 65 | 66 | - Review changes to 'CHANGELOG.md' file 67 | This file is assembled using git commit messages; review for completeness. 68 | 69 | - Review html documentation files 70 | These files are assembled using source code Doxygen tags; review for 71 | for completeness. 72 | 73 | - Add & commit source files, tag, push to origin/master; 74 | add & commit documentation files, push to origin/gh-pages: 75 | 76 | $ rake release 77 | 78 | EOF 79 | end # task :info 80 | 81 | 82 | desc "Prepare #{CHANGELOG_FILE} for release" 83 | task :prepare => 'prepare:default' 84 | 85 | namespace :prepare do 86 | task :default => [ 87 | :release_date, 88 | :library_properties, 89 | :changelog, 90 | :documentation 91 | ] 92 | 93 | desc 'Prepare documentation' 94 | task :documentation do 95 | version = Version.current.to_s 96 | 97 | # update parameters in Doxyfile 98 | file = File.join(CWD, 'doc', DOXYFILE) 99 | 100 | contents = IO.read(file) 101 | contents.sub!(/(^PROJECT_NUMBER\s*=)(.*)$/) do |match| 102 | "#{$1} v#{version}" 103 | end # contents.sub!(...) 104 | IO.write(file, contents) 105 | 106 | # chdir to doc/ and call doxygen to update documentation 107 | Dir.chdir(to = File.join(CWD, 'doc')) 108 | system('doxygen', DOXYFILE) 109 | 110 | # chdir to doc/latex and call doxygen to update documentation 111 | Dir.chdir(from = File.join(CWD, 'doc', 'latex')) 112 | system('make') 113 | 114 | # move/rename file to 'extras/GITHUB_REPO reference-x.y.pdf' 115 | to = File.join(CWD, 'extras') 116 | FileUtils.mv(File.join(from, 'refman.pdf'), 117 | File.join(to, "#{GITHUB_REPO} reference-#{version}.pdf")) 118 | end # task :documentation 119 | 120 | desc 'Prepare release history' 121 | GitHubChangelogGenerator::RakeTask.new(:changelog) do |config| 122 | config.add_issues_wo_labels = false 123 | config.add_pr_wo_labels = false 124 | config.enhancement_labels = [ 125 | 'Type: Enhancement' 126 | ] 127 | config.bug_labels = ['Type: Bug'] 128 | config.exclude_labels = ['Type: Question'] 129 | config.header = '# ModbusMaster CHANGELOG' 130 | config.include_labels = [ 131 | 'Type: Bug', 132 | 'Type: Enhancement', 133 | 'Type: Feature Request', 134 | 'Type: Maintenance' 135 | ] 136 | # config.since_tag = '0.1.0' 137 | config.future_release = "v#{Version.current.to_s}" 138 | config.user = GITHUB_USERNAME 139 | config.project = GITHUB_REPO 140 | end # GitHubChangelogGenerator::RakeTask.new 141 | 142 | desc 'Update version in library properties file' 143 | task :library_properties do 144 | version = Version.current.to_s 145 | 146 | file = File.join(CWD, PROPERTIES_FILE) 147 | 148 | contents = IO.read(file) 149 | contents.sub!(/(version=\s*)(.*)$/) do |match| 150 | "#{$1}#{version}" 151 | end # contents.sub!(...) 152 | IO.write(file, contents) 153 | end # task :library_properties 154 | 155 | desc 'Update release date in header file' 156 | task :release_date do 157 | file = File.join(CWD, 'src', HEADER_FILE) 158 | 159 | contents = IO.read(file) 160 | contents.sub!(/(\\date\s*)(.*)$/) do |match| 161 | "#{$1}#{Time.now.strftime('%-d %b %Y')}" 162 | end # contents.sub!(...) 163 | IO.write(file, contents) 164 | end # task :release_date 165 | 166 | end # namespace :prepare 167 | 168 | 169 | desc 'Release source & documentation' 170 | task :release => 'release:default' 171 | 172 | namespace :release do 173 | task :default => [:source, :documentation] 174 | 175 | desc 'Commit documentation changes related to version bump' 176 | task :documentation do 177 | version = Version.current.to_s 178 | cwd = File.expand_path(File.join(File.dirname(__FILE__), 'doc', 'html')) 179 | g = Git.open(cwd) 180 | 181 | # `git add .` 182 | g.add 183 | 184 | # remove each deleted item 185 | g.status.deleted.each do |item| 186 | g.remove(item[0]) 187 | end # g.status.deleted.each 188 | 189 | # commit changes if items added, changed, or deleted 190 | if g.status.added.size > 0 || g.status.changed.size > 0 || 191 | g.status.deleted.size > 0 then 192 | message = "Update documentation for v#{version}" 193 | puts g.commit(message) 194 | else 195 | puts "No changes to commit v#{version}" 196 | end # if g.status.added.size > 0 || g.status.changed.size > 0... 197 | 198 | g.push('origin', 'gh-pages') 199 | end # task :documentation 200 | 201 | desc 'Commit source changes related to version bump' 202 | task :source do 203 | version = Version.current.to_s 204 | `git add \ 205 | doc/#{DOXYFILE} \ 206 | "extras/#{GITHUB_REPO} reference-#{version}.pdf" \ 207 | src/#{HEADER_FILE} \ 208 | #{CHANGELOG_FILE} \ 209 | #{PROPERTIES_FILE} \ 210 | #{VERSION_FILE} \ 211 | ` 212 | `git commit -m 'Version bump to v#{version}'` 213 | `git tag -a -f -m 'Version v#{version}' v#{version}` 214 | `git push origin master` 215 | `git push --tags` 216 | end # task :source 217 | 218 | end # namespace :release 219 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/VERSION: -------------------------------------------------------------------------------- 1 | 2.0.1 2 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/examples/Basic/Basic.pde: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Basic.pde - example using ModbusMaster library 4 | 5 | Library:: ModbusMaster 6 | Author:: Doc Walker <4-20ma@wvfans.net> 7 | 8 | Copyright:: 2009-2016 Doc Walker 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | */ 23 | 24 | #include 25 | 26 | 27 | // instantiate ModbusMaster object 28 | ModbusMaster node; 29 | 30 | 31 | void setup() 32 | { 33 | // use Serial (port 0); initialize Modbus communication baud rate 34 | Serial.begin(19200); 35 | 36 | // communicate with Modbus slave ID 2 over Serial (port 0) 37 | node.begin(2, Serial); 38 | } 39 | 40 | 41 | void loop() 42 | { 43 | static uint32_t i; 44 | uint8_t j, result; 45 | uint16_t data[6]; 46 | 47 | i++; 48 | 49 | // set word 0 of TX buffer to least-significant word of counter (bits 15..0) 50 | node.setTransmitBuffer(0, lowWord(i)); 51 | 52 | // set word 1 of TX buffer to most-significant word of counter (bits 31..16) 53 | node.setTransmitBuffer(1, highWord(i)); 54 | 55 | // slave: write TX buffer to (2) 16-bit registers starting at register 0 56 | result = node.writeMultipleRegisters(0, 2); 57 | 58 | // slave: read (6) 16-bit registers starting at register 2 to RX buffer 59 | result = node.readHoldingRegisters(2, 6); 60 | 61 | // do something with data if read is successful 62 | if (result == node.ku8MBSuccess) 63 | { 64 | for (j = 0; j < 6; j++) 65 | { 66 | data[j] = node.getResponseBuffer(j); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/examples/PhoenixContact_nanoLC/PhoenixContact_nanoLC.pde: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | PhoenixContact_nanoLC.pde - example using ModbusMaster library 4 | to communicate with PHOENIX CONTACT nanoLine controller. 5 | 6 | Library:: ModbusMaster 7 | Author:: Doc Walker <4-20ma@wvfans.net> 8 | 9 | Copyright:: 2009-2016 Doc Walker 10 | 11 | Licensed under the Apache License, Version 2.0 (the "License"); 12 | you may not use this file except in compliance with the License. 13 | You may obtain a copy of the License at 14 | 15 | http://www.apache.org/licenses/LICENSE-2.0 16 | 17 | Unless required by applicable law or agreed to in writing, software 18 | distributed under the License is distributed on an "AS IS" BASIS, 19 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | See the License for the specific language governing permissions and 21 | limitations under the License. 22 | 23 | */ 24 | 25 | #include 26 | 27 | // discrete coils 28 | #define NANO_DO(n) (0x0000 + n) ///< returns nanoLC discrete output address 29 | #define NANO_FLAG(n) (0x1000 + n) ///< returns nanoLC flag address 30 | 31 | // discrete inputs 32 | #define NANO_DI(n) (0x0000 + n) ///< returns nanoLC discrete input address 33 | 34 | // analog holding registers 35 | #define NANO_REG(n) (0x0000 + 2 * n) ///< returns nanoLC holding register address 36 | #define NANO_AO(n) (0x1000 + 2 * n) ///< returns nanoLC analog output address 37 | #define NANO_TCP(n) (0x2000 + 2 * n) ///< returns nanoLC timer/counter preset address 38 | #define NANO_OTP(n) (0x3000 + 2 * n) ///< returns nanoLC discrete output preset address 39 | #define NANO_HSP(n) (0x4000 + 2 * n) ///< returns nanoLC high-speed counter preset address 40 | #define NANO_TCA(n) (0x5000 + 2 * n) ///< returns nanoLC timer/counter accumulator address 41 | #define NANO_OTA(n) (0x6000 + 2 * n) ///< returns nanoLC discrete output accumulator address 42 | #define NANO_HSA(n) (0x7000 + 2 * n) ///< returns nanoLC high-speed counter accumulator address 43 | 44 | // analog input registers 45 | #define NANO_AI(n) (0x0000 + 2 * n) ///< returns nanoLC analog input address 46 | 47 | 48 | // instantiate ModbusMaster object 49 | ModbusMaster nanoLC; 50 | 51 | 52 | void setup() 53 | { 54 | // use Serial (port 0); initialize Modbus communication baud rate 55 | Serial.begin(19200); 56 | 57 | // communicate with Modbus slave ID 1 over Serial (port 0) 58 | nanoLC.begin(1, Serial); 59 | } 60 | 61 | 62 | void loop() 63 | { 64 | static uint32_t u32ShiftRegister; 65 | static uint32_t i; 66 | uint8_t u8Status; 67 | 68 | u32ShiftRegister = ((u32ShiftRegister < 0x01000000) ? (u32ShiftRegister << 4) : 1); 69 | if (u32ShiftRegister == 0) u32ShiftRegister = 1; 70 | i++; 71 | 72 | // set word 0 of TX buffer to least-significant word of u32ShiftRegister (bits 15..0) 73 | nanoLC.setTransmitBuffer(0, lowWord(u32ShiftRegister)); 74 | 75 | // set word 1 of TX buffer to most-significant word of u32ShiftRegister (bits 31..16) 76 | nanoLC.setTransmitBuffer(1, highWord(u32ShiftRegister)); 77 | 78 | // set word 2 of TX buffer to least-significant word of i (bits 15..0) 79 | nanoLC.setTransmitBuffer(2, lowWord(i)); 80 | 81 | // set word 3 of TX buffer to most-significant word of i (bits 31..16) 82 | nanoLC.setTransmitBuffer(3, highWord(i)); 83 | 84 | // write TX buffer to (4) 16-bit registers starting at NANO_REG(1) 85 | // read (4) 16-bit registers starting at NANO_REG(0) to RX buffer 86 | // data is available via nanoLC.getResponseBuffer(0..3) 87 | nanoLC.readWriteMultipleRegisters(NANO_REG(0), 4, NANO_REG(1), 4); 88 | 89 | // write lowWord(u32ShiftRegister) to single 16-bit register starting at NANO_REG(3) 90 | nanoLC.writeSingleRegister(NANO_REG(3), lowWord(u32ShiftRegister)); 91 | 92 | // write highWord(u32ShiftRegister) to single 16-bit register starting at NANO_REG(3) + 1 93 | nanoLC.writeSingleRegister(NANO_REG(3) + 1, highWord(u32ShiftRegister)); 94 | 95 | // set word 0 of TX buffer to nanoLC.getResponseBuffer(0) (bits 15..0) 96 | nanoLC.setTransmitBuffer(0, nanoLC.getResponseBuffer(0)); 97 | 98 | // set word 1 of TX buffer to nanoLC.getResponseBuffer(1) (bits 31..16) 99 | nanoLC.setTransmitBuffer(1, nanoLC.getResponseBuffer(1)); 100 | 101 | // write TX buffer to (2) 16-bit registers starting at NANO_REG(4) 102 | nanoLC.writeMultipleRegisters(NANO_REG(4), 2); 103 | 104 | // read 17 coils starting at NANO_FLAG(0) to RX buffer 105 | // bits 15..0 are available via nanoLC.getResponseBuffer(0) 106 | // bit 16 is available via zero-padded nanoLC.getResponseBuffer(1) 107 | nanoLC.readCoils(NANO_FLAG(0), 17); 108 | 109 | // read (66) 16-bit registers starting at NANO_REG(0) to RX buffer 110 | // generates Modbus exception ku8MBIllegalDataAddress (0x02) 111 | u8Status = nanoLC.readHoldingRegisters(NANO_REG(0), 66); 112 | if (u8Status == nanoLC.ku8MBIllegalDataAddress) 113 | { 114 | // read (64) 16-bit registers starting at NANO_REG(0) to RX buffer 115 | // data is available via nanoLC.getResponseBuffer(0..63) 116 | u8Status = nanoLC.readHoldingRegisters(NANO_REG(0), 64); 117 | } 118 | 119 | // read (8) 16-bit registers starting at NANO_AO(0) to RX buffer 120 | // data is available via nanoLC.getResponseBuffer(0..7) 121 | nanoLC.readHoldingRegisters(NANO_AO(0), 8); 122 | 123 | // read (64) 16-bit registers starting at NANO_TCP(0) to RX buffer 124 | // data is available via nanoLC.getResponseBuffer(0..63) 125 | nanoLC.readHoldingRegisters(NANO_TCP(0), 64); 126 | 127 | // read (64) 16-bit registers starting at NANO_OTP(0) to RX buffer 128 | // data is available via nanoLC.getResponseBuffer(0..63) 129 | nanoLC.readHoldingRegisters(NANO_OTP(0), 64); 130 | 131 | // read (64) 16-bit registers starting at NANO_TCA(0) to RX buffer 132 | // data is available via nanoLC.getResponseBuffer(0..63) 133 | nanoLC.readHoldingRegisters(NANO_TCA(0), 64); 134 | 135 | // read (64) 16-bit registers starting at NANO_OTA(0) to RX buffer 136 | // data is available via nanoLC.getResponseBuffer(0..63) 137 | nanoLC.readHoldingRegisters(NANO_OTA(0), 64); 138 | 139 | // read (8) 16-bit registers starting at NANO_AI(0) to RX buffer 140 | // data is available via nanoLC.getResponseBuffer(0..7) 141 | nanoLC.readInputRegisters(NANO_AI(0), 8); 142 | } 143 | 144 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/examples/RS485_HalfDuplex/RS485_HalfDuplex.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | RS485_HalfDuplex.pde - example using ModbusMaster library to communicate 4 | with EPSolar LS2024B controller using a half-duplex RS485 transceiver. 5 | 6 | This example is tested against an EPSolar LS2024B solar charge controller. 7 | See here for protocol specs: 8 | http://www.solar-elektro.cz/data/dokumenty/1733_modbus_protocol.pdf 9 | 10 | Library:: ModbusMaster 11 | Author:: Marius Kintel 12 | 13 | Copyright:: 2009-2016 Doc Walker 14 | 15 | Licensed under the Apache License, Version 2.0 (the "License"); 16 | you may not use this file except in compliance with the License. 17 | You may obtain a copy of the License at 18 | 19 | http://www.apache.org/licenses/LICENSE-2.0 20 | 21 | Unless required by applicable law or agreed to in writing, software 22 | distributed under the License is distributed on an "AS IS" BASIS, 23 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24 | See the License for the specific language governing permissions and 25 | limitations under the License. 26 | 27 | */ 28 | 29 | #include 30 | 31 | /*! 32 | We're using a MAX485-compatible RS485 Transceiver. 33 | Rx/Tx is hooked up to the hardware serial port at 'Serial'. 34 | The Data Enable and Receiver Enable pins are hooked up as follows: 35 | */ 36 | #define MAX485_DE 3 37 | #define MAX485_RE_NEG 2 38 | 39 | // instantiate ModbusMaster object 40 | ModbusMaster node; 41 | 42 | void preTransmission() 43 | { 44 | digitalWrite(MAX485_RE_NEG, 1); 45 | digitalWrite(MAX485_DE, 1); 46 | } 47 | 48 | void postTransmission() 49 | { 50 | digitalWrite(MAX485_RE_NEG, 0); 51 | digitalWrite(MAX485_DE, 0); 52 | } 53 | 54 | void setup() 55 | { 56 | pinMode(MAX485_RE_NEG, OUTPUT); 57 | pinMode(MAX485_DE, OUTPUT); 58 | // Init in receive mode 59 | digitalWrite(MAX485_RE_NEG, 0); 60 | digitalWrite(MAX485_DE, 0); 61 | 62 | // Modbus communication runs at 115200 baud 63 | Serial.begin(115200); 64 | 65 | // Modbus slave ID 1 66 | node.begin(1, Serial); 67 | // Callbacks allow us to configure the RS485 transceiver correctly 68 | node.preTransmission(preTransmission); 69 | node.postTransmission(postTransmission); 70 | } 71 | 72 | bool state = true; 73 | 74 | void loop() 75 | { 76 | uint8_t result; 77 | uint16_t data[6]; 78 | 79 | // Toggle the coil at address 0x0002 (Manual Load Control) 80 | result = node.writeSingleCoil(0x0002, state); 81 | state = !state; 82 | 83 | // Read 16 registers starting at 0x3100) 84 | result = node.readInputRegisters(0x3100, 16); 85 | if (result == node.ku8MBSuccess) 86 | { 87 | Serial.print("Vbatt: "); 88 | Serial.println(node.getResponseBuffer(0x04)/100.0f); 89 | Serial.print("Vload: "); 90 | Serial.println(node.getResponseBuffer(0xC0)/100.0f); 91 | Serial.print("Pload: "); 92 | Serial.println((node.getResponseBuffer(0x0D) + 93 | node.getResponseBuffer(0x0E) << 16)/100.0f); 94 | } 95 | 96 | delay(1000); 97 | } 98 | 99 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/extras/ModbusMaster reference-2.0.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/epever/ModbusMaster-master/extras/ModbusMaster reference-2.0.1.pdf -------------------------------------------------------------------------------- /epever/ModbusMaster-master/extras/README.txt: -------------------------------------------------------------------------------- 1 | Documentation is available at: 2 | http://4-20ma.github.com/ModbusMaster 3 | 4 | Alternatively, you can download the HTML files at: 5 | [tarball] https://github.com/4-20ma/ModbusMaster/tarball/gh-pages 6 | [zipball] https://github.com/4-20ma/ModbusMaster/zipball/gh-pages 7 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For ModbusMaster 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ModbusMaster KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | lowWord KEYWORD2 16 | highWord KEYWORD2 17 | LONG KEYWORD2 18 | 19 | begin KEYWORD2 20 | 21 | getResponseBuffer KEYWORD2 22 | clearResponseBuffer KEYWORD2 23 | setTransmitBuffer KEYWORD2 24 | clearTransmitBuffer KEYWORD2 25 | 26 | readCoils KEYWORD2 27 | readDiscreteInputs KEYWORD2 28 | readHoldingRegisters KEYWORD2 29 | readInputRegisters KEYWORD2 30 | writeSingleCoil KEYWORD2 31 | writeSingleRegister KEYWORD2 32 | writeMultipleCoils KEYWORD2 33 | writeMultipleRegisters KEYWORD2 34 | maskWriteRegister KEYWORD2 35 | readWriteMultipleRegisters KEYWORD2 36 | 37 | ####################################### 38 | # Constants (LITERAL1) 39 | ####################################### 40 | 41 | ku8MBIllegalFunction LITERAL1 42 | ku8MBIllegalDataAddress LITERAL1 43 | ku8MBIllegalDataValue LITERAL1 44 | ku8MBSlaveDeviceFailure LITERAL1 45 | 46 | ku8MBSuccess LITERAL1 47 | ku8MBInvalidSlaveID LITERAL1 48 | ku8MBInvalidFunction LITERAL1 49 | ku8MBResponseTimedOut LITERAL1 50 | ku8MBInvalidCRC LITERAL1 51 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/library.properties: -------------------------------------------------------------------------------- 1 | name=ModbusMaster 2 | version=2.0.1 3 | author=Doc Walker 4 | maintainer=Doc Walker <4-20ma@wvfans.net> 5 | sentence=Enlighten your Arduino to be a Modbus master. 6 | paragraph=Enables communication with Modbus slaves over RS232/485 (via RTU protocol). Requires an RS232/485 transceiver. 7 | category=Communication 8 | url=https://github.com/4-20ma/ModbusMaster 9 | architectures=* 10 | includes=ModbusMaster.h 11 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/src/ModbusMaster.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file 3 | Arduino library for communicating with Modbus slaves over RS232/485 (via RTU protocol). 4 | 5 | @defgroup setup ModbusMaster Object Instantiation/Initialization 6 | @defgroup buffer ModbusMaster Buffer Management 7 | @defgroup discrete Modbus Function Codes for Discrete Coils/Inputs 8 | @defgroup register Modbus Function Codes for Holding/Input Registers 9 | @defgroup constant Modbus Function Codes, Exception Codes 10 | */ 11 | /* 12 | 13 | ModbusMaster.h - Arduino library for communicating with Modbus slaves 14 | over RS232/485 (via RTU protocol). 15 | 16 | Library:: ModbusMaster 17 | 18 | Copyright:: 2009-2016 Doc Walker 19 | 20 | Licensed under the Apache License, Version 2.0 (the "License"); 21 | you may not use this file except in compliance with the License. 22 | You may obtain a copy of the License at 23 | 24 | http://www.apache.org/licenses/LICENSE-2.0 25 | 26 | Unless required by applicable law or agreed to in writing, software 27 | distributed under the License is distributed on an "AS IS" BASIS, 28 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | See the License for the specific language governing permissions and 30 | limitations under the License. 31 | 32 | */ 33 | 34 | 35 | #ifndef ModbusMaster_h 36 | #define ModbusMaster_h 37 | 38 | 39 | /** 40 | @def __MODBUSMASTER_DEBUG__ (0) 41 | Set to 1 to enable debugging features within class: 42 | - PIN A cycles for each byte read in the Modbus response 43 | - PIN B cycles for each millisecond timeout during the Modbus response 44 | */ 45 | #define __MODBUSMASTER_DEBUG__ (0) 46 | #define __MODBUSMASTER_DEBUG_PIN_A__ 4 47 | #define __MODBUSMASTER_DEBUG_PIN_B__ 5 48 | 49 | /* _____STANDARD INCLUDES____________________________________________________ */ 50 | // include types & constants of Wiring core API 51 | #include "Arduino.h" 52 | 53 | /* _____UTILITY MACROS_______________________________________________________ */ 54 | 55 | 56 | /* _____PROJECT INCLUDES_____________________________________________________ */ 57 | // functions to calculate Modbus Application Data Unit CRC 58 | #include "util/crc16.h" 59 | 60 | // functions to manipulate words 61 | #include "util/word.h" 62 | 63 | 64 | /* _____CLASS DEFINITIONS____________________________________________________ */ 65 | /** 66 | Arduino class library for communicating with Modbus slaves over 67 | RS232/485 (via RTU protocol). 68 | */ 69 | class ModbusMaster 70 | { 71 | public: 72 | ModbusMaster(); 73 | 74 | void begin(uint8_t, Stream &serial); 75 | void idle(void (*)()); 76 | void preTransmission(void (*)()); 77 | void postTransmission(void (*)()); 78 | 79 | // Modbus exception codes 80 | /** 81 | Modbus protocol illegal function exception. 82 | 83 | The function code received in the query is not an allowable action for 84 | the server (or slave). This may be because the function code is only 85 | applicable to newer devices, and was not implemented in the unit 86 | selected. It could also indicate that the server (or slave) is in the 87 | wrong state to process a request of this type, for example because it is 88 | unconfigured and is being asked to return register values. 89 | 90 | @ingroup constant 91 | */ 92 | static const uint8_t ku8MBIllegalFunction = 0x01; 93 | 94 | /** 95 | Modbus protocol illegal data address exception. 96 | 97 | The data address received in the query is not an allowable address for 98 | the server (or slave). More specifically, the combination of reference 99 | number and transfer length is invalid. For a controller with 100 100 | registers, the ADU addresses the first register as 0, and the last one 101 | as 99. If a request is submitted with a starting register address of 96 102 | and a quantity of registers of 4, then this request will successfully 103 | operate (address-wise at least) on registers 96, 97, 98, 99. If a 104 | request is submitted with a starting register address of 96 and a 105 | quantity of registers of 5, then this request will fail with Exception 106 | Code 0x02 "Illegal Data Address" since it attempts to operate on 107 | registers 96, 97, 98, 99 and 100, and there is no register with address 108 | 100. 109 | 110 | @ingroup constant 111 | */ 112 | static const uint8_t ku8MBIllegalDataAddress = 0x02; 113 | 114 | /** 115 | Modbus protocol illegal data value exception. 116 | 117 | A value contained in the query data field is not an allowable value for 118 | server (or slave). This indicates a fault in the structure of the 119 | remainder of a complex request, such as that the implied length is 120 | incorrect. It specifically does NOT mean that a data item submitted for 121 | storage in a register has a value outside the expectation of the 122 | application program, since the MODBUS protocol is unaware of the 123 | significance of any particular value of any particular register. 124 | 125 | @ingroup constant 126 | */ 127 | static const uint8_t ku8MBIllegalDataValue = 0x03; 128 | 129 | /** 130 | Modbus protocol slave device failure exception. 131 | 132 | An unrecoverable error occurred while the server (or slave) was 133 | attempting to perform the requested action. 134 | 135 | @ingroup constant 136 | */ 137 | static const uint8_t ku8MBSlaveDeviceFailure = 0x04; 138 | 139 | // Class-defined success/exception codes 140 | /** 141 | ModbusMaster success. 142 | 143 | Modbus transaction was successful; the following checks were valid: 144 | - slave ID 145 | - function code 146 | - response code 147 | - data 148 | - CRC 149 | 150 | @ingroup constant 151 | */ 152 | static const uint8_t ku8MBSuccess = 0x00; 153 | 154 | /** 155 | ModbusMaster invalid response slave ID exception. 156 | 157 | The slave ID in the response does not match that of the request. 158 | 159 | @ingroup constant 160 | */ 161 | static const uint8_t ku8MBInvalidSlaveID = 0xE0; 162 | 163 | /** 164 | ModbusMaster invalid response function exception. 165 | 166 | The function code in the response does not match that of the request. 167 | 168 | @ingroup constant 169 | */ 170 | static const uint8_t ku8MBInvalidFunction = 0xE1; 171 | 172 | /** 173 | ModbusMaster response timed out exception. 174 | 175 | The entire response was not received within the timeout period, 176 | ModbusMaster::ku8MBResponseTimeout. 177 | 178 | @ingroup constant 179 | */ 180 | static const uint8_t ku8MBResponseTimedOut = 0xE2; 181 | 182 | /** 183 | ModbusMaster invalid response CRC exception. 184 | 185 | The CRC in the response does not match the one calculated. 186 | 187 | @ingroup constant 188 | */ 189 | static const uint8_t ku8MBInvalidCRC = 0xE3; 190 | 191 | uint16_t getResponseBuffer(uint8_t); 192 | void clearResponseBuffer(); 193 | uint8_t setTransmitBuffer(uint8_t, uint16_t); 194 | void clearTransmitBuffer(); 195 | 196 | void beginTransmission(uint16_t); 197 | uint8_t requestFrom(uint16_t, uint16_t); 198 | void sendBit(bool); 199 | void send(uint8_t); 200 | void send(uint16_t); 201 | void send(uint32_t); 202 | uint8_t available(void); 203 | uint16_t receive(void); 204 | 205 | 206 | uint8_t readCoils(uint16_t, uint16_t); 207 | uint8_t readDiscreteInputs(uint16_t, uint16_t); 208 | uint8_t readHoldingRegisters(uint16_t, uint16_t); 209 | uint8_t readInputRegisters(uint16_t, uint8_t); 210 | uint8_t writeSingleCoil(uint16_t, uint8_t); 211 | uint8_t writeSingleRegister(uint16_t, uint16_t); 212 | uint8_t writeMultipleCoils(uint16_t, uint16_t); 213 | uint8_t writeMultipleCoils(); 214 | uint8_t writeMultipleRegisters(uint16_t, uint16_t); 215 | uint8_t writeMultipleRegisters(); 216 | uint8_t maskWriteRegister(uint16_t, uint16_t, uint16_t); 217 | uint8_t readWriteMultipleRegisters(uint16_t, uint16_t, uint16_t, uint16_t); 218 | uint8_t readWriteMultipleRegisters(uint16_t, uint16_t); 219 | 220 | private: 221 | Stream* _serial; ///< reference to serial port object 222 | uint8_t _u8MBSlave; ///< Modbus slave (1..255) initialized in begin() 223 | static const uint8_t ku8MaxBufferSize = 64; ///< size of response/transmit buffers 224 | uint16_t _u16ReadAddress; ///< slave register from which to read 225 | uint16_t _u16ReadQty; ///< quantity of words to read 226 | uint16_t _u16ResponseBuffer[ku8MaxBufferSize]; ///< buffer to store Modbus slave response; read via GetResponseBuffer() 227 | uint16_t _u16WriteAddress; ///< slave register to which to write 228 | uint16_t _u16WriteQty; ///< quantity of words to write 229 | uint16_t _u16TransmitBuffer[ku8MaxBufferSize]; ///< buffer containing data to transmit to Modbus slave; set via SetTransmitBuffer() 230 | uint16_t* txBuffer; // from Wire.h -- need to clean this up Rx 231 | uint8_t _u8TransmitBufferIndex; 232 | uint16_t u16TransmitBufferLength; 233 | uint16_t* rxBuffer; // from Wire.h -- need to clean this up Rx 234 | uint8_t _u8ResponseBufferIndex; 235 | uint8_t _u8ResponseBufferLength; 236 | 237 | // Modbus function codes for bit access 238 | static const uint8_t ku8MBReadCoils = 0x01; ///< Modbus function 0x01 Read Coils 239 | static const uint8_t ku8MBReadDiscreteInputs = 0x02; ///< Modbus function 0x02 Read Discrete Inputs 240 | static const uint8_t ku8MBWriteSingleCoil = 0x05; ///< Modbus function 0x05 Write Single Coil 241 | static const uint8_t ku8MBWriteMultipleCoils = 0x0F; ///< Modbus function 0x0F Write Multiple Coils 242 | 243 | // Modbus function codes for 16 bit access 244 | static const uint8_t ku8MBReadHoldingRegisters = 0x03; ///< Modbus function 0x03 Read Holding Registers 245 | static const uint8_t ku8MBReadInputRegisters = 0x04; ///< Modbus function 0x04 Read Input Registers 246 | static const uint8_t ku8MBWriteSingleRegister = 0x06; ///< Modbus function 0x06 Write Single Register 247 | static const uint8_t ku8MBWriteMultipleRegisters = 0x10; ///< Modbus function 0x10 Write Multiple Registers 248 | static const uint8_t ku8MBMaskWriteRegister = 0x16; ///< Modbus function 0x16 Mask Write Register 249 | static const uint8_t ku8MBReadWriteMultipleRegisters = 0x17; ///< Modbus function 0x17 Read Write Multiple Registers 250 | 251 | // Modbus timeout [milliseconds] 252 | static const uint16_t ku16MBResponseTimeout = 2000; ///< Modbus timeout [milliseconds] 253 | 254 | // master function that conducts Modbus transactions 255 | uint8_t ModbusMasterTransaction(uint8_t u8MBFunction); 256 | 257 | // idle callback function; gets called during idle time between TX and RX 258 | void (*_idle)(); 259 | // preTransmission callback function; gets called before writing a Modbus message 260 | void (*_preTransmission)(); 261 | // postTransmission callback function; gets called after a Modbus message has been sent 262 | void (*_postTransmission)(); 263 | }; 264 | #endif 265 | 266 | /** 267 | @example examples/Basic/Basic.pde 268 | @example examples/PhoenixContact_nanoLC/PhoenixContact_nanoLC.pde 269 | @example examples/RS485_HalfDuplex/RS485_HalfDuplex.ino 270 | */ 271 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/src/util/crc16.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file 3 | CRC Computations 4 | 5 | @defgroup util_crc16 "util/crc16.h": CRC Computations 6 | @code#include "util/crc16.h"@endcode 7 | 8 | This header file provides functions for calculating 9 | cyclic redundancy checks (CRC) using common polynomials. 10 | Modified by Doc Walker to be processor-independent (removed inline 11 | assembler to allow it to compile on SAM3X8E processors). 12 | 13 | @par References: 14 | Jack Crenshaw's "Implementing CRCs" article in the January 1992 issue of @e 15 | Embedded @e Systems @e Programming. This may be difficult to find, but it 16 | explains CRC's in very clear and concise terms. Well worth the effort to 17 | obtain a copy. 18 | 19 | */ 20 | /* Copyright (c) 2002, 2003, 2004 Marek Michalkiewicz 21 | Copyright (c) 2005, 2007 Joerg Wunsch 22 | Copyright (c) 2013 Dave Hylands 23 | Copyright (c) 2013 Frederic Nadeau 24 | Copyright (c) 2015 Doc Walker 25 | All rights reserved. 26 | 27 | Redistribution and use in source and binary forms, with or without 28 | modification, are permitted provided that the following conditions are met: 29 | 30 | * Redistributions of source code must retain the above copyright 31 | notice, this list of conditions and the following disclaimer. 32 | 33 | * Redistributions in binary form must reproduce the above copyright 34 | notice, this list of conditions and the following disclaimer in 35 | the documentation and/or other materials provided with the 36 | distribution. 37 | 38 | * Neither the name of the copyright holders nor the names of 39 | contributors may be used to endorse or promote products derived 40 | from this software without specific prior written permission. 41 | 42 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 43 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 44 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 45 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 46 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 47 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 48 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 49 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 50 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 51 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 52 | POSSIBILITY OF SUCH DAMAGE. */ 53 | 54 | 55 | #ifndef _UTIL_CRC16_H_ 56 | #define _UTIL_CRC16_H_ 57 | 58 | 59 | /** @ingroup util_crc16 60 | Processor-independent CRC-16 calculation. 61 | 62 | Polynomial: x^16 + x^15 + x^2 + 1 (0xA001)
63 | Initial value: 0xFFFF 64 | 65 | This CRC is normally used in disk-drive controllers. 66 | 67 | @param uint16_t crc (0x0000..0xFFFF) 68 | @param uint8_t a (0x00..0xFF) 69 | @return calculated CRC (0x0000..0xFFFF) 70 | */ 71 | static uint16_t crc16_update(uint16_t crc, uint8_t a) 72 | { 73 | int i; 74 | 75 | crc ^= a; 76 | for (i = 0; i < 8; ++i) 77 | { 78 | if (crc & 1) 79 | crc = (crc >> 1) ^ 0xA001; 80 | else 81 | crc = (crc >> 1); 82 | } 83 | 84 | return crc; 85 | } 86 | 87 | 88 | #endif /* _UTIL_CRC16_H_ */ 89 | -------------------------------------------------------------------------------- /epever/ModbusMaster-master/src/util/word.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file 3 | Utility Functions for Manipulating Words 4 | 5 | @defgroup util_word "util/word.h": Utility Functions for Manipulating Words 6 | @code#include "util/word.h"@endcode 7 | 8 | This header file provides utility functions for manipulating words. 9 | 10 | */ 11 | /* 12 | 13 | word.h - Utility Functions for Manipulating Words 14 | 15 | This file is part of ModbusMaster. 16 | 17 | ModbusMaster is free software: you can redistribute it and/or modify 18 | it under the terms of the GNU General Public License as published by 19 | the Free Software Foundation, either version 3 of the License, or 20 | (at your option) any later version. 21 | 22 | ModbusMaster is distributed in the hope that it will be useful, 23 | but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 | GNU General Public License for more details. 26 | 27 | You should have received a copy of the GNU General Public License 28 | along with ModbusMaster. If not, see . 29 | 30 | Written by Doc Walker (Rx) 31 | Copyright © 2009-2015 Doc Walker <4-20ma at wvfans dot net> 32 | 33 | */ 34 | 35 | 36 | #ifndef _UTIL_WORD_H_ 37 | #define _UTIL_WORD_H_ 38 | 39 | 40 | /** @ingroup util_word 41 | Return low word of a 32-bit integer. 42 | 43 | @param uint32_t ww (0x00000000..0xFFFFFFFF) 44 | @return low word of input (0x0000..0xFFFF) 45 | */ 46 | static inline uint16_t lowWord(uint32_t ww) 47 | { 48 | return (uint16_t) ((ww) & 0xFFFF); 49 | } 50 | 51 | 52 | /** @ingroup util_word 53 | Return high word of a 32-bit integer. 54 | 55 | @param uint32_t ww (0x00000000..0xFFFFFFFF) 56 | @return high word of input (0x0000..0xFFFF) 57 | */ 58 | static inline uint16_t highWord(uint32_t ww) 59 | { 60 | return (uint16_t) ((ww) >> 16); 61 | } 62 | 63 | 64 | #endif /* _UTIL_WORD_H_ */ 65 | -------------------------------------------------------------------------------- /epever/Screenshot (18).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/epever/Screenshot (18).png -------------------------------------------------------------------------------- /epever/no_blynk_serial_2/no_blynk_serial_2.ino: -------------------------------------------------------------------------------- 1 | // CONNECT THE RS485 MODULE. 2 | // MAX485 module <-> ESP8266 3 | // - DI -> D10 / GPIO1 / TX 4 | // - RO -> D9 / GPIO3 / RX 5 | // - DE and RE are interconnected with a jumper and then connected do eighter pin D1 or D2 6 | // - VCC to +5V / VIN on ESP8266 7 | // - GNDs wired together 8 | // ------------------------------------- 9 | // You do not need to disconnect the RS485 while uploading code. 10 | // After first upload you should be able to upload over WiFi 11 | // Tested on NodeMCU + MAX485 module 12 | // RJ 45 cable: Green -> A, Blue -> B, Brown -> GND module + GND ESP8266 13 | // MAX485: DE + RE interconnected with a jumper and connected to D1 or D2 14 | // 15 | // Developed by @jaminNZx 16 | // With modifications by @tekk 17 | 18 | #include 19 | 20 | #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0])) 21 | 22 | const int defaultBaudRate = 115200; 23 | int timerTask1, timerTask2, timerTask3; 24 | float battChargeCurrent, battDischargeCurrent, battOverallCurrent, battChargePower; 25 | float bvoltage, ctemp, btemp, bremaining, lpower, lcurrent, pvvoltage, pvcurrent, pvpower; 26 | float stats_today_pv_volt_min, stats_today_pv_volt_max; 27 | uint8_t result; 28 | bool rs485DataReceived = true; 29 | bool loadPoweredOn = true; 30 | 31 | 32 | ModbusMaster node; 33 | 34 | void preTransmission() { 35 | } 36 | 37 | void postTransmission() { 38 | } 39 | 40 | // A list of the regisities to query in order 41 | typedef void (*RegistryList[])(); 42 | 43 | RegistryList Registries = { 44 | AddressRegistry_3100, 45 | AddressRegistry_3106, 46 | AddressRegistry_310D, 47 | AddressRegistry_311A, 48 | AddressRegistry_331B, 49 | }; 50 | 51 | // keep log of where we are 52 | uint8_t currentRegistryNumber = 0; 53 | 54 | // function to switch to next registry 55 | void nextRegistryNumber() { 56 | // better not use modulo, because after overlow it will start reading in incorrect order 57 | currentRegistryNumber++; 58 | if (currentRegistryNumber >= ARRAY_SIZE(Registries)) { 59 | currentRegistryNumber = 0; 60 | } 61 | } 62 | 63 | // **************************************************************************** 64 | 65 | // -------------------------------------------------------------------------------- 66 | 67 | 68 | // exec a function of registry read (cycles between different addresses) 69 | void executeCurrentRegistryFunction() { 70 | Registries[currentRegistryNumber](); 71 | } 72 | 73 | uint8_t setOutputLoadPower(uint8_t state) { 74 | Serial.print("Writing coil 0x0006 value to: "); 75 | Serial.println(state); 76 | 77 | delay(10); 78 | // Set coil at address 0x0006 (Force the load on/off) 79 | result = node.writeSingleCoil(0x0006, state); 80 | 81 | if (result == node.ku8MBSuccess) { 82 | node.getResponseBuffer(0x00); 83 | Serial.println("Success."); 84 | } 85 | 86 | return result; 87 | } 88 | 89 | // callback to on/off button state changes from the Blynk app 90 | 91 | 92 | uint8_t readOutputLoadState() { 93 | delay(10); 94 | result = node.readHoldingRegisters(0x903D, 1); 95 | 96 | if (result == node.ku8MBSuccess) { 97 | loadPoweredOn = (node.getResponseBuffer(0x00) & 0x02) > 0; 98 | 99 | Serial.print("Set success. Load: "); 100 | Serial.println(loadPoweredOn); 101 | } else { 102 | // update of status failed 103 | Serial.println("readHoldingRegisters(0x903D, 1) failed!"); 104 | } 105 | return result; 106 | } 107 | 108 | // reads Load Enable Override coil 109 | uint8_t checkLoadCoilState() { 110 | Serial.print("Reading coil 0x0006... "); 111 | 112 | delay(10); 113 | result = node.readCoils(0x0006, 1); 114 | 115 | Serial.print("Result: "); 116 | Serial.println(result); 117 | 118 | if (result == node.ku8MBSuccess) { 119 | loadPoweredOn = (node.getResponseBuffer(0x00) > 0); 120 | 121 | Serial.print(" Value: "); 122 | Serial.println(loadPoweredOn); 123 | } else { 124 | Serial.println("Failed to read coil 0x0006!"); 125 | } 126 | 127 | return result; 128 | } 129 | 130 | // ----------------------------------------------------------------- 131 | 132 | void AddressRegistry_3100() { 133 | result = node.readInputRegisters(0x3100, 6); 134 | 135 | if (result == node.ku8MBSuccess) { 136 | 137 | pvvoltage = node.getResponseBuffer(0x00) / 100.0f; 138 | Serial.print("PV Voltage: "); 139 | Serial.println(pvvoltage); 140 | 141 | pvcurrent = node.getResponseBuffer(0x01) / 100.0f; 142 | Serial.print("PV Current: "); 143 | Serial.println(pvcurrent); 144 | 145 | pvpower = (node.getResponseBuffer(0x02) | node.getResponseBuffer(0x03) << 16) / 100.0f; 146 | Serial.print("PV Power: "); 147 | Serial.println(pvpower); 148 | 149 | bvoltage = node.getResponseBuffer(0x04) / 100.0f; 150 | Serial.print("Battery Voltage: "); 151 | Serial.println(bvoltage); 152 | 153 | battChargeCurrent = node.getResponseBuffer(0x05) / 100.0f; 154 | Serial.print("Battery Charge Current: "); 155 | Serial.println(battChargeCurrent); 156 | } 157 | } 158 | 159 | void AddressRegistry_3106() 160 | { 161 | result = node.readInputRegisters(0x3106, 2); 162 | 163 | if (result == node.ku8MBSuccess) { 164 | battChargePower = (node.getResponseBuffer(0x00) | node.getResponseBuffer(0x01) << 16) / 100.0f; 165 | Serial.print("Battery Charge Power: "); 166 | Serial.println(battChargePower); 167 | } 168 | } 169 | 170 | void AddressRegistry_310D() 171 | { 172 | result = node.readInputRegisters(0x310D, 3); 173 | 174 | if (result == node.ku8MBSuccess) { 175 | lcurrent = node.getResponseBuffer(0x00) / 100.0f; 176 | Serial.print("Load Current: "); 177 | Serial.println(lcurrent); 178 | 179 | lpower = (node.getResponseBuffer(0x01) | node.getResponseBuffer(0x02) << 16) / 100.0f; 180 | Serial.print("Load Power: "); 181 | Serial.println(lpower); 182 | } else { 183 | rs485DataReceived = false; 184 | Serial.println("Read register 0x310D failed!"); 185 | } 186 | } 187 | 188 | void AddressRegistry_311A() { 189 | result = node.readInputRegisters(0x311A, 2); 190 | 191 | if (result == node.ku8MBSuccess) { 192 | bremaining = node.getResponseBuffer(0x00) / 1.0f; 193 | Serial.print("Battery Remaining %: "); 194 | Serial.println(bremaining); 195 | 196 | btemp = node.getResponseBuffer(0x01) / 100.0f; 197 | Serial.print("Battery Temperature: "); 198 | Serial.println(btemp); 199 | } else { 200 | rs485DataReceived = false; 201 | Serial.println("Read register 0x311A failed!"); 202 | } 203 | } 204 | 205 | void AddressRegistry_331B() { 206 | result = node.readInputRegisters(0x331B, 2); 207 | 208 | if (result == node.ku8MBSuccess) { 209 | battOverallCurrent = (node.getResponseBuffer(0x00) | node.getResponseBuffer(0x01) << 16) / 100.0f; 210 | Serial.print("Battery Discharge Current: "); 211 | Serial.println(battOverallCurrent); 212 | } else { 213 | rs485DataReceived = false; 214 | Serial.println("Read register 0x331B failed!"); 215 | } 216 | } 217 | 218 | 219 | #define p_ledtick LED_BUILTIN 220 | int ledState = LOW; 221 | unsigned long previousMillis = 0; 222 | 223 | #define RXD2 16 224 | #define TXD2 17 225 | 226 | void setup() 227 | { 228 | Serial.begin(defaultBaudRate); 229 | Serial2.begin(defaultBaudRate); 230 | 231 | // Modbus slave ID 1 232 | node.begin(1, Serial2); 233 | 234 | // callbacks to toggle DE + RE on MAX485 235 | node.preTransmission(preTransmission); 236 | node.postTransmission(postTransmission); 237 | 238 | 239 | pinMode(p_ledtick, OUTPUT); 240 | 241 | 242 | Serial.println("Setup OK!"); 243 | Serial.println("----------------------------"); 244 | Serial.println(); 245 | } 246 | 247 | void loop() 248 | { 249 | unsigned long currentMillis = millis(); 250 | const long interval = 5000; 251 | if (currentMillis - previousMillis >= interval) 252 | { 253 | previousMillis = currentMillis; 254 | 255 | if (ledState == LOW) 256 | { 257 | ledState = HIGH; 258 | } else { 259 | ledState = LOW; 260 | } 261 | 262 | digitalWrite(p_ledtick, ledState); 263 | 264 | executeCurrentRegistryFunction(); 265 | nextRegistryNumber(); 266 | } 267 | } 268 | -------------------------------------------------------------------------------- /esp32_firebase/firebase_legacy.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/esp32_firebase/firebase_legacy.zip -------------------------------------------------------------------------------- /esp32_ps3/esp32-ps3-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/esp32_ps3/esp32-ps3-master.zip -------------------------------------------------------------------------------- /esp32_ps3/esp32_ps3/esp32_ps3.ino: -------------------------------------------------------------------------------- 1 | #define pBuzzer 15 2 | #define pLedKonek 2 3 | #define pBatLow 4 4 | int flagBuzzer = 0; 5 | 6 | 7 | #define pMaju 33 8 | #define pMundur 25 9 | #define pKanan 26 10 | #define pKiri 27 11 | 12 | int flagMaju = 0; 13 | int flagMundur = 0; 14 | int flagKanan = 0; 15 | int flagKiri = 0; 16 | 17 | 18 | #include 19 | 20 | int player = 0; 21 | int battery = 0; 22 | 23 | void notify() 24 | { 25 | //--- Digital cross/square/triangle/circle button events --- 26 | if ( Ps3.event.button_down.cross ) 27 | { 28 | flagMaju = 1; 29 | Serial.println("Started pressing the cross button"); 30 | } 31 | if ( Ps3.event.button_up.cross ) 32 | { 33 | flagMaju = 0; 34 | Serial.println("Released the cross button"); 35 | } 36 | 37 | if ( Ps3.event.button_down.square ) 38 | { 39 | if (flagBuzzer == 0) 40 | flagBuzzer = 1; 41 | else 42 | flagBuzzer = 0; 43 | Serial.println("Started pressing the square button"); 44 | } 45 | if ( Ps3.event.button_up.square ) 46 | { 47 | Serial.println("Released the square button"); 48 | } 49 | 50 | //--------------- Digital D-pad button events -------------- 51 | 52 | 53 | if ( Ps3.event.button_down.right ) 54 | { 55 | flagKanan = 1; 56 | Serial.println("Started pressing the right button"); 57 | } 58 | if ( Ps3.event.button_up.right ) 59 | { 60 | flagKanan = 0; 61 | Serial.println("Released the right button"); 62 | } 63 | 64 | if ( Ps3.event.button_down.down ) 65 | { 66 | flagMundur = 1; 67 | Serial.println("Started pressing the down button"); 68 | } 69 | if ( Ps3.event.button_up.down ) 70 | { 71 | flagMundur = 0; 72 | Serial.println("Released the down button"); 73 | } 74 | 75 | if ( Ps3.event.button_down.left ) 76 | { 77 | flagKiri = 1; 78 | Serial.println("Started pressing the left button"); 79 | } 80 | if ( Ps3.event.button_up.left ) 81 | { 82 | flagKiri = 0; 83 | Serial.println("Released the left button"); 84 | } 85 | 86 | 87 | 88 | 89 | 90 | //---------------------- Battery events --------------------- 91 | if ( battery != Ps3.data.status.battery ) { 92 | battery = Ps3.data.status.battery; 93 | Serial.print("The controller battery is "); 94 | if ( battery == ps3_status_battery_charging ) Serial.println("charging"); 95 | else if ( battery == ps3_status_battery_full ) Serial.println("FULL"); 96 | else if ( battery == ps3_status_battery_high ) 97 | { 98 | Serial.println("HIGH"); 99 | digitalWrite(pBatLow, HIGH); 100 | } 101 | else if ( battery == ps3_status_battery_low) 102 | { 103 | Serial.println("LOW"); 104 | digitalWrite(pBatLow, LOW); 105 | } 106 | else if ( battery == ps3_status_battery_dying ) Serial.println("DYING"); 107 | else if ( battery == ps3_status_battery_shutdown ) Serial.println("SHUTDOWN"); 108 | else Serial.println("UNDEFINED"); 109 | } 110 | 111 | 112 | 113 | } 114 | 115 | void onConnect() { 116 | Serial.println("Connected."); 117 | digitalWrite(pLedKonek, HIGH); 118 | } 119 | 120 | void setup() 121 | { 122 | 123 | pinMode(pBuzzer, OUTPUT); 124 | pinMode(pLedKonek, OUTPUT); 125 | pinMode(pBatLow, OUTPUT); 126 | 127 | pinMode(pMaju, OUTPUT); 128 | pinMode(pMundur, OUTPUT); 129 | pinMode(pKanan, OUTPUT); 130 | pinMode(pKiri, OUTPUT); 131 | 132 | 133 | Serial.begin(115200); 134 | 135 | Ps3.attach(notify); 136 | Ps3.attachOnConnect(onConnect); 137 | Ps3.begin("01:02:03:04:05:06"); 138 | 139 | Serial.println("Ready."); 140 | } 141 | 142 | void loop() 143 | { 144 | if (!Ps3.isConnected()) 145 | { 146 | digitalWrite(pLedKonek, LOW); 147 | return; 148 | } 149 | 150 | digitalWrite(pBuzzer, flagBuzzer); 151 | digitalWrite(pMaju, flagMaju); 152 | digitalWrite(pMundur, flagMundur); 153 | digitalWrite(pKanan, flagKanan); 154 | digitalWrite(pKiri, flagKiri); 155 | 156 | } 157 | -------------------------------------------------------------------------------- /esp32bt/bt2legacyv2/bt2legacyv2.ino: -------------------------------------------------------------------------------- 1 | #define pOut1 LED_BUILTIN 2 | #define NYALA HIGH 3 | 4 | #include "BluetoothSerial.h" 5 | #if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) 6 | #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it 7 | #endif 8 | BluetoothSerial SerialBT; 9 | 10 | void setup() { 11 | Serial.begin(115200); 12 | SerialBT.begin("ESP32test"); //Bluetooth device name 13 | Serial.println("The device started, now you can pair it with bluetooth!"); 14 | 15 | pinMode(pOut1, OUTPUT); 16 | digitalWrite(pOut1, !NYALA); 17 | } 18 | 19 | String inputString = ""; 20 | int dataInt; 21 | bool stringComplete = false; 22 | 23 | 24 | void loop() { 25 | serialComplete(); //Aktifasi Relay 26 | serialCek(); //Cek data Bluetooth 27 | } 28 | 29 | void serialComplete() { 30 | if (stringComplete) { 31 | dataInt = inputString.toInt(); 32 | inputString = ""; 33 | stringComplete = false; 34 | 35 | 36 | //RELAY 37 | Serial.println(dataInt); 38 | if (dataInt == 1) 39 | digitalWrite(pOut1, NYALA); 40 | else if(dataInt==2) 41 | digitalWrite(pOut1, !NYALA); 42 | 43 | 44 | } 45 | } 46 | void serialCek() { 47 | while (SerialBT.available()) { 48 | char inChar = SerialBT.read(); 49 | if (inChar == '\n') 50 | stringComplete = true; 51 | else 52 | inputString += inChar; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /esp32bt/btblev2/btblev2.ino: -------------------------------------------------------------------------------- 1 | #define pOut1 LED_BUILTIN 2 | #define NYALA HIGH 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | 11 | BLECharacteristic *pCharacteristic; 12 | bool deviceConnected = false; 13 | uint8_t txValue = 0, state = 0; 14 | String inputString; 15 | int dataInt; 16 | bool stringComplete = false; 17 | 18 | // See the following for generating UUIDs: 19 | // https://www.uuidgenerator.net/ 20 | 21 | #define SERVICE_UUID "6E400001-B5A3-F393-E0A9-E50E24DCCA9E" // UART service UUID 22 | #define CHARACTERISTIC_UUID_RX "6E400002-B5A3-F393-E0A9-E50E24DCCA9E" 23 | #define CHARACTERISTIC_UUID_TX "6E400003-B5A3-F393-E0A9-E50E24DCCA9E" 24 | 25 | class MyServerCallbacks: public BLEServerCallbacks { 26 | void onConnect(BLEServer* pServer) { 27 | deviceConnected = true; 28 | }; 29 | 30 | void onDisconnect(BLEServer* pServer) { 31 | deviceConnected = false; 32 | } 33 | }; 34 | 35 | class MyCallbacks: public BLECharacteristicCallbacks { 36 | void onWrite(BLECharacteristic *pCharacteristic) { 37 | std::string rxValue = pCharacteristic->getValue(); 38 | 39 | inputString = rxValue.c_str(); // Convert to standard c string format 40 | //Serial.println(inputString); 41 | stringComplete = true; 42 | } 43 | }; 44 | 45 | void setup() { 46 | Serial.begin(115200); 47 | pinMode(pOut1, OUTPUT); 48 | digitalWrite(pOut1, !NYALA); 49 | 50 | // Create the BLE Device 51 | BLEDevice::init("ESP32 BLE"); 52 | 53 | // Create the BLE Server 54 | BLEServer *pServer = BLEDevice::createServer(); 55 | pServer->setCallbacks(new MyServerCallbacks()); 56 | 57 | // Create the BLE Service 58 | BLEService *pService = pServer->createService(SERVICE_UUID); 59 | 60 | // Create a BLE Characteristic 61 | pCharacteristic = pService->createCharacteristic( 62 | CHARACTERISTIC_UUID_TX, 63 | BLECharacteristic::PROPERTY_NOTIFY 64 | ); 65 | 66 | pCharacteristic->addDescriptor(new BLE2902()); 67 | 68 | BLECharacteristic *pCharacteristic = pService->createCharacteristic( 69 | CHARACTERISTIC_UUID_RX, 70 | BLECharacteristic::PROPERTY_WRITE 71 | ); 72 | 73 | pCharacteristic->setCallbacks(new MyCallbacks()); 74 | 75 | // Start the service 76 | pService->start(); 77 | 78 | // Start advertising 79 | pServer->getAdvertising()->start(); 80 | Serial.println("Waiting a client connection to notify..."); 81 | } 82 | 83 | void loop() { 84 | if (deviceConnected) { 85 | serialComplete(); 86 | } 87 | } 88 | 89 | void serialComplete() { 90 | if (stringComplete) { 91 | dataInt = inputString.toInt(); 92 | inputString = ""; 93 | stringComplete = false; 94 | 95 | 96 | //RELAY 97 | Serial.println(dataInt); 98 | if (dataInt == 1) 99 | digitalWrite(pOut1, NYALA); 100 | else if (dataInt == 2) 101 | digitalWrite(pOut1, !NYALA); 102 | 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /floatsprintf/floatsprintf.ino: -------------------------------------------------------------------------------- 1 | /* 2 | dtostrf(a, b, c, d); 3 | a = float variable 4 | b = This is the length of the string that will be created 5 | c = The number of digits after the deimal point to print 6 | d = the array to store the results 7 | */ 8 | void setup() 9 | { 10 | Serial.begin(115200); 11 | } 12 | 13 | double d = 111.1111; 14 | float f = 222.2222; 15 | char str_i[10]; //depend on your float lenght character 16 | char data[50]; 17 | 18 | void loop() 19 | { 20 | //-------------------------------------------- 21 | sprintf(data, "Can't display %f", f); //not working on arduino IDE 22 | Serial.println(data); 23 | 24 | //-------------------------------------------- DOUBLE 10 character and 6 digit after decimal point 25 | dtostrf(f, 10, 6, str_i ); 26 | sprintf(data, "Can display %s", str_i); 27 | Serial.println(data); 28 | 29 | //-------------------------------------------- FLOAT 10 character and 2 digit after decimal point 30 | dtostrf(f, 10, 2, str_i ); 31 | sprintf(data, "Can display %s", str_i); 32 | Serial.println(data); 33 | 34 | //-------------------------------------------- FLOAT 2 digit after decimal point 35 | dtostrf(f, 3, 2, str_i ); 36 | sprintf(data, "Can display %s", str_i); 37 | Serial.println(data); 38 | 39 | //-------------------------------------------- DOUBLE 2 digit after decimal point 40 | dtostrf(d, 3, 2, str_i ); 41 | sprintf(data, "Can display %s", str_i); 42 | Serial.println(data); 43 | 44 | while (2); //loop forever 45 | 46 | } 47 | -------------------------------------------------------------------------------- /gps10zubx/Presentation1.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/gps10zubx/Presentation1.pptx -------------------------------------------------------------------------------- /gps10zubx/RANGKUMAN protocol UBX.txt: -------------------------------------------------------------------------------- 1 | https://content.u-blox.com/sites/default/files/products/documents/u-blox8-M8_ReceiverDescrProtSpec_UBX-13003221.pdf 2 | 3 | payloadSize = (int)sizeof(NAV_POSLLH) 4 | (int)sizeof(NAV_POSLLH) => 32 5 | 6 | packet NAV-POL-LLH size 36 7 | header 2 8 | class 1 9 | id 1 10 | payload 28 11 | checksum A 2 12 | checksum B 2 13 | 14 | B5 62 01 02 1C 00 CC 25 D9 20 5C D8 AE 42 7E 4A => 16 15 | 29 FB 92 EC 01 00 02 C0 01 00 13 1E 00 00 1D 44 => 16 16 | 00 00 ED 5E 17 | 18 | B5 62 => Header 19 | 01 => Class 20 | 02 => ID 21 | 22 | payload = 28 23 | 24 | 1C 00 CC 25 => iTOW 25 | D9 20 5C D8 => lon 26 | AE 42 7E 4A => lat 27 | 29 FB 92 EC => height 28 | 01 00 02 C0 => hMSL 29 | 01 00 13 1E => hAcc 30 | 00 00 1D 44 => vAcc 31 | 32 | 00 00 ED 5E => CK_A CK_B 33 | 34 | 35 | 36 | B5 62 01 02 1C 00 34 49 DA 20 E8 D7 AE 42 B1 4B => 16 37 | 29 FB E1 E3 01 00 51 B7 01 00 03 18 00 00 88 2C => 16 38 | 00 00 02 30 39 | 40 | 41 | //---------------------------------------------------------- 42 | 43 | packet NAV-PVT size 100 44 | header 2 45 | class 1 46 | id 1 47 | payload 92 48 | checksum A 2 49 | checksum B 2 50 | 51 | B5 62 01 07 5C 00 2C 17 A5 21 E6 07 04 1E 0C 2F 52 | 1D 37 07 00 00 00 AF 09 CB 1D 03 01 0A 0C FA D5 53 | AE 42 18 48 29 FB 5A B8 01 00 CB 8B 01 00 50 07 54 | 00 00 C1 0D 00 00 C7 FF FF FF F5 FF FF FF D4 FF 55 | FF FF 3A 00 00 00 25 BB 9D 01 FA 00 00 00 BC 18 56 | 5D 00 A4 00 00 00 F8 4A 23 00 00 00 00 00 00 00 57 | 00 00 11 32 -------------------------------------------------------------------------------- /gps10zubx/UBX10Z.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/gps10zubx/UBX10Z.zip -------------------------------------------------------------------------------- /gps10zubx/u-blox8-M8_ReceiverDescrProtSpec_UBX-13003221.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/gps10zubx/u-blox8-M8_ReceiverDescrProtSpec_UBX-13003221.pdf -------------------------------------------------------------------------------- /konten_us_SMA/konten_us.ino: -------------------------------------------------------------------------------- 1 | #define p_trigPin_cadangan 15 2 | #define p_echoPin_cadangan 4 3 | 4 | void us_setup() 5 | { 6 | pinMode(p_trigPin_cadangan, OUTPUT); 7 | pinMode(p_echoPin_cadangan, INPUT); 8 | } 9 | float us_get_jarak(int triger, int echo) 10 | { 11 | long duration; 12 | float distance; 13 | int i; 14 | 15 | digitalWrite(triger, LOW); 16 | delayMicroseconds(2); 17 | digitalWrite(triger, HIGH); 18 | delayMicroseconds(10); 19 | digitalWrite(triger, LOW); 20 | duration = pulseIn(echo, HIGH,10000); //uS 21 | 22 | distance = duration * 0.034 / 2; 23 | 24 | return distance; 25 | } 26 | 27 | //--------------------------------#MY AVERAGE 28 | #define n_my_data 4 29 | float my_data[n_my_data]; 30 | int i_my_data = 0; 31 | 32 | float my_moving_average(float in_data, int debug) 33 | { 34 | float my_ave; 35 | float my_sum; 36 | 37 | my_data[i_my_data] = in_data; 38 | 39 | if (my_data[n_my_data - 1] == 0) 40 | { 41 | my_sum = 0; 42 | 43 | for (int i = 0; i <= i_my_data; i++) 44 | { 45 | my_sum += my_data[i]; 46 | } 47 | my_ave = my_sum / (i_my_data + 1); 48 | } 49 | else 50 | { 51 | my_sum = 0; 52 | for (int i = 0; i < n_my_data; i++) 53 | { 54 | my_sum += my_data[i]; 55 | } 56 | my_ave = my_sum / n_my_data; 57 | } 58 | 59 | 60 | //#Debug 61 | if (debug) 62 | { 63 | for (int i = 0; i < n_my_data; i++) 64 | { 65 | Serial.print(i); Serial.print(" "); Serial.println(my_data[i]); 66 | } 67 | Serial.print("i"); Serial.print(" "); Serial.println(i_my_data); 68 | Serial.print("Last"); Serial.print(" "); Serial.println(my_data[n_my_data - 1]); 69 | 70 | Serial.print("Sum"); Serial.print(" "); Serial.println(my_sum); 71 | Serial.print("Ave"); Serial.print(" "); Serial.println(my_ave); 72 | Serial.println(); 73 | } 74 | 75 | 76 | 77 | i_my_data++; 78 | if (i_my_data >= n_my_data) 79 | i_my_data = 0; 80 | 81 | return my_ave; 82 | } 83 | 84 | void my_moving_ave_clear() 85 | { 86 | //Make sure All Array is 0 87 | for (int i = 0; i < n_my_data; i++) 88 | { 89 | my_data[i] = 0; 90 | } 91 | } 92 | 93 | 94 | 95 | void setup() { 96 | Serial.begin(9600); 97 | us_setup(); 98 | my_moving_ave_clear(); 99 | } 100 | 101 | void loop() 102 | { 103 | 104 | float distance_cadangan = us_get_jarak(p_trigPin_cadangan, p_echoPin_cadangan); 105 | float average_cadangan = my_moving_average(distance_cadangan, 0); 106 | 107 | Serial.print(distance_cadangan); Serial.print(" "); 108 | Serial.print(average_cadangan); 109 | 110 | Serial.println(); 111 | delay(1000); 112 | } 113 | -------------------------------------------------------------------------------- /labview/190613_mesin.vi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/labview/190613_mesin.vi -------------------------------------------------------------------------------- /library/Adafruit_GPS-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/library/Adafruit_GPS-master.zip -------------------------------------------------------------------------------- /library/Mecha_QMC5883L-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/library/Mecha_QMC5883L-master.zip -------------------------------------------------------------------------------- /logger/logger.ino: -------------------------------------------------------------------------------- 1 | void setup() { 2 | // put your setup code here, to run once: 3 | 4 | Serial.begin(9600); 5 | 6 | //Header Column, separator data using space 7 | 8 | Serial.print("Data_1"); Serial.print(" "); 9 | Serial.print("Data_2"); Serial.print(" "); 10 | Serial.print("Data_3"); Serial.print(" "); 11 | Serial.print("Data_4"); Serial.print(" "); 12 | Serial.print("Data_5"); Serial.print(" "); 13 | Serial.println(); 14 | 15 | } 16 | 17 | void loop() { 18 | // put your main code here, to run repeatedly: 19 | 20 | Serial.print(random(5)); Serial.print(" "); 21 | Serial.print(random(10)); Serial.print(" "); 22 | Serial.print(random(12)); Serial.print(" "); 23 | Serial.print(random(20)); Serial.print(" "); 24 | Serial.print(random(30)); Serial.print(" "); 25 | Serial.println(); 26 | 27 | delay(1000); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /main_tombol.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/main_tombol.zip -------------------------------------------------------------------------------- /multi_plotter/multi_plotter.ino: -------------------------------------------------------------------------------- 1 | void setup() 2 | { 3 | // put your setup code here, to run once: 4 | Serial.begin(9600); 5 | Serial.print("Data_1"); Serial.print(" "); 6 | Serial.print("Data_2"); Serial.print(" "); 7 | 8 | Serial.println(); 9 | 10 | } 11 | 12 | void loop() { 13 | // put your main code here, to run repeatedly: 14 | 15 | Serial.print(random(5)); Serial.print(" "); 16 | Serial.print(random(5)); Serial.print(" "); 17 | 18 | Serial.println(); 19 | 20 | delay(100); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /nokia_tune/nokia_tune.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Nokia Tune 3 | Connect a piezo buzzer or speaker to pin 11 or select a new pin. 4 | More songs available at https://github.com/robsoncouto/arduino-songs 5 | 6 | Robson Couto, 2019 7 | */ 8 | #define NOTE_B0 31 9 | #define NOTE_C1 33 10 | #define NOTE_CS1 35 11 | #define NOTE_D1 37 12 | #define NOTE_DS1 39 13 | #define NOTE_E1 41 14 | #define NOTE_F1 44 15 | #define NOTE_FS1 46 16 | #define NOTE_G1 49 17 | #define NOTE_GS1 52 18 | #define NOTE_A1 55 19 | #define NOTE_AS1 58 20 | #define NOTE_B1 62 21 | #define NOTE_C2 65 22 | #define NOTE_CS2 69 23 | #define NOTE_D2 73 24 | #define NOTE_DS2 78 25 | #define NOTE_E2 82 26 | #define NOTE_F2 87 27 | #define NOTE_FS2 93 28 | #define NOTE_G2 98 29 | #define NOTE_GS2 104 30 | #define NOTE_A2 110 31 | #define NOTE_AS2 117 32 | #define NOTE_B2 123 33 | #define NOTE_C3 131 34 | #define NOTE_CS3 139 35 | #define NOTE_D3 147 36 | #define NOTE_DS3 156 37 | #define NOTE_E3 165 38 | #define NOTE_F3 175 39 | #define NOTE_FS3 185 40 | #define NOTE_G3 196 41 | #define NOTE_GS3 208 42 | #define NOTE_A3 220 43 | #define NOTE_AS3 233 44 | #define NOTE_B3 247 45 | #define NOTE_C4 262 46 | #define NOTE_CS4 277 47 | #define NOTE_D4 294 48 | #define NOTE_DS4 311 49 | #define NOTE_E4 330 50 | #define NOTE_F4 349 51 | #define NOTE_FS4 370 52 | #define NOTE_G4 392 53 | #define NOTE_GS4 415 54 | #define NOTE_A4 440 55 | #define NOTE_AS4 466 56 | #define NOTE_B4 494 57 | #define NOTE_C5 523 58 | #define NOTE_CS5 554 59 | #define NOTE_D5 587 60 | #define NOTE_DS5 622 61 | #define NOTE_E5 659 62 | #define NOTE_F5 698 63 | #define NOTE_FS5 740 64 | #define NOTE_G5 784 65 | #define NOTE_GS5 831 66 | #define NOTE_A5 880 67 | #define NOTE_AS5 932 68 | #define NOTE_B5 988 69 | #define NOTE_C6 1047 70 | #define NOTE_CS6 1109 71 | #define NOTE_D6 1175 72 | #define NOTE_DS6 1245 73 | #define NOTE_E6 1319 74 | #define NOTE_F6 1397 75 | #define NOTE_FS6 1480 76 | #define NOTE_G6 1568 77 | #define NOTE_GS6 1661 78 | #define NOTE_A6 1760 79 | #define NOTE_AS6 1865 80 | #define NOTE_B6 1976 81 | #define NOTE_C7 2093 82 | #define NOTE_CS7 2217 83 | #define NOTE_D7 2349 84 | #define NOTE_DS7 2489 85 | #define NOTE_E7 2637 86 | #define NOTE_F7 2794 87 | #define NOTE_FS7 2960 88 | #define NOTE_G7 3136 89 | #define NOTE_GS7 3322 90 | #define NOTE_A7 3520 91 | #define NOTE_AS7 3729 92 | #define NOTE_B7 3951 93 | #define NOTE_C8 4186 94 | #define NOTE_CS8 4435 95 | #define NOTE_D8 4699 96 | #define NOTE_DS8 4978 97 | #define REST 0 98 | 99 | 100 | // change this to make the song slower or faster 101 | int tempo = 180; 102 | 103 | // change this to whichever pin you want to use 104 | int buzzer = 11; 105 | 106 | // notes of the moledy followed by the duration. 107 | // a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on 108 | // !!negative numbers are used to represent dotted notes, 109 | // so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!! 110 | int melody[] = { 111 | 112 | // Nokia Ringtone 113 | // Score available at https://musescore.com/user/29944637/scores/5266155 114 | 115 | NOTE_E5, 8, NOTE_D5, 8, NOTE_FS4, 4, NOTE_GS4, 4, 116 | NOTE_CS5, 8, NOTE_B4, 8, NOTE_D4, 4, NOTE_E4, 4, 117 | NOTE_B4, 8, NOTE_A4, 8, NOTE_CS4, 4, NOTE_E4, 4, 118 | NOTE_A4, 2, 119 | }; 120 | 121 | // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits) 122 | // there are two values per note (pitch and duration), so for each note there are four bytes 123 | int notes = sizeof(melody) / sizeof(melody[0]) / 2; 124 | 125 | // this calculates the duration of a whole note in ms 126 | int wholenote = (60000 * 4) / tempo; 127 | 128 | int divider = 0, noteDuration = 0; 129 | 130 | void setup() { 131 | // iterate over the notes of the melody. 132 | // Remember, the array is twice the number of notes (notes + durations) 133 | for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) { 134 | 135 | // calculates the duration of each note 136 | divider = melody[thisNote + 1]; 137 | if (divider > 0) { 138 | // regular note, just proceed 139 | noteDuration = (wholenote) / divider; 140 | } else if (divider < 0) { 141 | // dotted notes are represented with negative durations!! 142 | noteDuration = (wholenote) / abs(divider); 143 | noteDuration *= 1.5; // increases the duration in half for dotted notes 144 | } 145 | 146 | // we only play the note for 90% of the duration, leaving 10% as a pause 147 | tone(buzzer, melody[thisNote], noteDuration * 0.9); 148 | 149 | // Wait for the specief duration before playing the next note. 150 | delay(noteDuration); 151 | 152 | // stop the waveform generation before the next note. 153 | noTone(buzzer); 154 | } 155 | } 156 | 157 | void loop() { 158 | // no need to repeat the melody. 159 | } 160 | -------------------------------------------------------------------------------- /nrf_remote/JoystickShield-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/nrf_remote/JoystickShield-master.zip -------------------------------------------------------------------------------- /nrf_remote/RF24-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/nrf_remote/RF24-master.zip -------------------------------------------------------------------------------- /nrf_remote/main/main.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino Wireless Communication Tutorial 3 | Example 1 - Receiver Code 4 | 5 | by Dejan Nedelkovski, www.HowToMechatronics.com 6 | 7 | Library: TMRh20/RF24, https://github.com/tmrh20/RF24/ 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | RF24 radio(9, 10); // CE, CSN 15 | 16 | const byte address[6] = "00001"; 17 | 18 | // Max size of this struct is 32 bytes - NRF24L01 buffer limit 19 | struct Data_Package { 20 | byte servo; 21 | byte maju; 22 | byte mundur; 23 | }; 24 | 25 | Data_Package data; //Create a variable with the above structure 26 | 27 | void setupNRF() { 28 | radio.begin(); 29 | radio.openReadingPipe(0, address); 30 | radio.setPALevel(RF24_PA_MIN); 31 | radio.startListening(); 32 | } 33 | 34 | 35 | #define Pin_D1_L 2 //lpwm 36 | #define Pin_D2_L 4 //rpwm 37 | #define Pin_E_L 3 //pwm enable 38 | 39 | 40 | #include 41 | Servo myservo; 42 | int pos = 0; 43 | 44 | void setup() 45 | { 46 | Serial.begin(115200); 47 | pinMode(Pin_D1_L, OUTPUT); 48 | pinMode(Pin_D2_L, OUTPUT); 49 | pinMode(Pin_E_L, OUTPUT); 50 | motor_stop(); 51 | myservo.attach(5); 52 | setupNRF(); 53 | } 54 | 55 | void loop() 56 | { 57 | if (radio.available()) { 58 | radio.read(&data, sizeof(Data_Package)); // Read the whole data and store it into the 'data' structure 59 | Serial.print("a: "); 60 | Serial.print(data.servo); 61 | Serial.print(" b: "); 62 | Serial.print(data.maju); 63 | Serial.print(" c: "); 64 | Serial.println(data.mundur); 65 | } 66 | 67 | if (data.maju > 10) { 68 | motor_cw(data.maju); 69 | } 70 | else if (data.mundur > 10) { 71 | motor_ccw(data.mundur); 72 | } 73 | else motor_stop(); 74 | 75 | myservo.write(pos); 76 | 77 | // motor_cw(); delay(1000); 78 | // motor_stop(); delay(1000); 79 | // motor_ccw(); delay(1000); 80 | // motor_stop(); delay(1000); 81 | // 82 | // 83 | // for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees 84 | // // in steps of 1 degree 85 | // myservo.write(pos); // tell servo to go to position in variable 'pos' 86 | // delay(15); // waits 15ms for the servo to reach the position 87 | // } 88 | // for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees 89 | // myservo.write(pos); // tell servo to go to position in variable 'pos' 90 | // delay(15); // waits 15ms for the servo to reach the position 91 | // } 92 | } 93 | 94 | void motor_cw(byte speedx) 95 | { 96 | analogWrite(Pin_E_L, speedx); 97 | digitalWrite(Pin_D1_L, HIGH); 98 | digitalWrite(Pin_D2_L, LOW); 99 | } 100 | 101 | void motor_ccw(byte speedx) 102 | { 103 | analogWrite(Pin_E_L, speedx); //0-255 104 | digitalWrite(Pin_D1_L, LOW); 105 | digitalWrite(Pin_D2_L, HIGH); 106 | } 107 | 108 | void motor_stop() 109 | { 110 | digitalWrite(Pin_D1_L, LOW); 111 | digitalWrite(Pin_D2_L, LOW); 112 | analogWrite(Pin_E_L, 0); 113 | } 114 | -------------------------------------------------------------------------------- /nrf_remote/main_remot/main_remot.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino Wireless Communication Tutorial 3 | Example 1 - Transmitter Code 4 | 5 | by Dejan Nedelkovski, www.HowToMechatronics.com 6 | 7 | Library: TMRh20/RF24, https://github.com/tmrh20/RF24/ 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | RF24 radio(9, 10); // CE, CSN 15 | 16 | const byte address[6] = "00001"; 17 | 18 | // Max size of this struct is 32 bytes - NRF24L01 buffer limit 19 | struct Data_Package { 20 | byte servo; 21 | byte maju; 22 | byte mundur; 23 | }; 24 | 25 | Data_Package data; // Create a variable with the above structure 26 | 27 | void setupNRF() { 28 | radio.begin(); 29 | radio.openWritingPipe(address); 30 | radio.setPALevel(RF24_PA_MIN); 31 | radio.stopListening(); 32 | } 33 | 34 | #define batas 50 35 | int batasServoKiri = 90 - batas; 36 | int batasServoKanan = 90 + batas; 37 | 38 | #include // include JoystickShield Library 39 | JoystickShield joystickShield; // create an instance of JoystickShield object 40 | 41 | void setup() { 42 | Serial.begin(115200); 43 | 44 | delay(100); 45 | joystickShield.calibrateJoystick(); 46 | 47 | setupNRF(); 48 | } 49 | 50 | unsigned long previousMillis = 0; 51 | const long interval = 100; 52 | void loop() { 53 | unsigned long currentMillis = millis(); 54 | 55 | if (currentMillis - previousMillis >= interval) 56 | { 57 | previousMillis = currentMillis; 58 | joystickShield.processEvents(); // process events 59 | 60 | if (joystickShield.isUpButton()) { 61 | //Serial.println("Up Button Clicked") ; 62 | data.mundur = 150; 63 | } 64 | else data.mundur = 0; 65 | 66 | 67 | // if (joystickShield.isRightButton()) { 68 | // Serial.println("Right Button Clicked") ; 69 | // 70 | // } 71 | // 72 | 73 | if (joystickShield.isDownButton()) { 74 | //Serial.println("Down Button Clicked") ; 75 | data.maju = 150; 76 | } 77 | else if (joystickShield.isLeftButton()) { 78 | //Serial.println("Left Button Clicked") ; 79 | data.maju = 220; 80 | } 81 | else data.maju = 0; 82 | 83 | 84 | // new position functions 85 | int x = joystickShield.xAmplitude(); 86 | //int y = joystickShield.yAmplitude(); 87 | //Serial.print("x "); Serial.println(x); 88 | //Serial.print(" y "); Serial.println(y); 89 | 90 | int xServo = map(x, -100, 100, batasServoKiri, batasServoKanan); 91 | //int yServo = map(y, -100, 100, 0, 180); 92 | 93 | //Serial.print("x "); Serial.println(xServo); 94 | data.servo = xServo; 95 | //Serial.print(" y "); Serial.println(yServo); 96 | 97 | 98 | //const char text[] = "Hello World"; 99 | radio.write(&data, sizeof(Data_Package)); 100 | //Serial.println("Kirim"); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /ph_arduino/ph kalibrasi.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/ph_arduino/ph kalibrasi.xlsx -------------------------------------------------------------------------------- /ph_arduino/ph_arduino.ino: -------------------------------------------------------------------------------- 1 | #define p_ph A2 2 | void setup() { 3 | 4 | Serial.begin(9600); 5 | 6 | } 7 | 8 | 9 | float adc_ph; 10 | void loop() { 11 | float ph; 12 | ph = sensor_ph(); 13 | 14 | Serial.print(ph); Serial.print(" "); 15 | Serial.println(adc_ph); 16 | } 17 | 18 | 19 | float sensor_ph() { 20 | const int analogInPin = p_ph; 21 | float avgValue = 0; 22 | int sensorValue = 0; 23 | int buf[50], temp; 24 | 25 | //AMBIL 10 SAMPEL ADC 26 | for (int i = 0; i < 10; i++) { 27 | buf[i] = analogRead(p_ph); 28 | delay(30); 29 | } 30 | //AMBIL 10 SAMPEL ADC 31 | 32 | //DIURUTKAN DARI TERKCECIL KE BESAR 33 | for (int i = 0; i < 9; i++) { 34 | 35 | for (int j = i + 1; j < 10; j++) { 36 | if (buf[i] > buf[j]) { 37 | temp = buf[i]; 38 | buf[i] = buf[j]; 39 | buf[j] = temp; 40 | } 41 | } 42 | } 43 | //DIURUTKAN DARI TERKCECIL KE BESAR 44 | 45 | //DIAMBIL 6 DATA TENGAH index 2-8 KEMUDIAN DIRATA RATA 46 | for (int i = 2; i < 8; i++) { 47 | avgValue += buf[i]; 48 | } 49 | avgValue = avgValue/6; 50 | //DIAMBIL 6 DATA TENGAH index 2-8 KEMUDIAN DIRATA RATA 51 | 52 | float phValue = -0.0308*avgValue + 23.059; 53 | 54 | 55 | adc_ph = avgValue; 56 | return phValue; 57 | } 58 | -------------------------------------------------------------------------------- /project/Brangkas_SIM_CAM-VC0706-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/project/Brangkas_SIM_CAM-VC0706-master.zip -------------------------------------------------------------------------------- /project/Kursi Bayi/BukuPA2_1110195022_Sayuna Ulfa Yakin.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/project/Kursi Bayi/BukuPA2_1110195022_Sayuna Ulfa Yakin.pdf -------------------------------------------------------------------------------- /project/Kursi Bayi/File Lain.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/project/Kursi Bayi/File Lain.zip -------------------------------------------------------------------------------- /random_number/random_number.ino: -------------------------------------------------------------------------------- 1 | void setup() { 2 | Serial.begin(9600); 3 | Serial.println("N INT FLOAT"); 4 | randomSeed(analogRead(0)); // using data from free analog pin to start data [0-1023] 5 | } 6 | 7 | int i = 0; 8 | void loop() { 9 | if (i < 10) 10 | { 11 | int random_int = random(0, 1000); 12 | float random_float = random_int / 1000.0; //must use .0 13 | Serial.print(i); 14 | Serial.print(" "); 15 | Serial.print(random_int); 16 | Serial.print(" "); 17 | Serial.print(random_float); 18 | Serial.println(); 19 | i++; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /rsa_edit/17.K1.0007-MICHAEL VALENTINO-LAMP_a.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/firebitlab/arduino/d81b2de20525fc5d71cabcea98b15aeaa4a0763d/rsa_edit/17.K1.0007-MICHAEL VALENTINO-LAMP_a.pdf -------------------------------------------------------------------------------- /rsa_edit/rsa.ino: -------------------------------------------------------------------------------- 1 | /*Inspired by http://www.trytoprogram.com/cpp-examples/cplusplus-program-encrypt-decrypt-string/ */ 2 | #include 3 | #include 4 | 5 | int p, q; 6 | int n, fn; 7 | int i; 8 | int check; 9 | long int e[50]; //Untuk menqimpan Public key 10 | long int d[50]; //Untuk menqimpan Private key 11 | long int temp[50]; 12 | long int j; 13 | char c[50]; //Ciphertext 14 | char m[50]; //Plaintext 15 | String msg = "9DA2715"; //Input pesan 16 | int check_prime(long int); //Untuk cek angka prima 17 | long int cd(long int); //Untuk cek nilai K 18 | void encryption_key(); 19 | void encrypt(); 20 | void decrypt(); 21 | void setup() { 22 | Serial.begin(115200); 23 | Serial.println("First Prime Number"); 24 | p = 17; 25 | Serial.println(p); 26 | check = check_prime(p); 27 | if (check == 1) { 28 | Serial.println("P is a Prime Number"); 29 | } else { 30 | Serial.println("P is NOT a Prime Number"); 31 | exit(0); 32 | } 33 | 34 | Serial.println("Second Prime Number"); 35 | q = 13; 36 | Serial.println(q); 37 | check = check_prime(q); 38 | if (check == 1) { 39 | Serial.println("Q is a Prime Number"); 40 | } else { 41 | Serial.println("Q is NOT a Prime Number"); 42 | exit(0); 43 | } 44 | 45 | Serial.println("Message or String To Encrypt\n"); 46 | Serial.println(msg); 47 | int msg_len = msg.length() + 1; 48 | char msg_arr[16]; 49 | msg.toCharArray(msg_arr, msg_len); 50 | for (i = 0; msg_arr[i] != 0 ; i++) 51 | { 52 | m[i] = msg [i]; 53 | } 54 | n = p * q; //Untuk cari nilai N 55 | fn = ((p - 1) * (q - 1)); //Untuk mencari nilai dari private key 56 | encryption_key(); 57 | unsigned long time1 = micros(); 58 | encrypt(); 59 | Serial.print("Waktu Encrypt : "); 60 | Serial.print(micros() - time1); 61 | Serial.println(" uS"); 62 | unsigned long time2 = micros(); 63 | decrypt(); 64 | Serial.print("\nWaktu Decrypt : "); 65 | Serial.print(micros() - time2); 66 | Serial.println(" uS"); 67 | } 68 | 69 | void loop() { 70 | } 71 | 72 | int check_prime(long int pri) { 73 | int i; 74 | for (i = 2; i <= pri - 1; i++) { 75 | if (pri % i == 0) 76 | return 0; 77 | } 78 | if (i == pri) 79 | return 1; 80 | } 81 | 82 | //Function untuk menghasilkan public dan private key 83 | void encryption_key() 84 | { 85 | int k; 86 | k = 0; 87 | for (i = 2; i < fn; i++) 88 | { 89 | if (fn % i == 0) 90 | continue; 91 | check = check_prime(i); 92 | if (check == 1 && i != p && i != q) 93 | { 94 | e[k] = i; 95 | check = cd(e[k]); 96 | if (check > 0) 97 | { 98 | d[k] = check; 99 | k++; 100 | } 101 | if (k == 99) 102 | break; 103 | } 104 | } 105 | } 106 | long int cd (long int a) { 107 | long int k = 1; 108 | while (1) { 109 | k = k + fn; 110 | if (k % a == 0) 111 | return (k / a); 112 | } 113 | } 114 | void encrypt() { 115 | long int pt, ct, key = e[0]; 116 | long int k, len; 117 | int i = 0; 118 | len = msg.length(); 119 | 120 | while (i != len) 121 | { 122 | pt = m[i]; 123 | pt = pt - 96; //Untuk mencegah character melebihi batas unsigned dan menjaga valua tetap dalam range 124 | k = 1; 125 | for (j = 0; j < key; j++) { 126 | k = k * pt; 127 | k = k % n; 128 | } 129 | temp[i] = k; 130 | ct = k + 96; 131 | c[i] = ct; 132 | i++; 133 | } 134 | c[i] = -1; 135 | Serial.println("\nThe Encrypted Message Is"); 136 | for (i = 0; c[i] != -1; i++) { 137 | Serial.print(c[i]); 138 | } 139 | Serial.println("\nThe Encrypted Message In HEX"); 140 | for (int i = 0; c[i] != -1 ; i++) { 141 | Serial.println(c[i] & 0xFF, DEC); 142 | } 143 | Serial.println("-----END OF HEX-----"); 144 | } 145 | void decrypt() { 146 | long int pt, ct, key = d[0]; 147 | long int k; 148 | int i = 0; 149 | while (c[i] != -1) 150 | { 151 | ct = temp[i]; 152 | k = 1; 153 | for (j = 0; j < key; j++) 154 | { 155 | k = k * ct; 156 | k = k % n; 157 | } 158 | pt = k + 96; 159 | m[i] = pt; 160 | i++; 161 | } 162 | m[i] = -1; 163 | Serial.println("\nThe Decrypted Message Is"); 164 | for (i = 0; m[i] != -1; i++) { 165 | Serial.print(m[i]); 166 | } 167 | 168 | } 169 | -------------------------------------------------------------------------------- /rsa_edit/rsa_edit.ino: -------------------------------------------------------------------------------- 1 | /*Inspired by http://www.trytoprogram.com/cpp-examples/cplusplus-program-encrypt-decrypt-string/ */ 2 | #include 3 | #include 4 | 5 | // 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 6 | int p = 5; 7 | int q = 29; 8 | int n, fn; 9 | int i; 10 | int check; 11 | long int e[50]; //Untuk menqimpan Public key 12 | long int d[50]; //Untuk menqimpan Private key 13 | long int temp[50]; 14 | long int j; 15 | char c[50]; //Ciphertext 16 | char m[50]; //Plaintext 17 | String msg = "E9DA2715"; //Input pesan 18 | 19 | int check_prime(long int pri) { 20 | int i; 21 | for (i = 2; i <= pri - 1; i++) { 22 | if (pri % i == 0) 23 | return 0; 24 | } 25 | if (i == pri) 26 | return 1; 27 | } 28 | 29 | //Function untuk menghasilkan public dan private key 30 | int encryption_key() { 31 | int k; 32 | k = 0; 33 | for (i = 2; i < fn; i++) 34 | { 35 | if (fn % i == 0) 36 | continue; 37 | 38 | check = check_prime(i); 39 | 40 | if (check == 1 && i != p && i != q) 41 | { 42 | e[k] = i; 43 | //Serial.print("e["); Serial.print(k); Serial.print("]="); Serial.println(e[k]); 44 | check = cd(e[k]); 45 | if (check > 0) 46 | { 47 | d[k] = check; 48 | //Serial.print("d["); Serial.print(k); Serial.print("]="); Serial.println(e[k]); 49 | k++; 50 | } 51 | if (k == 99) 52 | break; 53 | } 54 | } 55 | return k; 56 | } 57 | long int cd (long int a) { 58 | long int k = 1; 59 | while (1) { 60 | k = k + fn; 61 | if (k % a == 0) 62 | return (k / a); 63 | } 64 | } 65 | void encrypt() { 66 | 67 | 68 | long int pt, ct, key = e[0]; 69 | long int k, len; 70 | int i = 0; 71 | len = msg.length(); 72 | 73 | Serial.print("e = "); Serial.println(key); 74 | 75 | Serial.println(); 76 | Serial.println("---------Step 4"); 77 | 78 | Serial.print("Message To Encrypt = "); Serial.println(msg); 79 | Serial.print("Message In DEC = "); 80 | for (int i = 0; msg[i] != 0 ; i++) { 81 | Serial.print(msg[i] & 0xFF, DEC); 82 | Serial.print(" "); 83 | } 84 | Serial.println(); 85 | Serial.println(); 86 | 87 | while (i != len) 88 | { 89 | pt = m[i]; 90 | //pt = pt - 96; //Untuk mencegah character melebihi batas unsigned dan menjaga valua tetap dalam range 91 | pt = pt; 92 | k = 1; 93 | for (j = 0; j < key; j++) { 94 | k = k * pt; 95 | k = k % n; 96 | } 97 | temp[i] = k; 98 | //ct = k + 96; 99 | ct = k; 100 | c[i] = ct; 101 | i++; 102 | } 103 | c[i] = -1; 104 | Serial.print("The Encrypted Message Is = "); 105 | for (i = 0; c[i] != -1; i++) { 106 | Serial.print(c[i]); 107 | } 108 | Serial.println(); 109 | 110 | 111 | Serial.print("The Encrypted Message In DEC = "); 112 | for (int i = 0; c[i] != -1 ; i++) { 113 | Serial.print(c[i] & 0xFF, DEC); 114 | Serial.print(" "); 115 | } 116 | Serial.println(); 117 | } 118 | void decrypt() { 119 | long int pt, ct, key = d[0]; 120 | long int k; 121 | int i = 0; 122 | 123 | Serial.println(); 124 | Serial.println("---------Step 5"); 125 | Serial.print("d = "); Serial.println(key); 126 | 127 | while (c[i] != -1) 128 | { 129 | ct = temp[i]; 130 | k = 1; 131 | for (j = 0; j < key; j++) 132 | { 133 | k = k * ct; 134 | k = k % n; 135 | } 136 | //pt = k + 96; 137 | pt = k; 138 | m[i] = pt; 139 | i++; 140 | } 141 | m[i] = -1; 142 | Serial.print("\nThe Decrypted Message Is = "); 143 | for (i = 0; m[i] != -1; i++) { 144 | Serial.print(m[i]); 145 | } 146 | 147 | } 148 | 149 | //Reference https://www.cs.drexel.edu/~jpopyack/IntroCS/HW/RSAWorksheet.html 150 | void setup() { 151 | Serial.begin(115200); 152 | Serial.println("---------RSA Calculator"); 153 | 154 | Serial.println(); 155 | Serial.println("---------Step 1"); 156 | 157 | Serial.print ("First Prime Number (P) = "); Serial.println(p); 158 | check = check_prime(p); 159 | if (check == 1) { 160 | Serial.println("P is a Prime Number"); 161 | } else { 162 | Serial.println("P is NOT a Prime Number"); 163 | exit(0); 164 | } 165 | 166 | 167 | Serial.print("Second Prime Number (Q) = "); Serial.println(q); 168 | check = check_prime(q); 169 | if (check == 1) { 170 | Serial.println("Q is a Prime Number"); 171 | } else { 172 | Serial.println("Q is NOT a Prime Number"); 173 | exit(0); 174 | } 175 | 176 | int msg_len = msg.length() + 1; 177 | char msg_arr[16]; 178 | msg.toCharArray(msg_arr, msg_len); 179 | for (i = 0; msg_arr[i] != 0 ; i++) 180 | { 181 | m[i] = msg [i]; 182 | //Serial.println(m[i]); 183 | } 184 | n = p * q; //Untuk cari nilai N 185 | Serial.print("Nilai N = "); Serial.println(n); 186 | 187 | fn = ((p - 1) * (q - 1)); //Untuk mencari nilai dari private key 188 | Serial.print("Nilai r = "); Serial.println(fn); 189 | 190 | // Serial.println(); 191 | // Serial.println("---------Step 2"); 192 | //Serial.print("Nilai K = "); Serial.println(encryption_key()); 193 | 194 | encryption_key(); 195 | 196 | unsigned long time1 = micros(); 197 | 198 | Serial.println(); 199 | Serial.println("---------Step 3"); 200 | 201 | encrypt(); 202 | Serial.print("Waktu Encrypt (uS) = "); Serial.println(micros() - time1); 203 | unsigned long time2 = micros(); 204 | decrypt(); 205 | Serial.print("\nWaktu Decrypt (uS) = "); Serial.print(micros() - time2); 206 | } 207 | 208 | void loop() { 209 | } 210 | -------------------------------------------------------------------------------- /scrolllcd/left/left.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Hello World 3 | 4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "Hello World!" to the LCD 10 | and shows the time. 11 | 12 | The circuit: 13 | * LCD RS pin to digital pin 12 14 | * LCD Enable pin to digital pin 11 15 | * LCD D4 pin to digital pin 5 16 | * LCD D5 pin to digital pin 4 17 | * LCD D6 pin to digital pin 3 18 | * LCD D7 pin to digital pin 2 19 | * LCD R/W pin to ground 20 | * LCD VSS pin to ground 21 | * LCD VCC pin to 5V 22 | * 10K resistor: 23 | * ends to +5V and ground 24 | * wiper to LCD VO pin (pin 3) 25 | 26 | Library originally added 18 Apr 2008 27 | by David A. Mellis 28 | library modified 5 Jul 2009 29 | by Limor Fried (http://www.ladyada.net) 30 | example added 9 Jul 2009 31 | by Tom Igoe 32 | modified 22 Nov 2010 33 | by Tom Igoe 34 | 35 | This example code is in the public domain. 36 | 37 | http://www.arduino.cc/en/Tutorial/LiquidCrystal 38 | */ 39 | 40 | // include the library code: 41 | #include 42 | 43 | // initialize the library with the numbers of the interface pins 44 | LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // DEPEND ON YOUR CIRCUIT 45 | 46 | void setup() 47 | { 48 | lcd.begin(16, 2); 49 | 50 | lcd.setCursor(0,0); 51 | //lcd.print("0123456789012345"); 52 | lcd.print("D4 LJ ELIN PENS"); // TEXT WANT TO SCROLL 53 | delay(2000); //WAIT 2 SECOND OPTIONAL 54 | } 55 | 56 | void loop() 57 | { 58 | lcd.scrollDisplayRight(); 59 | delay(200); // DELAY EVERY MOVE //thats why for scroll riht using first scketh 60 | 61 | //thankyou 62 | 63 | } -------------------------------------------------------------------------------- /scrolllcd/right/right.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Hello World 3 | 4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "Hello World!" to the LCD 10 | and shows the time. 11 | 12 | The circuit: 13 | * LCD RS pin to digital pin 12 14 | * LCD Enable pin to digital pin 11 15 | * LCD D4 pin to digital pin 5 16 | * LCD D5 pin to digital pin 4 17 | * LCD D6 pin to digital pin 3 18 | * LCD D7 pin to digital pin 2 19 | * LCD R/W pin to ground 20 | * LCD VSS pin to ground 21 | * LCD VCC pin to 5V 22 | * 10K resistor: 23 | * ends to +5V and ground 24 | * wiper to LCD VO pin (pin 3) 25 | 26 | Library originally added 18 Apr 2008 27 | by David A. Mellis 28 | library modified 5 Jul 2009 29 | by Limor Fried (http://www.ladyada.net) 30 | example added 9 Jul 2009 31 | by Tom Igoe 32 | modified 22 Nov 2010 33 | by Tom Igoe 34 | 35 | This example code is in the public domain. 36 | 37 | http://www.arduino.cc/en/Tutorial/LiquidCrystal 38 | */ 39 | 40 | // include the library code: 41 | #include 42 | 43 | // initialize the library with the numbers of the interface pins 44 | LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // DEPEND ON YOUR CIRCUIT 45 | 46 | void setup() 47 | { 48 | lcd.begin(16, 2); 49 | 50 | lcd.setCursor(0,0); 51 | //lcd.print("0123456789012345"); 52 | lcd.print("D4 LJ ELIN PENS"); // TEXT WANT TO SCROLL 53 | delay(2000); //WAIT 2 SECOND OPTIONAL 54 | } 55 | 56 | void loop() 57 | { 58 | for (int i = 0; i < (16+10+13); i++) // 16 + 10 + 15 CHANGE UP TO YOU AND YOU WILL FIND WHY I AM USING THIS NUMBER 59 | { 60 | lcd.scrollDisplayRight(); 61 | delay(200); // DELAY EVERY MOVE 62 | } 63 | while(1){} //DEBUG / FOR DEBUG HOW MANY SCROLL HAPPEN WITH THAT NUMBER 64 | 65 | lcd.clear(); //to reset scroll cursor 66 | lcd.setCursor(0,0); // FOR CONTINUE SCROLL NEDD TO SET CURSOR TO START AGAIN 0.0 67 | lcd.print("D4 LJ ELIN PENS"); // SAME TEXT / LETS TRY 68 | 69 | } -------------------------------------------------------------------------------- /sensor_getar/sensor_getar.ino: -------------------------------------------------------------------------------- 1 | #define p_sensor 19 2 | 3 | void setup() 4 | { 5 | Serial.begin(9600); 6 | pinMode(p_sensor, INPUT); 7 | } 8 | 9 | void loop() 10 | { 11 | unsigned char d_sensor = digitalRead(p_sensor); 12 | if (d_sensor == HIGH) 13 | { 14 | Serial.println(d_sensor); 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tayo/i_sensor.ino: -------------------------------------------------------------------------------- 1 | #define psensor1 A1 2 | #define psensor2 A2 3 | #define psensor3 A3 4 | #define psensor4 A4 5 | #define psensor5 A5 6 | 7 | #define nsensor 5 8 | int sensor[nsensor]; 9 | float threshold[nsensor]; 10 | int data_hitam[nsensor] = {0, 0, 0, 0, 0}; 11 | int data_putih[nsensor] = {994, 992, 994, 994, 995}; 12 | 13 | 14 | void hitung_treshold_sensor() 15 | { 16 | for (int i = 0; i < nsensor; i++) 17 | { 18 | threshold[i] = data_hitam[i] - ((data_hitam[i] - data_putih[i]) * sensitifity_sensor); //0.0 - 1.0 makin besar makin sensitif 19 | } 20 | } 21 | 22 | void baca_sensor() 23 | { 24 | sensor[0] = analogRead(psensor1); delay(2); 25 | sensor[1] = analogRead(psensor2); delay(2); 26 | sensor[2] = analogRead(psensor3); delay(2); 27 | sensor[3] = analogRead(psensor4); delay(2); 28 | sensor[4] = analogRead(psensor5); delay(2); 29 | 30 | } 31 | 32 | void print_sensor() 33 | { 34 | for (int i = 0; i < nsensor; i++) 35 | { 36 | Serial.print(sensor[i]); 37 | Serial.print("-"); 38 | } 39 | Serial.println(""); 40 | } 41 | 42 | 43 | String inputString = ""; 44 | 45 | unsigned char baca_garis() 46 | { 47 | baca_sensor(); 48 | for (unsigned char i = 0; i < nsensor; i++) 49 | { 50 | if (sensor[i] > threshold[i]) 51 | sensor[i] = 1; 52 | else 53 | sensor[i] = 0; 54 | } 55 | unsigned char dsensor = (sensor[0] * 1) + (sensor[1] * 2) + (sensor[2] * 4) + (sensor[3] * 8) + (sensor[4] * 16); 56 | return dsensor; 57 | } 58 | -------------------------------------------------------------------------------- /tayo/o_motor.ino: -------------------------------------------------------------------------------- 1 | void motorLR(unsigned char speedL, unsigned char speedR) 2 | { 3 | analogWrite(pPwmL, speedL); 4 | analogWrite(pPwmR, speedR); 5 | } 6 | -------------------------------------------------------------------------------- /tayo/tayo.ino: -------------------------------------------------------------------------------- 1 | //-------------------------------------------SETTING 2 | #define sensitifity_sensor 0.5 //0.1 -- 0.9 high more sensitif depend on light 3 | #define kecepatan 75 4 | 5 | 6 | //-------------------------------------------MOTOR 7 | 8 | #define pPwmL 5 9 | #define pPwmR 6 10 | 11 | int speedka, speedki; 12 | 13 | void setup() 14 | { 15 | 16 | Serial.begin(115200); 17 | pinMode(pPwmL, OUTPUT); 18 | pinMode(pPwmR, OUTPUT); 19 | motorLR(0, 0); 20 | hitung_treshold_sensor(); 21 | 22 | //DEBUG MOTOR 23 | // while(1){ 24 | // motorLR(70,90); //lurus beda 20; 25 | // } 26 | 27 | //DEBUG SENSOR 28 | // while (1) { 29 | // baca_garis(); 30 | // //baca_sensor(); 31 | // print_sensor(); 32 | // } 33 | 34 | 35 | 36 | } 37 | 38 | 39 | void loop() 40 | { 41 | jalan(); 42 | } 43 | 44 | char error; 45 | char lastError; 46 | void jalan() 47 | { 48 | 49 | unsigned char dsensor = baca_garis(); 50 | 51 | //dsensor = ~dsensor; 52 | switch (dsensor) 53 | { 54 | case 0b01111: error = 4; break; 55 | case 0b00111: error = 3; break; 56 | case 0b10111: error = 2; break; 57 | case 0b10011: error = 1; break; 58 | case 0b11011: error = 0; break; 59 | case 0b11001: error = -1; break; 60 | case 0b11101: error = -2; break; 61 | case 0b11100: error = -3; break; 62 | case 0b11110: error = -4; break; 63 | 64 | case 0b01110: error = 10; break; 65 | case 0b00100: error = 10; break; 66 | case 0b00000: error = 10; break; 67 | // case 0b01111110: error = 10; break; 68 | // case 0b00000000: error = 10; break; 69 | // case 0b10000001: error = 10; break; 70 | // case 0b11000011: error = 10; break; 71 | default : error = lastError; break; //mengetahui terakhir kena sensor kanan apa kiri 72 | } 73 | 74 | 75 | 76 | 77 | float kp = 15; 78 | float ki = 0.1; 79 | float kd = 0.2; 80 | float pid = kp * error + ki * (error + lastError) + kd * (error - lastError); 81 | unsigned char maxSpeed = 90; 82 | unsigned char speedL = maxSpeed - 20; //beda kecepatan motor 83 | unsigned char speedR = maxSpeed; 84 | 85 | if (error > 5) 86 | { 87 | speedL = speedL; 88 | speedR = speedR; 89 | } 90 | else 91 | { 92 | if (error > 0) 93 | speedL = maxSpeed - pid; 94 | else 95 | speedR = maxSpeed + pid; 96 | } 97 | 98 | 99 | motorLR(speedL, speedR); 100 | 101 | 102 | 103 | //DEBUG 104 | Serial.print(pid); Serial.print(";"); 105 | Serial.print(speedL); Serial.print(";"); 106 | Serial.print(speedR); Serial.print(";"); 107 | Serial.print(error, DEC); Serial.print(";"); 108 | Serial.print(lastError, DEC); Serial.print(";"); 109 | Serial.println(); 110 | 111 | lastError = error; 112 | 113 | 114 | 115 | } 116 | --------------------------------------------------------------------------------