├── .gitignore ├── README.md ├── arduino ├── AnalogReadSerial │ └── AnalogReadSerial.ino ├── AnalogReadSerial_allpins │ └── AnalogReadSerial_allpins.ino ├── AnalogReadSerial_one_digi_one_ana │ └── AnalogReadSerial_one_digi_one_ana.ino ├── AnalogReadSerial_one_digi_one_ana_three_inputs │ └── AnalogReadSerial_one_digi_one_ana_three_inputs.ino ├── AnalogReadSerial_two_digi_oneanalog_inner_loop_dual_sensor │ └── AnalogReadSerial_two_digi_oneanalog_inner_loop_dual_sensor.ino ├── DS18x20_Temp_combine_with_sdi12_neat │ └── DS18x20_Temp_combine_with_sdi12_neat.ino ├── DS18x20_Temp_moisture_mega_for_bp │ └── DS18x20_Temp_moisture_mega_for_bp.ino ├── DS18x20_Temperature_combine_with_sdi12 │ └── DS18x20_Temperature_combine_with_sdi12.ino ├── Mega_DHT11_DS18x20_temp_ana1_digi1_bp │ ├── DHT.cpp │ ├── DHT.h │ └── Mega_DHT11_DS18x20_temp_ana1_digi1_bp.ino ├── Mega_DHT22_DS18x20_temp_ana1_digi1_bp │ ├── DHT.cpp │ ├── DHT.h │ └── Mega_DHT21_DS18x20_temp_ana1_digi1_bp.ino ├── Mega_DS18x20_temp_sdi12_ana1_digi1_roof │ └── Mega_DS18x20_temp_sdi12_ana1_digi1_roof.ino ├── Mega_one_digi_one_ana_2_13 │ └── Mega_one_digi_one_ana_2_13.ino ├── Mega_si1145_DS18x20_temp_sdi12_ana_input_roof │ └── Mega_si1145_DS18x20_temp_sdi12_ana_input_roof.ino ├── Mux2_moisture_analog_Digi2_temp │ └── Mux2_moisture_analog_Digi2_temp.ino ├── MuxShieldAnalogIn │ └── MuxShieldAnalogIn.ino ├── Mux_DHT11_DS18x20_temp_ana1_digi1_bp │ ├── DHT.cpp │ ├── DHT.h │ └── Mux_DHT11_DS18x20_temp_ana1_digi1_bp.ino ├── Test_time │ └── Test_time.ino ├── area51_2mo_3heatsuc1min_2salt_2drsuc_2gs3_compacted_redmud │ └── area51_2mo_3heatsuc1min_2salt_2drsuc_2gs3_compacted_redmud.ino ├── area51_2mo_3heatsuc1min_2salt_2drsuc_redmud │ └── area51_2mo_3heatsuc1min_2salt_2drsuc_redmud.ino ├── cali_2moist_2heatsuc_2salinity_2ceramsuc │ └── cali_2moist_2heatsuc_2salinity_2ceramsuc.ino ├── cali_2moist_2heatsuc_2salinity_2ceramsuc_12V1min │ └── cali_2moist_2heatsuc_2salinity_2ceramsuc_12V1min.ino ├── calibrate_load_cell │ └── calibrate_load_cell.ino ├── calibrate_load_cell_two_layers │ └── calibrate_load_cell_two_layers.ino ├── ciao │ └── ciao.ino ├── column_aster │ └── column_aster.ino ├── column_bougainvillea │ └── column_bougainvillea.ino ├── daisy_prototype_logger │ ├── DHT.cpp │ ├── DHT.h │ └── daisy_prototype_logger.ino ├── digital_temp_DS18B20 │ └── digital_temp_DS18B20.ino ├── grange_a │ └── grange_a.ino ├── grange_b │ └── grange_b.ino ├── grange_d │ └── grange_d.ino ├── heat_suction_function_and_calibration │ └── heat_suction_function_and_calibration.ino ├── heat_suction_function_and_calibration_tmp36 │ └── heat_suction_function_and_calibration_tmp36.ino ├── libraries │ ├── Adafruit_SHT31 │ │ ├── .Adafruit_SHT31.h.swp │ │ ├── .github │ │ │ ├── ISSUE_TEMPLATE.md │ │ │ └── PULL_REQUEST_TEMPLATE.md │ │ ├── .travis.yml │ │ ├── Adafruit_SHT31.cpp │ │ ├── Adafruit_SHT31.h │ │ ├── README.md │ │ ├── examples │ │ │ └── SHT31test │ │ │ │ └── SHT31test.ino │ │ └── library.properties │ ├── Adafruit_SI1145_Library │ │ ├── Adafruit_SI1145.cpp │ │ ├── Adafruit_SI1145.h │ │ ├── README.txt │ │ ├── examples │ │ │ └── si1145test │ │ │ │ └── si1145test.ino │ │ └── library.properties │ ├── DallasTemperature │ │ ├── DallasTemperature.cpp │ │ ├── DallasTemperature.h │ │ ├── README.md │ │ ├── change.txt │ │ ├── examples │ │ │ ├── Alarm │ │ │ │ └── Alarm.pde │ │ │ ├── AlarmHandler │ │ │ │ └── AlarmHandler.pde │ │ │ ├── Multibus_simple │ │ │ │ └── Multibus_simple.ino │ │ │ ├── Multiple │ │ │ │ └── Multiple.pde │ │ │ ├── Simple │ │ │ │ └── Simple.pde │ │ │ ├── Single │ │ │ │ └── Single.pde │ │ │ ├── Tester │ │ │ │ └── Tester.pde │ │ │ ├── TwoPin_DS18B20 │ │ │ │ └── TwoPin_DS18B20.ino │ │ │ ├── WaitForConversion │ │ │ │ └── WaitForConversion.pde │ │ │ ├── WaitForConversion2 │ │ │ │ └── WaitForConversion2.pde │ │ │ ├── oneWireSearch │ │ │ │ └── oneWireSearch.ino │ │ │ └── setUserData │ │ │ │ └── SetUserData.ino │ │ ├── keywords.txt │ │ ├── library.json │ │ └── library.properties │ ├── OneWire │ │ ├── OneWire.cpp │ │ ├── OneWire.h │ │ ├── examples │ │ │ ├── DS18x20_Temperature │ │ │ │ └── DS18x20_Temperature.pde │ │ │ ├── DS2408_Switch │ │ │ │ └── DS2408_Switch.pde │ │ │ └── DS250x_PROM │ │ │ │ └── DS250x_PROM.pde │ │ └── keywords.txt │ ├── SDI12 │ │ ├── LICENSE.md │ │ ├── OverviewOfInterrupts.md │ │ ├── README.md │ │ ├── examples │ │ │ ├── ReadMe.md │ │ │ ├── a_wild_card │ │ │ │ ├── ReadMe.md │ │ │ │ └── a_wild_card.ino │ │ │ ├── b_address_change │ │ │ │ ├── ReadMe.md │ │ │ │ └── b_address_change.ino │ │ │ ├── c_check_all_addresses │ │ │ │ ├── ReadMe.md │ │ │ │ └── c_check_all_addresses.ino │ │ │ ├── d_simple_logger │ │ │ │ ├── ReadMe.md │ │ │ │ └── d_simple_logger.ino │ │ │ ├── e_simple_parsing │ │ │ │ ├── ReadMe.md │ │ │ │ └── e_simple_parsing.ino │ │ │ ├── f_basic_data_request │ │ │ │ ├── ReadMe.md │ │ │ │ └── f_basic_data_request.ino │ │ │ ├── g_terminal_window │ │ │ │ ├── ReadMe.md │ │ │ │ └── g_terminal_window.ino │ │ │ ├── h_SDI-12_slave_implementation │ │ │ │ ├── ReadMe.md │ │ │ │ └── h_SDI-12_slave_implementation.ino │ │ │ ├── i_SDI-12_interface │ │ │ │ ├── ReadMe.md │ │ │ │ └── i_SDI-12_interface.ino │ │ │ └── j_external_pcint_library │ │ │ │ ├── ReadMe.md │ │ │ │ └── j_external_pcint_library.ino │ │ ├── keywords.txt │ │ ├── library.json │ │ ├── library.properties │ │ └── src │ │ │ ├── ReadMe.md │ │ │ ├── SDI12.cpp │ │ │ └── SDI12.h │ ├── Sensirion │ │ ├── README.txt │ │ ├── Sensirion.cpp │ │ ├── Sensirion.h │ │ ├── examples │ │ │ ├── NonBlocking │ │ │ │ └── NonBlocking.pde │ │ │ └── SimpleSensirion │ │ │ │ └── SimpleSensirion.pde │ │ └── keywords.txt │ ├── SparkFun_MS5803_I2C │ │ ├── SparkFun_MS5803_I2C.cpp │ │ └── SparkFun_MS5803_I2C.h │ ├── dht │ │ ├── dht.cpp │ │ └── dht.h │ ├── hydrogeolog │ │ ├── hydrogeolog.cpp │ │ └── hydrogeolog.h │ └── rc-switch │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── RCSwitch.cpp │ │ ├── RCSwitch.h │ │ ├── README.md │ │ ├── examples │ │ ├── ReceiveDemo_Advanced │ │ │ ├── ReceiveDemo_Advanced.ino │ │ │ └── output.ino │ │ ├── ReceiveDemo_Simple │ │ │ └── ReceiveDemo_Simple.ino │ │ ├── SendDemo │ │ │ ├── .SendDemo.ino.swp │ │ │ └── SendDemo.ino │ │ ├── TypeA_WithDIPSwitches │ │ │ └── TypeA_WithDIPSwitches.ino │ │ ├── TypeA_WithDIPSwitches_Lightweight │ │ │ └── TypeA_WithDIPSwitches_Lightweight.ino │ │ ├── TypeB_WithRotaryOrSlidingSwitches │ │ │ └── TypeB_WithRotaryOrSlidingSwitches.ino │ │ ├── TypeC_Intertechno │ │ │ └── TypeC_Intertechno.ino │ │ ├── TypeD_REV │ │ │ └── TypeD_REV.ino │ │ └── Webserver │ │ │ └── Webserver.ino │ │ ├── keywords.txt │ │ ├── library.json │ │ └── library.properties ├── load_cell_two_layers_two_controller_digi_ctrl │ └── load_cell_two_layers_two_controller_digi_ctrl.ino ├── loadcell_twolayer_tas606_TE │ └── loadcell_twolayer_tas606_TE.ino ├── loadcell_twolayer_tas606_TE_stringinput │ └── loadcell_twolayer_tas606_TE_stringinput.ino ├── logger3 │ ├── DHT.cpp │ ├── DHT.h │ ├── hydrogeolog │ │ ├── hydrogeolog.cpp │ │ └── hydrogeolog.h │ └── logger3.ino ├── mega_david_logger_1 │ └── mega_david_logger_1.ino ├── mega_david_logger_v3_analog_heat_suction │ └── mega_david_logger_v3_analog_heat_suction.ino ├── mega_logger3_camellias_roof_codes │ └── mega_logger3_camellias_roof_codes.ino ├── mux2_EC5_ARead_DPow_DGnd │ └── mux2_EC5_ARead_DPow_DGnd.ino ├── mux2_moist_1AnaRead_1DigiPowGnD │ └── mux2_moist_1AnaRead_1DigiPowGnD.ino ├── mux2_moist_AnaRead_DigiPow │ └── mux2_moist_AnaRead_DigiPow.ino ├── mux2_moist_AnaRead_DigiPow_DigiGnd │ └── mux2_moist_AnaRead_DigiPow_DigiGnd.ino ├── mux2_moist_AnaRead_DigiPow_Temp_Digiread │ └── mux2_moist_AnaRead_DigiPow_Temp_Digiread.ino ├── separatevalue │ ├── DHT.cpp │ ├── DHT.h │ ├── hydrogeolog │ │ ├── hydrogeolog.cpp │ │ └── hydrogeolog.h │ └── separatevalue.ino ├── sleep_mode │ ├── mega_sleep_wake_by_serial │ │ └── mega_sleep_wake_by_serial.ino │ └── very_deep_sleep │ │ └── very_deep_sleep.ino ├── stanwell │ └── stanwell.ino ├── stanwell_sdi12 │ └── stanwell_sdi12.ino ├── stanwell_sdi12_460 │ └── stanwell_sdi12_460.ino ├── stanwell_sdi12_460_v2 │ ├── Makefile │ ├── SDI12_function.cpp │ ├── SDI12_function.h │ ├── common.h │ ├── platformio.ini │ ├── stanwell_sdi12_460_v2.ino │ ├── timing.cpp │ └── timing.h ├── temp_sensor │ └── temp_sensor.ino ├── tmp36_tmperature_sensor │ └── tmp36_tmperature_sensor.ino ├── weather_default │ ├── SparkFunHTU21D.cpp │ ├── SparkFunHTU21D.h │ ├── SparkFunMPL3115A2.cpp │ ├── SparkFunMPL3115A2.h │ └── weather_default.ino ├── weather_default_improve │ ├── SparkFunMPL3115A2.cpp │ ├── SparkFunMPL3115A2.h │ ├── SparkFun_Si7021_Breakout_Library.cpp │ ├── SparkFun_Si7021_Breakout_Library.h │ └── weather_default_improve.ino ├── weather_default_improve_mps │ ├── SparkFunMPL3115A2.cpp │ ├── SparkFunMPL3115A2.h │ ├── SparkFun_Si7021_Breakout_Library.cpp │ ├── SparkFun_Si7021_Breakout_Library.h │ └── weather_default_improve_mps.ino └── wifi_check │ └── wifi_check.ino ├── bash ├── README.md ├── add_user ├── arduino_read_ec5_mux_shield_roof1.sh ├── arduino_read_moist_DS18x20_sht11_bp_phant.sh ├── arduino_read_weather_station_1.sh ├── arduino_read_weather_station_2.sh ├── area51_2mo_3heatsuc_2salt_2drsuc_gs3_compacted_redmud.sh ├── autossh_first_channel.sh ├── autossh_mango_for_vnc.sh ├── autossh_second_channel.sh ├── autossh_to_sftp_uqgec.sh ├── bacteria.sh ├── cali_2moist_2heatsuc_2salinity_2ceramsuc_phant.sh ├── camera_photo.sh ├── campbell_logging.sh ├── change_wlan0_to_router.sh ├── check_internet_connection_and_reboot_if_needed.sh ├── configure_new_rpi3_strech_as_hydrogeologger.sh ├── ec5_mps2_ds18_weather_uv_pet_et_roof_daisy.sh ├── gelita_watch_update.sh ├── grange_4_type_abd_column_6.sh ├── grange_5_column_4.sh ├── grange_a.sh ├── grange_d.sh ├── hard_reset_system.sh ├── hard_shutdown_pi.sh ├── humidity_chamber.sh ├── kathy_tensiometer.sh ├── loadcell_twolayer_tas606_TE.sh ├── mega_logger1_aster.sh ├── mux_logger2_bougainvillea.sh ├── reboot_pi.sh ├── reset_mcu.sh ├── rs232_ohaus_nvl20000_phant.sh ├── savage_weater_1_mps.sh ├── send_ip_tb.sh ├── serial_session.sh ├── shutdown_pi.sh └── stanwell.sh ├── credential └── readme.md ├── data └── readme ├── html ├── cali_2loadcell_2sucmoist_2moist_2saltrh_2sucheat.html ├── d3_json_multiple_graph.html ├── plot_calibration_geolab_1st_scale.html └── plot_calibrtion_geolab_2sucmoist_2moist_2saltrh_2sucheat.html ├── particle ├── Phant_roof_nosolar │ ├── OneWire.cpp │ ├── OneWire.h │ ├── README.md │ ├── SparkFunPhant.cpp │ ├── SparkFunPhant.h │ ├── SparkFun_Photon_Weather_Phant_Roof.ino │ ├── SparkFun_Photon_Weather_Shield_Library.cpp │ ├── SparkFun_Photon_Weather_Shield_Library.h │ ├── spark-dallas-temperature.cpp │ └── spark-dallas-temperature.h └── SparkFun_Photon_Weather_Phant │ ├── OneWire.cpp │ ├── OneWire.h │ ├── README.md │ ├── SparkFunPhant.cpp │ ├── SparkFunPhant.h │ ├── SparkFun_Photon_Weather_Phant.ino │ ├── SparkFun_Photon_Weather_Shield_Library.cpp │ ├── SparkFun_Photon_Weather_Shield_Library.h │ ├── spark-dallas-temperature.cpp │ └── spark-dallas-temperature.h └── python ├── Felipe.py ├── TB_io_test.py ├── Weather_station_davis ├── README.md ├── WS_roof1_rain_windspd.py └── WS_roof2_winddir_temphumidity.py ├── amrit_amphirol_enclosure_1.py ├── amrit_amphirol_enclosure_2.py ├── area51_2mo_3heatsuc40s_ds18_tmp36_2salt_2drsuc_redmud.py ├── area51_marandoo.py ├── bacteria.py ├── basin_test_cali.py ├── boiling.py ├── cali_2moist_2heatsuc_2salinity_2ceramsuc_phant.py ├── camellia_prototype_logger.py ├── camellia_prototype_weather.py ├── campbell_logging.py ├── campbell_logging_area51_cr1000.py ├── csv_tools.py ├── daisy_prototype_logger.py ├── daisy_prototype_weather.py ├── davis_wind └── UQ_davis_wind.py ├── ec5_mps2_ds18_weather_uv_pet_et_roof_daisy.py ├── ewatering ├── ewatering_sa1_sensor.py ├── ewatering_sa2_sensor.py ├── ewatering_sa3_sensor.py └── weather_sa1.py ├── gelita_pizo_update_mango.py ├── get_ip.pyc ├── gpio_floodlight_camera.py ├── grange_4_type_abd_column_6.py ├── grange_5.py ├── grange_type_D.py ├── grange_type_a.py ├── grange_type_b ├── grange_type_b.py ├── grange_type_b.py_180807 ├── grange_weather_1_mps ├── grange_weather_1_mps.py ├── grange_weather_b_mps ├── grange_weather_b_mps.py ├── humidity_chamber.py ├── kathy_portbris_enclosure_1.py ├── kathy_portbris_enclosure_2.py ├── kathy_tensiometer.py ├── lepton_record.py ├── lib ├── README.md ├── __init__.py └── mqtthelper │ ├── __init__.py │ └── readme.md ├── loadcell_twolayer_tas606_TE.py ├── loggerV1_reset_rpi.py ├── logger_manual_reset.py ├── mega_logger1_aster.py ├── mega_logger3_camellias_roof_codes.py ├── mux_logger_bougainvillea.py ├── pizo.py ├── post_processing ├── class_exp.py ├── class_scale.py ├── class_scale1.py ├── constants.py ├── constants_and_constitutional_laws.py ├── figlib.py ├── init_pandas.py ├── initialize.py ├── interpolate.py ├── pandas_scale.py ├── pandas_scale_py3.py ├── phant_downloader.py ├── polynomial.py ├── sensorfun.py ├── thingsboard_to_pandas.py └── thingsboard_to_pandas_py3.py ├── qal.py ├── railway_tank.py ├── rainFall └── UQ_RainFall_grange5.py ├── read_arduino.py ├── read_arduino_ec5_ts.py ├── read_arduino_loadcell_ts.py ├── read_arduino_save_locally.py ├── read_arduino_sdi12_onewire.py ├── read_arduino_ts.py ├── read_ec5_mps2_D18_roof1_phant.py ├── read_moist_DS18x20_sht11_bp_phant.py ├── read_moist_DS18x20_sht22_scale_bp_phant.py ├── read_weather_station_1_phant.py ├── read_weather_station_1_ts.py ├── read_weather_station_2_ts.py ├── redmud_desiccation ├── README.txt ├── get_data_py3.py ├── sensor_calibration.py ├── sensor_normalization.py └── video.py ├── reset_rpi.py ├── rs232_ohaus_nvl20000_phant.py ├── salt_marsh_sensor.py ├── salt_marsh_weather.py ├── scales_habib ├── scales_habib.py ├── scales_kathy ├── scales_kathy.py ├── scales_partha.py ├── scales_partha_0907.py ├── serial_openlock.pyc ├── serial_read_python3.py ├── stanwell.py ├── tb_to_csv ├── get_data.py ├── get_data_py3.py └── schedule.json ├── upload_phant.pyc ├── utility └── datalogger.v3_test.py ├── wwl1.py ├── wwl2.py ├── wwl_cali.py ├── yuan_20210423.py └── zero_pressure.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore VSCode IDE specific files 2 | **/.vscode/* 3 | 4 | # Python Byte-compiled / optimized / DLL files 5 | __pycache__/ 6 | *.py[cod] 7 | 8 | # Platformio Files 9 | **/.pio/* -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | ## Arduino Firmware Directory 3 | ~\pyduino\arduino\stanwell_sdi12_460_v2 4 | 5 | In linux: can use makefile 6 | ``` 7 | make upload 8 | make softupload 9 | ``` 10 | 11 | 12 | # Serial Example 13 | in serial connection: 14 | 15 | ``` 16 | RESET 17 | ``` 18 | -- will reset raspberry pi in 21 seconds 19 | 20 | 21 | 22 | 23 | ```python 24 | read_suction_sensor(ard,input_command="dht22,10,power,48,points,2,dummies,1,interval_mm,200,debug,1",names_address={'humidity':11,'temp_air':10},delimiter=',') 25 | ``` 26 | 27 | 28 | TO200904 It would be better not install multiple analog sensor in to one analog channel as it will be interfered by the neighbouring sensors. --- learned from redmud amphirol case study. 29 | 30 | 31 | TO201118 lists of commands used for version 3 datalogger 32 | 33 | on board humidity sensor: 34 | 35 | ``` 36 | dht22,54,power,2,points,2,dummies,1,interval_mm,200,debug,1 37 | ``` 38 | 39 | 40 | Reading the onboard DC voltage (VSENSE, requiring the pins are propoerly setup) 41 | ``` 42 | analog,15,power,9,points,5,dummies,3,interval_mm,200,257.00, 43 | ``` 44 | 45 | 46 | Thermal suction sensor 47 | ``` 48 | fred,5A22A047,dgin,18,snpw,26,htpw,23,itv,6000,otno,5 49 | ``` 50 | 51 | SDI12 decagon moisture sensor: 52 | 53 | ``` 54 | SDI-12,53,power,46,default_cmd,read,debug,1 55 | ``` 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /arduino/AnalogReadSerial/AnalogReadSerial.ino: -------------------------------------------------------------------------------- 1 | /* 2 | AnalogReadSerial 3 | Reads an analog input on pin 0, prints the result to the serial monitor. 4 | Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. 5 | 6 | This example code is in the public domain. 7 | */ 8 | 9 | // the setup routine runs once when you press reset: 10 | void setup() { 11 | // initialize serial communication at 9600 bits per second: 12 | Serial.begin(9600); 13 | pinMode(0,INPUT_PULLUP); 14 | pinMode(1,INPUT_PULLUP); 15 | pinMode(2,INPUT_PULLUP); 16 | } 17 | 18 | // the loop routine runs over and over again forever: 19 | void loop() { 20 | // read the input on analog pin 0: 21 | int sensorValue = analogRead(A0); 22 | delay(1000); 23 | int sensorValue1 = analogRead(A1); 24 | delay(1000); 25 | int sensorValue2 = analogRead(A2); 26 | // print out the value you read: 27 | Serial.print(sensorValue); 28 | // by this way data could be print in a row 29 | Serial.print(','); 30 | // if it is println, the next print will start from the beginning of the next row 31 | Serial.print(sensorValue1); 32 | Serial.print(','); 33 | // if it is println, the next print will start from the beginning of the next row 34 | Serial.println(sensorValue2); 35 | //Serial.print('\t') //this prints a tab 36 | delay(3000); // delay in between reads for stability 37 | } 38 | -------------------------------------------------------------------------------- /arduino/AnalogReadSerial_allpins/AnalogReadSerial_allpins.ino: -------------------------------------------------------------------------------- 1 | /* 2 | AnalogReadSerial 3 | Reads an analog input on pin 0, prints the result to the serial monitor. 4 | Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. 5 | 6 | This example code is in the public domain. 7 | */ 8 | 9 | static const uint8_t analog_pins[] = {A0,A1,A2,A3,A4,A5}; 10 | int AnalogVals1[3]; 11 | int AnalogVals2[3]; 12 | // the delimiter between each reading. it is good to use ',' alwyas 13 | char seperator=','; 14 | //Arrays to store analog values after recieving them 15 | int number_sensors=3; 16 | // the setup routine runs once when you press reset: 17 | void setup() { 18 | // initialize serial communication at 9600 bits per second: 19 | Serial.begin(9600); 20 | // let all of the pins as output 21 | pinMode(0,OUTPUT); 22 | pinMode(1,OUTPUT); 23 | pinMode(2,OUTPUT); 24 | pinMode(3,OUTPUT); 25 | pinMode(4,OUTPUT); 26 | pinMode(5,OUTPUT); 27 | pinMode(6,OUTPUT); 28 | pinMode(7,OUTPUT); 29 | } 30 | 31 | // the loop routine runs over and over again forever: 32 | void loop() { 33 | // read the input on analog pin 0: 34 | 35 | 36 | for (int i=0; i= 100 10 | #include "Arduino.h" 11 | #else 12 | #include "WProgram.h" 13 | #endif 14 | 15 | 16 | // Uncomment to enable printing out nice debug messages. 17 | //#define DHT_DEBUG 18 | 19 | // Define where debug output will be printed. 20 | #define DEBUG_PRINTER Serial 21 | 22 | // Setup debug printing macros. 23 | #ifdef DHT_DEBUG 24 | #define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); } 25 | #define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); } 26 | #else 27 | #define DEBUG_PRINT(...) {} 28 | #define DEBUG_PRINTLN(...) {} 29 | #endif 30 | 31 | // Define types of sensors. 32 | #define DHT11 11 33 | #define DHT22 22 34 | #define DHT21 21 35 | #define AM2301 21 36 | 37 | 38 | class DHT { 39 | public: 40 | DHT(uint8_t pin, uint8_t type, uint8_t count=6); 41 | void begin(void); 42 | float readTemperature(bool S=false, bool force=false); 43 | float convertCtoF(float); 44 | float convertFtoC(float); 45 | float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true); 46 | float readHumidity(bool force=false); 47 | boolean read(bool force=false); 48 | 49 | private: 50 | uint8_t data[5]; 51 | uint8_t _pin, _type; 52 | #ifdef __AVR 53 | // Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask 54 | // for the digital pin connected to the DHT. Other platforms will use digitalRead. 55 | uint8_t _bit, _port; 56 | #endif 57 | uint32_t _lastreadtime, _maxcycles; 58 | bool _lastresult; 59 | 60 | uint32_t expectPulse(bool level); 61 | 62 | }; 63 | 64 | class InterruptLock { 65 | public: 66 | InterruptLock() { 67 | noInterrupts(); 68 | } 69 | ~InterruptLock() { 70 | interrupts(); 71 | } 72 | 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /arduino/Mega_DHT22_DS18x20_temp_ana1_digi1_bp/DHT.h: -------------------------------------------------------------------------------- 1 | /* DHT library 2 | 3 | MIT license 4 | written by Adafruit Industries 5 | */ 6 | #ifndef DHT_H 7 | #define DHT_H 8 | 9 | #if ARDUINO >= 100 10 | #include "Arduino.h" 11 | #else 12 | #include "WProgram.h" 13 | #endif 14 | 15 | 16 | // Uncomment to enable printing out nice debug messages. 17 | //#define DHT_DEBUG 18 | 19 | // Define where debug output will be printed. 20 | #define DEBUG_PRINTER Serial 21 | 22 | // Setup debug printing macros. 23 | #ifdef DHT_DEBUG 24 | #define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); } 25 | #define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); } 26 | #else 27 | #define DEBUG_PRINT(...) {} 28 | #define DEBUG_PRINTLN(...) {} 29 | #endif 30 | 31 | // Define types of sensors. 32 | #define DHT11 11 33 | #define DHT22 22 34 | #define DHT21 21 35 | #define AM2301 21 36 | 37 | 38 | class DHT { 39 | public: 40 | DHT(uint8_t pin, uint8_t type, uint8_t count=6); 41 | void begin(void); 42 | float readTemperature(bool S=false, bool force=false); 43 | float convertCtoF(float); 44 | float convertFtoC(float); 45 | float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true); 46 | float readHumidity(bool force=false); 47 | boolean read(bool force=false); 48 | 49 | private: 50 | uint8_t data[5]; 51 | uint8_t _pin, _type; 52 | #ifdef __AVR 53 | // Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask 54 | // for the digital pin connected to the DHT. Other platforms will use digitalRead. 55 | uint8_t _bit, _port; 56 | #endif 57 | uint32_t _lastreadtime, _maxcycles; 58 | bool _lastresult; 59 | 60 | uint32_t expectPulse(bool level); 61 | 62 | }; 63 | 64 | class InterruptLock { 65 | public: 66 | InterruptLock() { 67 | noInterrupts(); 68 | } 69 | ~InterruptLock() { 70 | interrupts(); 71 | } 72 | 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /arduino/Mega_one_digi_one_ana_2_13/Mega_one_digi_one_ana_2_13.ino: -------------------------------------------------------------------------------- 1 | 2 | // below is needed for analog sensor 3 | 4 | static const uint8_t analog_pins[] = {A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13}; 5 | // the array below works for digital sensor arrays 6 | int digital_pins[] = {2, 3, 4, 5, 6, 7,8,9,10,11,12,13}; 7 | float analogvals1[12]; 8 | int i; 9 | // the delimiter between each reading. it is good to use ',' alwyas 10 | char seperator=','; 11 | //Arrays to store analog values after recieving them 12 | int number_sensors=12; 13 | // the setup routine runs once when you press reset: 14 | 15 | int number_readings=20; 16 | 17 | int dummy_readings=30; 18 | 19 | void setup() { 20 | // initialize serial communication at 9600 bits per second: 21 | Serial.begin(9600); 22 | // let all of the digital pins as output 23 | for (int i=0; i 4 | 5 | //Initialize the Mux Shield 6 | MuxShield muxShield; 7 | 8 | void setup() 9 | { 10 | //open up the internal pull-up resistor 11 | // it is confirmed that if using a 10k ohm +-5% resistor between 5+ and gnd, 12 | // the noise will be completely removed. TO160905. 13 | // However: if both the resistor and the following code 14 | pinMode(A0,INPUT_PULLDOWN); 15 | pinMode(A1,INPUT_PULLDOWN); 16 | pinMode(A2,INPUT_PULLDOWN); 17 | 18 | //Set I/O 1, I/O 2, and I/O 3 as analog inputs 19 | muxShield.setMode(1,ANALOG_IN); 20 | muxShield.setMode(2,ANALOG_IN); 21 | muxShield.setMode(3,ANALOG_IN); 22 | 23 | Serial.begin(9600); 24 | } 25 | 26 | //Arrays to store analog values after recieving them 27 | //int IO1AnalogVals[16]; 28 | int IO2AnalogVals[16]; 29 | //int IO3AnalogVals[16]; 30 | 31 | void loop() 32 | { 33 | //digitalWrite(A1, LOW); 34 | //digitalWrite(A0, LOW); 35 | int delay_mmsec=200; 36 | int number_sensors=16; 37 | for (int i=0; i= 100 10 | #include "Arduino.h" 11 | #else 12 | #include "WProgram.h" 13 | #endif 14 | 15 | 16 | // Uncomment to enable printing out nice debug messages. 17 | //#define DHT_DEBUG 18 | 19 | // Define where debug output will be printed. 20 | #define DEBUG_PRINTER Serial 21 | 22 | // Setup debug printing macros. 23 | #ifdef DHT_DEBUG 24 | #define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); } 25 | #define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); } 26 | #else 27 | #define DEBUG_PRINT(...) {} 28 | #define DEBUG_PRINTLN(...) {} 29 | #endif 30 | 31 | // Define types of sensors. 32 | #define DHT11 11 33 | #define DHT22 22 34 | #define DHT21 21 35 | #define AM2301 21 36 | 37 | 38 | class DHT { 39 | public: 40 | DHT(uint8_t pin, uint8_t type, uint8_t count=6); 41 | void begin(void); 42 | float readTemperature(bool S=false, bool force=false); 43 | float convertCtoF(float); 44 | float convertFtoC(float); 45 | float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true); 46 | float readHumidity(bool force=false); 47 | boolean read(bool force=false); 48 | 49 | private: 50 | uint8_t data[5]; 51 | uint8_t _pin, _type; 52 | #ifdef __AVR 53 | // Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask 54 | // for the digital pin connected to the DHT. Other platforms will use digitalRead. 55 | uint8_t _bit, _port; 56 | #endif 57 | uint32_t _lastreadtime, _maxcycles; 58 | bool _lastresult; 59 | 60 | uint32_t expectPulse(bool level); 61 | 62 | }; 63 | 64 | class InterruptLock { 65 | public: 66 | InterruptLock() { 67 | noInterrupts(); 68 | } 69 | ~InterruptLock() { 70 | interrupts(); 71 | } 72 | 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /arduino/Test_time/Test_time.ino: -------------------------------------------------------------------------------- 1 | /* 2 | AnalogReadSerial 3 | Reads an analog input on pin 0, prints the result to the serial monitor. 4 | Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. 5 | 6 | This example code is in the public domain. 7 | */ 8 | // http://playground.arduino.cc/Code/time 9 | #include 10 | 11 | #define TIME_MSG_LEN 11 // time sync to PC is HEADER followed by Unix time_t as ten ASCII digits 12 | #define TIME_HEADER 'T' // Header tag for serial time sync message 13 | #define TIME_REQUEST 7 // ASCII bell character requests a time sync message 14 | 15 | 16 | // the setup routine runs once when you press reset: 17 | void setup() { 18 | // // all defination associated with time 19 | // // http://playground.arduino.cc/Code/DateTime 20 | // #include 21 | // #include 22 | // 23 | // #define TIME_MSG_LEN 11 // time sync to PC is HEADER and unix time_t as ten ascii digits 24 | // #define TIME_HEADER 255 // Header tag for serial time sync message 25 | 26 | // initialize serial communication at 9600 bits per second: 27 | Serial.begin(9600); 28 | pinMode(0,INPUT_PULLUP); 29 | pinMode(1,INPUT_PULLUP); 30 | pinMode(2,INPUT_PULLUP); 31 | //getPCtime(); // try to get time sync from pc 32 | } 33 | 34 | // the loop routine runs over and over again forever: 35 | void loop() { 36 | // read the input on analog pin 0: 37 | int sensorValue0 = analogRead(A0); 38 | delay(1000); 39 | int sensorValue1 = analogRead(A1); 40 | delay(1000); 41 | int sensorValue2 = analogRead(A2); 42 | // print out the value you read: 43 | Serial.print(year()); 44 | Serial.print('/'); 45 | Serial.print(month()); 46 | Serial.print('/'); 47 | Serial.print(day()); 48 | Serial.print(','); 49 | Serial.print(hour()); 50 | Serial.print(':'); 51 | Serial.print(minute()); 52 | Serial.print(':'); 53 | Serial.print(second()); 54 | Serial.print(','); 55 | 56 | Serial.print(sensorValue0); 57 | // by this way data could be print in a row 58 | Serial.print(','); 59 | // if it is println, the next print will start from the beginning of the next row 60 | Serial.print(sensorValue1); 61 | Serial.print(','); 62 | // if it is println, the next print will start from the beginning of the next row 63 | Serial.println(sensorValue2); 64 | //Serial.print('\t') //this prints a tab 65 | delay(3000); // delay in between reads for stability 66 | } 67 | 68 | 69 | 70 | 71 | 72 | void processSyncMessage() { 73 | // if time sync available from serial port, update time and return true 74 | while(Serial.available() >= TIME_MSG_LEN ){ // time message consists of header & 10 ASCII digits 75 | char c = Serial.read() ; 76 | Serial.print(c); 77 | if( c == TIME_HEADER ) { 78 | time_t pctime = 0; 79 | for(int i=0; i < TIME_MSG_LEN -1; i++){ 80 | c = Serial.read(); 81 | if( c >= '0' && c <= '9'){ 82 | pctime = (10 * pctime) + (c - '0') ; // convert digits to a number 83 | } 84 | } 85 | setTime(pctime); // Sync Arduino clock to the time received on the serial port 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /arduino/ciao/ciao.ino: -------------------------------------------------------------------------------- 1 | /* 2 | File: RestClient.ino 3 | This example makes an HTTP request after 10 seconds and shows the result both in 4 | serial monitor and in the wifi console of the Arduino Uno WiFi. 5 | 6 | Note: works only with Arduino Uno WiFi Developer Edition. 7 | 8 | http://www.arduino.org/learning/tutorials/boards-tutorials/restserver-and-restclient 9 | */ 10 | 11 | #include 12 | #include 13 | const char* connector = "rest"; 14 | const char* server = "144.6.225.24"; 15 | const char* method = "GET"; 16 | //const char* method = "POST"; 17 | //const char* resource = "/latest.txt"; 18 | const char* resource = "/input/2DG1298g0PSMaX9JeYJeHwNQPxma?private_key=vVW3MzgNmDt3BD7ja5jaH7LrMAlg&humidity=3.51&temp=22.69"; 19 | void setup() { 20 | //http://144.6.225.24:8080/input/2DG1298g0PSMaX9JeYJeHwNQPxma?private_key=vVW3MzgNmDt3BD7ja5jaH7LrMAlg&humidity=3.51&temp=22.69 21 | 22 | //String uri = "/input/2DG1298g0PSMaX9JeYJeHwNQPxma?private_key=vVW3MzgNmDt3BD7ja5jaH7LrMAlg&humidity=3.51&temp=22.69"; 23 | Serial.begin(9600); 24 | Ciao.begin(); 25 | 26 | pinMode(2, INPUT); 27 | //char * CONNECTOR = "rest"; 28 | //char * SERVER_ADDR = "144.6.225.24:8080"; 29 | delay(10000); 30 | //doRequest(connector, server, resource, method); 31 | //CiaoData data = Ciao.write(CONNECTOR,SERVER_ADDR, uri,method); 32 | Serial.println(server); 33 | Serial.println(resource); 34 | CiaoData data = Ciao.write(connector, server, resource); 35 | } 36 | 37 | void loop() { 38 | delay(5000); 39 | CiaoData data = Ciao.write(connector, server, resource); 40 | } 41 | 42 | void doRequest(const char* conn, const char* server, const char* command, const char* method){ 43 | CiaoData data = Ciao.write(conn, server, command, method); 44 | if (!data.isEmpty()){ 45 | Ciao.println( "State: " + String (data.get(1)) ); 46 | Ciao.println( "Response: " + String (data.get(2)) ); 47 | Serial.println( "State: " + String (data.get(1)) ); 48 | Serial.println( "Response: " + String (data.get(2)) ); 49 | } 50 | else{ 51 | Ciao.println ("Write Error"); 52 | Serial.println ("Write Error"); 53 | } 54 | delay(5000); 55 | } 56 | -------------------------------------------------------------------------------- /arduino/column_aster/column_aster.ino: -------------------------------------------------------------------------------- 1 | static const uint8_t moist_analog_pins[] = {A0,A1,A2,A3,A4,A5,A6,A7,A8,A9}; 2 | // the array below works for digital sensor arrays 3 | int moist_digital_pins[] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; 4 | float moist_data[10]; 5 | int i; 6 | // the delimiter between each reading. it is good to use ',' alwyas 7 | char delimiter=','; 8 | //Arrays to store analog values after recieving them 9 | int moist_number_sensors=10; 10 | // the setup routine runs once when you press reset: 11 | 12 | 13 | int moist_number_readings=11; 14 | 15 | int moist_dummy_readings=4; 16 | void setup() { 17 | // initialize serial communication at 9600 bits per second: 18 | Serial.begin(9600); 19 | // let all of the pins as output 20 | 21 | for (int i=0; i= 100 10 | #include "Arduino.h" 11 | #else 12 | #include "WProgram.h" 13 | #endif 14 | 15 | 16 | // Uncomment to enable printing out nice debug messages. 17 | //#define DHT_DEBUG 18 | 19 | // Define where debug output will be printed. 20 | #define DEBUG_PRINTER Serial 21 | 22 | // Setup debug printing macros. 23 | #ifdef DHT_DEBUG 24 | #define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); } 25 | #define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); } 26 | #else 27 | #define DEBUG_PRINT(...) {} 28 | #define DEBUG_PRINTLN(...) {} 29 | #endif 30 | 31 | // Define types of sensors. 32 | #define DHT11 11 33 | #define DHT22 22 34 | #define DHT21 21 35 | #define AM2301 21 36 | 37 | 38 | class DHT { 39 | public: 40 | DHT(uint8_t pin, uint8_t type, uint8_t count=6); 41 | void begin(void); 42 | float readTemperature(bool S=false, bool force=false); 43 | float convertCtoF(float); 44 | float convertFtoC(float); 45 | float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true); 46 | float readHumidity(bool force=false); 47 | boolean read(bool force=false); 48 | 49 | private: 50 | uint8_t data[5]; 51 | uint8_t _pin, _type; 52 | #ifdef __AVR 53 | // Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask 54 | // for the digital pin connected to the DHT. Other platforms will use digitalRead. 55 | uint8_t _bit, _port; 56 | #endif 57 | uint32_t _lastreadtime, _maxcycles; 58 | bool _lastresult; 59 | 60 | uint32_t expectPulse(bool level); 61 | 62 | }; 63 | 64 | class InterruptLock { 65 | public: 66 | InterruptLock() { 67 | noInterrupts(); 68 | } 69 | ~InterruptLock() { 70 | interrupts(); 71 | } 72 | 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /arduino/libraries/Adafruit_SHT31/.Adafruit_SHT31.h.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hydrogeologger/pyduino/47b96c04b8c070ca040bc57824ee28e49d4c7033/arduino/libraries/Adafruit_SHT31/.Adafruit_SHT31.h.swp -------------------------------------------------------------------------------- /arduino/libraries/Adafruit_SHT31/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for opening an issue on an Adafruit Arduino library repository. To 2 | improve the speed of resolution please review the following guidelines and 3 | common troubleshooting steps below before creating the issue: 4 | 5 | - **Do not use GitHub issues for troubleshooting projects and issues.** Instead use 6 | the forums at http://forums.adafruit.com to ask questions and troubleshoot why 7 | something isn't working as expected. In many cases the problem is a common issue 8 | that you will more quickly receive help from the forum community. GitHub issues 9 | are meant for known defects in the code. If you don't know if there is a defect 10 | in the code then start with troubleshooting on the forum first. 11 | 12 | - **If following a tutorial or guide be sure you didn't miss a step.** Carefully 13 | check all of the steps and commands to run have been followed. Consult the 14 | forum if you're unsure or have questions about steps in a guide/tutorial. 15 | 16 | - **For Arduino projects check these very common issues to ensure they don't apply**: 17 | 18 | - For uploading sketches or communicating with the board make sure you're using 19 | a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes 20 | very hard to tell the difference between a data and charge cable! Try using the 21 | cable with other devices or swapping to another cable to confirm it is not 22 | the problem. 23 | 24 | - **Be sure you are supplying adequate power to the board.** Check the specs of 25 | your board and plug in an external power supply. In many cases just 26 | plugging a board into your computer is not enough to power it and other 27 | peripherals. 28 | 29 | - **Double check all soldering joints and connections.** Flakey connections 30 | cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints. 31 | 32 | - **Ensure you are using an official Arduino or Adafruit board.** We can't 33 | guarantee a clone board will have the same functionality and work as expected 34 | with this code and don't support them. 35 | 36 | If you're sure this issue is a defect in the code and checked the steps above 37 | please fill in the following fields to provide enough troubleshooting information. 38 | You may delete the guideline and text above to just leave the following details: 39 | 40 | - Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE** 41 | 42 | - Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO 43 | VERSION HERE** 44 | 45 | - List the steps to reproduce the problem below (if possible attach a sketch or 46 | copy the sketch code in too): **LIST REPRO STEPS BELOW** 47 | -------------------------------------------------------------------------------- /arduino/libraries/Adafruit_SHT31/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for creating a pull request to contribute to Adafruit's GitHub code! 2 | Before you open the request please review the following guidelines and tips to 3 | help it be more easily integrated: 4 | 5 | - **Describe the scope of your change--i.e. what the change does and what parts 6 | of the code were modified.** This will help us understand any risks of integrating 7 | the code. 8 | 9 | - **Describe any known limitations with your change.** For example if the change 10 | doesn't apply to a supported platform of the library please mention it. 11 | 12 | - **Please run any tests or examples that can exercise your modified code.** We 13 | strive to not break users of the code and running tests/examples helps with this 14 | process. 15 | 16 | Thank you again for contributing! We will try to test and integrate the change 17 | as soon as we can, but be aware we have many GitHub repositories to manage and 18 | can't immediately respond to every request. There is no need to bump or check in 19 | on a pull request (it will clutter the discussion of the request). 20 | 21 | Also don't be worried if the request is closed or not integrated--sometimes the 22 | priorities of Adafruit's GitHub code (education, ease of use) might not match the 23 | priorities of the pull request. Don't fret, the open source community thrives on 24 | forks and GitHub makes it easy to keep your changes in a forked repo. 25 | 26 | After reviewing the guidelines above you can delete this text from the pull request. 27 | -------------------------------------------------------------------------------- /arduino/libraries/Adafruit_SHT31/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | sudo: false 3 | cache: 4 | directories: 5 | - ~/arduino_ide 6 | - ~/.arduino15/packages/ 7 | git: 8 | depth: false 9 | quiet: true 10 | env: 11 | global: 12 | - ARDUINO_IDE_VERSION="1.8.7" 13 | - PRETTYNAME="Adafruit SHT31-D Library" 14 | # Optional, will default to "$TRAVIS_BUILD_DIR/Doxyfile" 15 | # - DOXYFILE: $TRAVIS_BUILD_DIR/Doxyfile 16 | 17 | before_install: 18 | - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh) 19 | 20 | install: 21 | - true 22 | 23 | script: 24 | - build_main_platforms 25 | 26 | # Generate and deploy documentation 27 | after_success: 28 | - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/library_check.sh) 29 | - source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/doxy_gen_and_deploy.sh) 30 | -------------------------------------------------------------------------------- /arduino/libraries/Adafruit_SHT31/README.md: -------------------------------------------------------------------------------- 1 | # Adafruit SHT31-D Temperature and Humidity Sensor Breakout [![Build Status](https://travis-ci.org/adafruit/Adafruit_SHT31.svg?branch=master)](https://travis-ci.org/adafruit/Adafruit_SHT31) 2 | 3 | ![Adafruit SHT31](https://cdn-learn.adafruit.com/assets/assets/000/028/970/small360/adafruit_products_2857_iso_ORIG.jpg?1449606376) 4 | 5 | This is a library for the SHT31 Digital Humidity + Temp sensor. 6 | 7 | It is designed specifically to work with the SHT31 Digital in the Adafruit shop: 8 | 9 | - https://www.adafruit.com/products/2857 10 | 11 | These sensors use **I2C** to communicate, 2 pins are required to interface 12 | 13 | Adafruit invests time and resources providing this open source code, 14 | please support Adafruit and open-source hardware by purchasing 15 | products from Adafruit! 16 | 17 | Written by Limor Fried/Ladyada for Adafruit Industries. 18 | BSD license, all text above must be included in any redistribution 19 | 20 | Check out the links above for our tutorials and wiring diagrams 21 | 22 | ## Installation 23 | 24 | Use the Arduino Library Manager to install this library. If you're unfamiliar 25 | with how this works, we have a great tutorial on Arduino library installation 26 | at: http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use 27 | 28 | 29 | 30 | ## Compatibility 31 | 32 | MCU | Tested Works | Doesn't Work | Not Tested | Notes 33 | ------------------ | :----------: | :----------: | :---------: | ----- 34 | Atmega328 @ 16MHz | X | | | 35 | Atmega328 @ 12MHz | X | | | 36 | Atmega32u4 @ 16MHz | X | | | 37 | Atmega32u4 @ 8MHz | X | | | 38 | ESP8266 | X | | | 39 | Atmega2560 @ 16MHz | X | | | 40 | ATSAM3X8E | X | | | 41 | ATSAM21D | X | | | 42 | ATtiny85 @ 16MHz | X | | | 43 | ATtiny85 @ 8MHz | X | | | 44 | Intel Curie @ 32MHz | | | X | 45 | STM32F2 | | | X | 46 | 47 | * ATmega328 @ 16MHz : Arduino UNO, Adafruit Pro Trinket 5V, Adafruit Metro 328, Adafruit Metro Mini 48 | * ATmega328 @ 12MHz : Adafruit Pro Trinket 3V 49 | * ATmega32u4 @ 16MHz : Arduino Leonardo, Arduino Micro, Arduino Yun, Teensy 2.0 50 | * ATmega32u4 @ 8MHz : Adafruit Flora, Bluefruit Micro 51 | * ESP8266 : Adafruit Huzzah 52 | * ATmega2560 @ 16MHz : Arduino Mega 53 | * ATSAM3X8E : Arduino Due 54 | * ATSAM21D : Arduino Zero, M0 Pro 55 | * ATtiny85 @ 16MHz : Adafruit Trinket 5V 56 | * ATtiny85 @ 8MHz : Adafruit Gemma, Arduino Gemma, Adafruit Trinket 3V 57 | 58 | 59 | -------------------------------------------------------------------------------- /arduino/libraries/Adafruit_SHT31/examples/SHT31test/SHT31test.ino: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is an example for the SHT31-D Humidity & Temp Sensor 3 | 4 | Designed specifically to work with the SHT31-D sensor from Adafruit 5 | ----> https://www.adafruit.com/products/2857 6 | 7 | These sensors use I2C to communicate, 2 pins are required to 8 | interface 9 | ****************************************************/ 10 | 11 | #include 12 | #include 13 | #include "Adafruit_SHT31.h" 14 | 15 | Adafruit_SHT31 sht31 = Adafruit_SHT31(); 16 | 17 | void setup() { 18 | Serial.begin(9600); 19 | 20 | while (!Serial) 21 | delay(10); // will pause Zero, Leonardo, etc until serial console opens 22 | 23 | Serial.println("SHT31 test"); 24 | if (! sht31.begin(0x44)) { // Set to 0x45 for alternate i2c addr 25 | Serial.println("Couldn't find SHT31"); 26 | while (1) delay(1); 27 | } 28 | } 29 | 30 | 31 | void loop() { 32 | float t = sht31.readTemperature(); 33 | float h = sht31.readHumidity(); 34 | 35 | if (! isnan(t)) { // check if 'is not a number' 36 | Serial.print("Temp *C = "); Serial.println(t); 37 | } else { 38 | Serial.println("Failed to read temperature"); 39 | } 40 | 41 | if (! isnan(h)) { // check if 'is not a number' 42 | Serial.print("Hum. % = "); Serial.println(h); 43 | } else { 44 | Serial.println("Failed to read humidity"); 45 | } 46 | Serial.println(); 47 | delay(1000); 48 | } -------------------------------------------------------------------------------- /arduino/libraries/Adafruit_SHT31/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit SHT31 Library 2 | version=1.1.0 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Arduino library for SHT31 temperature & humidity sensor. 6 | paragraph=Arduino library for SHT31 temperature & humidity sensor. 7 | category=Sensors 8 | url=https://github.com/adafruit/Adafruit_SHT31 9 | architectures=* 10 | -------------------------------------------------------------------------------- /arduino/libraries/Adafruit_SI1145_Library/README.txt: -------------------------------------------------------------------------------- 1 | This is a library for the Si1145 UV/IR/Visible Light Sensor 2 | 3 | Designed specifically to work with the Si1145 sensor in the adafruit shop 4 | ----> https://www.adafruit.com/products/1777 5 | 6 | These sensors use I2C to communicate, 2 pins are required to 7 | interface 8 | Adafruit invests time and resources providing this open source code, 9 | please support Adafruit and open-source hardware by purchasing 10 | products from Adafruit! 11 | 12 | Check out the links above for our tutorials and wiring diagrams 13 | 14 | Written by Limor Fried/Ladyada for Adafruit Industries. 15 | BSD license, all text above must be included in any redistribution 16 | 17 | To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_SI1145. Check that the Adafruit_SI1145 folder contains Adafruit_SI1145.cpp and Adafruit_SI1145.h 18 | 19 | Place the Adafruit_SI1145 library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. -------------------------------------------------------------------------------- /arduino/libraries/Adafruit_SI1145_Library/examples/si1145test/si1145test.ino: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for the Si1145 UV/IR/Visible Light Sensor 3 | 4 | Designed specifically to work with the Si1145 sensor in the 5 | adafruit shop 6 | ----> https://www.adafruit.com/products/1777 7 | 8 | These sensors use I2C to communicate, 2 pins are required to 9 | interface 10 | Adafruit invests time and resources providing this open source code, 11 | please support Adafruit and open-source hardware by purchasing 12 | products from Adafruit! 13 | 14 | Written by Limor Fried/Ladyada for Adafruit Industries. 15 | BSD license, all text above must be included in any redistribution 16 | ****************************************************/ 17 | 18 | #include 19 | #include "Adafruit_SI1145.h" 20 | 21 | Adafruit_SI1145 uv = Adafruit_SI1145(); 22 | 23 | void setup() { 24 | Serial.begin(9600); 25 | 26 | Serial.println("Adafruit SI1145 test"); 27 | 28 | if (! uv.begin()) { 29 | Serial.println("Didn't find Si1145"); 30 | while (1); 31 | } 32 | 33 | Serial.println("OK!"); 34 | } 35 | 36 | void loop() { 37 | Serial.println("==================="); 38 | Serial.print("Vis: "); Serial.println(uv.readVisible()); 39 | Serial.print("IR: "); Serial.println(uv.readIR()); 40 | 41 | // Uncomment if you have an IR LED attached to LED pin! 42 | //Serial.print("Prox: "); Serial.println(uv.readProx()); 43 | 44 | float UVindex = uv.readUV(); 45 | // the index is multiplied by 100 so to get the 46 | // integer index, divide by 100! 47 | UVindex /= 100.0; 48 | Serial.print("UV: "); Serial.println(UVindex); 49 | 50 | delay(1000); 51 | } -------------------------------------------------------------------------------- /arduino/libraries/Adafruit_SI1145_Library/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit SI1145 Library 2 | version=1.0.0 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Arduino library for the SI1145 sensors in the Adafruit shop 6 | paragraph=Arduino library for the SI1145 sensors in the Adafruit shop 7 | category=Sensors 8 | url=https://github.com/adafruit/Adafruit_SI1145_Library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /arduino/libraries/DallasTemperature/README.md: -------------------------------------------------------------------------------- 1 | # Arduino Library for Maxim Temperature Integrated Circuits 2 | 3 | ## Usage 4 | 5 | This library supports the following devices : 6 | 7 | 8 | * DS18B20 9 | * DS18S20 - Please note there appears to be an issue with this series. 10 | * DS1822 11 | * DS1820 12 | 13 | 14 | You will need a pull-up resistor of about 5 KOhm between the 1-Wire data line 15 | and your 5V power. If you are using the DS18B20, ground pins 1 and 3. The 16 | centre pin is the data line '1-wire'. 17 | 18 | We have included a "REQUIRESNEW" and "REQUIRESALARMS" definition. If you 19 | want to slim down the code feel free to use either of these by including 20 | 21 | 22 | 23 | #define REQUIRESNEW 24 | 25 | or 26 | 27 | #define REQUIRESALARMS 28 | 29 | 30 | at the top of DallasTemperature.h 31 | 32 | 33 | ## Credits 34 | 35 | The OneWire code has been derived from 36 | http://www.arduino.cc/playground/Learning/OneWire. 37 | Miles Burton originally developed this library. 38 | Tim Newsome added support for multiple sensors on 39 | the same bus. 40 | Guil Barros [gfbarros@bappos.com] added getTempByAddress (v3.5) 41 | Rob Tillaart [rob.tillaart@gmail.com] added async modus (v3.7.0) 42 | 43 | 44 | ## Website 45 | 46 | 47 | You can find the latest version of the library at 48 | http://milesburton.com/index.php?title=Dallas_Temperature_Control_Library 49 | 50 | # License 51 | 52 | This library is free software; you can redistribute it and/or 53 | modify it under the terms of the GNU Lesser General Public 54 | License as published by the Free Software Foundation; either 55 | version 2.1 of the License, or (at your option) any later version. 56 | 57 | This library is distributed in the hope that it will be useful, 58 | but WITHOUT ANY WARRANTY; without even the implied warranty of 59 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 60 | Lesser General Public License for more details. 61 | 62 | You should have received a copy of the GNU Lesser General Public 63 | License along with this library; if not, write to the Free Software 64 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 65 | -------------------------------------------------------------------------------- /arduino/libraries/DallasTemperature/examples/Multibus_simple/Multibus_simple.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int oneWirePins[]={3,7};//OneWire DS18x20 temperature sensors on these wires 5 | const int oneWirePinsCount=sizeof(oneWirePins)/sizeof(int); 6 | 7 | OneWire ds18x20[oneWirePinsCount]; 8 | DallasTemperature sensor[oneWirePinsCount]; 9 | 10 | 11 | void setup(void) { 12 | // start serial port 13 | Serial.begin(9600); 14 | Serial.println("Dallas Temperature Multiple Bus Control Library Simple Demo"); 15 | Serial.print("============Ready with "); 16 | Serial.print(oneWirePinsCount); 17 | Serial.println(" Sensors================"); 18 | 19 | // Start up the library on all defined bus-wires 20 | DeviceAddress deviceAddress; 21 | for (int i=0; i 3 | #include 4 | 5 | // Data wire is plugged into port 2 on the Arduino 6 | #define ONE_WIRE_BUS 2 7 | 8 | // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) 9 | OneWire oneWire(ONE_WIRE_BUS); 10 | 11 | // Pass our oneWire reference to Dallas Temperature. 12 | DallasTemperature sensors(&oneWire); 13 | 14 | /* 15 | * The setup function. We only start the sensors here 16 | */ 17 | void setup(void) 18 | { 19 | // start serial port 20 | Serial.begin(9600); 21 | Serial.println("Dallas Temperature IC Control Library Demo"); 22 | 23 | // Start up the library 24 | sensors.begin(); 25 | } 26 | 27 | /* 28 | * Main function, get and show the temperature 29 | */ 30 | void loop(void) 31 | { 32 | // call sensors.requestTemperatures() to issue a global temperature 33 | // request to all devices on the bus 34 | Serial.print("Requesting temperatures..."); 35 | sensors.requestTemperatures(); // Send the command to get temperatures 36 | Serial.println("DONE"); 37 | // After we got the temperatures, we can print them here. 38 | // We use the function ByIndex, and as an example get the temperature from the first sensor only. 39 | Serial.print("Temperature for the device 1 (index 0) is: "); 40 | Serial.println(sensors.getTempCByIndex(0)); 41 | } 42 | -------------------------------------------------------------------------------- /arduino/libraries/DallasTemperature/examples/TwoPin_DS18B20/TwoPin_DS18B20.ino: -------------------------------------------------------------------------------- 1 | // 2 | // FILE: TwoPin_DS18B20.ino 3 | // AUTHOR: Rob Tillaart 4 | // VERSION: 0.1.00 5 | // PURPOSE: two pins for two sensors demo 6 | // DATE: 2014-06-13 7 | // URL: http://forum.arduino.cc/index.php?topic=216835.msg1764333#msg1764333 8 | // 9 | // Released to the public domain 10 | // 11 | 12 | #include 13 | #include 14 | 15 | #define ONE_WIRE_BUS_1 2 16 | #define ONE_WIRE_BUS_2 4 17 | 18 | OneWire oneWire_in(ONE_WIRE_BUS_1); 19 | OneWire oneWire_out(ONE_WIRE_BUS_2); 20 | 21 | DallasTemperature sensor_inhouse(&oneWire_in); 22 | DallasTemperature sensor_outhouse(&oneWire_out); 23 | 24 | void setup(void) 25 | { 26 | Serial.begin(9600); 27 | Serial.println("Dallas Temperature Control Library Demo - TwoPin_DS18B20"); 28 | 29 | sensor_inhouse.begin(); 30 | sensor_outhouse.begin(); 31 | } 32 | 33 | void loop(void) 34 | { 35 | Serial.print("Requesting temperatures..."); 36 | sensor_inhouse.requestTemperatures(); 37 | sensor_outhouse.requestTemperatures(); 38 | Serial.println(" done"); 39 | 40 | Serial.print("Inhouse: "); 41 | Serial.println(sensor_inhouse.getTempCByIndex(0)); 42 | 43 | Serial.print("Outhouse: "); 44 | Serial.println(sensor_outhouse.getTempCByIndex(0)); 45 | } -------------------------------------------------------------------------------- /arduino/libraries/DallasTemperature/examples/WaitForConversion/WaitForConversion.pde: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Data wire is plugged into port 2 on the Arduino 5 | #define ONE_WIRE_BUS 2 6 | 7 | // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) 8 | OneWire oneWire(ONE_WIRE_BUS); 9 | 10 | // Pass our oneWire reference to Dallas Temperature. 11 | DallasTemperature sensors(&oneWire); 12 | 13 | void setup(void) 14 | { 15 | // start serial port 16 | Serial.begin(115200); 17 | Serial.println("Dallas Temperature Control Library - Async Demo"); 18 | Serial.println("\nDemo shows the difference in length of the call\n\n"); 19 | 20 | // Start up the library 21 | sensors.begin(); 22 | } 23 | 24 | void loop(void) 25 | { 26 | // Request temperature conversion (traditional) 27 | Serial.println("Before blocking requestForConversion"); 28 | unsigned long start = millis(); 29 | 30 | sensors.requestTemperatures(); 31 | 32 | unsigned long stop = millis(); 33 | Serial.println("After blocking requestForConversion"); 34 | Serial.print("Time used: "); 35 | Serial.println(stop - start); 36 | 37 | // get temperature 38 | Serial.print("Temperature: "); 39 | Serial.println(sensors.getTempCByIndex(0)); 40 | Serial.println("\n"); 41 | 42 | // Request temperature conversion - non-blocking / async 43 | Serial.println("Before NON-blocking/async requestForConversion"); 44 | start = millis(); 45 | sensors.setWaitForConversion(false); // makes it async 46 | sensors.requestTemperatures(); 47 | sensors.setWaitForConversion(true); 48 | stop = millis(); 49 | Serial.println("After NON-blocking/async requestForConversion"); 50 | Serial.print("Time used: "); 51 | Serial.println(stop - start); 52 | 53 | 54 | // 9 bit resolution by default 55 | // Note the programmer is responsible for the right delay 56 | // we could do something usefull here instead of the delay 57 | int resolution = 9; 58 | delay(750/ (1 << (12-resolution))); 59 | 60 | // get temperature 61 | Serial.print("Temperature: "); 62 | Serial.println(sensors.getTempCByIndex(0)); 63 | Serial.println("\n\n\n\n"); 64 | 65 | delay(5000); 66 | } 67 | -------------------------------------------------------------------------------- /arduino/libraries/DallasTemperature/examples/WaitForConversion2/WaitForConversion2.pde: -------------------------------------------------------------------------------- 1 | // 2 | // Sample of using Async reading of Dallas Temperature Sensors 3 | // 4 | #include 5 | #include 6 | 7 | // Data wire is plugged into port 2 on the Arduino 8 | #define ONE_WIRE_BUS 2 9 | 10 | // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) 11 | OneWire oneWire(ONE_WIRE_BUS); 12 | 13 | // Pass our oneWire reference to Dallas Temperature. 14 | DallasTemperature sensors(&oneWire); 15 | 16 | DeviceAddress tempDeviceAddress; 17 | 18 | int resolution = 12; 19 | unsigned long lastTempRequest = 0; 20 | int delayInMillis = 0; 21 | float temperature = 0.0; 22 | int idle = 0; 23 | // 24 | // SETUP 25 | // 26 | void setup(void) 27 | { 28 | Serial.begin(115200); 29 | Serial.println("Dallas Temperature Control Library - Async Demo"); 30 | Serial.print("Library Version: "); 31 | Serial.println(DALLASTEMPLIBVERSION); 32 | Serial.println("\n"); 33 | 34 | sensors.begin(); 35 | sensors.getAddress(tempDeviceAddress, 0); 36 | sensors.setResolution(tempDeviceAddress, resolution); 37 | 38 | sensors.setWaitForConversion(false); 39 | sensors.requestTemperatures(); 40 | delayInMillis = 750 / (1 << (12 - resolution)); 41 | lastTempRequest = millis(); 42 | 43 | pinMode(13, OUTPUT); 44 | } 45 | 46 | void loop(void) 47 | { 48 | 49 | if (millis() - lastTempRequest >= delayInMillis) // waited long enough?? 50 | { 51 | digitalWrite(13, LOW); 52 | Serial.print(" Temperature: "); 53 | temperature = sensors.getTempCByIndex(0); 54 | Serial.println(temperature, resolution - 8); 55 | Serial.print(" Resolution: "); 56 | Serial.println(resolution); 57 | Serial.print("Idle counter: "); 58 | Serial.println(idle); 59 | Serial.println(); 60 | 61 | idle = 0; 62 | 63 | // immediately after fetching the temperature we request a new sample 64 | // in the async modus 65 | // for the demo we let the resolution change to show differences 66 | resolution++; 67 | if (resolution > 12) resolution = 9; 68 | 69 | sensors.setResolution(tempDeviceAddress, resolution); 70 | sensors.requestTemperatures(); 71 | delayInMillis = 750 / (1 << (12 - resolution)); 72 | lastTempRequest = millis(); 73 | } 74 | 75 | digitalWrite(13, HIGH); 76 | // we can do usefull things here 77 | // for the demo we just count the idle time in millis 78 | delay(1); 79 | idle++; 80 | } 81 | -------------------------------------------------------------------------------- /arduino/libraries/DallasTemperature/examples/oneWireSearch/oneWireSearch.ino: -------------------------------------------------------------------------------- 1 | // 2 | // FILE: oneWireSearch.ino 3 | // AUTHOR: Rob Tillaart 4 | // VERSION: 0.1.02 5 | // PURPOSE: scan for 1-Wire devices + code snippet generator 6 | // DATE: 2015-june-30 7 | // URL: http://forum.arduino.cc/index.php?topic=333923 8 | // 9 | // inspired by http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html 10 | // 11 | // Released to the public domain 12 | // 13 | // 0.1.00 initial version 14 | // 0.1.01 first published version 15 | // 0.1.02 small output changes 16 | 17 | #include 18 | 19 | void setup() 20 | { 21 | Serial.begin(115200); 22 | Serial.println("//\n// Start oneWireSearch.ino \n//"); 23 | 24 | for (uint8_t pin = 2; pin < 13; pin++) 25 | { 26 | findDevices(pin); 27 | } 28 | Serial.println("\n//\n// End oneWireSearch.ino \n//"); 29 | } 30 | 31 | void loop() 32 | { 33 | } 34 | 35 | uint8_t findDevices(int pin) 36 | { 37 | OneWire ow(pin); 38 | 39 | uint8_t address[8]; 40 | uint8_t count = 0; 41 | 42 | 43 | if (ow.search(address)) 44 | { 45 | Serial.print("\nuint8_t pin"); 46 | Serial.print(pin, DEC); 47 | Serial.println("[][8] = {"); 48 | { 49 | count++; 50 | Serial.println(" {"); 51 | for (uint8_t i = 0; i < 8; i++) 52 | { 53 | Serial.print("0x"); 54 | if (address[i] < 0x10) Serial.print("0"); 55 | Serial.print(address[i], HEX); 56 | if (i < 7) Serial.print(", "); 57 | } 58 | Serial.println(" },"); 59 | } while (ow.search(address)); 60 | 61 | Serial.println("};"); 62 | Serial.print("// nr devices found: "); 63 | Serial.println(count); 64 | } 65 | 66 | return count; 67 | } 68 | -------------------------------------------------------------------------------- /arduino/libraries/DallasTemperature/examples/setUserData/SetUserData.ino: -------------------------------------------------------------------------------- 1 | // 2 | // This sketch does not use the ALARM registers and uses those 2 bytes as a counter 3 | // these 2 bytes can be used for other purposes as well e.g. last temperature or 4 | // a specific ID. 5 | // 6 | 7 | #include 8 | #include 9 | 10 | // Data wire is plugged into port 2 on the Arduino 11 | #define ONE_WIRE_BUS 2 12 | 13 | // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) 14 | OneWire oneWire(ONE_WIRE_BUS); 15 | 16 | // Pass our oneWire reference to Dallas Temperature. 17 | DallasTemperature sensors(&oneWire); 18 | 19 | int count = 0; 20 | 21 | void setup(void) 22 | { 23 | // start serial port 24 | Serial.begin(9600); 25 | Serial.println("Dallas Temperature IC Control Library Demo"); 26 | 27 | // Start up the library 28 | sensors.begin(); 29 | 30 | } 31 | 32 | void loop(void) 33 | { 34 | // call sensors.requestTemperatures() to issue a global temperature 35 | // request to all devices on the bus 36 | Serial.print("Requesting temperatures..."); 37 | sensors.requestTemperatures(); // Send the command to get temperatures 38 | Serial.println("DONE"); 39 | 40 | Serial.print("Temperature for the device 1 (index 0) is: "); 41 | Serial.println(sensors.getTempCByIndex(0)); 42 | 43 | count++; 44 | sensors.setUserDataByIndex(0, count); 45 | int x = sensors.getUserDataByIndex(0); 46 | Serial.println(count); 47 | } 48 | -------------------------------------------------------------------------------- /arduino/libraries/DallasTemperature/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For DallasTemperature 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | DallasTemperature KEYWORD1 9 | OneWire KEYWORD1 10 | AlarmHandler KEYWORD1 11 | DeviceAddress KEYWORD1 12 | 13 | ####################################### 14 | # Methods and Functions (KEYWORD2) 15 | ####################################### 16 | 17 | setResolution KEYWORD2 18 | getResolution KEYWORD2 19 | getTempC KEYWORD2 20 | toFahrenheit KEYWORD2 21 | getTempF KEYWORD2 22 | getTempCByIndex KEYWORD2 23 | getTempFByIndex KEYWORD2 24 | setWaitForConversion KEYWORD2 25 | getWaitForConversion KEYWORD2 26 | requestTemperatures KEYWORD2 27 | requestTemperaturesByAddress KEYWORD2 28 | requestTemperaturesByIndex KEYWORD2 29 | isParasitePowerMode KEYWORD2 30 | begin KEYWORD2 31 | getDeviceCount KEYWORD2 32 | getAddress KEYWORD2 33 | validAddress KEYWORD2 34 | isConnected KEYWORD2 35 | readScratchPad KEYWORD2 36 | writeScratchPad KEYWORD2 37 | readPowerSupply KEYWORD2 38 | setHighAlarmTemp KEYWORD2 39 | setLowAlarmTemp KEYWORD2 40 | getHighAlarmTemp KEYWORD2 41 | getLowAlarmTemp KEYWORD2 42 | resetAlarmSearch KEYWORD2 43 | alarmSearch KEYWORD2 44 | hasAlarm KEYWORD2 45 | toCelsius KEYWORD2 46 | processAlarmss KEYWORD2 47 | setAlarmHandlers KEYWORD2 48 | defaultAlarmHandler KEYWORD2 49 | calculateTemperature KEYWORD2 50 | 51 | ####################################### 52 | # Constants (LITERAL1) 53 | ####################################### 54 | 55 | -------------------------------------------------------------------------------- /arduino/libraries/DallasTemperature/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "DallasTemperature", 3 | "keywords": "onewire, 1-wire, bus, sensor, temperature", 4 | "description": "Arduino Library for Dallas Temperature ICs (DS18B20, DS18S20, DS1822, DS1820)", 5 | "repository": 6 | { 7 | "type": "git", 8 | "url": "https://github.com/milesburton/Arduino-Temperature-Control-Library.git" 9 | }, 10 | "authors": 11 | [ 12 | { 13 | "name": "Miles Burton", 14 | "email": "miles@mnetcs.com", 15 | "url": "http://www.milesburton.com", 16 | "maintainer": true 17 | }, 18 | { 19 | "name": "Tim Newsome", 20 | "email": "nuisance@casualhacker.net" 21 | }, 22 | { 23 | "name": "Guil Barros", 24 | "email": "gfbarros@bappos.com" 25 | }, 26 | { 27 | "name": "Rob Tillaart", 28 | "email": "rob.tillaart@gmail.com" 29 | } 30 | ], 31 | "dependencies": 32 | { 33 | "name": "OneWire", 34 | "authors": "Paul Stoffregen", 35 | "frameworks": "arduino" 36 | }, 37 | "version": "3.7.6", 38 | "frameworks": "arduino", 39 | "platforms": "*" 40 | } 41 | -------------------------------------------------------------------------------- /arduino/libraries/DallasTemperature/library.properties: -------------------------------------------------------------------------------- 1 | name=DallasTemperature 2 | version=3.7.6 3 | author=Miles Burton , Tim Newsome , Guil Barros , Rob Tillaart 4 | maintainer=Miles Burton 5 | sentence=Arduino Library for Dallas Temperature ICs 6 | paragraph=Supports DS18B20, DS18S20, DS1822, DS1820 7 | category=Sensors 8 | url=https://github.com/milesburton/Arduino-Temperature-Control-Library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /arduino/libraries/OneWire/examples/DS2408_Switch/DS2408_Switch.pde: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | * DS2408 8-Channel Addressable Switch 5 | * 6 | * Writte by Glenn Trewitt, glenn at trewitt dot org 7 | * 8 | * Some notes about the DS2408: 9 | * - Unlike most input/output ports, the DS2408 doesn't have mode bits to 10 | * set whether the pins are input or output. If you issue a read command, 11 | * they're inputs. If you write to them, they're outputs. 12 | * - For reading from a switch, you should use 10K pull-up resisters. 13 | */ 14 | 15 | void PrintBytes(uint8_t* addr, uint8_t count, bool newline=0) { 16 | for (uint8_t i = 0; i < count; i++) { 17 | Serial.print(addr[i]>>4, HEX); 18 | Serial.print(addr[i]&0x0f, HEX); 19 | } 20 | if (newline) 21 | Serial.println(); 22 | } 23 | 24 | void ReadAndReport(OneWire* net, uint8_t* addr) { 25 | Serial.print(" Reading DS2408 "); 26 | PrintBytes(addr, 8); 27 | Serial.println(); 28 | 29 | uint8_t buf[13]; // Put everything in the buffer so we can compute CRC easily. 30 | buf[0] = 0xF0; // Read PIO Registers 31 | buf[1] = 0x88; // LSB address 32 | buf[2] = 0x00; // MSB address 33 | net->write_bytes(buf, 3); 34 | net->read_bytes(buf+3, 10); // 3 cmd bytes, 6 data bytes, 2 0xFF, 2 CRC16 35 | net->reset(); 36 | 37 | if (!OneWire::check_crc16(buf, 11, &buf[11])) { 38 | Serial.print("CRC failure in DS2408 at "); 39 | PrintBytes(addr, 8, true); 40 | return; 41 | } 42 | Serial.print(" DS2408 data = "); 43 | // First 3 bytes contain command, register address. 44 | Serial.println(buf[3], BIN); 45 | } 46 | 47 | OneWire net(10); // on pin 10 48 | 49 | void setup(void) { 50 | Serial.begin(9600); 51 | } 52 | 53 | void loop(void) { 54 | byte i; 55 | byte present = 0; 56 | byte addr[8]; 57 | 58 | if (!net.search(addr)) { 59 | Serial.print("No more addresses.\n"); 60 | net.reset_search(); 61 | delay(1000); 62 | return; 63 | } 64 | 65 | if (OneWire::crc8(addr, 7) != addr[7]) { 66 | Serial.print("CRC is not valid!\n"); 67 | return; 68 | } 69 | 70 | if (addr[0] != 0x29) { 71 | PrintBytes(addr, 8); 72 | Serial.print(" is not a DS2408.\n"); 73 | return; 74 | } 75 | 76 | ReadAndReport(&net, addr); 77 | } 78 | -------------------------------------------------------------------------------- /arduino/libraries/OneWire/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For OneWire 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | OneWire KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | reset KEYWORD2 16 | write_bit KEYWORD2 17 | read_bit KEYWORD2 18 | write KEYWORD2 19 | write_bytes KEYWORD2 20 | read KEYWORD2 21 | read_bytes KEYWORD2 22 | select KEYWORD2 23 | skip KEYWORD2 24 | depower KEYWORD2 25 | reset_search KEYWORD2 26 | search KEYWORD2 27 | crc8 KEYWORD2 28 | crc16 KEYWORD2 29 | check_crc16 KEYWORD2 30 | 31 | ####################################### 32 | # Instances (KEYWORD2) 33 | ####################################### 34 | 35 | 36 | ####################################### 37 | # Constants (LITERAL1) 38 | ####################################### 39 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/LICENSE.md: -------------------------------------------------------------------------------- 1 | ## Software License Agreement (BSD-3 License) 2 | 3 | **Copyright (c) 2013, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team.** 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without modification, 7 | are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 16 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 17 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/examples/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Examples using the SDI-12 Library 2 | 3 | - Example A: Gets sensor information from a single attached sensor and prints it to the serial port 4 | - Example B: Allows you to change the address of your SDI-12 Sensor 5 | - Example C: Checks all addresses for active sensors, and prints their status to the serial port 6 | - Example D: Checks all addresses for active sensors, and logs data for each sensor every minute 7 | - Example E: Demonstrates the ability to parse integers and floats from the buffer. 8 | - Example F: Issues a data request to a single specified sensor 9 | - Example G: Demonstrates using the Arduino as a command terminal for SDI-12 sensors. 10 | - Example H: Demonstrates using SDI-12 in slave mode 11 | - Example I: Shows code for an Arduino-based USB dongle to translate between SDI-12 and a PC 12 | - Example J: Shows how to use an external PCInt library to call the interrupts for this library. 13 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/examples/a_wild_card/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Example A: Using the wildcard - Getting single sensor information 2 | 3 | This is a simple demonstration of the SDI-12 library for Arduino. 4 | It requests information about a single attached sensor, including its address and manufacturer info, and prints it to the serial port 5 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/examples/a_wild_card/a_wild_card.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ######################## 3 | # OVERVIEW # 4 | ######################## 5 | 6 | Example A: Using the wildcard. 7 | 8 | This is a simple demonstration of the SDI-12 library for Arduino. 9 | It requests information about the attached sensor, including its address and manufacturer info. 10 | 11 | ######################### 12 | # THE CIRCUIT # 13 | ######################### 14 | 15 | You should not have more than one SDI-12 device attached for this example. 16 | 17 | See: 18 | https://raw.github.com/Kevin-M-Smith/SDI-12-Circuit-Diagrams/master/basic_setup_no_usb.png 19 | or 20 | https://raw.github.com/Kevin-M-Smith/SDI-12-Circuit-Diagrams/master/compat_setup_usb.png 21 | 22 | ########################### 23 | # COMPATIBILITY # 24 | ########################### 25 | 26 | This library requires the use of pin change interrupts (PCINT). 27 | Not all Arduino boards have the same pin capabilities. 28 | The known compatibile pins for common variants are shown below. 29 | 30 | Arduino Uno: All pins. 31 | 32 | Arduino Mega or Mega 2560: 33 | 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), 34 | A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69). 35 | 36 | Arduino Leonardo: 37 | 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI) 38 | 39 | ######################### 40 | # RESOURCES # 41 | ######################### 42 | 43 | Written by Kevin M. Smith in 2013. 44 | Contact: SDI12@ethosengineering.org 45 | 46 | The SDI-12 specification is available at: http://www.sdi-12.org/ 47 | The library is available at: https://github.com/EnviroDIY/Arduino-SDI-12 48 | */ 49 | 50 | #include "SDI12.h" 51 | 52 | #define DATAPIN 9 // change to the proper pin 53 | SDI12 mySDI12(DATAPIN); 54 | 55 | /* 56 | '?' is a wildcard character which asks any and all sensors to respond 57 | 'I' indicates that the command wants information about the sensor 58 | '!' finishes the command 59 | */ 60 | String myCommand = "?I!"; 61 | 62 | void setup(){ 63 | Serial.begin(9600); 64 | mySDI12.begin(); 65 | } 66 | 67 | void loop(){ 68 | mySDI12.sendCommand(myCommand); 69 | delay(300); // wait a while for a response 70 | while(mySDI12.available()){ // write the response to the screen 71 | Serial.write(mySDI12.read()); 72 | } 73 | delay(3000); // print again in three seconds 74 | } 75 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/examples/b_address_change/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Example B: Changing the Address of your SDI-12 Sensor 2 | 3 | Communication with an SDI-12 sensor depends on its 1-character alphanumeric address (1-9, A-Z, a-z). A sensor can also be programmed with an address of 0, but that address cannot always be used to get measurements from the sensor. This sketch enables you to find and change the address of your sensor. 4 | 5 | First, physically connect your SDI-12 sensor to your device. Some helpful hits for connecting it can be found here: https://envirodiy.org/topic/logging-mayfly-with-decagon-sdi-12-sensor/#post-2129. 6 | 7 | Once your sensor is physically connected to your board, download this library and open this sketch. Scroll to line 53 of the sketch and set the pin number that your sensor is attached to. Set the pin to provide power to your sensor in line 54. If your sensor is continuously powered, set the power pin to -1. Upload the sketch to your board. After the upload finishes, open up the serial port monitor at a baud rate of 9600. 8 | 9 | In the serial monitor you will see it begin scanning through all possible SDI-12 addresses. Once it has found an occupied address, it will stop and ask you to enter a new address. Send your desired address to the serial port. On the screen you should see "Readdressing Sensor." followed by "Success. Rescanning for verification." The scan will begin again, stopping at your new address. If you are now happy with the address you've selected, smile and close the serial port monitor. 10 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/examples/c_check_all_addresses/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Example C: Checks all addresses for active sensors, and prints their status to the serial port. 2 | 3 | This is a simple demonstration of the SDI-12 library for Arduino. 4 | 5 | It discovers the address of all sensors active on any pin on your board. 6 | 7 | Each sensor should have a unique address already - if not, multiple sensors may respond simultaenously to the same request and the output will not be readable by the Arduino. 8 | 9 | To address a sensor, please see Example B: b_address_change.ino 10 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/examples/d_simple_logger/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Example D: Checks all addresses for active sensors, and logs data for each sensor every minute. 2 | 3 | This is a simple demonstration of the SDI-12 library for Arduino. 4 | 5 | It discovers the address of all sensors active on a single bus and takes measurements from them. 6 | 7 | Every SDI-12 device is different in the time it takes to take a measurement, and the amount of data it returns. This sketch will not serve every sensor type, but it will likely be helpful in getting you started. 8 | 9 | Each sensor should have a unique address already - if not, multiple sensors may respond simultaenously to the same request and the output will not be readable by the Arduino. 10 | 11 | To address a sensor, please see Example B: b_address_change.ino 12 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/examples/e_simple_parsing/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Example E: This example demonstrates the ability to parse integers and floats from the buffer. 2 | 3 | This is based closely on example D, however, every other time it prints out data, it multiplies the data by a factor of 2, just to demonstrate what can be done with floating point data. 4 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/examples/f_basic_data_request/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Example F: Basic data request to a single sensor 2 | 3 | This is a simple demonstration of the SDI-12 library for Arduino. 4 | 5 | This is a very basic (stripped down) example where the user initiates a measurement and receives the results to a terminal window without typing numerous commands into the terminal. 6 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/examples/f_basic_data_request/f_basic_data_request.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example F: Basic data request. 3 | Edited by Ruben Kertesz for ISCO Nile 502 2/10/2016 4 | This is a simple demonstration of the SDI-12 library for Arduino. 5 | This is a very basic (stripped down) example where the user initiates a measurement 6 | and receives the results to a terminal window without typing numerous commands into 7 | the terminal. 8 | The SDI-12 specification is available at: http://www.sdi-12.org/ 9 | The library is available at: https://github.com/EnviroDIY/Arduino-SDI-12 10 | The forked library with additional example files is available at: https://github.com/rkertesz/Arduino-SDI-12 11 | The circuit: You should not have more than one SDI-12 device attached for this example. 12 | See: 13 | https://raw.github.com/Kevin-M-Smith/SDI-12-Circuit-Diagrams/master/basic_setup_no_usb.png 14 | or 15 | https://raw.github.com/Kevin-M-Smith/SDI-12-Circuit-Diagrams/master/compat_setup_usb.png 16 | Written by Kevin M. Smith in 2013. 17 | Contact: SDI12@ethosengineering.org 18 | Extended by Ruben Kertesz in 2016 19 | Contact: github@emnet.net or @rinnamon on twitter 20 | */ 21 | 22 | 23 | #include "SDI12.h" 24 | 25 | #define DATAPIN 12 // change to the proper pin 26 | #define SENSOR_ADDRESS 1 27 | 28 | SDI12 mySDI12(DATAPIN); 29 | 30 | String sdiResponse = ""; 31 | String myCommand = ""; 32 | 33 | void setup() { 34 | Serial.begin(9600); 35 | mySDI12.begin(); 36 | } 37 | 38 | void loop() { 39 | do { // wait for a response from the serial terminal to do anything 40 | delay (30); 41 | } 42 | while (!Serial.available()); 43 | char nogo = Serial.read(); // simply hit enter in the terminal window or press send and 44 | // the characters get discarded but now the rest of the loop continues 45 | 46 | //first command to take a measurement 47 | myCommand = String(SENSOR_ADDRESS) + "M!"; 48 | Serial.println(myCommand); // echo command to terminal 49 | 50 | mySDI12.sendCommand(myCommand); 51 | delay(30); // wait a while for a response 52 | 53 | while (mySDI12.available()) { // build response string 54 | char c = mySDI12.read(); 55 | if ((c != '\n') && (c != '\r')) { 56 | sdiResponse += c; 57 | delay(5); 58 | } 59 | } 60 | if (sdiResponse.length() > 1) Serial.println(sdiResponse); //write the response to the screen 61 | mySDI12.clearBuffer(); 62 | 63 | 64 | delay(1000); // delay between taking reading and requesting data 65 | sdiResponse = ""; // clear the response string 66 | 67 | 68 | // next command to request data from last measurement 69 | myCommand = String(SENSOR_ADDRESS) + "D0!"; 70 | Serial.println(myCommand); // echo command to terminal 71 | 72 | mySDI12.sendCommand(myCommand); 73 | delay(30); // wait a while for a response 74 | 75 | while (mySDI12.available()) { // build string from response 76 | char c = mySDI12.read(); 77 | if ((c != '\n') && (c != '\r')) { 78 | sdiResponse += c; 79 | delay(5); 80 | } 81 | } 82 | if (sdiResponse.length() > 1) Serial.println(sdiResponse); //write the response to the screen 83 | mySDI12.clearBuffer(); 84 | 85 | //now go back to top and wait until user hits enter on terminal window 86 | } 87 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/examples/g_terminal_window/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Example G: Using the Arduino as a command terminal for SDI-12 sensors. 2 | 3 | This is a simple demonstration of the SDI-12 library for Arduino. 4 | 5 | It's purpose is to allow a user to interact with an SDI-12 sensor directly, issuing commands through a serial terminal window. 6 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/examples/g_terminal_window/g_terminal_window.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example G: Using the Arduino as a command terminal for SDI-12 sensors. 3 | 4 | Edited by Ruben Kertesz for ISCO Nile 502 2/10/2016…//functions as terminal 5 | 6 | This is a simple demonstration of the SDI-12 library for Arduino. 7 | It's purpose is to allow a user to interact with an SDI-12 sensor directly, 8 | issuing commands through a serial terminal window. 9 | The SDI-12 specification is available at: http://www.sdi-12.org/ 10 | The master library is available at: https://github.com/EnviroDIY/Arduino-SDI-12 11 | The forked library with additional example files is available at: https://github.com/rkertesz/Arduino-SDI-12 12 | The circuit: It is recommended that you not have more than one SDI-12 device attached for this example. 13 | See: 14 | https://raw.github.com/Kevin-M-Smith/SDI-12-Circuit-Diagrams/master/basic_setup_no_usb.png 15 | or 16 | https://raw.github.com/Kevin-M-Smith/SDI-12-Circuit-Diagrams/master/compat_setup_usb.png 17 | Written by Kevin M. Smith in 2013. 18 | Contact: SDI12@ethosengineering.org 19 | Extended by Ruben Kertesz in 2016 20 | Contact: github@emnet.net or @rinnamon on twitter 21 | */ 22 | 23 | 24 | #include "SDI12.h" 25 | 26 | #define DATAPIN 12 // change to the proper pin 27 | SDI12 mySDI12(DATAPIN); 28 | 29 | char inByte = 0; 30 | String sdiResponse = ""; 31 | String myCommand = ""; 32 | 33 | void setup(){ 34 | Serial.begin(9600); 35 | mySDI12.begin(); 36 | } 37 | 38 | void loop(){ 39 | if (Serial.available()) { 40 | inByte = Serial.read(); 41 | if((inByte!='\n') && (inByte!='\r')) { //read all values entered in terminal window before enter 42 | myCommand += inByte; 43 | delay(5); 44 | } 45 | } 46 | 47 | if(inByte == '\r'){ // once we press enter, send string to SDI sensor/probe 48 | inByte = 0; 49 | Serial.println(myCommand); 50 | mySDI12.sendCommand(myCommand); 51 | delay(30); // wait a while for a response 52 | 53 | while(mySDI12.available()){ // build a string of the response 54 | char c = mySDI12.read(); 55 | if((c!='\n') && (c!='\r')) { 56 | sdiResponse += c; 57 | delay(5); 58 | } 59 | } 60 | if (sdiResponse.length()>1) Serial.println(sdiResponse); //write the response to the screen 61 | 62 | mySDI12.clearBuffer(); //clear the line 63 | myCommand = ""; 64 | sdiResponse = ""; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/examples/h_SDI-12_slave_implementation/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Example H: Using SDI-12 in slave mode 2 | 3 | Example sketch demonstrating how to implement an arduino as a slave on an SDI-12 bus. This may be used, for example, as a middleman between an I2C sensor and an SDI-12 datalogger. 4 | 5 | Note that an SDI-12 slave must respond to M! or C! with the number of values it will report and the max time until these values will be available. This example uses 9 values available in 21 s, but references to these numbers and the output array size and datatype should be changed for your specific application. 6 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/examples/i_SDI-12_interface/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Example I: SDI-12 PC Interface 2 | 3 | Code for an Arduino-based USB dongle translates serial comm from PC to SDI-12 (electrical and timing) 4 | 1. Allows user to communicate to SDI-12 devices from a serial terminal emulator (e.g. PuTTY). 5 | 2. Able to spy on an SDI-12 bus for troubleshooting comm between datalogger and sensors. 6 | 3. Can also be used as a hardware middleman for interfacing software to an SDI-12 sensor. For example, implementing an SDI-12 datalogger in Python on a PC. Use verbatim mode with feedback off in this case. 7 | 8 | Note: "translation" means timing and electrical interface. It does not ensure SDI-12 compliance of commands sent via it. 9 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/examples/j_external_pcint_library/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Example J: Checks all addresses for active sensors, and logs data for each sensor every minute. 2 | 3 | This is identical to example D, except that instead of using internal definitions of pin change interrupt vectors, it depends on another library to define them for it. 4 | 5 | To use this example, you must remove the comment braces around "#define SDI12_EXTERNAL_PCINT" in the library and re-compile it. 6 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/keywords.txt: -------------------------------------------------------------------------------- 1 | 2 | # Syntax Coloring Map for SDI12 when 3 | # using the Arduino IDE. 4 | 5 | ### Classes (KEYWORD1) 6 | 7 | SDI12 KEYWORD1 8 | 9 | ### Methods and Functions (KEYWORD2) 10 | 11 | begin KEYWORD2 12 | end KEYWORD2 13 | forceHold KEYWORD2 14 | forceListen KEYWORD2 15 | sendCommand KEYWORD2 16 | sendResponse KEYWORD2 17 | available KEYWORD2 18 | peek KEYWORD2 19 | read KEYWORD2 20 | clearBuffer KEYWORD2 21 | flush KEYWORD2 22 | setActive KEYWORD2 23 | isActive KEYWORD2 24 | handleInterrupt KEYWORD2 25 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Arduino-SDI-12", 3 | "version": "1.0.2", 4 | "keywords": "SDI-12, sdi12, communication, bus, sensor, Decagon", 5 | "description": "Arduino library for SDI-12 communications to a wide variety of environmental sensors.", 6 | "repository": 7 | { 8 | "type": "git", 9 | "url": "https://github.com/EnviroDIY/Arduino-SDI-12.git" 10 | }, 11 | "authors": 12 | [ 13 | { 14 | "name": "Kevin M. Smith", 15 | "email": "Kevin@elite-education.org" 16 | }, 17 | { 18 | "name": "Shannon Hicks", 19 | "email": "shicks@stroudcenter.org" 20 | }, 21 | { 22 | "name": "Sara Damiano", 23 | "email": "sdamiano@stroudcenter.org", 24 | "maintainer": true 25 | } 26 | ], 27 | "license": "BSD-3-Clause", 28 | "frameworks": "arduino", 29 | "platforms": "atmelavr, atmelsam" 30 | } 31 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/library.properties: -------------------------------------------------------------------------------- 1 | name=Arduino-SDI-12 2 | version=1.0.2 3 | author=Kevin M. Smith , Shannon Hicks 4 | maintainer=Sara Damiano 5 | sentence=Arduino library for SDI-12 communications to a wide variety of environmental sensors. 6 | paragraph=This library provides a general software solution, without requiring any additional hardware. 7 | category=Communication 8 | url=https://github.com/EnviroDIY/Arduino-SDI-12 9 | architectures=avr,sam,samd 10 | -------------------------------------------------------------------------------- /arduino/libraries/SDI12/src/ReadMe.md: -------------------------------------------------------------------------------- 1 | These are the library source files. 2 | -------------------------------------------------------------------------------- /arduino/libraries/Sensirion/README.txt: -------------------------------------------------------------------------------- 1 | Sensirion: An Arduino Library for the Sensirion SHT1x and SHT7x family of 2 | temperature and humidity sensors. 3 | 4 | Created by Markus Schatzl, November 28, 2008 5 | Revised (v1.1) by Carl Jackson, August 4, 2010 6 | Rewritten (v2.0) by Carl Jackson, December 8, 2010 7 | 8 | Revision History 9 | 10 | 1.0 - Original code provides a constructor, two public functions, plus 11 | several private functions. The primary public function, "measure", 12 | commands the sensor to perform both a temperature and a humidity 13 | measurement and then calculates the dewpoint. Total execution time 14 | is approximately 400 milliseconds. 15 | 16 | 1.1 - Added several new functions while touching as little as possible of 17 | the original code. The primary new feature is the ability to perform 18 | non-blocking measurements, ie, to return control to the calling routine 19 | after sending a command to the sensor rather than to spin waiting for 20 | the measurement to complete. Also added the ability to set the sensor 21 | measurement precision (14-bit/12-bit Temp/RH vs. 12-bit/8-bit Temp/RH) 22 | for precision vs. speed trade-off. Updated equation coefficients for 23 | the V4 version of the sensors per Sensirion recommendations. 24 | 25 | 2.0 - Extensive changes for robustness, code size, and new features. Added 26 | CRC checking, consistent handling of the data pin internal pullup, and 27 | improved error reporting. Added sensor status register read function 28 | and expanded status register write function to cover all setable bits. 29 | 30 | 31 | Usage Information 32 | 33 | CRC error detection is enabled by default. It may be disabled by deleting 34 | the line "#define CRC_ENA" in the library header file (Sensrion.h). This 35 | reduces the code size by about 150 bytes. When enabled, CRC errors are 36 | indicated via the return code S_Err_CRC. In addition, the value 0xFFFF is 37 | substituted for the affected data. 38 | 39 | The library header file defines two macros (PULSE_SHORT and PULSE_LONG) 40 | that are used in generating the sensor interface signaling. By default, 41 | PULSE_SHORT delays 1 microsecond and PULSE_LONG delays 3 microseconds. 42 | These delays appear reliable for wire lengths of at least 1 foot (30 cm). 43 | Long connections may require adjustments to the delay macros and may also 44 | require serial termination, low pass filtering, or other approaches to 45 | improve the sensor interface signal integrity. 46 | 47 | To avoid self heating of the sensor, Sensirion recommends that the 48 | sensor not be active for more than 10% of the time. In its default high 49 | resolution mode, the sensor performs 14-bit temperature measurements and 50 | 12-bit humidity measurements which may take up to 320 msec and 80 msec 51 | respectively to complete. One set of temperature / humidity measurements 52 | thus takes up to 400 msec so at least 4 seconds should elapse between 53 | successive sets of measurements. In low resolution mode, the sensor 54 | performs 12-bit temperature measurements and 8-bit humidity measurements, 55 | reducing these times to 80 msec and 20 msec respectively for a total of 56 | 100 msec for a set. In this case, at least 1 second should elapse between 57 | successive sets of measurements. 58 | -------------------------------------------------------------------------------- /arduino/libraries/Sensirion/Sensirion.h: -------------------------------------------------------------------------------- 1 | /* ========================================================================== */ 2 | /* Sensirion.h - Library for Sensirion SHT1x & SHT7x family temperature */ 3 | /* and humidity sensors */ 4 | /* Created by Markus Schatzl, November 28, 2008 */ 5 | /* Released into the public domain */ 6 | /* */ 7 | /* Revised (v1.1) by Carl Jackson, August 4, 2010 */ 8 | /* Rewritten (v2.0) by Carl Jackson, December 10, 2010 */ 9 | /* See README.txt file for details */ 10 | /* ========================================================================== */ 11 | 12 | #ifndef Sensirion_h 13 | #define Sensirion_h 14 | 15 | #include 16 | 17 | // Enable CRC checking 18 | #define CRC_ENA 19 | 20 | // Enable ('1') or disable ('0') internal pullup on DATA line 21 | // Commenting out this #define saves code space but leaves internal pullup 22 | // state undefined (ie, depends on last bit transmitted) 23 | #define DATA_PU 1 24 | 25 | // Clock pulse timing macros 26 | // Lengthening these may assist communication over long wires 27 | #define PULSE_LONG delayMicroseconds(3) 28 | #define PULSE_SHORT delayMicroseconds(1) 29 | 30 | // Useful macros 31 | #define measTemp(result) meas(TEMP, result, BLOCK) 32 | #define measHumi(result) meas(HUMI, result, BLOCK) 33 | 34 | // User constants 35 | const uint8_t TEMP = 0; 36 | const uint8_t HUMI = 1; 37 | const bool BLOCK = true; 38 | const bool NONBLOCK = false; 39 | 40 | // Status register bit definitions 41 | const uint8_t LOW_RES = 0x01; // 12-bit Temp / 8-bit RH (vs. 14 / 12) 42 | const uint8_t NORELOAD = 0x02; // No reload of calibrarion data 43 | const uint8_t HEAT_ON = 0x04; // Built-in heater on 44 | const uint8_t BATT_LOW = 0x40; // VDD < 2.47V 45 | 46 | // Function return code definitions 47 | const uint8_t S_Err_NoACK = 1; // ACK expected but not received 48 | const uint8_t S_Err_CRC = 2; // CRC failure 49 | const uint8_t S_Err_TO = 3; // Timeout 50 | const uint8_t S_Meas_Rdy = 4; // Measurement ready 51 | 52 | class Sensirion 53 | { 54 | private: 55 | uint8_t _pinData; 56 | uint8_t _pinClock; 57 | uint16_t *_presult; 58 | uint8_t _stat_reg; 59 | #ifdef CRC_ENA 60 | uint8_t _crc; 61 | #endif 62 | uint8_t getResult(uint16_t *result); 63 | uint8_t putByte(uint8_t value); 64 | uint8_t getByte(bool ack); 65 | void startTransmission(void); 66 | void resetConnection(void); 67 | #ifdef CRC_ENA 68 | void calcCRC(uint8_t value, uint8_t *crc); 69 | uint8_t bitrev(uint8_t value); 70 | #endif 71 | public: 72 | Sensirion(uint8_t dataPin, uint8_t clockPin); 73 | uint8_t measure(float *temp, float *humi, float *dew); 74 | uint8_t meas(uint8_t cmd, uint16_t *result, bool block); 75 | uint8_t measRdy(void); 76 | uint8_t writeSR(uint8_t value); 77 | uint8_t readSR(uint8_t *result); 78 | uint8_t reset(void); 79 | float calcTemp(uint16_t rawData); 80 | float calcHumi(uint16_t rawData, float temp); 81 | float calcDewpoint(float humi, float temp); 82 | }; 83 | 84 | #endif // #ifndef Sensirion_h 85 | -------------------------------------------------------------------------------- /arduino/libraries/Sensirion/examples/SimpleSensirion/SimpleSensirion.pde: -------------------------------------------------------------------------------- 1 | /* 2 | * Query a SHT10 temperature and humidity sensor 3 | * 4 | * A simple example that queries the sensor every 5 seconds 5 | * and communicates the result over a serial connection. 6 | * Error handling is omitted in this example. 7 | */ 8 | 9 | #include 10 | 11 | const uint8_t dataPin = 2; 12 | const uint8_t clockPin = 3; 13 | 14 | float temperature; 15 | float humidity; 16 | float dewpoint; 17 | 18 | Sensirion tempSensor = Sensirion(dataPin, clockPin); 19 | 20 | void setup() 21 | { 22 | Serial.begin(9600); 23 | } 24 | 25 | void loop() 26 | { 27 | tempSensor.measure(&temperature, &humidity, &dewpoint); 28 | 29 | Serial.print("Temperature: "); 30 | Serial.print(temperature); 31 | Serial.print(" C, Humidity: "); 32 | Serial.print(humidity); 33 | Serial.print(" %, Dewpoint: "); 34 | Serial.print(dewpoint); 35 | Serial.println(" C"); 36 | 37 | delay(5000); 38 | } 39 | -------------------------------------------------------------------------------- /arduino/libraries/Sensirion/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Sensirion 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | Sensirion KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | measure KEYWORD2 16 | meas KEYWORD2 17 | measTemp KEYWORD2 18 | measHumi KEYWORD2 19 | measRdy KEYWORD2 20 | writeSR KEYWORD2 21 | readSR KEYWORD2 22 | reset KEYWORD2 23 | calcTemp KEYWORD2 24 | calcHumi KEYWORD2 25 | calcDewpoint KEYWORD2 26 | 27 | ####################################### 28 | # Constants (LITERAL1) 29 | ####################################### 30 | 31 | TEMP LITERAL1 32 | HUMI LITERAL1 33 | BLOCK LITERAL1 34 | NONBLOCK LITERAL1 35 | LOW_RES LITERAL1 36 | NORELOAD LITERAL1 37 | HEAT_ON LITERAL1 38 | BATT_LOW LITERAL1 39 | S_Err_NoACK LITERAL1 40 | S_Err_CRC LITERAL1 41 | S_Err_TO LITERAL1 42 | S_Meas_Rdy LITERAL1 43 | -------------------------------------------------------------------------------- /arduino/libraries/SparkFun_MS5803_I2C/SparkFun_MS5803_I2C.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | MS5803_I2C.h 3 | Library for MS5803 pressure sensors. 4 | Casey Kuhns @ SparkFun Electronics 5 | 6/26/2014 6 | https://github.com/sparkfun/MS5803-14BA_Breakout 7 | 8 | The MS58XX MS57XX and MS56XX by Measurement Specialties is a low cost I2C pressure 9 | sensor. This sensor can be used in weather stations and for altitude 10 | estimations. It can also be used underwater for water depth measurements. 11 | 12 | In this file are the function prototypes in the MS5803 class 13 | 14 | Resources: 15 | This library uses the Arduino Wire.h to complete I2C transactions. 16 | 17 | Development environment specifics: 18 | IDE: Arduino 1.0.5 19 | Hardware Platform: Arduino Pro 3.3V/8MHz 20 | MS5803 Breakout Version: 1.0 21 | 22 | **Updated for Arduino 1.6.4 5/2015** 23 | 24 | This code is beerware. If you see me (or any other SparkFun employee) at the 25 | local pub, and you've found our code helpful, please buy us a round! 26 | 27 | Distributed as-is; no warranty is given. 28 | ******************************************************************************/ 29 | 30 | #ifndef SparkFun_MS5803_I2C_h 31 | #define SparkFun_MS5803_I2C_h 32 | 33 | #include 34 | 35 | // Define units for conversions. 36 | enum temperature_units 37 | { 38 | CELSIUS, 39 | FAHRENHEIT, 40 | }; 41 | 42 | // Define measurement type. 43 | enum measurement 44 | { 45 | PRESSURE = 0x00, 46 | TEMPERATURE = 0x10 47 | }; 48 | 49 | // Define constants for Conversion precision 50 | enum precision 51 | { 52 | ADC_256 = 0x00, 53 | ADC_512 = 0x02, 54 | ADC_1024 = 0x04, 55 | ADC_2048 = 0x06, 56 | ADC_4096 = 0x08 57 | }; 58 | 59 | // Define address choices for the device (I2C mode) 60 | enum ms5803_addr 61 | { 62 | ADDRESS_HIGH = 0x76, 63 | ADDRESS_LOW = 0x77 64 | }; 65 | 66 | //Commands 67 | #define CMD_RESET 0x1E // reset command 68 | #define CMD_ADC_READ 0x00 // ADC read command 69 | #define CMD_ADC_CONV 0x40 // ADC conversion command 70 | 71 | #define CMD_PROM 0xA0 // Coefficient location 72 | 73 | class MS5803 74 | { 75 | public: 76 | MS5803(ms5803_addr address); 77 | void reset(void); //Reset device 78 | uint8_t begin(void); // Collect coefficients from sensor 79 | 80 | // Return calculated temperature from sensor 81 | float getTemperature(temperature_units units, precision _precision); 82 | // Return calculated pressure from sensor 83 | float getPressure(precision _precision); 84 | 85 | private: 86 | int32_t _temperature_actual; 87 | int32_t _pressure_actual; 88 | 89 | ms5803_addr _address; // Variable used to store I2C device address. 90 | uint16_t coefficient[8]; // Coefficients; 91 | 92 | void getMeasurements(precision _precision); 93 | 94 | void sendCommand(uint8_t command); // General I2C send command function 95 | uint32_t getADCconversion(measurement _measurement, precision _precision); // Retrieve ADC result 96 | 97 | void sensorWait(uint8_t time); // General delay function see: delay() 98 | }; 99 | 100 | #endif -------------------------------------------------------------------------------- /arduino/libraries/dht/dht.h: -------------------------------------------------------------------------------- 1 | // 2 | // FILE: dht.h 3 | // AUTHOR: Rob Tillaart 4 | // VERSION: 0.1.14 5 | // PURPOSE: DHT Temperature & Humidity Sensor library for Arduino 6 | // URL: http://arduino.cc/playground/Main/DHTLib 7 | // 8 | // HISTORY: 9 | // see dht.cpp file 10 | // 11 | 12 | #ifndef dht_h 13 | #define dht_h 14 | 15 | #if ARDUINO < 100 16 | #include 17 | #else 18 | #include 19 | #endif 20 | 21 | #define DHT_LIB_VERSION "0.1.14" 22 | 23 | #define DHTLIB_OK 0 24 | #define DHTLIB_ERROR_CHECKSUM -1 25 | #define DHTLIB_ERROR_TIMEOUT -2 26 | #define DHTLIB_INVALID_VALUE -999 27 | 28 | #define DHTLIB_DHT11_WAKEUP 18 29 | #define DHTLIB_DHT_WAKEUP 1 30 | 31 | // max timeout is 100 usec. 32 | // For a 16 Mhz proc 100 usec is 1600 clock cycles 33 | // loops using DHTLIB_TIMEOUT use at least 4 clock cycli 34 | // so 100 us takes max 400 loops 35 | // so by dividing F_CPU by 40000 we "fail" as fast as possible 36 | #define DHTLIB_TIMEOUT (F_CPU / 40000) 37 | 38 | class dht 39 | { 40 | public: 41 | // return values: 42 | // DHTLIB_OK 43 | // DHTLIB_ERROR_CHECKSUM 44 | // DHTLIB_ERROR_TIMEOUT 45 | int read11(uint8_t pin); 46 | int read(uint8_t pin); 47 | 48 | inline int read21(uint8_t pin) { return read(pin); }; 49 | inline int read22(uint8_t pin) { return read(pin); }; 50 | inline int read33(uint8_t pin) { return read(pin); }; 51 | inline int read44(uint8_t pin) { return read(pin); }; 52 | 53 | double humidity; 54 | double temperature; 55 | 56 | private: 57 | uint8_t bits[5]; // buffer to receive data 58 | int _readSensor(uint8_t pin, uint8_t wakeupDelay); 59 | }; 60 | #endif 61 | // 62 | // END OF FILE 63 | // -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/.gitignore: -------------------------------------------------------------------------------- 1 | # Mac stuff 2 | .DS_Store 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | 9 | # Compiled Dynamic libraries 10 | *.so 11 | *.dylib 12 | 13 | # Compiled Static libraries 14 | *.lai 15 | *.la 16 | *.a 17 | 18 | -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | python: 3 | - "2.7" 4 | 5 | # Cache PlatformIO packages using Travis CI container-based infrastructure 6 | cache: 7 | pip: true 8 | directories: 9 | - "~/.platformio" 10 | 11 | env: 12 | - > 13 | PLATFORMIO_CI_SRC=$PWD/examples/Webserver 14 | ARDUINOIDE_CI_SRC=$PLATFORMIO_CI_SRC/Webserver.ino 15 | BOARDS="--board=diecimilaatmega328 --board=uno --board=esp01" 16 | - > 17 | PLATFORMIO_CI_SRC=$PWD/examples/ReceiveDemo_Simple 18 | ARDUINOIDE_CI_SRC=$PLATFORMIO_CI_SRC/ReceiveDemo_Simple.ino 19 | BOARDS="--board=diecimilaatmega328 --board=uno --board=esp01" 20 | - > 21 | PLATFORMIO_CI_SRC=$PWD/examples/TypeC_Intertechno 22 | ARDUINOIDE_CI_SRC=$PLATFORMIO_CI_SRC/TypeC_Intertechno.ino 23 | BOARDS="--board=diecimilaatmega328 --board=uno --board=esp01 --board=attiny25 --board=attiny24" 24 | - > 25 | PLATFORMIO_CI_SRC=$PWD/examples/TypeD_REV 26 | ARDUINOIDE_CI_SRC=$PLATFORMIO_CI_SRC/TypeD_REV.ino 27 | BOARDS="--board=diecimilaatmega328 --board=uno --board=esp01 --board=attiny25 --board=attiny24" 28 | - > 29 | PLATFORMIO_CI_SRC=$PWD/examples/TypeA_WithDIPSwitches 30 | ARDUINOIDE_CI_SRC=$PLATFORMIO_CI_SRC/TypeA_WithDIPSwitches.ino 31 | BOARDS="--board=diecimilaatmega328 --board=uno --board=esp01 --board=attiny25 --board=attiny24" 32 | - > 33 | PLATFORMIO_CI_SRC=$PWD/examples/TypeA_WithDIPSwitches_Lightweight 34 | ARDUINOIDE_CI_SRC=$PLATFORMIO_CI_SRC/TypeA_WithDIPSwitches_Lightweight.ino 35 | BOARDS="--board=diecimilaatmega328 --board=uno --board=esp01 --board=attiny25 --board=attiny24" 36 | - > 37 | PLATFORMIO_CI_SRC=$PWD/examples/TypeB_WithRotaryOrSlidingSwitches 38 | ARDUINOIDE_CI_SRC=$PLATFORMIO_CI_SRC/TypeB_WithRotaryOrSlidingSwitches.ino 39 | BOARDS="--board=diecimilaatmega328 --board=uno --board=esp01 --board=attiny25 --board=attiny24" 40 | - > 41 | PLATFORMIO_CI_SRC=$PWD/examples/SendDemo 42 | ARDUINOIDE_CI_SRC=$PLATFORMIO_CI_SRC/SendDemo.ino 43 | BOARDS="--board=diecimilaatmega328 --board=uno --board=esp01" 44 | - > 45 | PLATFORMIO_CI_SRC=$PWD/examples/ReceiveDemo_Advanced 46 | ARDUINOIDE_CI_SRC=$PLATFORMIO_CI_SRC/ReceiveDemo_Advanced.ino 47 | BOARDS="--board=diecimilaatmega328 --board=uno --board=esp01" 48 | 49 | before_install: 50 | # Arduino IDE 51 | - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16" 52 | - sleep 3 53 | - export DISPLAY=:1.0 54 | - wget http://downloads.arduino.cc/arduino-1.6.9-linux64.tar.xz 55 | - tar xf arduino-1.6.9-linux64.tar.xz 56 | - sudo mv arduino-1.6.9 /usr/local/share/arduino 57 | - sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino 58 | 59 | install: 60 | # Arduino IDE 61 | - ln -s $PWD /usr/local/share/arduino/libraries/rc-switch 62 | # PlatformIO 63 | - sudo pip install -U platformio 64 | 65 | script: 66 | # Arduino IDE 67 | - arduino --verify --board arduino:avr:uno ${ARDUINOIDE_CI_SRC} 68 | # PlatformIO 69 | - platformio ci --lib="." ${BOARDS} 70 | -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/README.md: -------------------------------------------------------------------------------- 1 | # rc-switch 2 | [![Build Status](https://travis-ci.org/sui77/rc-switch.svg?branch=master)](https://travis-ci.org/sui77/rc-switch) 3 | 4 | Use your Arduino or Raspberry Pi to operate remote radio controlled devices 5 | 6 | ## Download 7 | https://github.com/sui77/rc-switch/releases/latest 8 | 9 | rc-switch is also listed in the arduino library manager. 10 | 11 | ## Wiki 12 | https://github.com/sui77/rc-switch/wiki 13 | 14 | ## Info 15 | ### Send RC codes 16 | 17 | Use your Arduino or Raspberry Pi to operate remote radio controlled devices. 18 | This will most likely work with all popular low cost power outlet sockets. If 19 | yours doesn't work, you might need to adjust the pulse length. 20 | 21 | All you need is a Arduino or Raspberry Pi, a 315/433MHz AM transmitter and one 22 | or more devices with one of the supported chipsets: 23 | 24 | - SC5262 / SC5272 25 | - HX2262 / HX2272 26 | - PT2262 / PT2272 27 | - EV1527 / RT1527 / FP1527 / HS1527 28 | - Intertechno outlets 29 | - HT6P20X 30 | 31 | ### Receive and decode RC codes 32 | 33 | Find out what codes your remote is sending. Use your remote to control your 34 | Arduino. 35 | 36 | All you need is an Arduino, a 315/433MHz AM receiver (altough there is no 37 | instruction yet, yes it is possible to hack an existing device) and a remote 38 | hand set. 39 | 40 | For the Raspberry Pi, clone the https://github.com/ninjablocks/433Utils project to 41 | compile a sniffer tool and transmission commands. 42 | -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/examples/ReceiveDemo_Advanced/ReceiveDemo_Advanced.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for receiving 3 | 4 | https://github.com/sui77/rc-switch/ 5 | 6 | If you want to visualize a telegram copy the raw data and 7 | paste it into http://test.sui.li/oszi/ 8 | */ 9 | 10 | #include 11 | 12 | RCSwitch mySwitch = RCSwitch(); 13 | 14 | void setup() { 15 | Serial.begin(9600); 16 | mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2 17 | } 18 | 19 | void loop() { 20 | if (mySwitch.available()) { 21 | output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol()); 22 | mySwitch.resetAvailable(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/examples/ReceiveDemo_Advanced/output.ino: -------------------------------------------------------------------------------- 1 | static const char* bin2tristate(const char* bin); 2 | static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength); 3 | 4 | void output(unsigned long decimal, unsigned int length, unsigned int delay, unsigned int* raw, unsigned int protocol) { 5 | 6 | const char* b = dec2binWzerofill(decimal, length); 7 | Serial.print("Decimal: "); 8 | Serial.print(decimal); 9 | Serial.print(" ("); 10 | Serial.print( length ); 11 | Serial.print("Bit) Binary: "); 12 | Serial.print( b ); 13 | Serial.print(" Tri-State: "); 14 | Serial.print( bin2tristate( b) ); 15 | Serial.print(" PulseLength: "); 16 | Serial.print(delay); 17 | Serial.print(" microseconds"); 18 | Serial.print(" Protocol: "); 19 | Serial.println(protocol); 20 | 21 | Serial.print("Raw data: "); 22 | for (unsigned int i=0; i<= length*2; i++) { 23 | Serial.print(raw[i]); 24 | Serial.print(","); 25 | } 26 | Serial.println(); 27 | Serial.println(); 28 | } 29 | 30 | static const char* bin2tristate(const char* bin) { 31 | static char returnValue[50]; 32 | int pos = 0; 33 | int pos2 = 0; 34 | while (bin[pos]!='\0' && bin[pos+1]!='\0') { 35 | if (bin[pos]=='0' && bin[pos+1]=='0') { 36 | returnValue[pos2] = '0'; 37 | } else if (bin[pos]=='1' && bin[pos+1]=='1') { 38 | returnValue[pos2] = '1'; 39 | } else if (bin[pos]=='0' && bin[pos+1]=='1') { 40 | returnValue[pos2] = 'F'; 41 | } else { 42 | return "not applicable"; 43 | } 44 | pos = pos+2; 45 | pos2++; 46 | } 47 | returnValue[pos2] = '\0'; 48 | return returnValue; 49 | } 50 | 51 | static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength) { 52 | static char bin[64]; 53 | unsigned int i=0; 54 | 55 | while (Dec > 0) { 56 | bin[32+i++] = ((Dec & 1) > 0) ? '1' : '0'; 57 | Dec = Dec >> 1; 58 | } 59 | 60 | for (unsigned int j = 0; j< bitLength; j++) { 61 | if (j >= bitLength - i) { 62 | bin[j] = bin[ 31 + i - (j - (bitLength - i)) ]; 63 | } else { 64 | bin[j] = '0'; 65 | } 66 | } 67 | bin[bitLength] = '\0'; 68 | 69 | return bin; 70 | } 71 | -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/examples/ReceiveDemo_Simple/ReceiveDemo_Simple.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Simple example for receiving 3 | 4 | https://github.com/sui77/rc-switch/ 5 | */ 6 | 7 | #include 8 | 9 | RCSwitch mySwitch = RCSwitch(); 10 | 11 | void setup() { 12 | Serial.begin(9600); 13 | mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2 14 | } 15 | 16 | void loop() { 17 | if (mySwitch.available()) { 18 | 19 | Serial.print("Received "); 20 | Serial.print( mySwitch.getReceivedValue() ); 21 | Serial.print(" / "); 22 | Serial.print( mySwitch.getReceivedBitlength() ); 23 | Serial.print("bit "); 24 | Serial.print("Protocol: "); 25 | Serial.println( mySwitch.getReceivedProtocol() ); 26 | 27 | mySwitch.resetAvailable(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/examples/SendDemo/.SendDemo.ino.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hydrogeologger/pyduino/47b96c04b8c070ca040bc57824ee28e49d4c7033/arduino/libraries/rc-switch/examples/SendDemo/.SendDemo.ino.swp -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/examples/SendDemo/SendDemo.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for different sending methods 3 | 4 | https://github.com/sui77/rc-switch/ 5 | 6 | */ 7 | 8 | #include 9 | char *binarycode[] = {"011101101101100000001111100111100", "011101101101100000001110100111110"}; 10 | 11 | RCSwitch mySwitch = RCSwitch(); 12 | 13 | void setup() { 14 | 15 | Serial.begin(9600); 16 | 17 | // Transmitter is connected to Arduino Pin #10 18 | mySwitch.enableTransmit(10); 19 | 20 | // Optional set protocol (default is 1, will work for most outlets) 21 | // mySwitch.setProtocol(2); 22 | 23 | // Optional set pulse length. 24 | mySwitch.setPulseLength(320); 25 | 26 | // Optional set number of transmission repetitions. 27 | // mySwitch.setRepeatTransmit(15); 28 | 29 | } 30 | 31 | void loop() { 32 | 33 | /* See Example: TypeA_WithDIPSwitches */ 34 | //mySwitch.switchOn("11111", "00010"); 35 | //delay(1000); 36 | //mySwitch.switchOff("11111", "00010"); 37 | //delay(1000); 38 | 39 | ///* Same switch as above, but using decimal code */ 40 | //mySwitch.send(5393, 24); 41 | //delay(1000); 42 | //mySwitch.send(5396, 24); 43 | //delay(1000); 44 | 45 | /* Same switch as above, but using binary code */ 46 | mySwitch.send(binarycode[0]); 47 | delay(1000); 48 | //mySwitch.send("011101101101100000001110100111110"); 49 | //delay(1000); 50 | 51 | /* Same switch as above, but tri-state code */ 52 | //mySwitch.sendTriState("00000FFF0F0F"); 53 | //delay(1000); 54 | //mySwitch.sendTriState("00000FFF0FF0"); 55 | //delay(1000); 56 | 57 | delay(5000); 58 | } 59 | -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/examples/TypeA_WithDIPSwitches/TypeA_WithDIPSwitches.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for outlets which are configured with a 10 pole DIP switch. 3 | 4 | https://github.com/sui77/rc-switch/ 5 | */ 6 | 7 | #include 8 | 9 | RCSwitch mySwitch = RCSwitch(); 10 | 11 | void setup() { 12 | 13 | // Transmitter is connected to Arduino Pin #10 14 | mySwitch.enableTransmit(10); 15 | 16 | // Optional set pulse length. 17 | // mySwitch.setPulseLength(320); 18 | 19 | } 20 | 21 | void loop() { 22 | 23 | // Switch on: 24 | // The first parameter represents the setting of the first 5 DIP switches. 25 | // In this example it's ON-ON-OFF-OFF-ON. 26 | // 27 | // The second parameter represents the setting of the last 5 DIP switches. 28 | // In this example the last 5 DIP switches are OFF-ON-OFF-ON-OFF. 29 | mySwitch.switchOn("11001", "01010"); 30 | 31 | // Wait a second 32 | delay(1000); 33 | 34 | // Switch off 35 | mySwitch.switchOff("11001", "01010"); 36 | 37 | // Wait another second 38 | delay(1000); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/examples/TypeA_WithDIPSwitches_Lightweight/TypeA_WithDIPSwitches_Lightweight.ino: -------------------------------------------------------------------------------- 1 | /* 2 | This is a minimal sketch without using the library at all but only works for 3 | the 10 pole dip switch sockets. It saves a lot of memory and thus might be 4 | very useful to use with ATTinys :) 5 | 6 | https://github.com/sui77/rc-switch/ 7 | */ 8 | 9 | int RCLpin = 7; 10 | 11 | void setup() { 12 | pinMode(RCLpin, OUTPUT); 13 | } 14 | 15 | void loop() { 16 | RCLswitch(0b010001000001); // DIPs an Steckdose: 0100010000 An:01 17 | delay(2000); 18 | 19 | RCLswitch(0b010001000010); // DIPs an Steckdose: 0100010000 Aus:10 20 | delay(2000); 21 | } 22 | 23 | void RCLswitch(uint16_t code) { 24 | for (int nRepeat=0; nRepeat<6; nRepeat++) { 25 | for (int i=4; i<16; i++) { 26 | RCLtransmit(1,3); 27 | if (((code << (i-4)) & 2048) > 0) { 28 | RCLtransmit(1,3); 29 | } else { 30 | RCLtransmit(3,1); 31 | } 32 | } 33 | RCLtransmit(1,31); 34 | } 35 | } 36 | 37 | void RCLtransmit(int nHighPulses, int nLowPulses) { 38 | digitalWrite(RCLpin, HIGH); 39 | delayMicroseconds( 350 * nHighPulses); 40 | digitalWrite(RCLpin, LOW); 41 | delayMicroseconds( 350 * nLowPulses); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/examples/TypeB_WithRotaryOrSlidingSwitches/TypeB_WithRotaryOrSlidingSwitches.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for outlets which are configured with two rotary/sliding switches. 3 | 4 | https://github.com/sui77/rc-switch/ 5 | */ 6 | 7 | #include 8 | 9 | RCSwitch mySwitch = RCSwitch(); 10 | 11 | void setup() { 12 | 13 | // Transmitter is connected to Arduino Pin #10 14 | mySwitch.enableTransmit(10); 15 | 16 | // Optional set pulse length. 17 | // mySwitch.setPulseLength(320); 18 | 19 | } 20 | 21 | void loop() { 22 | 23 | // Switch on: 24 | // The first parameter represents the setting of the first rotary switch. 25 | // In this example it's switched to "1" or "A" or "I". 26 | // 27 | // The second parameter represents the setting of the second rotary switch. 28 | // In this example it's switched to "4" or "D" or "IV". 29 | mySwitch.switchOn(1, 4); 30 | 31 | // Wait a second 32 | delay(1000); 33 | 34 | // Switch off 35 | mySwitch.switchOff(1, 4); 36 | 37 | // Wait another second 38 | delay(1000); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/examples/TypeC_Intertechno/TypeC_Intertechno.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for Intertechno outlets 3 | 4 | https://github.com/sui77/rc-switch/ 5 | */ 6 | 7 | #include 8 | 9 | RCSwitch mySwitch = RCSwitch(); 10 | 11 | void setup() { 12 | 13 | // Transmitter is connected to Arduino Pin #10 14 | mySwitch.enableTransmit(10); 15 | 16 | // Optional set pulse length. 17 | // mySwitch.setPulseLength(320); 18 | 19 | } 20 | 21 | void loop() { 22 | 23 | // Switch on: 24 | // The first parameter represents the familycode (a, b, c, ... f) 25 | // The second parameter represents the group number 26 | // The third parameter represents the device number 27 | // 28 | // In this example it's family 'b', group #3, device #2 29 | mySwitch.switchOn('b', 3, 2); 30 | 31 | // Wait a second 32 | delay(1000); 33 | 34 | // Switch off 35 | mySwitch.switchOff('b', 3, 2); 36 | 37 | // Wait another second 38 | delay(1000); 39 | 40 | } -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/examples/TypeD_REV/TypeD_REV.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for REV outlets (e.g. 8342L) 3 | 4 | https://github.com/sui77/rc-switch/ 5 | 6 | Need help? http://forum.ardumote.com 7 | */ 8 | 9 | #include 10 | 11 | RCSwitch mySwitch = RCSwitch(); 12 | 13 | void setup() { 14 | 15 | // Transmitter is connected to Arduino Pin #10 16 | mySwitch.enableTransmit(10); 17 | 18 | // set pulse length. 19 | mySwitch.setPulseLength(360); 20 | 21 | } 22 | 23 | void loop() { 24 | 25 | // Switch on: 26 | // The first parameter represents the channel (a, b, c, d) 27 | // The second parameter represents the device number 28 | // 29 | // In this example it's family 'd', device #2 30 | mySwitch.switchOn('d', 2); 31 | 32 | // Wait a second 33 | delay(1000); 34 | 35 | // Switch off 36 | mySwitch.switchOff('d', 2); 37 | 38 | // Wait another second 39 | delay(1000); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For RCSwitch 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | RCSwitch KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | ########## 16 | #SENDS Begin 17 | ########## 18 | switchOn KEYWORD2 19 | switchOff KEYWORD2 20 | sendTriState KEYWORD2 21 | send KEYWORD2 22 | ########## 23 | #SENDS End 24 | ########## 25 | 26 | ########## 27 | #RECEIVE Begin 28 | ########## 29 | enableReceive KEYWORD2 30 | disableReceive KEYWORD2 31 | available KEYWORD2 32 | resetAvailable KEYWORD2 33 | setReceiveTolerance KEYWORD2 34 | getReceivedValue KEYWORD2 35 | getReceivedBitlength KEYWORD2 36 | getReceivedDelay KEYWORD2 37 | getReceivedProtocol KEYWORD2 38 | getReceivedRawdata KEYWORD2 39 | ########## 40 | #RECEIVE End 41 | ########## 42 | 43 | ########## 44 | #OTHERS Begin 45 | ########## 46 | enableTransmit KEYWORD2 47 | disableTransmit KEYWORD2 48 | setPulseLength KEYWORD2 49 | setProtocol KEYWORD2 50 | setRepeatTransmit KEYWORD2 51 | ########## 52 | #OTHERS End 53 | ########## 54 | 55 | ####################################### 56 | # Constants (LITERAL1) 57 | ####################################### 58 | -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rc-switch", 3 | "description": "Use your Arduino or Raspberry Pi to operate remote radio controlled devices", 4 | "keywords": "rf, radio, wireless", 5 | "authors": 6 | { 7 | "name": "Suat Ozgur" 8 | }, 9 | "repository": 10 | { 11 | "type": "git", 12 | "url": "https://github.com/sui77/rc-switch.git" 13 | }, 14 | "version": "2.6.2", 15 | "frameworks": [ 16 | "arduino", 17 | "energia", 18 | "wiringpi" 19 | ], 20 | "platforms": "*" 21 | } 22 | -------------------------------------------------------------------------------- /arduino/libraries/rc-switch/library.properties: -------------------------------------------------------------------------------- 1 | name=rc-switch 2 | version=2.6.2 3 | author=sui77 4 | maintainer=sui77,fingolfin 5 | sentence=Operate 433/315Mhz devices. 6 | paragraph=Use your Arduino, ESP8266/ESP32 or Raspberry Pi to operate remote radio controlled devices. This will most likely work with all popular low cost power outlet sockets. 7 | category=Device Control 8 | url=https://github.com/sui77/rc-switch 9 | architectures=avr,esp8266,esp32 10 | includes=RCSwitch.h 11 | -------------------------------------------------------------------------------- /arduino/loadcell_twolayer_tas606_TE/loadcell_twolayer_tas606_TE.ino: -------------------------------------------------------------------------------- 1 | #include "HX711.h" 2 | 3 | #define DOUT2 5 4 | #define CLK2 4 5 | 6 | //HX711 scale_0(DOUT1, CLK1); 7 | HX711 scale_1(DOUT2, CLK2); 8 | 9 | 10 | 11 | float calibration_factor[5]= {23080,72800,72800,72800,72800}; 12 | 13 | float te_scale = 0.; 14 | float reading_1 = 0.; 15 | 16 | float scale_data[5]; 17 | 18 | const int number_readings=7; 19 | const int dummy_readings=3; 20 | 21 | float reading_ind_1[number_readings]; 22 | char delimiter=','; 23 | 24 | 25 | 26 | //---------------------below required by module heat_suction_sensor----------------------------------------------------# 27 | 28 | const int te_analog_pin=3; 29 | 30 | //---------------------above required by module heat_suction_sensor----------------------------------------------------# 31 | 32 | 33 | void setup() { 34 | Serial.begin(9600); 35 | scale_1.set_scale(); 36 | 37 | long zero_factor_1 = scale_1.read_average(); //Get a baseline reading 38 | 39 | pinMode(6, OUTPUT); 40 | pinMode(3, OUTPUT); 41 | pinMode(2, OUTPUT); 42 | 43 | } 44 | 45 | void loop() { 46 | //char temp = Serial.read(); 47 | // be careful here! if it is a string, use double quote, if it is a char, use single quote 48 | // http://stackoverflow.com/questions/5697047/convert-serial-read-into-a-useable-string-using-arduino 49 | Serial.print("scale"); 50 | Serial.print(delimiter); 51 | te_scale_read(); 52 | delay(5000); 53 | tas606_read(); 54 | Serial.println(); 55 | delay_min(10); 56 | } //loop 57 | 58 | void te_scale_read() { 59 | 60 | digitalWrite(2, HIGH); 61 | for (int j=0;j= 100 10 | #include "Arduino.h" 11 | #else 12 | #include "WProgram.h" 13 | #endif 14 | 15 | 16 | // Uncomment to enable printing out nice debug messages. 17 | //#define DHT_DEBUG 18 | 19 | // Define where debug output will be printed. 20 | #define DEBUG_PRINTER Serial 21 | 22 | // Setup debug printing macros. 23 | #ifdef DHT_DEBUG 24 | #define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); } 25 | #define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); } 26 | #else 27 | #define DEBUG_PRINT(...) {} 28 | #define DEBUG_PRINTLN(...) {} 29 | #endif 30 | 31 | // Define types of sensors. 32 | #define DHT11 11 33 | #define DHT22 22 34 | #define DHT21 21 35 | #define AM2301 21 36 | 37 | 38 | class DHT { 39 | public: 40 | DHT(uint8_t pin, uint8_t type, uint8_t count=6); 41 | void begin(void); 42 | float readTemperature(bool S=false, bool force=false); 43 | float convertCtoF(float); 44 | float convertFtoC(float); 45 | float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true); 46 | float readHumidity(bool force=false); 47 | boolean read(bool force=false); 48 | 49 | private: 50 | uint8_t data[5]; 51 | uint8_t _pin, _type; 52 | #ifdef __AVR 53 | // Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask 54 | // for the digital pin connected to the DHT. Other platforms will use digitalRead. 55 | uint8_t _bit, _port; 56 | #endif 57 | uint32_t _lastreadtime, _maxcycles; 58 | bool _lastresult; 59 | 60 | uint32_t expectPulse(bool level); 61 | 62 | }; 63 | 64 | class InterruptLock { 65 | public: 66 | InterruptLock() { 67 | noInterrupts(); 68 | } 69 | ~InterruptLock() { 70 | interrupts(); 71 | } 72 | 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /arduino/logger3/hydrogeolog/hydrogeolog.h: -------------------------------------------------------------------------------- 1 | #ifndef hydrogeolog_h 2 | #define hydrogeolog_h 3 | 4 | #include "Arduino.h" 5 | #include 6 | //#include 7 | #include 8 | //#include "hydrogeolog" 9 | 10 | class hydrogeolog 11 | { 12 | public: 13 | hydrogeolog(const char delimiter); 14 | //int split_strings(String inp); 15 | //void print_str_ay(int number_opts); 16 | int split_strings(String inp2,String str_ay2[20]); 17 | void print_str_ay(int number_opts,String str_ay2[20]); 18 | int strcmpi(String str_source, int number_opts,String str_ay2[20]); 19 | float analog_excite_read(int power_sw_idx,int analog_idx,int number_of_dummies,int number_of_measurement,int measure_time_interval); 20 | int parse_argument(String str_source, int default_values, int number_opts, String str_ay2[20]); 21 | void switch_power(int power_sw_idx,int status); 22 | void dht22_excite_read(int power_sw_idx,int digi_idx,int number_of_dummies,int number_of_measurements,int measure_time_interval); 23 | void print_string_delimiter_value(String string_input,String value); 24 | void search_ds18b20(int digi_pin,int power_switch); 25 | String parse_argument_string(String str_source, String default_values, int number_opts, String str_ay2[20]); 26 | char parse_argument_char(String str_source, char default_values, int number_opts, String str_ay2[20]); 27 | void read_DS18B20_by_addr(byte addr[8],int digi_pin); 28 | private: 29 | int _pin; 30 | String inp2; 31 | String str_ay2[20]; 32 | int number_opts; 33 | const char delimiter=','; 34 | 35 | }; // class 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /arduino/mega_david_logger_1/mega_david_logger_1.ino: -------------------------------------------------------------------------------- 1 | static const uint8_t analog_pins[] = {A0,A1,A2,A3,A4,A5,A6,A7,A8,A9}; 2 | // the array below works for digital sensor arrays 3 | int digital_pins[] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; 4 | float AnalogVals1[10]; 5 | //float AnalogVals2[10]; 6 | int i; 7 | // the delimiter between each reading. it is good to use ',' alwyas 8 | char seperator=','; 9 | //Arrays to store analog values after recieving them 10 | int number_sensors=10; 11 | // the setup routine runs once when you press reset: 12 | 13 | 14 | int number_readings=3; 15 | 16 | int dummy_readings=3; 17 | void setup() { 18 | // initialize serial communication at 9600 bits per second: 19 | Serial.begin(9600); 20 | // let all of the pins as output 21 | 22 | for (int i=0; i= 100 10 | #include "Arduino.h" 11 | #else 12 | #include "WProgram.h" 13 | #endif 14 | 15 | 16 | // Uncomment to enable printing out nice debug messages. 17 | //#define DHT_DEBUG 18 | 19 | // Define where debug output will be printed. 20 | #define DEBUG_PRINTER Serial 21 | 22 | // Setup debug printing macros. 23 | #ifdef DHT_DEBUG 24 | #define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); } 25 | #define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); } 26 | #else 27 | #define DEBUG_PRINT(...) {} 28 | #define DEBUG_PRINTLN(...) {} 29 | #endif 30 | 31 | // Define types of sensors. 32 | #define DHT11 11 33 | #define DHT22 22 34 | #define DHT21 21 35 | #define AM2301 21 36 | 37 | 38 | class DHT { 39 | public: 40 | DHT(uint8_t pin, uint8_t type, uint8_t count=6); 41 | void begin(void); 42 | float readTemperature(bool S=false, bool force=false); 43 | float convertCtoF(float); 44 | float convertFtoC(float); 45 | float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit=true); 46 | float readHumidity(bool force=false); 47 | boolean read(bool force=false); 48 | 49 | private: 50 | uint8_t data[5]; 51 | uint8_t _pin, _type; 52 | #ifdef __AVR 53 | // Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask 54 | // for the digital pin connected to the DHT. Other platforms will use digitalRead. 55 | uint8_t _bit, _port; 56 | #endif 57 | uint32_t _lastreadtime, _maxcycles; 58 | bool _lastresult; 59 | 60 | uint32_t expectPulse(bool level); 61 | 62 | }; 63 | 64 | class InterruptLock { 65 | public: 66 | InterruptLock() { 67 | noInterrupts(); 68 | } 69 | ~InterruptLock() { 70 | interrupts(); 71 | } 72 | 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /arduino/separatevalue/hydrogeolog/hydrogeolog.h: -------------------------------------------------------------------------------- 1 | #ifndef hydrogeolog_h 2 | #define hydrogeolog_h 3 | 4 | #include "Arduino.h" 5 | #include 6 | //#include 7 | #include 8 | //#include "hydrogeolog" 9 | 10 | class hydrogeolog 11 | { 12 | public: 13 | hydrogeolog(const char delimiter); 14 | //int split_strings(String inp); 15 | //void print_str_ay(int number_opts); 16 | int split_strings(String inp2,String str_ay2[20]); 17 | void print_str_ay(int number_opts,String str_ay2[20]); 18 | int strcmpi(String str_source, int number_opts,String str_ay2[20]); 19 | float analog_excite_read(int power_sw_idx,int analog_idx,int number_of_dummies,int number_of_measurement,int measure_time_interval); 20 | int parse_argument(String str_source, int default_values, int number_opts, String str_ay2[20]); 21 | void switch_power(int power_sw_idx,int status); 22 | void dht22_excite_read(int power_sw_idx,int digi_idx,int number_of_dummies,int number_of_measurements,int measure_time_interval); 23 | void print_string_delimiter_value(String string_input,String value); 24 | void search_ds18b20(int digi_pin,int power_switch); 25 | String parse_argument_string(String str_source, String default_values, int number_opts, String str_ay2[20]); 26 | void read_DS18B20_by_addr(byte addr[8],int digi_pin); 27 | private: 28 | int _pin; 29 | String inp2; 30 | String str_ay2[20]; 31 | int number_opts; 32 | const char delimiter=','; 33 | 34 | }; // class 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /arduino/sleep_mode/very_deep_sleep/very_deep_sleep.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | const byte AWAKE_LED = 8; 6 | const byte GREEN_LED = 9; 7 | const unsigned long WAIT_TIME = 5000; 8 | const byte RX_PIN = 4; 9 | const byte TX_PIN = 5; 10 | 11 | SoftwareSerial mySerial(RX_PIN, TX_PIN); // RX, TX 12 | 13 | void setup() 14 | { 15 | pinMode (GREEN_LED, OUTPUT); 16 | pinMode (AWAKE_LED, OUTPUT); 17 | digitalWrite (AWAKE_LED, HIGH); 18 | mySerial.begin(9600); 19 | } // end of setup 20 | 21 | unsigned long lastSleep; 22 | 23 | void loop() 24 | { 25 | if (millis () - lastSleep >= WAIT_TIME) 26 | { 27 | lastSleep = millis (); 28 | 29 | noInterrupts (); 30 | 31 | byte old_ADCSRA = ADCSRA; 32 | // disable ADC 33 | ADCSRA = 0; 34 | 35 | set_sleep_mode (SLEEP_MODE_PWR_DOWN); 36 | power_adc_disable(); 37 | power_spi_disable(); 38 | power_timer0_disable(); 39 | power_timer1_disable(); 40 | power_timer2_disable(); 41 | power_twi_disable(); 42 | 43 | sleep_enable(); 44 | digitalWrite (AWAKE_LED, LOW); 45 | interrupts (); 46 | sleep_cpu (); 47 | digitalWrite (AWAKE_LED, HIGH); 48 | sleep_disable(); 49 | power_all_enable(); 50 | 51 | ADCSRA = old_ADCSRA; 52 | } // end of time to sleep 53 | 54 | if (mySerial.available () > 0) 55 | { 56 | byte flashes = mySerial.read () - '0'; 57 | if (flashes > 0 && flashes < 10) 58 | { 59 | // flash LED x times 60 | for (byte i = 0; i < flashes; i++) 61 | { 62 | digitalWrite (GREEN_LED, HIGH); 63 | delay (200); 64 | digitalWrite (GREEN_LED, LOW); 65 | delay (200); 66 | } 67 | } 68 | } // end of if 69 | 70 | } // end of loop 71 | -------------------------------------------------------------------------------- /arduino/stanwell_sdi12_460_v2/Makefile: -------------------------------------------------------------------------------- 1 | ## How to use 2 | # make upload - upload over hardware serial (normal bootloader) 3 | # make upload 2400 - upload over hardware serial (modified bootloader) 4 | # make softupload - for uploading over software serial (modified bootloader) 5 | 6 | BOARD_TAG = mega 7 | BOARD_SUB = atmega2560 8 | USER_LIB_PATH = /home/$(USER)/pyduino/arduino/libraries/ 9 | ARDUINO_LIBS = SDI12 hydrogeolog SparkFun_MS5803_I2C Sensirion OneWire dht DallasTemperature Adafruit_SI1145_Library Wire rc-switch Adafruit_SHT31 10 | 11 | .PHONY: softupload 2400 12 | 13 | # Declares Port and baudrate settings 14 | ifndef MONITOR_PORT 15 | ifneq ($(filter softupload, $(MAKECMDGOALS)),) 16 | # is software serial upload 17 | export MONITOR_PORT = /dev/ttySOFT0 18 | export AVRDUDE_ARD_BAUDRATE = 2400 19 | else 20 | # Is hardware serial upload, serial0 reference to primary UART 21 | # RPI: ttyS0, BPI: ttyS3 22 | export MONITOR_PORT = /dev/serial0 23 | ifneq ($(filter 2400, $(MAKECMDGOALS)),) 24 | # If modified bootloader, modify upload baudrate 25 | export AVRDUDE_ARD_BAUDRATE = 2400 26 | endif 27 | endif 28 | $(info uploading over $(MONITOR_PORT) at $(AVRDUDE_ARD_BAUDRATE)) 29 | endif 30 | 31 | softupload: upload 32 | 33 | include /usr/share/arduino/Arduino.mk 34 | -------------------------------------------------------------------------------- /arduino/stanwell_sdi12_460_v2/SDI12_function.h: -------------------------------------------------------------------------------- 1 | #ifndef _SDI12_FUNCTION_H_ 2 | #define _SDI12_FUNCTION_H_ 3 | 4 | #include "Arduino.h" 5 | #include 6 | 7 | #define MAX_NUM_ADDR 62 8 | 9 | static volatile uint32_t addressSpace[2] = {(uint32_t)0x00, (uint32_t)0x00}; 10 | 11 | static SDI12 mySDI12(0); 12 | 13 | 14 | void process_command(String cmd, int sensors, String new_addr, boolean isCustom); 15 | boolean sdi12_check_pin(int sdi12_data); 16 | boolean sdi12_init(int sdi12_pin); 17 | int8_t sdi12_scan(void); 18 | void sdi12_end(void); 19 | void sdi12_loop(); 20 | void takeMeasurement_sdi12(char i); 21 | uint8_t printBufferToScreen(void); 22 | boolean checkActive(char i); 23 | uint8_t convert_char_to_bit_number(char c); 24 | char convert_bit_number_to_char(uint8_t bit); 25 | boolean setTaken(char c); 26 | boolean isTaken(char c); 27 | void printInfo(char i); 28 | boolean sdi12_change(char new_addr); 29 | void sdi12_send_command(String cmd, boolean read); 30 | #endif -------------------------------------------------------------------------------- /arduino/stanwell_sdi12_460_v2/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #include "Arduino.h" 5 | 6 | #define TRUE 1 7 | #define FALSE 0 8 | #define INVALID -1 9 | #define DEFAULT_POINTS 5 10 | #define DEFAULT_DUMMIES 3 11 | #define DEFAULT_INTERVAL 10 12 | 13 | /* 14 | v 2.0 PCB global pins variables 15 | */ 16 | #define PI_SW 6 17 | #define HUMIDITY_SEN_SW 2 18 | #define MULTIPLEXER_SW 7 19 | #define REVERSE_SW_1 10 20 | #define REVERSE_SW_2 11 21 | #define REVERSE_SW_3 12 22 | #define REVERSE_SW_4 13 23 | #define _12V5V_SW_1 8 24 | #define _12V5V_SW_2 9 25 | 26 | #define DIGITAL_DHT_COUNT = 6; 27 | volatile static const int digi_dht_ay[] = {3, 4, 5}; 28 | 29 | #define ANALOG_MOIS_COUNT 6 30 | volatile static const uint8_t ana_o2_ay[] = {A0, A1, A2, A3, A5, A6}; 31 | volatile static const uint8_t ana_moisture_ay[] = {A7, A8, A9, A10, A11, A12}; 32 | 33 | #define ANALOG_PIN_COUNT 16; 34 | volatile static const uint8_t analog_pins[] = {A0, A1, A2, A3, A4, 35 | A5, A6, A7, A8, A9, 36 | A10, A11, A12, A13, A14, 37 | A15}; 38 | 39 | /* ATmega2560 / Arduino Mega or Mega 2560 compatible SDi-12 Pins 40 | 0 (Rx0), 11, 12, 13, 14 (Tx3), 15 (Rx3), 50, 51, 52, 53, A8 (62), A9 (63), 41 | A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69) 42 | */ 43 | #define SDI12_PIN_COUNT 12 44 | volatile static const uint8_t sdi12_pins[] = {50, 51, 52, 53, A8, A9, A10, A11, 45 | A12, A13, A14, A15}; 46 | 47 | #define PWM_PIN_COUNT 9 48 | volatile static const uint8_t pwm_pins[] = {3, 4, 5, _12V5V_SW_1, _12V5V_SW_2, 49 | REVERSE_SW_1, REVERSE_SW_2, REVERSE_SW_3, REVERSE_SW_4}; 50 | 51 | #define DIGITAL_PIN_COUNT 37 52 | volatile static int digi_out_pins[] = { 53 | 22, 23, 24, 25, 26, 27, 28, 54 | 29, 30, 31, 32, 33, 34, 35, 55 | 36, 37, 38, 39, 40, 41, 42, 56 | 43, 44, 45, 46, 47, 48, 49, 57 | MULTIPLEXER_SW, PI_SW, HUMIDITY_SEN_SW, 58 | REVERSE_SW_1, REVERSE_SW_2, REVERSE_SW_3, REVERSE_SW_4, 59 | _12V5V_SW_1, _12V5V_SW_2}; 60 | 61 | #define DELIMITER ',' 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /arduino/stanwell_sdi12_460_v2/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | 3 | [platformio] 4 | description = Pyduino datalogger firmware 5 | src_dir = . 6 | 7 | [env] 8 | build_flags = -Wall 9 | lib_ldf_mode = deep+ 10 | lib_extra_dirs = 11 | ..\libraries 12 | 13 | [env:megaatmega2560] 14 | board = megaatmega2560 15 | platform = atmelavr 16 | framework = arduino 17 | build_flags = ${env.build_flags} -std=gnu++11 18 | -------------------------------------------------------------------------------- /arduino/stanwell_sdi12_460_v2/timing.cpp: -------------------------------------------------------------------------------- 1 | #include "timing.h" 2 | #include "common.h" 3 | #include "Arduino.h" 4 | void setMillis(unsigned long new_millis) 5 | /* 6 | set the new value for millis() 7 | */ 8 | { 9 | uint8_t oldSREG = SREG; // save the current status of arduino 'register' 10 | cli(); // stop interrupt "background service" service, which means freeze loop service. 11 | timer0_millis = new_millis; 12 | SREG = oldSREG;// remove 13 | sei();// resume the interrupt background service 14 | } 15 | 16 | void timeout_reset_pi() { 17 | if (millis() > TIMEOUT) 18 | { 19 | /*reset*/ 20 | setMillis(0); 21 | isComm = FALSE; 22 | digitalWrite(PI_SW, HIGH); 23 | delay(DOWN_TIME); 24 | digitalWrite(PI_SW, LOW); 25 | } 26 | } 27 | 28 | void command_reset_pi(String content) { 29 | if (content == "RESET") 30 | { 31 | Serial.println("Reboot in 30 s...."); 32 | delay(30000); // usually it is safe to have 30 sec to allow rpi reboot 33 | setMillis(0); 34 | isComm = FALSE; 35 | digitalWrite(PI_SW, HIGH); 36 | delay(DOWN_TIME); 37 | digitalWrite(PI_SW, LOW); 38 | } 39 | } 40 | 41 | void command_check_millis(String content) { 42 | if (content == "check_millis") 43 | { 44 | Serial.print("The current mill is: "); 45 | Serial.println(millis()); 46 | } 47 | } 48 | void timing_no_comm() { 49 | /*No communication reset millis*/ 50 | if (isComm == TRUE) 51 | { 52 | setMillis(0); 53 | isComm = FALSE; 54 | } 55 | } 56 | 57 | void reset_timer() { 58 | setMillis(0); 59 | isComm = TRUE; 60 | } 61 | -------------------------------------------------------------------------------- /arduino/stanwell_sdi12_460_v2/timing.h: -------------------------------------------------------------------------------- 1 | #ifndef _TIMMING_H_ 2 | #define _TIMMING_H_ 3 | 4 | #include "Arduino.h" 5 | 6 | extern volatile unsigned long timer0_millis; 7 | static volatile unsigned char isComm; 8 | #define TIMEOUT (unsigned long)(12ul * 60ul * 60ul * 1000ul) 9 | #define DOWN_TIME 3 * 1000 //seconds 10 | 11 | void setMillis(unsigned long new_millis); 12 | void timeout_reset_pi(); 13 | void command_reset_pi(String content); 14 | void command_check_millis(String content); 15 | void timing_no_comm(); 16 | void reset_timer(); 17 | #endif 18 | -------------------------------------------------------------------------------- /arduino/temp_sensor/temp_sensor.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2 4 | 5 | //Temperature chip i/o 6 | OneWire ds(DS18S20_Pin); // on digital pin 2 7 | 8 | void setup(void) { 9 | Serial.begin(9600); 10 | } 11 | 12 | void loop(void) { 13 | float temperature = getTemp(); //will take about 750ms to run 14 | Serial.println(temperature); 15 | 16 | } 17 | 18 | 19 | float getTemp(){ 20 | //returns the temperature from one DS18S20 in DEG Celsius 21 | 22 | byte data[12]; 23 | byte addr[8]; 24 | 25 | if ( !ds.search(addr)) { 26 | //no more sensors on chain, reset search 27 | ds.reset_search(); 28 | return -1000; 29 | } 30 | 31 | if ( OneWire::crc8( addr, 7) != addr[7]) { 32 | Serial.println("CRC is not valid!"); 33 | return -1000; 34 | } 35 | 36 | if ( addr[0] != 0x10 && addr[0] != 0x28) { 37 | Serial.print("Device is not recognized"); 38 | return -1000; 39 | } 40 | 41 | ds.reset(); 42 | ds.select(addr); 43 | ds.write(0x44,1); // start conversion, with parasite power on at the end 44 | 45 | delay(750); // Wait for temperature conversion to complete 46 | 47 | byte present = ds.reset(); 48 | ds.select(addr); 49 | ds.write(0xBE); // Read Scratchpad 50 | 51 | 52 | for (int i = 0; i < 9; i++) { // we need 9 bytes 53 | data[i] = ds.read(); 54 | } 55 | 56 | ds.reset_search(); 57 | 58 | byte MSB = data[1]; 59 | byte LSB = data[0]; 60 | 61 | float tempRead = ((MSB << 8) | LSB); //using two's compliment 62 | float TemperatureSum = tempRead / 16; 63 | 64 | return TemperatureSum; 65 | 66 | } 67 | -------------------------------------------------------------------------------- /arduino/tmp36_tmperature_sensor/tmp36_tmperature_sensor.ino: -------------------------------------------------------------------------------- 1 | //TMP36 Pin Variables 2 | int sensorPin = 5; //the analog pin the TMP36's Vout (sense) pin is connected to 3 | //the resolution is 10 mV / degree centigrade with a 4 | //500 mV offset to allow for negative temperatures 5 | 6 | /* 7 | * setup() - this function runs once when you turn your Arduino on 8 | * We initialize the serial connection with the computer 9 | */ 10 | void setup() 11 | { 12 | Serial.begin(9600); //Start the serial connection with the computer 13 | //to view the result open the serial monitor 14 | } 15 | 16 | void loop() // run over and over again 17 | { 18 | //getting the voltage reading from the temperature sensor 19 | int reading = analogRead(sensorPin); 20 | 21 | // converting that reading to voltage, for 3.3v arduino use 3.3 22 | float voltage = reading * 5.0; 23 | voltage /= 1024.0; 24 | 25 | // print out the voltage 26 | Serial.print(voltage); Serial.println(" volts"); 27 | 28 | // now print out the temperature 29 | float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset 30 | //to degrees ((voltage - 500mV) times 100) 31 | Serial.print(temperatureC); Serial.println(" degrees C"); 32 | 33 | 34 | delay(1000); //waiting a second 35 | } 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /arduino/weather_default/SparkFunHTU21D.h: -------------------------------------------------------------------------------- 1 | /* 2 | HTU21D Humidity Sensor Library 3 | By: Nathan Seidle 4 | SparkFun Electronics 5 | Date: September 22nd, 2013 6 | License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license). 7 | 8 | Get humidity and temperature from the HTU21D sensor. 9 | 10 | This same library should work for the other similar sensors including the Si 11 | 12 | */ 13 | 14 | #pragma once 15 | 16 | #if defined(ARDUINO) && ARDUINO >= 100 17 | #include "Arduino.h" 18 | #else 19 | #include "WProgram.h" 20 | #endif 21 | 22 | #include 23 | 24 | #define HTU21D_ADDRESS 0x40 //Unshifted 7-bit I2C address for the sensor 25 | 26 | #define ERROR_I2C_TIMEOUT 998 27 | #define ERROR_BAD_CRC 999 28 | 29 | #define TRIGGER_TEMP_MEASURE_HOLD 0xE3 30 | #define TRIGGER_HUMD_MEASURE_HOLD 0xE5 31 | #define TRIGGER_TEMP_MEASURE_NOHOLD 0xF3 32 | #define TRIGGER_HUMD_MEASURE_NOHOLD 0xF5 33 | #define WRITE_USER_REG 0xE6 34 | #define READ_USER_REG 0xE7 35 | #define SOFT_RESET 0xFE 36 | 37 | #define USER_REGISTER_RESOLUTION_MASK 0x81 38 | #define USER_REGISTER_RESOLUTION_RH12_TEMP14 0x00 39 | #define USER_REGISTER_RESOLUTION_RH8_TEMP12 0x01 40 | #define USER_REGISTER_RESOLUTION_RH10_TEMP13 0x80 41 | #define USER_REGISTER_RESOLUTION_RH11_TEMP11 0x81 42 | 43 | #define USER_REGISTER_END_OF_BATTERY 0x40 44 | #define USER_REGISTER_HEATER_ENABLED 0x04 45 | #define USER_REGISTER_DISABLE_OTP_RELOAD 0x02 46 | 47 | class HTU21D { 48 | 49 | public: 50 | HTU21D(); 51 | 52 | //Public Functions 53 | void begin(TwoWire &wirePort = Wire); //If user doesn't specificy then Wire will be used 54 | float readHumidity(void); 55 | float readTemperature(void); 56 | void setResolution(byte resBits); 57 | 58 | byte readUserRegister(void); 59 | void writeUserRegister(byte val); 60 | 61 | //Public Variables 62 | 63 | private: 64 | //Private Functions 65 | TwoWire *_i2cPort; //The generic connection to user's chosen I2C hardware 66 | 67 | byte checkCRC(uint16_t message_from_sensor, uint8_t check_value_from_sensor); 68 | uint16_t readValue(byte cmd); 69 | 70 | //Private Variables 71 | 72 | }; 73 | -------------------------------------------------------------------------------- /arduino/weather_default_improve/SparkFun_Si7021_Breakout_Library.h: -------------------------------------------------------------------------------- 1 | /* 2 | SparkFun Si7021 Temperature and Humidity Breakout 3 | By: Joel Bartlett 4 | SparkFun Electronics 5 | Date: December 10, 2015 6 | 7 | This is an Arduino library for the Si7021 Temperature and Humidity Sensor Breakout 8 | 9 | This library is based on the following libraries: 10 | 11 | HTU21D Temperature / Humidity Sensor Library 12 | By: Nathan Seidle 13 | https://github.com/sparkfun/HTU21D_Breakout/tree/master/Libraries 14 | 15 | Arduino Si7010 relative humidity + temperature sensor 16 | By: Jakub Kaminski, 2014 17 | https://github.com/teoqba/ADDRESS 18 | 19 | This Library is free software: you can redistribute it and/or modify 20 | it under the terms of the GNU General Public License as published by 21 | the Free Software Foundation, either version 3 of the License, or 22 | (at your option) any later version. 23 | 24 | This Library is distributed in the hope that it will be useful, 25 | but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | GNU General Public License for more details. 28 | 29 | For a copy of the GNU General Public License, see 30 | . 31 | */ 32 | 33 | #ifndef SparkFun_Si7021_Breakout_Library_h 34 | #define SparkFun_Si7021_Breakout_Library_h 35 | 36 | #include 37 | 38 | /****************Si7021 & HTU21D Definitions***************************/ 39 | 40 | #define ADDRESS 0x40 41 | 42 | #define TEMP_MEASURE_HOLD 0xE3 43 | #define HUMD_MEASURE_HOLD 0xE5 44 | #define TEMP_MEASURE_NOHOLD 0xF3 45 | #define HUMD_MEASURE_NOHOLD 0xF5 46 | #define TEMP_PREV 0xE0 47 | 48 | #define WRITE_USER_REG 0xE6 49 | #define READ_USER_REG 0xE7 50 | #define SOFT_RESET 0xFE 51 | 52 | #define HTRE 0x02 53 | #define _BV(bit) (1 << (bit)) 54 | 55 | #define CRC_POLY 0x988000 // Shifted Polynomial for CRC check 56 | 57 | // Error codes 58 | #define I2C_TIMEOUT 998 59 | #define BAD_CRC 999 60 | 61 | 62 | /****************Si7021 & HTU21D Class**************************************/ 63 | class Weather 64 | { 65 | public: 66 | // Constructor 67 | Weather(); 68 | 69 | bool begin(); 70 | 71 | // Si7021 & HTU21D Public Functions 72 | float getRH(); 73 | float readTemp(); 74 | float getTemp(); 75 | float readTempF(); 76 | float getTempF(); 77 | void heaterOn(); 78 | void heaterOff(); 79 | void changeResolution(uint8_t i); 80 | void reset(); 81 | uint8_t checkID(); 82 | 83 | 84 | 85 | private: 86 | //Si7021 & HTU21D Private Functions 87 | uint16_t makeMeasurment(uint8_t command); 88 | void writeReg(uint8_t value); 89 | uint8_t readReg(); 90 | }; 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /arduino/weather_default_improve_mps/SparkFun_Si7021_Breakout_Library.h: -------------------------------------------------------------------------------- 1 | /* 2 | SparkFun Si7021 Temperature and Humidity Breakout 3 | By: Joel Bartlett 4 | SparkFun Electronics 5 | Date: December 10, 2015 6 | 7 | This is an Arduino library for the Si7021 Temperature and Humidity Sensor Breakout 8 | 9 | This library is based on the following libraries: 10 | 11 | HTU21D Temperature / Humidity Sensor Library 12 | By: Nathan Seidle 13 | https://github.com/sparkfun/HTU21D_Breakout/tree/master/Libraries 14 | 15 | Arduino Si7010 relative humidity + temperature sensor 16 | By: Jakub Kaminski, 2014 17 | https://github.com/teoqba/ADDRESS 18 | 19 | This Library is free software: you can redistribute it and/or modify 20 | it under the terms of the GNU General Public License as published by 21 | the Free Software Foundation, either version 3 of the License, or 22 | (at your option) any later version. 23 | 24 | This Library is distributed in the hope that it will be useful, 25 | but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | GNU General Public License for more details. 28 | 29 | For a copy of the GNU General Public License, see 30 | . 31 | */ 32 | 33 | #ifndef SparkFun_Si7021_Breakout_Library_h 34 | #define SparkFun_Si7021_Breakout_Library_h 35 | 36 | #include 37 | 38 | /****************Si7021 & HTU21D Definitions***************************/ 39 | 40 | #define ADDRESS 0x40 41 | 42 | #define TEMP_MEASURE_HOLD 0xE3 43 | #define HUMD_MEASURE_HOLD 0xE5 44 | #define TEMP_MEASURE_NOHOLD 0xF3 45 | #define HUMD_MEASURE_NOHOLD 0xF5 46 | #define TEMP_PREV 0xE0 47 | 48 | #define WRITE_USER_REG 0xE6 49 | #define READ_USER_REG 0xE7 50 | #define SOFT_RESET 0xFE 51 | 52 | #define HTRE 0x02 53 | #define _BV(bit) (1 << (bit)) 54 | 55 | #define CRC_POLY 0x988000 // Shifted Polynomial for CRC check 56 | 57 | // Error codes 58 | #define I2C_TIMEOUT 998 59 | #define BAD_CRC 999 60 | 61 | 62 | /****************Si7021 & HTU21D Class**************************************/ 63 | class Weather 64 | { 65 | public: 66 | // Constructor 67 | Weather(); 68 | 69 | bool begin(); 70 | 71 | // Si7021 & HTU21D Public Functions 72 | float getRH(); 73 | float readTemp(); 74 | float getTemp(); 75 | float readTempF(); 76 | float getTempF(); 77 | void heaterOn(); 78 | void heaterOff(); 79 | void changeResolution(uint8_t i); 80 | void reset(); 81 | uint8_t checkID(); 82 | 83 | 84 | 85 | private: 86 | //Si7021 & HTU21D Private Functions 87 | uint16_t makeMeasurment(uint8_t command); 88 | void writeReg(uint8_t value); 89 | uint8_t readReg(); 90 | }; 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /arduino/wifi_check/wifi_check.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char ssid[] = "giraffe_and_robots"; // your network SSID (name) 5 | char key[] = "qy7ttvj7vg7qphyqxhd3"; // your network key 6 | int keyIndex = 0; // your network key Index number 7 | int status = WL_IDLE_STATUS; // the Wifi radio's status 8 | 9 | void setup() { 10 | //Initialize serial and wait for port to open: 11 | Serial.begin(9600); 12 | while (!Serial) { 13 | ; // wait for serial port to connect. Needed for Leonardo only 14 | } 15 | 16 | // check for the presence of the shield: 17 | if (WiFi.status() == WL_NO_SHIELD) { 18 | Serial.println("WiFi shield not present"); 19 | // don't continue: 20 | while (true); 21 | } 22 | 23 | // attempt to connect to Wifi network: 24 | while ( status != WL_CONNECTED) { 25 | Serial.print("Attempting to connect to WEP network, SSID: "); 26 | Serial.println(ssid); 27 | status = WiFi.begin(ssid, keyIndex, key); 28 | 29 | // wait 10 seconds for connection: 30 | delay(10000); 31 | } 32 | 33 | // once you are connected : 34 | Serial.print("You're connected to the network"); 35 | } 36 | 37 | void loop() { 38 | // check the network status connection once every 10 seconds: 39 | delay(10000); 40 | Serial.println(WiFi.status()); 41 | } 42 | -------------------------------------------------------------------------------- /bash/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | in *~/.bashrc* put in 4 | 5 | ``` 6 | if [ -f ~/pyduino/bash/pyduino_variables.sh ]; then 7 | source ~/pyduino/bash/pyduino_variables.sh 8 | fi 9 | ``` 10 | 11 | in *~/pyduino/bash/pyduino_variables* put in 12 | 13 | ``` 14 | #!/bin/bash 15 | ### below are the variables for pyduino, put in /home/pi/arduino/bash/arduino_variables.sh 16 | # becareful that ssh_port_on_sftp_uqgec ssh_monitoring_port_on_sftp_uqgec and ssh_monitoring_port_on_sftp_uqgec+1 should be unique for all the ports for the server. for example, if one client is using ssh_port_on_sftp_uqgec=1999 ssh_monitoring_port_on_sftp_uqgec=20008, the second client should never use ssh_monitoring_port_on_sftp_uqgec=20009 as the previous client uses 20009 as returing heartbeating port 17 | # also note that there is no space on both side of '=' 18 | 19 | 20 | ssh_username_first_channel=sftp 21 | ssh_port_first_channel=1967 22 | ssh_monitoring_port_first_channel=20017 23 | ssh_address_first_channel=www.abc.def 24 | ssh_credential_path_first_channel=/home/pi/.ssh/id_rsa_sftp_uqgec 25 | 26 | ssh_username_second_channel=sftp 27 | ssh_port_second_channel=1967 28 | ssh_monitoring_port_second_channel=20015 29 | ssh_address_second_channel=www.xyz.cloud.edu.au 30 | ssh_credential_path_second_channel=/home/pi/.ssh/abc 31 | 32 | secondary_data_server=www.xxx.cloud.edu.au 33 | 34 | vnc_server_address=xxx.uq.edu.au 35 | vnc_monitoring_port=20009 36 | vnc_ssh_forward_port=1985 37 | vnc_forward_port=1986 38 | 39 | 40 | ssh_scp_photo_address=username@servername:/address/to/server/name/ 41 | local_photo_address=/home/pi/ 42 | 43 | ``` 44 | 45 | 46 | -------------------------------------------------------------------------------- /bash/add_user: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | new_user_name=$1 4 | echo "now creating new user $new_user_name" 5 | useradd $new_user_name 6 | passwd $new_user_name 7 | 8 | mkdir /home/$new_user_name 9 | chown $new_user_name:$new_user_name /home/$new_user_name 10 | chmod 744 /home/$new_user_name 11 | 12 | #add below: 13 | #chenming:x:1001:1001::/home/chenming:/bin/bash 14 | 15 | sed -i '${s/$/\/bin\/bash/}' /etc/passwd 16 | 17 | usermod -aG ssh,netdev,crontab,users,plugdev,video,backup,www-data,audio,dialout,man,disk $new_user_name 18 | -------------------------------------------------------------------------------- /bash/arduino_read_ec5_mux_shield_roof1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this scripts wirte the detail about what is going to be sent through email 3 | # for example the new ip address, whether the sensors/programs is working and so on. 4 | 5 | sleep 5 6 | cd /home/pi/pyduino/python/ 7 | python read_arduino_ec5_ts.py 8 | 9 | -------------------------------------------------------------------------------- /bash/arduino_read_moist_DS18x20_sht11_bp_phant.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this scripts wirte the detail about what is going to be sent through email 3 | # for example the new ip address, whether the sensors/programs is working and so on. 4 | 5 | sleep 5 6 | cd /home/pi/pyduino/python/ 7 | #python read_moist_DS18x20_sht11_bp_phant.py >>output_record 8 | python read_moist_DS18x20_sht22_scale_bp_phant.py >>output_record 9 | -------------------------------------------------------------------------------- /bash/arduino_read_weather_station_1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this scripts wirte the detail about what is going to be sent through email 3 | # for example the new ip address, whether the sensors/programs is working and so on. 4 | 5 | sleep 3 6 | #su pi 7 | cd /home/pi/pyduino/python/ 8 | #python rs232_adam.py 9 | python read_weather_station_1_ts.py 10 | 11 | -------------------------------------------------------------------------------- /bash/arduino_read_weather_station_2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this scripts wirte the detail about what is going to be sent through email 3 | # for example the new ip address, whether the sensors/programs is working and so on. 4 | 5 | sleep 18 6 | #su pi 7 | cd /home/pi/pyduino/python/ 8 | #python rs232_adam.py 9 | python read_weather_station_2_ts.py 10 | 11 | -------------------------------------------------------------------------------- /bash/area51_2mo_3heatsuc_2salt_2drsuc_gs3_compacted_redmud.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this scripts wirte the detail about what is going to be sent through email 3 | # for example the new ip address, whether the sensors/programs is working and so on. 4 | 5 | sleep 33 6 | #su pi 7 | cd /home/pi/pyduino/python/ 8 | /usr/bin/stdbuf -i0 -o0 -e0 python area51_2mo_3heatsuc_2salt_2drsuc_2gs3_compacted_redmud.py >>area51_log 2>&1 9 | -------------------------------------------------------------------------------- /bash/autossh_first_channel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## following parameters needs to be defined in bashrc 3 | #ssh_port_on_sftp_uqgec=1997 4 | #ssh_monitoring_port_on_sftp_uqgec=20003 5 | #uqgec_ssh_address=www.xxxud.edu.au 6 | #uqgec_data_server=xxxx.abc.org 7 | #uqgec_phant_server=xxx.abc.:8090 8 | 9 | 10 | sleep 70 # wait for 70 seconds, a time to stablise the internet connection 11 | source ~/pyduino/bash/pyduino_variables.sh 12 | ssh-keygen -f "/home/pi/.ssh/known_hosts" -R ${ssh_address_first_channel} # this line is executed in case when the ip in uqgec is changed 13 | AUTOSSH_DEBUG=1 AUTOSSH_LOGLEVEL=7 AUTOSSH_LOGFILE=/home/pi/autossh_debug_1 \ 14 | autossh -M ${ssh_monitoring_port_first_channel} \ 15 | -f -o "StrictHostKeyChecking=no" \ 16 | -o "ServerAliveInterval=12000" \ 17 | -o "ServerAliveCountMax=10" \ 18 | -o "ExitOnForwardFailure=Yes" \ 19 | -i ${ssh_credential_path_first_channel} \ 20 | -N ${ssh_username_first_channel}@${ssh_address_first_channel} \ 21 | -R ${ssh_port_first_channel}:localhost:22 -C 22 | 23 | -------------------------------------------------------------------------------- /bash/autossh_mango_for_vnc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## following parameters needs to be defined in bashrc 3 | #ssh_port_on_sftp_uqgec=1997 4 | #ssh_monitoring_port_on_sftp_uqgec=20003 5 | #uqgec_ssh_address=www.xxxud.edu.au 6 | #uqgec_data_server=xxxx.abc.org 7 | #uqgec_phant_server=xxx.abc.:8090 8 | #vnc_server_address=abc.eait.uq.edu.au 9 | #vnc_monitoring_port=20009 10 | #vnc_ssh_forward_port=1985 11 | #vnc_forward_port=1986 12 | 13 | 14 | source ~/pyduino/bash/pyduino_variables.sh 15 | #AUTOSSH_DEBUG=1 AUTOSSH_LOGLEVEL=7 AUTOSSH_LOGFILE=/home/pi/autossh_debug_vnc autossh -M ${vnc_monitoring_port} -f -o "ServerAliveInterval=12000" -o "ServerAliveCountMax=10" -o "ExitOnForwardFailure=Yes" -i ~/.ssh/id_rsa_sftp_uqgec -N sftp@${uqgec_ssh_address} -R ${ssh_port_on_sftp_uqgec}:localhost:22 -C 16 | AUTOSSH_DEBUG=1 AUTOSSH_LOGLEVEL=7 AUTOSSH_LOGFILE=/home/pi/autossh_debug_vnc autossh -M ${vnc_monitoring_port} -f -o "ServerAliveInterval=12000" -o "ServerAliveCountMax=10" -o "ExitOnForwardFailure=Yes" -N uqczhan2@${vnc_server_address} -R ${vnc_ssh_forward_port}:localhost:22 -R ${vnc_forward_port}:localhost:5901 -C 17 | 18 | -------------------------------------------------------------------------------- /bash/autossh_second_channel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## following parameters needs to be defined in bashrc 3 | #ssh_port_on_sftp_uqgec=1997 4 | #ssh_monitoring_port_on_sftp_uqgec=20003 5 | #uqgec_ssh_address=www.xxxud.edu.au 6 | #uqgec_data_server=xxxx.abc.org 7 | #uqgec_phant_server=xxx.abc.:8090 8 | 9 | 10 | sleep 80 11 | source ~/pyduino/bash/pyduino_variables.sh 12 | ssh-keygen -f "/home/pi/.ssh/known_hosts" -R ${ssh_address_second_channel} # this line is executed in case when the ip in uqgec is changed 13 | AUTOSSH_DEBUG=1 AUTOSSH_LOGLEVEL=7 AUTOSSH_LOGFILE=/home/pi/autossh_debug_2 \ 14 | autossh -M ${ssh_monitoring_port_second_channel} -f -o "StrictHostKeyChecking=no" -o "ServerAliveInterval=12000" \ 15 | -o "ServerAliveCountMax=10" -o "ExitOnForwardFailure=Yes" \ 16 | -i ${ssh_credential_path_second_channel} \ 17 | -N ${ssh_username_second_channel}@${ssh_address_second_channel} \ 18 | -R ${ssh_port_second_channel}:localhost:22 -C 19 | 20 | -------------------------------------------------------------------------------- /bash/autossh_to_sftp_uqgec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## following parameters needs to be defined in bashrc 3 | #ssh_port_on_sftp_uqgec=1997 4 | #ssh_monitoring_port_on_sftp_uqgec=20003 5 | #uqgec_ssh_address=www.xxxud.edu.au 6 | #uqgec_data_server=xxxx.abc.org 7 | #uqgec_phant_server=xxx.abc.:8090 8 | 9 | sleep 120 10 | source ~/pyduino/bash/pyduino_variables.sh 11 | AUTOSSH_DEBUG=1 AUTOSSH_LOGLEVEL=7 AUTOSSH_LOGFILE=/home/pi/autossh_debug_2 autossh -M ${ssh_monitoring_port_on_sftp_uqgec} -f -o "ServerAliveInterval=12000" -o "ServerAliveCountMax=10" -o "ExitOnForwardFailure=Yes" -i ~/.ssh/id_rsa_sftp_uqgec -N sftp@${uqgec_ssh_address} -R ${ssh_port_on_sftp_uqgec}:localhost:22 -C 12 | 13 | -------------------------------------------------------------------------------- /bash/bacteria.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sleep 33 3 | #su pi 4 | cd /home/pi/pyduino/python/ 5 | /usr/bin/stdbuf -i0 -o0 -e0 python bacteria.py >>bacteria 2>&1 6 | 7 | -------------------------------------------------------------------------------- /bash/cali_2moist_2heatsuc_2salinity_2ceramsuc_phant.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this scripts wirte the detail about what is going to be sent through email 3 | # for example the new ip address, whether the sensors/programs is working and so on. 4 | 5 | sleep 33 6 | #su pi 7 | cd /home/pi/pyduino/python/ 8 | python cali_2moist_2heatsuc_2salinity_2ceramsuc_phant.py 9 | 10 | -------------------------------------------------------------------------------- /bash/camera_photo.sh: -------------------------------------------------------------------------------- 1 | echo "wait for 120 second" 2 | #sleep 240 3 | #need enough time for pi to reboot and load modules required by camera, and connect to wifi if this script is run by crontab on reboot, this sleep is importtant because crontab start to count time before wifi is ready, if sleep time is too short, user may not even able to see the username command prompt, particularly when the script is end up with shutdown. 4 | 5 | source $pyduino/bash/pyduino_variables.sh 6 | cd $local_photo_address 7 | DATE=$(date +"%Y-%m-%d_%H%M")_sa3.jpg 8 | 9 | 10 | echo "taking photos" 11 | raspistill -vf -o $DATE 2>> camera_error 12 | echo "sleep for 5 sec" 13 | sleep 5 14 | 15 | scp $local_photo_address/$DATE $ssh_scp_photo_address 2>> camera_error 16 | -------------------------------------------------------------------------------- /bash/campbell_logging.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this scripts wirte the detail about what is going to be sent through email 3 | # for example the new ip address, whether the sensors/programs is working and so on. 4 | 5 | sleep 38 6 | cd /home/pi/pyduino/python/ 7 | /usr/bin/stdbuf -i0 -o0 -e0 python campbell_logging.py >> campbell_log 8 | 9 | -------------------------------------------------------------------------------- /bash/change_wlan0_to_router.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # reference: https://github.com/hydrogeologger/pyduino/wiki/Making-Raspberry-Pi-as-an-internet-Router-(NAT) 3 | 4 | apt-get install dnsmasq hostapd 5 | 6 | if [ -f /etc/dhcpcd.conf ]; then 7 | cp /etc/dhcpcd.conf /etc/dhcpcd_orig.conf # note this needs to be copied and also work for the first time when we do the config 8 | fi 9 | 10 | 11 | cat <> /etc/dhcpcd.conf 12 | interface wlan0 13 | static ip_address=192.168.4.1/24 14 | EOT 15 | 16 | 17 | if [ -f /etc/dnsmasq.conf ]; then 18 | mv /etc/dnsmasq.conf /etc/dnsmasq_orig.conf 19 | fi 20 | 21 | 22 | cat <> /etc/dnsmasq.conf 23 | interface=wlan0 # Use the require wireless interface - usually wlan0 24 | dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h 25 | EOT 26 | 27 | 28 | 29 | 30 | if [ -f /etc/hostapd/hostapd.conf ]; then 31 | mv /etc/hostapd/hostapd.conf /etc/hostapd/hostapd_orig.conf 32 | fi 33 | 34 | 35 | 36 | cat <> /etc/hostapd/hostapd.conf 37 | interface=wlan0 38 | driver=nl80211 39 | ssid=sa1 40 | hw_mode=g 41 | channel=7 42 | wmm_enabled=0 43 | macaddr_acl=0 44 | auth_algs=1 45 | ignore_broadcast_ssid=0 46 | wpa=2 47 | wpa_passphrase=uqgec 48 | wpa_key_mgmt=WPA-PSK 49 | wpa_pairwise=TKIP 50 | rsn_pairwise=CCMP 51 | EOT 52 | 53 | 54 | 55 | 56 | if [ -f /etc/default/hostapd ]; then 57 | mv /etc/default/hostapd /etc/default/hostapd_orig 58 | fi 59 | 60 | 61 | 62 | cat <> /etc/default/hostapd 63 | DAEMON_CONF="/etc/hostapd/hostapd.conf" 64 | EOT 65 | 66 | systemctl unmask hostapd 67 | systemctl unmask dnsmasq 68 | 69 | systemctl enable hostapd 70 | systemctl enable dnsmasq 71 | -------------------------------------------------------------------------------- /bash/check_internet_connection_and_reboot_if_needed.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ADD ACCESS_TOKEN and TB_DOMAIN variables in /pyduino/credential/tb.sh 3 | machine_name=$(cat /etc/hostname) 4 | ip_address=$(hostname -I|xargs) 5 | # ip_address=$(hostname -I|xargs| tr -d '[:space:]') 6 | date=$(date) 7 | #volume=$(df -Hh|grep root| tr -d '[:space:]') 8 | key=$ip_address 9 | log_file=/home/pi/internet_connection.log 10 | source /home/pi/pyduino/credential/tb.sh 11 | #Fix the problem where CRONTAB does not get the environmental variables in .bashrc 12 | #echo $ACCESS_TOKEN (for debug) 13 | #echo $TB_DOMAIN (for debug) 14 | #curl "http://144.6.225.24:8080/input/$sparkfun_public_key?private_key=$sparkfun_private_key&ip=$ip_address&name=$machine_name&volume=$volume" 15 | #curl "http://monitoring.uqgec.org:8080/devices/ACCESS_TOKE=$ACCESS_TOKEN&key=$key&value=$ip_address" 16 | #tb_domain=$(cat /home/pi/pyduino/credential/tb_domain) 17 | #access_token=$(cat /home/pi/pyduino/credential/access_token) 18 | 19 | curl -v -d "{$(cat /etc/hostname): \"$ip_address\"}" $TB_DOMAIN/api/v1/$ACCESS_TOKEN/telemetry --header "Content-Type:application/json" 20 | 21 | 22 | #echo $date >> $log_file 23 | 24 | curl_outcome=$? 25 | #echo $curl_outcome >> $log_file 26 | 27 | sleep 1 28 | 29 | 30 | wget -q --spider http://google.com 31 | 32 | wget_outcome=$? 33 | 34 | #echo $wget_outcome >> $log_file 35 | 36 | sleep 1 37 | 38 | 39 | echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 40 | 41 | echo_outcome=$? 42 | 43 | #echo $echo_outcome >> $log_file 44 | 45 | sleep 1 46 | if [ $curl_outcome -eq 0 ] && [ $wget_outcome -eq 0 ] && [ $echo_outcome -eq 0 ] ; then 47 | echo "${date} ${curl_outcome} ${wget_outcome} ${echo_outcome} Online 2" >> $log_file 48 | elif [ $curl_outcome -ne 0 ] && [ $wget_outcome -ne 0 ] && [ $echo_outcome -ne 0 ] ; then 49 | echo "${date} ${curl_outcome} ${wget_outcome} ${echo_outcome} completely offline, start reboot" >> $log_file 50 | pkill -f python 51 | sleep 10 52 | echo -n "abc" > /dev/ttyS0 53 | sleep 1 54 | echo -n "RESET" > /dev/ttyS0 55 | sleep 1 56 | sudo /sbin/shutdown -h now 57 | else 58 | echo "${date} ${curl_outcome} ${wget_outcome} ${echo_outcome} partially offline 2" >> $log_file 59 | fi 60 | 61 | -------------------------------------------------------------------------------- /bash/configure_new_rpi3_strech_as_hydrogeologger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | systemctl enable ssh 4 | systemctl start ssh 5 | apt update 6 | apt install vim tmux tightvncserver ipython autossh mplayer python 7 | sed -i '${s/raspberrypi/hydrogeologger/}' /etc/hosts 8 | sed -i '${s/raspberrypi/hydrogeologger/}' /etc/hostname 9 | 10 | 11 | #https://raspberrypi.stackexchange.com/questions/14229/how-can-i-enable-the-camera-without-using-raspi-config 12 | 13 | 14 | 15 | #su pi 16 | ##this is runnings as normal users 17 | #ssh-keygen 18 | #python phant 19 | #send ip copy script 20 | #disable serial 21 | #enable pycamera 22 | #add cron to send ip address 23 | -------------------------------------------------------------------------------- /bash/ec5_mps2_ds18_weather_uv_pet_et_roof_daisy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this scripts wirte the detail about what is going to be sent through email 3 | # for example the new ip address, whether the sensors/programs is working and so on. 4 | 5 | sleep 18 6 | #su pi 7 | cd /home/pi/pyduino/python/ 8 | #python rs232_adam.py 9 | #python ec5_mps2_ds18_weather_uv_pet_et_roof_daisy.py >>daisy_log 10 | # https://stackoverflow.com/questions/3465619/how-to-make-output-of-any-shell-command-unbuffered 11 | #/usr/bin/stdbuf -i0 -o0 -e0 python ec5_mps2_ds18_weather_uv_pet_et_roof_daisy.py >>daisy_log 2>&1 12 | /usr/bin/stdbuf -i0 -o0 -e0 python daisy_prototype_logger.py >>daisy_log 2>&1 13 | 14 | -------------------------------------------------------------------------------- /bash/gelita_watch_update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd $pyduino 3 | inotifywait -q -m -e close_write data/gelita_borehole | 4 | while read -r filename event; do 5 | #./myfile.py # or "./$filename" 6 | # date >> b.txt 7 | #aDATE=$(date +"%Y_%m_%d_%H_%M_%S")_gelita 8 | #cp data/gelita_borehole data/tmp 9 | #mv data/tmp data/$aDATE 10 | python python/gelita_pizo_update_mango.py 11 | done 12 | 13 | -------------------------------------------------------------------------------- /bash/grange_4_type_abd_column_6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sleep 23 3 | #su pi 4 | cd /home/pi/pyduino/python/ 5 | /usr/bin/stdbuf -i0 -o0 -e0 python grange_4_type_abd_column_6.py >>grange_4_type_abd_column_6 2>&1 6 | 7 | -------------------------------------------------------------------------------- /bash/grange_5_column_4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sleep 23 3 | #su pi 4 | cd /home/pi/pyduino/python/ 5 | /usr/bin/stdbuf -i0 -o0 -e0 python grange_5.py >>grange_5 2>&1 6 | 7 | -------------------------------------------------------------------------------- /bash/grange_a.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sleep 23 3 | #su pi 4 | cd /home/pi/pyduino/python/ 5 | /usr/bin/stdbuf -i0 -o0 -e0 python grange_type_a.py >>grange_type_a 2>&1 6 | 7 | -------------------------------------------------------------------------------- /bash/grange_d.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sleep 33 3 | #su pi 4 | cd /home/pi/pyduino/python/ 5 | /usr/bin/stdbuf -i0 -o0 -e0 python grange_type_D.py >>grange_type_D 2>&1 6 | 7 | -------------------------------------------------------------------------------- /bash/hard_reset_system.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # shellcheck source-path=SCRIPTDIR source=reset_mcu.sh 3 | source "$(dirname "${BASH_SOURCE[0]}")/reset_mcu.sh" 4 | 5 | buffer_seconds=10 6 | while [ $buffer_seconds -gt 0 ]; do 7 | echo -ne "Killing all python processes, shutdown RPI and perform power cycle in ${buffer_seconds}s\033[0K\r" 8 | sleep 1 9 | : $((buffer_seconds--)) 10 | done 11 | 12 | echo -ne "Killing all python processes, shutdown RPI and perform power cycle in ${buffer_seconds}s\033[0K\r\n" 13 | pkill -f python 14 | sleep 5 15 | 16 | if ! mcu_comms_is_good; then 17 | echo "MCU serial not responsive!" 18 | reset_mcu 19 | sleep 1 20 | else 21 | echo "MCU serial is responsive." 22 | fi 23 | 24 | echo -ne "RESET" > "$TTY_PORT" 25 | read -r -e -t 1 < "$TTY_PORT" 26 | # sleep 1 27 | sudo /sbin/shutdown -h now 28 | -------------------------------------------------------------------------------- /bash/hard_shutdown_pi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo -n "RESET" > /dev/ttyS0 3 | /sbin/shutdown -h now 4 | -------------------------------------------------------------------------------- /bash/humidity_chamber.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sleep 23 3 | #su pi 4 | cd /home/pi/pyduino/python/ 5 | /usr/bin/stdbuf -i0 -o0 -e0 python humidity_chamber.py >>humidity_chamber 2>&1 6 | 7 | -------------------------------------------------------------------------------- /bash/kathy_tensiometer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sleep 23 3 | #su pi 4 | cd /home/pi/pyduino/python/ 5 | /usr/bin/stdbuf -i0 -o0 -e0 python kathy_tensiometer.py >>kathy_tensiometer 2>&1 6 | 7 | -------------------------------------------------------------------------------- /bash/loadcell_twolayer_tas606_TE.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this scripts wirte the detail about what is going to be sent through email 3 | # for example the new ip address, whether the sensors/programs is working and so on. 4 | 5 | sleep 17 6 | #su pi 7 | cd /home/pi/pyduino/python/ 8 | python loadcell_twolayer_tas606_TE.py 9 | 10 | -------------------------------------------------------------------------------- /bash/mega_logger1_aster.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this scripts wirte the detail about what is going to be sent through email 3 | # for example the new ip address, whether the sensors/programs is working and so on. 4 | 5 | sleep 18 6 | #su pi 7 | cd /home/pi/pyduino/python/ 8 | #python rs232_adam.py 9 | /usr/bin/stdbuf -i0 -o0 -e0 python mega_logger1_aster.py >>aster_log 10 | 11 | -------------------------------------------------------------------------------- /bash/mux_logger2_bougainvillea.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this scripts wirte the detail about what is going to be sent through email 3 | # for example the new ip address, whether the sensors/programs is working and so on. 4 | 5 | sleep 38 6 | #su pi 7 | cd /home/pi/pyduino/python/ 8 | /usr/bin/stdbuf -i0 -o0 -e0 python mux_logger_bougainvillea.py >>bougainvillea_log 9 | 10 | -------------------------------------------------------------------------------- /bash/reboot_pi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | /sbin/shutdown -r now 3 | 4 | -------------------------------------------------------------------------------- /bash/reset_mcu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script is inteded to be used to reset the secondary microcontroller 3 | 4 | MCU_RESET_PIN=27 # Reset pin, BCM Pin number 5 | TTY_PORT="/dev/serial0" # Serial port 6 | 7 | function WAIT_GPIO() { 8 | sleep 0.1 9 | } 10 | 11 | function setup() { 12 | # Exports pin to userspace 13 | if [ ! -d "/sys/class/gpio/gpio$MCU_RESET_PIN" ]; then 14 | echo "$MCU_RESET_PIN" > /sys/class/gpio/export; WAIT_GPIO 15 | fi 16 | 17 | # set GPIOs as output 18 | echo "out" > "/sys/class/gpio/gpio$MCU_RESET_PIN/direction"; WAIT_GPIO 19 | } 20 | 21 | function cleanup() { 22 | # Remove pin from userspace 23 | if [ -d /sys/class/gpio/gpio${MCU_RESET_PIN} ]; then 24 | echo "in" > "/sys/class/gpio/gpio$MCU_RESET_PIN/direction"; WAIT_GPIO 25 | echo "$MCU_RESET_PIN" > /sys/class/gpio/unexport; WAIT_GPIO 26 | fi 27 | } 28 | 29 | function reset_mcu() { 30 | setup 31 | 32 | echo "Resetting MCU through GPIO$MCU_RESET_PIN..." 33 | 34 | echo "0" > "/sys/class/gpio/gpio$MCU_RESET_PIN/value"; 35 | sleep 3 36 | # echo "1" > "/sys/class/gpio/gpio$MCU_RESET_PIN/value"; WAIT_GPIO 37 | 38 | cleanup 39 | } 40 | 41 | function mcu_comms_is_good() { 42 | local tty_response 43 | stty -F "$TTY_PORT" 9600 44 | WAIT_GPIO 45 | echo -ne "abc" > "$TTY_PORT" 46 | read -r -e -s -t 1 tty_response < "$TTY_PORT" 47 | if [ "$tty_response" == "abc" ]; then 48 | # echo "MCU serial is responsive." 49 | return 0 # comms is success 50 | else 51 | # echo "MCU serial not responsive!" 52 | return 1 # comms is failure 53 | fi 54 | } 55 | 56 | 57 | # Only perform reset if script is executed and not sourced 58 | if test ${#BASH_SOURCE[@]} -eq 1; then 59 | reset_mcu 60 | 61 | exit 0 62 | fi 63 | -------------------------------------------------------------------------------- /bash/rs232_ohaus_nvl20000_phant.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this scripts wirte the detail about what is going to be sent through email 3 | # for example the new ip address, whether the sensors/programs is working and so on. 4 | 5 | sleep 45 6 | #su pi 7 | cd /home/pi/pyduino/python/ 8 | python rs232_ohaus_nvl20000_phant.py 9 | 10 | -------------------------------------------------------------------------------- /bash/savage_weater_1_mps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sleep 13 3 | #su pi 4 | cd /home/pi/pyduino/python/ 5 | /usr/bin/stdbuf -i0 -o0 -e0 python grange_weather_1_mps.py >>grange_weather_1_mps 2>&1 6 | 7 | -------------------------------------------------------------------------------- /bash/send_ip_tb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sleep 30 3 | # ADD ACCESS_TOKEN and TB_DOMAIN variables in /pyduino/credential/tb.sh 4 | machine_name=$(cat /etc/hostname) 5 | ip_address=$(hostname -I|xargs) 6 | # ip_address=$(hostname -I|xargs| tr -d '[:space:]') 7 | date=$(date) 8 | #volume=$(df -Hh|grep root| tr -d '[:space:]') 9 | key=$ip_address 10 | source /home/pi/pyduino/credential/tb.sh 11 | #Fix the problem where CRONTAB does not get the environmental variables in .bashrc 12 | #echo $ACCESS_TOKEN (for debug) 13 | #echo $TB_DOMAIN (for debug) 14 | #curl "http://144.6.225.24:8080/input/$sparkfun_public_key?private_key=$sparkfun_private_key&ip=$ip_address&name=$machine_name&volume=$volume" 15 | #curl "http://monitoring.uqgec.org:8080/devices/ACCESS_TOKE=$ACCESS_TOKEN&key=$key&value=$ip_address" 16 | #tb_domain=$(cat /home/pi/pyduino/credential/tb_domain) 17 | #access_token=$(cat /home/pi/pyduino/credential/access_token) 18 | 19 | # curl -v -d "{$(cat /etc/hostname): \"$ip_address\"}" $TB_DOMAIN/api/v1/$ACCESS_TOKEN/telemetry --header "Content-Type:application/json" 20 | 21 | # Publish IP to all allocated thingsboard access tokens, add multiple access tokens using array format 22 | for ACCESS_TOKEN in ${ACCESS_TOKEN[@]}; do 23 | curl -v --data "{$machine_name: \"$ip_address\"}" $TB_DOMAIN/api/v1/$ACCESS_TOKEN/telemetry --header "Content-Type:application/json" 24 | # echo -e "$ACCESS_TOKEN" 25 | done 26 | 27 | -------------------------------------------------------------------------------- /bash/serial_session.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # Set up device 5 | 6 | exec 9>&2 7 | exec 8> >( 8 | while [ "$r" != "1" ]; do 9 | # read input, no field separators or backslash escaping, 1/20th second timeout 10 | IFS='' read -rt 0.05 line 11 | r=$? 12 | # if we have input, print the color change control char and what input we have 13 | if ! [ "${#line}" = "0" ]; then 14 | echo -ne "\e[1;33m${line}" 15 | fi 16 | # end of line detected, print default color control char and newline 17 | if [ "$r" = "0" ] ; then 18 | echo -e "\e[0m" 19 | fi 20 | # slow infinite loops on unexpected returns - shouldn't happen 21 | if ! [ "$r" = "0" ] && ! [ "$r" = "142" ]; then 22 | sleep 0.05 23 | fi 24 | done 25 | ) 26 | function undirect(){ exec 1>&9; } 27 | function redirect(){ exec 1>&8; } 28 | trap "redirect;" DEBUG 29 | PROMPT_COMMAND='undirect;' 30 | 31 | echo "Starting serial communication with arduino\n" 32 | stty raw -echo < /dev/ttyS0 33 | stty -F /dev/ttyS0 cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts 34 | 35 | # Check if error ocurred 36 | if [ "$?" -ne 0 ]; then 37 | echo "\n\nError ocurred, stty exited $?\n\n" 38 | exit 1; 39 | fi 40 | 41 | echo "Set up serial complete!" 42 | echo "Session begins, type 'exit' to stop" 43 | 44 | # Let cat read the device $1 in the background 45 | 46 | # Capture PID of background process so it is possible to terminate it when done 47 | 48 | cat /dev/ttyS0 57 | done 58 | 59 | # Terminate background read process 60 | kill "$bgPid" 61 | 62 | -------------------------------------------------------------------------------- /bash/shutdown_pi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | /sbin/shutdown -h now 3 | 4 | -------------------------------------------------------------------------------- /bash/stanwell.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sleep 23 3 | #su pi 4 | cd /home/pi/pyduino/python/ 5 | /usr/bin/stdbuf -i0 -o0 -e0 python stanwell.py >>stanwell 2>&1 6 | 7 | -------------------------------------------------------------------------------- /credential/readme.md: -------------------------------------------------------------------------------- 1 | # Credentials 2 | All credentials are stored here 3 | 4 | Check host address is correct and replace `********************` with appropriate token 5 | 6 | ## Logger Credentials 7 | The credentials for logger data are stored here in a JSON file, below is a example: 8 | ```json 9 | { 10 | "thingsboard_host": "www.abc.cloud.edu.au", 11 | "access_token": "********************" 12 | } 13 | ``` 14 | 15 | ## IP Reporting 16 | To add extra location for logger to report IP addresses to, please add the following lines to appropriate shell file 17 | ``` 18 | # Add comment on secondary location ip is reported to 19 | ACCESS_TOKEN+=("********************") 20 | ``` -------------------------------------------------------------------------------- /data/readme: -------------------------------------------------------------------------------- 1 | all the data are stored here 2 | -------------------------------------------------------------------------------- /particle/Phant_roof_nosolar/README.md: -------------------------------------------------------------------------------- 1 | create a new file called 'credential.h' with the following contents 2 | // Replace with your actual SSID and password: 3 | //https://arduino.stackexchange.com/questions/40411/hiding-wlan-password-when-pushing-to-github 4 | //create a profile in sparkfun with the following items: 5 | //"winddir","windspeedmps","rainmm","dailyrainmm","tempcel","humidity","barotempcel","hectopascals","soiltempcel","soilmoisture","uv_up","uv_down","ir_up","ir_down","vis_up","vis_down" 6 | 7 | ---------------------------------------------- 8 | #define SPARKFUN_SERVER_ADDR "your bare web address in quote, no port number, no http://" 9 | #define SPARKFUN_SERVER_KEY_PUBLIC "your publickey in the quote" 10 | #define SPARKFUN_SERVER_KEY_PRIVATE "your private in the quote" 11 | #define REPORT_INTERVAL_SECOND 60 12 | #define SPARKFUN_SERVER_PORT 8080 13 | -------------------------------------------------------------------------------- /particle/Phant_roof_nosolar/SparkFunPhant.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Phant.h 3 | * 4 | * .-.._ 5 | * __ /` '. 6 | * .-' `/ ( a \ 7 | * / ( \,_ \ 8 | * /| '---` |\ =| 9 | * ` \ /__.-/ / | | 10 | * | / / \ \ \ \_\ jgs 11 | * |__|_| |_|__\ 12 | * never forget. 13 | * 14 | * Original Author: Todd Treece 15 | * Edited for Particle by: Jim Lindblom 16 | * 17 | * Copyright (c) 2014 SparkFun Electronics. 18 | * Licensed under the GPL v3 license. 19 | * 20 | */ 21 | 22 | #ifndef Phant_h 23 | #define Phant_h 24 | 25 | #include "application.h" 26 | 27 | class Phant { 28 | 29 | public: 30 | Phant(String host, String publicKey, String privateKey); 31 | void add(String field, String data); 32 | void add(String field, char data); 33 | void add(String field, int data); 34 | void add(String field, byte data); 35 | void add(String field, long data); 36 | void add(String field, unsigned int data); 37 | void add(String field, unsigned long data); 38 | void add(String field, float data, unsigned int precision = 4); 39 | void add(String field, double data, unsigned int precision = 4); 40 | 41 | String queryString(); 42 | String url(); 43 | String get(); 44 | String post(); 45 | String clear(); 46 | 47 | int particlePost(); 48 | 49 | private: 50 | String _pub; 51 | String _prv; 52 | String _host; 53 | String _params; 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /particle/SparkFun_Photon_Weather_Phant/README.md: -------------------------------------------------------------------------------- 1 | create a new file called 'credential.h' with the following contents 2 | // Replace with your actual SSID and password: 3 | //https://arduino.stackexchange.com/questions/40411/hiding-wlan-password-when-pushing-to-github 4 | //create a profile in sparkfun with the following items: 5 | //"winddir","windspeedmps","rainmm","dailyrainmm","tempcel","humidity","barotempCel","hectopascals","soiltempCel","soilmoisture","uv_up","uv_down","ir_up","ir_down","vis_up","vis_down" 6 | 7 | ---------------------------------------------- 8 | 9 | 10 | ```C 11 | #define SPARKFUN_SERVER_ADDR "your bare web address in quote, no port number, no http://" 12 | #define SPARKFUN_SERVER_KEY_PUBLIC "your publickey in the quote" 13 | #define SPARKFUN_SERVER_KEY_PRIVATE "your private in the quote" 14 | #define REPORT_INTERVAL_SECOND 60 15 | #define SPARKFUN_SERVER_PORT 8080 16 | ``` 17 | -------------------------------------------------------------------------------- /particle/SparkFun_Photon_Weather_Phant/SparkFunPhant.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Phant.h 3 | * 4 | * .-.._ 5 | * __ /` '. 6 | * .-' `/ ( a \ 7 | * / ( \,_ \ 8 | * /| '---` |\ =| 9 | * ` \ /__.-/ / | | 10 | * | / / \ \ \ \_\ jgs 11 | * |__|_| |_|__\ 12 | * never forget. 13 | * 14 | * Original Author: Todd Treece 15 | * Edited for Particle by: Jim Lindblom 16 | * 17 | * Copyright (c) 2014 SparkFun Electronics. 18 | * Licensed under the GPL v3 license. 19 | * 20 | */ 21 | 22 | #ifndef Phant_h 23 | #define Phant_h 24 | 25 | #include "application.h" 26 | 27 | class Phant { 28 | 29 | public: 30 | Phant(String host, String publicKey, String privateKey); 31 | void add(String field, String data); 32 | void add(String field, char data); 33 | void add(String field, int data); 34 | void add(String field, byte data); 35 | void add(String field, long data); 36 | void add(String field, unsigned int data); 37 | void add(String field, unsigned long data); 38 | void add(String field, float data, unsigned int precision = 4); 39 | void add(String field, double data, unsigned int precision = 4); 40 | 41 | String queryString(); 42 | String url(); 43 | String get(); 44 | String post(); 45 | String clear(); 46 | 47 | int particlePost(); 48 | 49 | private: 50 | String _pub; 51 | String _prv; 52 | String _host; 53 | String _params; 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /python/TB_io_test.py: -------------------------------------------------------------------------------- 1 | import paho.mqtt.client as mqtt 2 | import json 3 | import time 4 | import serial 5 | 6 | 7 | 8 | port_sensor = '/dev/ttyS0' # port for serial connection 9 | ard=serial.Serial(port_sensor,timeout=60) 10 | 11 | 12 | 13 | # The callback for when the client receives a CONNACK response from the server. 14 | def on_connect(client, userdata, rc, *extra_params): 15 | print('Connected with result code ' + str(rc)) 16 | # Subscribing to receive RPC requests 17 | client.subscribe('v1/devices/me/rpc/request/+') 18 | 19 | 20 | # The callback for when a PUBLISH message is received from the server. 21 | def on_message(client, userdata, msg): 22 | print('Topic: ' + msg.topic + '\nMessage: ' + str(msg.payload)) 23 | data = json.loads(msg.payload) 24 | if data['method'] == 'getData': 25 | ard.write("dht22,54,power,2,points,2,dummies,1,interval_mm,2000,debug,1") 26 | ard.flushInput() 27 | msg=ard.readline() 28 | print(msg) 29 | current_read=msg.split(',')[0:-1] 30 | rh = float(current_read[-1]) 31 | t = float(current_read[-2]) 32 | d = {'dht22_rh' : rh, 'dht22_t' : t} 33 | client.publish('v1/devices/me/telemetry', json.dumps(d), 1) 34 | if data['method'] == 'getTermInfo': 35 | print("term requested") 36 | d = { 37 | 'ok': True, 38 | 'platform': os.platform(), 39 | 'type': os.type(), 40 | 'release': os.release() 41 | } 42 | print(d) 43 | client.publish('v1/devices/me/telemetry', json.dumps(d), 1) 44 | if data['method'] == 'setValue': 45 | print(data['params']) 46 | if data['params'] is True: 47 | print("SWITCH ON") 48 | ard.write("power_switch,10,power_switch_status,0,debug,1") 49 | ard.flushInput() 50 | #print(ard.readline()) 51 | if data['params'] is False: 52 | print("SWITCH OFF") 53 | ard.write("power_switch,10,power_switch_status,255,debug,1") 54 | ard.flushInput() 55 | #print(ard.readline()) 56 | 57 | 58 | client = mqtt.Client() 59 | client.on_connect = on_connect 60 | client.on_message = on_message 61 | client.username_pw_set('TUdndmZQO0Ob3sTmM64y') 62 | client.connect('www.uqtailingsmonitoringengine.cloud.edu.au', 1883, 60) 63 | 64 | time.sleep(2) 65 | 66 | 67 | try: 68 | client.loop_forever() 69 | except KeyboardInterrupt: 70 | exit() 71 | 72 | 73 | -------------------------------------------------------------------------------- /python/Weather_station_davis/README.md: -------------------------------------------------------------------------------- 1 | # Davis weather station set up 2 | To set up a weather station, you should prepare: 3 | 1. One Davis rain gauge; 4 | 2. One Davis wind anemometer & vane; 5 | 3. One radiation shield (one SHT31 humidity sensor inside); 6 | 4. One UV sensor; 7 | 5. One enclosure box; 8 | 6. One solar panel assembled with steel angle, a lead acid battery and a solar regulator; 9 | 7. One tripod to support all the sensors, solar panel and enclosue; 10 | 8. One datalogger; 11 | 9. One WLAN adapter and antenna. 12 | 13 | The main components of the weather station are shown as follows: 14 | ![main components of the weaterh station on the roof](https://user-images.githubusercontent.com/44887873/105043996-f15c4780-5ab1-11eb-9a32-de825d602f75.png) 15 | 16 | ## Sensors' wiring 17 | ### Sensors' wiring sketch 18 | Note: For Davis anemometer, it is necessary to connect a pull-up resistor (4k7 Ohm or larger) to Analog pin in datalogger. 19 | ![sensors' wiring sketch](https://user-images.githubusercontent.com/44887873/105043943-de497780-5ab1-11eb-89cf-29fe453180ef.png) 20 | 21 | ### Sensors' connection to datalogger V3 22 | 23 | ![sensors' connecntion to datalogger v3](https://user-images.githubusercontent.com/44887873/105043972-e7d2df80-5ab1-11eb-9cb5-1b1a620dfede.png) 24 | 25 | ## Davis vane - wind direction measurement diagram 26 | 27 | ![wind direction](https://user-images.githubusercontent.com/44887873/105043981-ea353980-5ab1-11eb-9dbc-c56854234272.png) 28 | The wind vane has a 20k linear potentiometer attached to it. The output from the wind direction circuit is connected to a analog pin on the Arduino. 29 | As we move the wind vane around we should get a reading between 0 and 1023. The Arduino has a 10 bit A to D converter which gives us the range of 0 to 1023. 30 | This would also correspond to a voltage of 0 to 5V. In the software we need to convert the 0 to 1023 to a 0 to 360 range to give us the wind direction. 31 | 32 | How to hoopup Davis anemometer to Arduino: 33 | http://cactus.io/hookups/weather/anemometer/davis/hookup-arduino-to-davis-anemometer 34 | 35 | ## The completed weather station set up on the roof 36 | 37 | ![the view of the weather station](https://user-images.githubusercontent.com/44887873/105043988-ec979380-5ab1-11eb-8953-e74d46c381ec.png) 38 | 39 | Please note: it is quite important to put weight on the tripod feet or fix with mouniting wires to protect the weather station from being blew down by strong wind. 40 | 41 | -------------------------------------------------------------------------------- /python/campbell_logging.py: -------------------------------------------------------------------------------- 1 | import time 2 | import datetime 3 | from pycampbellcr1000 import CR1000 4 | 5 | delta_t_sec=30*60 6 | time_current=datetime.datetime.now() 7 | time_previous=datetime.datetime.now() - datetime.timedelta(seconds=delta_t_sec) 8 | 9 | #logger_address='serial:/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0:38400' 10 | #device = CR1000.from_url('serial:/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0:38400') 11 | #time.sleep(5) 12 | #device = CR1000.from_url(logger_address) 13 | 14 | file_name='campbell_output.csv' 15 | 16 | fid= open(file_name,'a',0) 17 | 18 | 19 | while True: 20 | log_attempt=1 21 | while log_attempt<10: 22 | try: 23 | device = CR1000.from_url('serial:/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0:38400') 24 | data = device.get_data('WPS_Tab_noarray',time_previous,time_current) 25 | break 26 | except Exception, e: 27 | # https://stackoverflow.com/questions/1483429/how-to-print-an-error-in-python 28 | print time_current.strftime("%d/%b/%Y %H:%M:%S")+" extracting failed "+str(log_attempt)+ ' '+ str(e) 29 | log_attempt+=1 30 | time.sleep(10) 31 | #device = CR1000.from_url('serial:/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0:38400') 32 | continue 33 | data[0]['Datetime'] =data[0]['Datetime'].strftime("%d/%b/%Y %H:%M:%S") 34 | #data['Datetime'] =data['Datetime'].strftime("%d/%b/%Y %H:%M:%S") 35 | 36 | str_data='' 37 | for key in data[0]: 38 | str_data+=key+','+str(data[0][key])+',' 39 | fid.write(str_data+'\n') 40 | print data[0]['Datetime']+' done' 41 | time.sleep(delta_t_sec) 42 | time_previous=time_current 43 | time_current=datetime.datetime.now() 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /python/campbell_logging_area51_cr1000.py: -------------------------------------------------------------------------------- 1 | import time 2 | import datetime 3 | from pycampbellcr1000 import CR1000 4 | 5 | delta_t_sec=30*60 6 | time_current=datetime.datetime.now() 7 | time_previous=datetime.datetime.now() - datetime.timedelta(seconds=delta_t_sec) 8 | 9 | #logger_address='serial:/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0:38400' 10 | #device = CR1000.from_url('serial:/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0:38400') 11 | #time.sleep(5) 12 | #device = CR1000.from_url(logger_address) 13 | 14 | file_name='campbell_output.csv' 15 | 16 | fid= open(file_name,'a',0) 17 | 18 | 19 | while True: 20 | log_attempt=1 21 | while log_attempt<10: 22 | try: 23 | device = CR1000.from_url('serial:/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0:38400') 24 | data = device.get_data('WPS_Tab_noarray',time_previous,time_current) 25 | break 26 | except Exception, e: 27 | # https://stackoverflow.com/questions/1483429/how-to-print-an-error-in-python 28 | print time_current.strftime("%d/%b/%Y %H:%M:%S")+" extracting failed "+str(log_attempt)+ ' '+ str(e) 29 | log_attempt+=1 30 | time.sleep(10) 31 | #device = CR1000.from_url('serial:/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0:38400') 32 | continue 33 | data[0]['Datetime'] =data[0]['Datetime'].strftime("%d/%b/%Y %H:%M:%S") 34 | #data['Datetime'] =data['Datetime'].strftime("%d/%b/%Y %H:%M:%S") 35 | 36 | str_data='' 37 | for key in data[0]: 38 | str_data+=key+','+str(data[0][key])+',' 39 | fid.write(str_data+'\n') 40 | print data[0]['Datetime']+' done' 41 | time.sleep(delta_t_sec) 42 | time_previous=time_current 43 | time_current=datetime.datetime.now() 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /python/csv_tools.py: -------------------------------------------------------------------------------- 1 | def tail( f, lines=20 ): 2 | ''' 3 | csv_tools aims to make reading csv file more convinentpublic_pizo_preip 4 | ''' 5 | total_lines_wanted = lines 6 | 7 | BLOCK_SIZE = 5024 8 | f.seek(0, 2) 9 | block_end_byte = f.tell() 10 | lines_to_go = total_lines_wanted 11 | block_number = -1 12 | blocks = [] # blocks of size BLOCK_SIZE, in reverse order starting 13 | # from the end of the file 14 | while lines_to_go > 0 and block_end_byte > 0: 15 | if (block_end_byte - BLOCK_SIZE > 0): 16 | # read the last block we haven't yet read 17 | f.seek(block_number*BLOCK_SIZE, 2) 18 | blocks.append(f.read(BLOCK_SIZE)) 19 | else: 20 | # file too small, start from begining 21 | f.seek(0,0) 22 | # only read what was not read 23 | blocks.append(f.read(block_end_byte)) 24 | lines_found = blocks[-1].count('\n') 25 | lines_to_go -= lines_found 26 | block_end_byte -= BLOCK_SIZE 27 | block_number -= 1 28 | all_read_text = ''.join(reversed(blocks)) 29 | return '\n'.join(all_read_text.splitlines()[-total_lines_wanted:]) 30 | #def tail_linux(f,lines=1): 31 | 32 | def get_one_line(f): 33 | ''' 34 | get_one_line is used to get the first line from a file 35 | ''' 36 | with open(f, 'r') as myfile: 37 | public_pizo_pre=myfile.read().replace('\n', '') 38 | return public_pizo_pre 39 | 40 | 41 | def get_first_line(f): 42 | ''' 43 | get_one_line is used to get the first line from a file 44 | ''' 45 | with open(f, 'r') as f: 46 | first_line = f.readline() 47 | return first_line 48 | -------------------------------------------------------------------------------- /python/gelita_pizo_update_mango.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import os 3 | import sys 4 | pyduino_path=os.environ['pyduino'] 5 | pyduino_data_path=pyduino_path+'/data/' 6 | pyduino_credential_path=pyduino_path+'/credential/' 7 | pyduino_python_path=pyduino_path+'/python/' 8 | sys.path.append(pyduino_python_path) 9 | 10 | import serial 11 | import time 12 | import numpy as np 13 | import sys 14 | import csv_tools 15 | from phant import Phant 16 | import serial_openlock 17 | import get_ip 18 | from upload_phant import upload_phant 19 | from time import sleep, strftime,localtime # lets us have a delay 20 | import subprocess 21 | 22 | public_pizo_pre=csv_tools.get_one_line(pyduino_credential_path+'public_pizo_pre') 23 | private_pizo_pre=csv_tools.get_one_line(pyduino_credential_path+'private_pizo_pre') 24 | nectar_address=csv_tools.get_one_line(pyduino_credential_path+'nectar_address') 25 | 26 | 27 | field_name=['dp0','hum0','pre0','pre1','pre2','pre3','pre4','pretmp0','pretmp1','pretmp2','pretmp3','pretmp4','timestamp','tmp0','tmp1','tmp10','tmp11','tmp12','tmp2','tmp3','tmp4','tmp5','tmp6','tmp7','tmp8','tmp9','volt0'] 28 | pizo_pre=dict((el,0.0) for el in field_name) 29 | pht_pizo_pre = Phant(publicKey=public_pizo_pre, fields=field_name ,privateKey=private_pizo_pre,baseUrl=nectar_address) 30 | 31 | 32 | 33 | # whether the result will be displayed on the screen 34 | screen_display=True 35 | 36 | # whether save the result as a file 37 | save_to_file=True 38 | 39 | # the delimiter between files, it is prefered to use ',' which is standard for csv file 40 | delimiter=',' 41 | 42 | __author__ = 'chenming' 43 | 44 | file_name_gelita_1=pyduino_data_path+'gelita_borehole' 45 | fn_gelita=open(file_name_gelita_1,'r') 46 | msg_gelita=csv_tools.tail(fn_gelita,1) 47 | if screen_display: print msg_gelita.rstrip() 48 | current_read=msg_gelita.split(',')[0:-1] 49 | 50 | 51 | pre_ind=[i for i,x in enumerate(current_read) if x == '9548'] 52 | pizo_pre["pre0"]=float(current_read[pre_ind[0]+17]) 53 | pizo_pre["tmp0"]=float(current_read[pre_ind[0]+16]) 54 | pizo_pre["pre1"]=float(current_read[pre_ind[1]+17]) 55 | pizo_pre["tmp1"]=float(current_read[pre_ind[1]+16]) 56 | pizo_pre["pre2"]=float(current_read[pre_ind[2]+17]) 57 | pizo_pre["tmp2"]=float(current_read[pre_ind[2]+16]) 58 | 59 | 60 | pizo_pre["pretmp1"]=pizo_pre["pre1"]-pizo_pre["pre0"] 61 | pizo_pre["pretmp2"]=pizo_pre["pre2"]-pizo_pre["pre0"] 62 | 63 | 64 | pre_ind=[i for i,x in enumerate(current_read) if x == 'analog'] 65 | pizo_pre["volt0"]=float(current_read[pre_ind[0]+2]) 66 | 67 | 68 | upload_phant(pht_pizo_pre,pizo_pre,screen_display) 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /python/get_ip.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hydrogeologger/pyduino/47b96c04b8c070ca040bc57824ee28e49d4c7033/python/get_ip.pyc -------------------------------------------------------------------------------- /python/gpio_floodlight_camera.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import sys 3 | import time 4 | from time import sleep 5 | import RPi.GPIO as GPIO # import RPi.GPIO module 6 | from time import sleep 7 | import picamera 8 | import subprocess 9 | GPIO.setmode(GPIO.BCM) # choose BCM or BOARD 10 | #GPIO.setwarnings(False) 11 | GPIO.setup(23, GPIO.OUT) # set GPIO24 as an output 12 | #subprocess.call("/home/pi/script/raspstill_snapshot_marandoo.sh", shell=True) 13 | GPIO.output(23, 1) # set GPIO24 to 1/GPIO.HIGH/True 14 | 15 | with open('/home/pi/script/pass/cmd_area51_taking_photo', 'r') as myfile: 16 | cmd_area51_taking_photo=myfile.read().replace('\n', '') 17 | 18 | sleep(5) 19 | 20 | #camera.capture('/home/pi/photo/'+file_name_basin_2) 21 | #camera = picamera.PiCamera() 22 | process=subprocess.Popen('/home/pi/script/raspistill_snapshot_bacteria_basin_2.sh', stdout=subprocess.PIPE) 23 | process=subprocess.Popen(cmd_area51_taking_photo.split(), stdout=subprocess.PIPE) 24 | process.wait() 25 | #time.sleep(5) 26 | #time.sleep(10) 27 | GPIO.output(23,0) 28 | 29 | sleep(5) 30 | #camera.close() 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /python/grange_weather_1_mps: -------------------------------------------------------------------------------- 1 | Traceback (most recent call last): 2 | File "grange_weather_1_mps.py", line 16, in 3 | with open('/home/pi/script/pass/public_grange_ad_weather_nectar', 'r') as myfile: 4 | IOError: [Errno 2] No such file or directory: '/home/pi/script/pass/public_grange_ad_weather_nectar' 5 | Traceback (most recent call last): 6 | File "grange_weather_1_mps.py", line 16, in 7 | with open('/home/pi/script/pass/public_grange_ad_weather_nectar', 'r') as myfile: 8 | IOError: [Errno 2] No such file or directory: '/home/pi/script/pass/public_grange_ad_weather_nectar' 9 | Traceback (most recent call last): 10 | File "grange_weather_1_mps.py", line 16, in 11 | with open('/home/pi/script/pass/public_grange_ad_weather_nectar', 'r') as myfile: 12 | IOError: [Errno 2] No such file or directory: '/home/pi/script/pass/public_grange_ad_weather_nectar' 13 | Traceback (most recent call last): 14 | File "grange_weather_1_mps.py", line 16, in 15 | with open('/home/pi/script/pass/public_grange_ad_weather_nectar', 'r') as myfile: 16 | IOError: [Errno 2] No such file or directory: '/home/pi/script/pass/public_grange_ad_weather_nectar' 17 | Traceback (most recent call last): 18 | File "grange_weather_1_mps.py", line 16, in 19 | with open('/home/pi/script/pass/public_grange_ad_weather_nectar', 'r') as myfile: 20 | IOError: [Errno 2] No such file or directory: '/home/pi/script/pass/public_grange_ad_weather_nectar' 21 | Traceback (most recent call last): 22 | File "grange_weather_1_mps.py", line 16, in 23 | with open('/home/pi/script/pass/public_grange_ad_weather_nectar', 'r') as myfile: 24 | IOError: [Errno 2] No such file or directory: '/home/pi/script/pass/public_grange_ad_weather_nectar' 25 | Traceback (most recent call last): 26 | File "grange_weather_1_mps.py", line 16, in 27 | with open('/home/pi/script/pass/public_grange_ad_weather_nectar', 'r') as myfile: 28 | IOError: [Errno 2] No such file or directory: '/home/pi/script/pass/public_grange_ad_weather_nectar' 29 | Traceback (most recent call last): 30 | File "grange_weather_1_mps.py", line 16, in 31 | with open('/home/pi/script/pass/public_grange_ad_weather_nectar', 'r') as myfile: 32 | IOError: [Errno 2] No such file or directory: '/home/pi/script/pass/public_grange_ad_weather_nectar' 33 | -------------------------------------------------------------------------------- /python/lepton_record.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | from pylepton import Lepton 4 | from collections import Iterable 5 | import csv 6 | import time 7 | import os 8 | time_now=time.strftime("%Y_%b_%d_%H_%M_%S") 9 | 10 | 11 | os.chdir('/home/pi/pypleton/') 12 | 13 | file_name= 'flir.csv' 14 | fid= open(file_name,'a',0) 15 | 16 | with Lepton() as l: 17 | a,_ = l.capture() 18 | 19 | cv2.normalize(a, a, 0, 65535, cv2.NORM_MINMAX) # extend contrast 20 | np.right_shift(a, 8, a) # fit data into 8 bits 21 | cv2.imwrite(time_now+'.jpg', np.uint8(a)) # write it! 22 | 23 | b = a.ravel() 24 | 25 | x_arrstr = np.char.mod('%i', b) 26 | x_str = ",".join(x_arrstr) 27 | 28 | fid.write(time_now+','+x_str+'\n\r') 29 | -------------------------------------------------------------------------------- /python/lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hydrogeologger/pyduino/47b96c04b8c070ca040bc57824ee28e49d4c7033/python/lib/__init__.py -------------------------------------------------------------------------------- /python/loggerV1_reset_rpi.py: -------------------------------------------------------------------------------- 1 | import RPi.GPIO as GPIO # import RPi.GPIO module 2 | def reset(bb): 3 | import RPi.GPIO as GPIO # import RPi.GPIO module 4 | 5 | from time import sleep 6 | import time 7 | 8 | GPIO.setmode(GPIO.BCM) 9 | pin=17 10 | GPIO.setup(pin, GPIO.OUT) 11 | GPIO.output(pin, GPIO.HIGH) 12 | time.sleep(bb) 13 | GPIO.output(pin, GPIO.LOW) 14 | 15 | -------------------------------------------------------------------------------- /python/logger_manual_reset.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | ### run this on python to reset arduin 4 | import RPi.GPIO as GPIO 5 | import sys, os, re, time, fcntl 6 | 7 | #fd = sys.stdin.fileno() 8 | #fl = fcntl.fcntl(fd, fcntl.F_GETFL) 9 | #fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK) 10 | 11 | GPIO.setwarnings(False) 12 | GPIO.setmode(GPIO.BCM) 13 | 14 | def reset(): 15 | pin = 27 16 | GPIO.setup(pin, GPIO.OUT) 17 | #GPIO.output(pin, GPIO.HIGH) 18 | #time.sleep(0.32) 19 | GPIO.output(pin, GPIO.LOW) 20 | time.sleep(5) 21 | 22 | 23 | print("RESET") 24 | reset() 25 | GPIO.cleanup() 26 | #print "done with autoreset - ignore Broken pipe errors if Done uploading" 27 | exit 28 | -------------------------------------------------------------------------------- /python/post_processing/class_exp.py: -------------------------------------------------------------------------------- 1 | #An example of a class 2 | # http://sthurlow.com/python/lesson08/ 3 | class Shape: 4 | def __init__(self,x,y): 5 | self.x = x 6 | self.y = y 7 | description = "This shape has not been described yet" 8 | author = "Nobody has claimed to make this shape yet" 9 | def area(self): 10 | return self.x * self.y 11 | def perimeter(self): 12 | return 2 * self.x + 2 * self.y 13 | def describe(self,text): 14 | self.description = text 15 | def authorName(self,text): 16 | self.author = text 17 | def scaleSize(self,scale): 18 | self.x = self.x * scale 19 | self.y = self.y * scale 20 | -------------------------------------------------------------------------------- /python/post_processing/figlib.py: -------------------------------------------------------------------------------- 1 | #http://stackoverflow.com/questions/2682745/how-to-create-a-constant-in-python 2 | import numpy as np 3 | import matplotlib.pyplot as plt 4 | # belwow are all the constants 5 | def single_fig_initialise(): 6 | import matplotlib.pylab as pylab 7 | params = {'legend.fontsize': 13, 8 | 'figure.figsize': (10, 5), 9 | 'axes.labelsize': 12, 10 | 'axes.titlesize':'x-large', 11 | 'xtick.labelsize':'20', 12 | 'ytick.labelsize':'20', 13 | # 'ytick.labelweight':'bold', 14 | 'axes.labelsize': 16, 15 | 'axes.labelweight':'bold'} 16 | # 'axes.grid':'linewidth=grid_width,color = '0.5''} 17 | # 'linewidth':lw,'markers.size':ms,'markers.edgewidth':mew} 18 | plt.rcParams["font.weight"] = "bold" 19 | plt.rcParams["axes.labelweight"] = "bold" 20 | pylab.rcParams.update(params) 21 | 22 | fig = plt.figure(figsize=(8.2,8.2)) 23 | lw=6 24 | ms=8 25 | mew=3 26 | grid_width=2 27 | y_fontsize=20 28 | ax = fig.add_subplot(111) 29 | fig.subplots_adjust(left=0.17, right=0.98, top=0.99, bottom=0.17) 30 | for axis in ['top','bottom','left','right']: 31 | ax.spines[axis].set_linewidth(2) 32 | return fig 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /python/post_processing/initialize.py: -------------------------------------------------------------------------------- 1 | #import sys 2 | #sys.modules[__name__].__dict__.clear() 3 | import os 4 | import numpy as np 5 | #http://stackoverflow.com/questions/5607283/how-can-i-manually-generate-a-pyc-file-from-a-py-file 6 | import py_compile 7 | import sys 8 | a=1 9 | del a 10 | #os.path.dirname(os.path.realpath(__file__)) 11 | current_path=os.getcwd() 12 | #path_column_roof='/home/chenming/Dropbox/tailing_column/data/column_on_roof/' 13 | file_list_column_roof=os.listdir(current_path+'/data/column_on_roof/') 14 | path_data_column_roof=current_path+'/data/column_on_roof/' 15 | #execfile('class_scale.py') 16 | sys.path.append(current_path+'/python/') 17 | sys.path.append(current_path+'/python/') 18 | py_compile.compile(current_path+'/python/class_scale.py') 19 | import class_scale 20 | reload(class_scale) 21 | 22 | a=class_scale.scale(path_data_column_roof+'scale_2016_Jul_03.dat') 23 | a.surf_area1=np.pi*(0.265/2)**2 24 | self=a 25 | 26 | 27 | for n in np.arange(len(file_list_column_roof)): 28 | a.append_file(path_data_column_roof+file_list_column_roof[n]) 29 | 30 | a.export_data_as_csv('2016-06-25_2016-07-11.dat') 31 | #a.spline_scale_readings(coef=0.001,time_interval_sec_sp=600) 32 | #a.spline_scale_readings(coef=0.0000001,time_interval_sec_sp=600) 33 | #a.spline_scale_readings(coef=1e-8,time_interval_sec_sp=600) 34 | #a.spline_scale_readings(coef=1e-10,time_interval_sec_sp=600) 35 | #a.spline_scale_readings(coef=1e-13,time_interval_sec_sp=600) 36 | a.spline_scale_readings(coef=1e-14,time_interval_sec_sp=600) 37 | #a.spline_scale_readings(coef=1e-15,time_interval_sec_sp=600) 38 | -------------------------------------------------------------------------------- /python/post_processing/sensorfun.py: -------------------------------------------------------------------------------- 1 | #http://stackoverflow.com/questions/2682745/how-to-create-a-constant-in-python 2 | import numpy as np 3 | # belwow are all the constants 4 | 5 | 6 | 7 | # permitivity suction fuction 8 | def dielectric_suction_fit(**kwargs): 9 | '''fit fuction to correlate the suction sensor output to sction value''' 10 | arg_defaults = { 11 | 'x_offset' :399., 12 | 'x_scale' :5.0, 13 | 'y_scale' :-20.0, 14 | 'y_offset' :16.4, 15 | 'lamb':0.65, 16 | 'x':500. 17 | #'x_offset' :455., 18 | #'x_scale' :5.0, 19 | #'y_scale' :-20.0, 20 | #'y_offset' :18.7, 21 | #'lambda':0.65, 22 | #'x':500. 23 | } 24 | arg=arg_defaults 25 | for d in kwargs: 26 | arg[d]= kwargs.get(d) 27 | output=np.zeros(len(np.atleast_1d(arg['x']))) 28 | 29 | for ind,value in enumerate(np.atleast_1d(arg['x'])) : 30 | if value1 : output[ind]=1 63 | return output 64 | -------------------------------------------------------------------------------- /python/redmud_desiccation/README.txt: -------------------------------------------------------------------------------- 1 | Guidelines: 2 | 3 | Step 1: Download Data from Thingsboard: 4 | -prepare schedule.json and tb_ch.json (These 2 files contain credential info and hence not included in this folder) 5 | -execute get_data_py3.py and generate the CSV file contains all the data for balances and sensors 6 | 7 | Step 2: Prepare photos: 8 | -create a folder with 5 sub-folders named: basinA, basinB, basinC, basinD and basinE, respectively 9 | The names of the JPG files must be in specific format. E.g. basinA_2022_05_25_12_00_01.jpg 10 | This folder is used to store the original photos. 11 | -create another folder 12 | This folder is used to store the selected photos for the video. 13 | 14 | Step 3: Execute video.py: 15 | -Directories must be revised accordingly befor executing the video.py -------------------------------------------------------------------------------- /python/reset_rpi.py: -------------------------------------------------------------------------------- 1 | import RPi.GPIO as GPIO # import RPi.GPIO module 2 | def reset(bb): 3 | import RPi.GPIO as GPIO # import RPi.GPIO module 4 | 5 | from time import sleep 6 | import time 7 | 8 | GPIO.setmode(GPIO.BCM) 9 | pin=17 10 | GPIO.setup(pin, GPIO.OUT) 11 | GPIO.output(pin, GPIO.HIGH) 12 | time.sleep(bb) 13 | GPIO.output(pin, GPIO.LOW) 14 | 15 | -------------------------------------------------------------------------------- /python/rs232_ohaus_nvl20000_phant.py: -------------------------------------------------------------------------------- 1 | # this script records scale readings from adam gfk 600 2 | import serial 3 | import time 4 | import numpy as np 5 | import sys 6 | from phant import Phant 7 | ser = serial.Serial('/dev/serial/by-id/usb-FTDI_USB__-__Serial-if00-port0') 8 | 9 | no_of_readings=60000 # totally how many readings will be done 10 | sleep_time_seconds=300 # the interval of neighbouring reading 11 | 12 | 13 | field_name=['commercial','nvl','ohaus','measure_local_time']; 14 | 15 | pht = Phant(publicKey='7Jlzv3bb9vhZ4LLd9Waj', 16 | fields=field_name ,privateKey='mz4rqWGGoqHjeYYaB9Nn') 17 | 18 | parsed_data={'commercial':0.0,'nvl':0.0,'ohaus':0.0,'measure_local_time':''}; 19 | 20 | 21 | # the Filename of the csv file for storing file 22 | file_name= 'rs232_ohaus_nvl20000_phant.csv' 23 | 24 | save_to_file=True 25 | screen_display=True 26 | #temp=["" for x in range(no_of_readings)] 27 | #reading_scale=["" for x in range(no_of_readings)] 28 | #reading_time =["" for x in range(no_of_readings)] 29 | 30 | __author__ = 'chenming' 31 | 32 | 33 | #if __name__ == "__main__": 34 | # while True: 35 | # fid= open('scale_record.dat','a',0) 36 | # #ser.write('P\n\r') 37 | # ser.write('IP\n\r') 38 | # ser.readline() 39 | # 40 | # 41 | # 42 | # for n in range(0, no_of_readings-1): 43 | # #ser.write('P\n\r') # output STABLE results. warning, not good for roof test or test under a fan 44 | # ser.write('IP\n\r') # output constant result, if it is a unsable one, the result ends up with a question mark. 45 | # temp[n]=ser.readline() 46 | # current_scale_read=temp[n].split()[0] 47 | # thermometer(current_scale_read) 48 | # fid.write(time.strftime("%d/%b/%Y %H:%M:%S")+temp[n]) 49 | # time.sleep(sleep_time_seconds) 50 | # 51 | # fid.close() 52 | # ser.close() 53 | 54 | 55 | ser.write('IP\n\r') 56 | # throw away the first reading as it is always formated poorly 57 | msg = ser.readline() 58 | if save_to_file: fid= open(file_name,'a',0) 59 | for i in xrange(no_of_readings): 60 | ser.write('IP\n\r') 61 | msg = ser.readline() 62 | current_read=msg.split()[0] 63 | parsed_data['commercial']=float(current_read) 64 | parsed_data['nvl']=0.0 65 | parsed_data['ohaus']=0.0 66 | time_now=time.strftime("%Y-%b-%d %H:%M:%S") 67 | parsed_data['measure_local_time']=time_now 68 | 69 | 70 | log_attempts=1 71 | while log_attempts<10: 72 | try: 73 | pht.log(parsed_data['commercial'] # warning: the sequence of the upload values has to follow strict from sequence in variable pased_data and field name 74 | ,parsed_data['nvl'] 75 | ,parsed_data['ohaus'] 76 | ,parsed_data['measure_local_time']) 77 | break 78 | except: # catch all errors 79 | log_attempts+=1 80 | time.sleep(30) 81 | continue 82 | if screen_display: print i,delimiter,time_now,delimiter,msg.rstrip() 83 | if save_to_file: fid.write(time_now+delimiter+msg) 84 | 85 | time.sleep(sleep_time_seconds) 86 | 87 | 88 | fid.close() 89 | ser.close() 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /python/serial_openlock.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hydrogeologger/pyduino/47b96c04b8c070ca040bc57824ee28e49d4c7033/python/serial_openlock.pyc -------------------------------------------------------------------------------- /python/serial_read_python3.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import time 3 | import serial 4 | SCREEN_DISPLAY=True 5 | SAVE_TO_FILE=True 6 | DELIMITER=',' 7 | 8 | #SERIAL_PORT='/dev/ttyACM0' # serial port terminal 9 | SERIAL_PORT='COM5' 10 | 11 | file_name= 'output.csv' 12 | fid= open(file_name,'ab') 13 | 14 | scale=serial.Serial(SERIAL_PORT,timeout=20,baudrate=4800) 15 | 16 | while True: 17 | str_scale=scale.readline() 18 | time_now=time.strftime("%Y-%m-%d %H:%M:%S") 19 | 20 | if SCREEN_DISPLAY: print(str.encode(time_now+DELIMITER)+str_scale) 21 | time.sleep(0.01) # in seconds 22 | if SAVE_TO_FILE: fid.write(str.encode(time_now)+str_scale) 23 | 24 | scale.close() 25 | fid.close() 26 | -------------------------------------------------------------------------------- /python/tb_to_csv/schedule.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_name" : "ewatering", 3 | "start_time" : "2021/Mar/15 15:00", 4 | "end_time" : "2021/Jun/1 12:00", 5 | "delta_t_s" : 600 6 | } 7 | -------------------------------------------------------------------------------- /python/upload_phant.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hydrogeologger/pyduino/47b96c04b8c070ca040bc57824ee28e49d4c7033/python/upload_phant.pyc --------------------------------------------------------------------------------