├── Arduino M0 ├── M0_BC66_ATtest │ └── M0_BC66_ATtest.ino ├── M0_BMP28x │ └── M0_BMP28x.ino ├── M0_BMx280 │ └── M0_BMx280.ino ├── README.md └── SerialOutBTM0 │ └── SerialOutBTM0.ino ├── Arduino MKR ├── MKR1000_PushOver_Status │ ├── MKR1000_PushOver_Status.ino │ ├── arduino_secrets.h │ ├── functions.ino │ └── send_message.ino ├── MKR1000_Pushover │ └── MKR1000_Pushover.ino ├── MKRWAN1300_TTN │ ├── MKRWAN1300_TTN.ino │ └── buildPacket.ino ├── MKRWAN1300_Vbat │ ├── MKRWAN1300_Vbat.ino │ ├── RTC.ino │ └── buildPacket.ino └── MKRWAN1300_getEUI │ └── MKRWAN1300_getEUI.ino ├── Arduino Nano ├── NanoEvery_Transmit_Serial │ ├── NanoEvery_Transmit_Serial.ino │ └── sendMessage.ino ├── Nano_Transmit_CAN │ ├── Nano_Transmit_CAN.ino │ └── sendMessage.ino ├── Nano_Transmit_I2C │ ├── Nano_Transmit_I2C.ino │ └── sendMessage.ino ├── Nano_Transmit_SPI │ ├── Nano_Transmit_SPI.ino │ └── sendMessage.ino └── README.md ├── Arduino Uno ├── ArduinoUnoTest │ ├── ArduinoUnoTest.ino │ ├── README.md │ ├── UnoArduSim.png │ ├── UnoArduSim_lo.png │ ├── myArduPrefs.txt │ └── myIODevs.txt ├── ExternalInterrupts │ └── ExternalInterrupts.ino ├── HC_SR04_Proximity │ └── HC_SR04_Proximity.ino ├── NewPingTimerMedian │ └── NewPingTimerMedian.ino ├── README.md ├── SerialOutBT │ └── SerialOutBT.ino ├── UnoETH_IperfServer │ └── UnoETH_IperfServer.ino ├── UnoETH_WebClient │ └── UnoETH_WebClient.ino ├── Uno_1WireModul │ ├── Uno_1WireModul.ino │ ├── readDS18B20.ino │ └── readDS2438.ino ├── Uno_A4988 │ └── Uno_A4988.ino ├── Uno_AirQuality │ ├── README.md │ ├── Uno_AirQuality.ino │ └── dispBargraph.ino ├── Uno_AnalogKeypad │ └── Uno_AnalogKeypad.ino ├── Uno_BH1750 │ └── Uno_BH1750.ino ├── Uno_BLDC │ └── Uno_BLDC.ino ├── Uno_DHT11 │ ├── Uno_DHT11.ino │ └── Uno_JsonOutputv6 │ │ └── Uno_JsonOutputv6.ino ├── Uno_DOGS102_Icon │ ├── Uno_DOGS102_Icon.ino │ └── logo_BMP.h ├── Uno_DS18B20 │ └── Uno_DS18B20.ino ├── Uno_DotStar │ └── Uno_DotStar.ino ├── Uno_EEPROM │ └── Uno_EEPROM.ino ├── Uno_EasyDriver │ └── Uno_EasyDriver.ino ├── Uno_FastLED │ └── Uno_FastLED.ino ├── Uno_Flasher │ ├── Uno_Flasher.ino │ └── Uno_Si7021 │ │ └── Uno_Si7021.ino ├── Uno_Grove_LCD │ └── Uno_Grove_LCD.ino ├── Uno_HC-SR501 │ └── Uno_HC-SR501.ino ├── Uno_Joystick_Test │ └── Uno_Joystick_Test.ino ├── Uno_JsonOutputv6 │ └── Uno_JsonOutputv6.ino ├── Uno_KY40_Test1 │ └── Uno_KY40_Test1.ino ├── Uno_KY40_Test2 │ └── Uno_KY40_Test2.ino ├── Uno_Keys │ └── Uno_Keys.ino ├── Uno_L293 │ └── Uno_L293.ino ├── Uno_L293_MotorShield │ └── Uno_L293_MotorShield.ino ├── Uno_LCDKeypadShield │ └── Uno_LCDKeypadShield.ino ├── Uno_LEDMatrix │ ├── Font.h │ └── Uno_LEDMatrix.ino ├── Uno_LEDMatrix_Marquee │ ├── Font.h │ ├── Uno_LEDMatrix.mp4 │ └── Uno_LEDMatrix_Marquee.ino ├── Uno_MQ135 │ └── Uno_MQ135.ino ├── Uno_MotorShield_R3 │ └── Uno_MotorShield_R3.ino ├── Uno_NTC │ └── Uno_NTC.ino ├── Uno_NeoPixels │ └── Uno_NeoPixels.ino ├── Uno_NeoPixels_Spektrum │ ├── Spectrum.ino │ └── Uno_NeoPixels_Spektrum.ino ├── Uno_NextionHMI │ ├── README.md │ ├── Uno_NeoPixels │ │ └── Uno_NeoPixels.ino │ ├── WS-0C.png │ ├── WS-0F.png │ ├── WS-20C.png │ ├── WS-20F.png │ ├── WS-25C.png │ ├── WS-25F.png │ ├── WS-45C.png │ ├── WS-45F.png │ ├── WS-5C.png │ ├── WS-5F.png │ └── Weatherstation.tft ├── Uno_Nextion_Weatherstation │ ├── Uno_Nextion_Weatherstation.ino │ ├── Weatherstation.tft │ └── getValue.ino ├── Uno_Nokia5110 │ ├── Uno_Nokia5110.ino │ └── startScreen.ino ├── Uno_OLED │ └── Uno_OLED.ino ├── Uno_PPD42NS │ └── Uno_PPD42NS.ino ├── Uno_RGB │ ├── Uno_RGB.ino │ ├── Uno_RGB_HD 720p.mp4 │ ├── blinkLED.ino │ └── fadeLED.ino ├── Uno_RGB_adjust │ └── Uno_RGB_adjust.ino ├── Uno_ReadMFRC522 │ └── Uno_ReadMFRC522.ino ├── Uno_ReadNFCTag │ └── Uno_ReadNFCTag.ino ├── Uno_Receive_CAN │ └── Uno_Receive_CAN.ino ├── Uno_Receive_I2C │ └── Uno_Receive_I2C.ino ├── Uno_Receive_SPI │ └── Uno_Receive_SPI.ino ├── Uno_Receive_Serial │ └── Uno_Receive_Serial.ino ├── Uno_Relais │ └── Uno_Relais.ino ├── Uno_Runtime │ └── Uno_Runtime.ino ├── Uno_Runtime_EEPROM │ └── Uno_Runtime_EEPROM.ino ├── Uno_Runtime_FRAM │ └── Uno_Runtime_FRAM.ino ├── Uno_Runtime_extEEPROM │ └── Uno_Runtime_extEEPROM.ino ├── Uno_SCD30_Monitor │ └── Uno_SCD30_Monitor.ino ├── Uno_Servo │ └── Uno_Servo.ino ├── Uno_Si7021 │ └── Uno_Si7021.ino ├── Uno_Stepper │ ├── README.md │ ├── Stepper_HD 720p.mp4 │ └── Uno_Stepper.ino ├── Uno_TCS3200 │ └── Uno_TCS3200.ino ├── Uno_TM1637 │ └── Uno_TM1637.ino ├── Uno_TMP36 │ └── Uno_TMP36.ino ├── Uno_TMP36_Thingspeak │ ├── TCP.ino │ ├── Uno_TMP36_Thingspeak.ino │ ├── arduino_secrets.h │ └── getValue.ino ├── Uno_TouchPanel1 │ └── Uno_TouchPanel1.ino ├── Uno_TouchPanel2 │ └── Uno_TouchPanel2.ino ├── Uno_TouchSensor │ └── Uno_TouchSensor.ino ├── Uno_VL53L0X │ └── Uno_VL53L0X.ino ├── Uno_Waveshare28_TFT │ ├── Uno_Waveshare28_TFT.ino │ ├── getValue.ino │ └── showBMP.ino ├── Uno_Waveshare28_Touch │ ├── Uno_Waveshare28_Touch.ino │ ├── point.ino │ └── random.ino ├── Uno_Weather │ └── Uno_Weather.ino ├── Uno_WriteMFRC522 │ └── Uno_WriteMFRC522.ino ├── Uno_WriteNFCTag │ └── Uno_WriteNFCTag.ino ├── Uno_extEEPROM │ └── Uno_extEEPROM.ino └── Uno_extFRAM │ └── Uno_extFRAM.ino ├── Arduino Yun ├── README.md ├── Yun_Commands │ └── Yun_Commands.ino ├── Yun_SHT31 │ └── Yun_SHT31.ino ├── Yun_SHT31_FileIO │ └── Yun_SHT31_FileIO.ino ├── openweather.py └── thingspeak.sh ├── Benchmarks ├── CoreMark │ ├── CoreMark.ino │ ├── core_list_join.c │ ├── core_main.c │ ├── core_matrix.c │ ├── core_portme.c │ ├── core_portme.h │ ├── core_state.c │ ├── core_util.c │ └── coremark.h ├── IOBench │ └── IOBench.ino ├── IOLoop │ └── IOLoop.ino ├── README.md ├── Whetstone │ └── Whetstone.ino ├── dhry21a │ ├── dhry.h │ └── dhry21a.ino └── sieve_arduino │ └── sieve_arduino.ino ├── CubeCell ├── Capsule_ChipID │ └── Capsule_ChipID.ino ├── Capsule_LoRaWan │ └── Capsule_LoRaWan.ino ├── Capsule_ReadSensors │ └── Capsule_ReadSensors.ino ├── CubeCell-AB02A_LoRaWan │ ├── BMP280.ino │ └── CubeCell-AB02A_LoRaWan.ino ├── CubeCell_ChipID │ └── CubeCell_ChipID.ino ├── CubeCell_LoRaWan │ ├── CubeCell_LoRaWan.ino │ └── batteryVoltage.ino ├── CubeCell_LowPower_WakeUpByTimer │ ├── CubeCell_DeepSleep.png │ └── CubeCell_LowPower_WakeUpByTimer.ino ├── CubeCell_RGB │ ├── Adafruit_NeoPixel.cpp │ ├── Adafruit_NeoPixel.h │ └── CubeCell_RGB.ino └── CubeCell_Settings.png ├── ESP-NOW ├── ESP-NOW_Gateway │ └── ESP-NOW_Gateway.ino ├── ESP-NOW_Gateway_WiFi │ ├── ESP-NOW_Gateway_WiFi.ino │ ├── arduino_secrets.h │ ├── configureMQTT.ino │ └── connectWiFi.ino ├── ESP32_SensorNode │ ├── ESP32_SensorNode.ino │ └── getValues.ino └── Readme.md ├── ESP32 ├── ESP-NOW_Gateway │ └── ESP-NOW_Gateway.ino ├── ESP-NOW_Gateway_WiFi │ ├── ESP-NOW_Gateway_WiFi.ino │ ├── configureMQTT.ino │ └── connectWiFi.ino ├── ESP32_BLE_Peripheral │ ├── ESP32_BLE_Peripheral.ino │ └── getValues.ino ├── ESP32_BLE_Server │ ├── ESP32_BLE_Server.ino │ └── getValues.ino ├── ESP32_CCS811_ReadEnvData │ ├── ESP32_CCS811_ReadEnvData.ino │ └── filter.ino ├── ESP32_CO2_Ampel │ ├── CO2 Green.jpg │ ├── CO2 Red.jpg │ ├── CO2 Yellow.jpg │ ├── ESP32_CO2_Ampel.ino │ ├── Free_Fonts.h │ ├── sensor.ino │ └── tone.ino ├── ESP32_ReadEnvData │ └── ESP32_ReadEnvData.ino ├── ESP32_SensorNode │ ├── ESP32_SensorNode.ino │ └── getValues.ino ├── ESP32_T5_v2.3_Node │ ├── BMP280.ino │ ├── ESP32_T5_v2.3_Node.ino │ ├── WiFi.ino │ └── arduino_secrets.h ├── ESP32_TFT_graphicstest_PDQ │ ├── ESP32_TFT_graphicstest_PDQ.ino │ ├── Readme │ └── User_Setup.h ├── ESP32_ePulse │ ├── BMP280.ino │ ├── ESP32_ePulse.ino │ ├── WiFi.ino │ └── arduino_secrets.h ├── Heltec_LoRa32_Receive │ └── Heltec_LoRa32_Receive.ino ├── Heltec_LoRa32_TTN │ ├── Heltec_LoRa32_TTN.ino │ └── getValue.ino ├── Heltec_LoRa32_Transmit │ ├── Heltec_LoRa32_Transmit.ino │ └── debug.log ├── HiGrowESP32Pushover │ ├── HiGrowESP32Pushover.ino │ ├── README.md │ ├── Screenshot 2022-07-14 131320.jpg │ ├── WiFi.ino │ ├── arduino_secrets.h │ ├── getValues.ino │ ├── pushOver.ino │ └── wakeup.ino ├── README.md ├── SineExample │ ├── SineExample.ino │ └── sine_model.h ├── get_ESP_MAC_Address │ └── get_ESP_MAC_Address.ino └── mi_temp3 │ ├── config.h │ └── mi_temp3.ino ├── ESP8266 ├── D1mini_Paperino_GFXdemo │ └── D1mini_Paperino_GFXdemo.ino ├── ESP8266_AZ-Envy_Data │ └── ESP8266_AZ-Envy_Data.ino ├── ESP8266_AZ-Envy_RawData │ └── ESP8266_AZ-Envy_RawData.ino ├── ESP8266_D1Lamp │ ├── ESP8266_D1Lamp.ino │ ├── Menu Tools.png │ ├── arduino_secrets.h │ └── functions.ino └── ESP8266_TH_Webserver │ ├── ESP8266_TH_Webserver.ino │ ├── ESP8266_TH_Webserver.jpg │ └── arduino_secrets.h ├── GMC ├── M5Atom_GMC_Cajoe │ ├── M5Atom_GMC_Cajoe.ino │ ├── WiFi.ino │ └── arduino_secrets.h ├── M5StickC_GMC_Gravity │ ├── LCD.ino │ ├── M5StickC_GMC_Gravity.ino │ ├── WiFi.ino │ └── arduino_secrets.h ├── M5StickC_GMC_PiGI │ ├── LCD.ino │ ├── M5StickC_GMC_PiGI.ino │ ├── WiFi.ino │ └── arduino_secrets.h ├── M5StickC_GMC_Test │ ├── LCD.ino │ └── M5StickC_GMC_Test.ino └── README.md ├── Generic ├── Arduino.h ├── Calculation │ └── Calculation.ino ├── ExternalInterrupts │ └── ExternalInterrupts.ino ├── FlipDot │ └── FlipDot.ino ├── HC_SR04_Proximity │ └── HC_SR04_Proximity.ino ├── HelloWorld │ └── HelloWorld.ino ├── Key-States-Test-on-Serial-Monitor │ └── Key-States-Test-on-Serial-Monitor.ino ├── NewPingTimerMedian │ └── NewPingTimerMedian.ino ├── Progmem │ └── Progmem.ino ├── README.md ├── SerialOutBT │ └── SerialOutBT.ino ├── SerialOutBTM0 │ └── SerialOutBTM0.ino ├── VariableDatatypes │ └── VariableDatatypes.ino ├── add │ └── add.ino ├── array │ └── array.ino ├── bitbyte │ └── bitbyte.ino ├── call │ └── call.ino ├── class │ └── class.ino ├── enum │ └── enum.ino ├── math │ └── math.ino ├── overload │ └── overload.ino ├── pointer │ └── pointer.ino ├── qualifier │ └── qualifier.ino ├── random │ ├── putRandom.ino │ └── random.ino ├── struct │ └── struct.ino ├── tone │ └── tone.ino └── union │ └── union.ino ├── LICENSE ├── LilyPad Arduino └── LightControlledBlinking │ └── LightControlledBlinking.ino ├── M5Atom ├── M5AtomLite_LedSet │ ├── M5AtomLite_LedSet.ino │ └── M5AtomLite_LedSet.png ├── M5Atom_Display │ ├── M5Atom_Display.ino │ └── image.h ├── M5Atom_DrawPixel │ └── M5Atom_DrawPixel.ino ├── M5Atom_ENV_Unit │ ├── DHT12.cpp │ ├── DHT12.h │ ├── M5Atom_ENV_Unit.ino │ └── M5Atom_ENV_Unit.png ├── M5Atom_I2C_Test │ └── M5Atom_I2C_Test.ino └── M5Atom_Telegram │ ├── M5Atom_Telegram.ino │ ├── WiFi_reconnect.ino │ ├── arduino_secrets.h │ └── display.ino ├── M5Stack ├── CoreInk_EnvII_Node │ ├── CoreInk_EnvII_Node.ino │ ├── SHT3X.cpp │ ├── SHT3X.h │ ├── WiFi.ino │ ├── arduino_secrets.h │ └── voltage.ino ├── CoreInk_PIR │ ├── CoreInk_PIR.ino │ ├── output.ino │ ├── voltage.ino │ └── wakeup.ino ├── M5Core2_CalibrationValues │ ├── M5Core2_CalibrationValues.ino │ └── README.md ├── M5Core2_EnvMonitor │ ├── LED.ino │ ├── M5Core2_EnvMonitor.ino │ ├── WiFi.ino │ ├── displayValues.ino │ ├── getValues.ino │ └── pushover.ino ├── M5Paper_SHT31 │ ├── M5Paper_SHT31.ino │ ├── WiFi.ino │ └── arduino_secrets.h ├── M5Stack_GPSSpeed │ └── M5Stack_GPSSpeed.ino ├── M5Stack_GPSSpeed_Vbat │ └── M5Stack_GPSSpeed_Vbat.ino └── M5Stack_SIM800L │ └── M5Stack_SIM800L.ino ├── M5StickC ├── FactoryTest │ ├── DHT12.cpp │ ├── DHT12.h │ ├── FactoryTest.ino │ ├── Logo.c │ ├── esp32_rmt.cpp │ ├── esp32_rmt.h │ ├── nec.cpp │ ├── rc5_rc6.cpp │ ├── rmt.c │ └── rmt.h ├── M5StickC_DS18B20 │ └── M5StickC_DS18B20.ino ├── M5StickC_EnvHat │ ├── Adafruit_Sensor.h │ ├── DHT12.cpp │ ├── DHT12.h │ └── M5StickC_EnvHat.ino ├── M5StickC_NCIR │ └── M5StickC_NCIR.ino ├── M5StickC_PIR │ └── M5StickC_PIR.ino ├── M5StickC_TFT_graphicstest_PDQ │ ├── M5StickC_TFT_graphicstest_PDQ.ino │ ├── image.h │ └── rose.h └── README.md ├── M5StickCPlus ├── M5StickCPlus_CO2_Monitor │ ├── M5StickCPlus_CO2_Monitor.ino │ └── filter.ino ├── M5StickCPlus_TFT_graphicstest_PDQ │ ├── M5StickCPlus_TFT_graphicstest_PDQ.ino │ ├── image.h │ ├── r.h │ └── rose.h └── mi_temp3_display │ ├── config.h │ └── mi_temp3_display.ino ├── MQTT └── MQTT_Unit │ └── MQTT_Unit.ino ├── Maduino A6 ├── A6_GPRS_FileDownload │ ├── A6_GPRS_FileDownload.ino │ └── functions.ino ├── A6_GPRS_HTTP_Test │ └── A6_GPRS_HTTP_Test.ino └── AT_Debug │ └── AT_Debug.ino ├── Maixduino ├── CoreMark │ ├── CoreMark.ino │ ├── README.md │ ├── core_list_join.c │ ├── core_main.c │ ├── core_matrix.c │ ├── core_portme.c │ ├── core_portme.h │ ├── core_state.c │ ├── core_util.c │ ├── coremark.h │ └── coremark.ino ├── Coremark.png ├── README.md ├── Sieve.png └── sieve_arduino │ └── sieve_arduino.ino ├── MicroView ├── README.md └── uView_HelloWorld │ └── uView_HelloWorld.ino ├── Nicla Sense ME └── Nicla_EnvironmentalSensor │ └── Nicla_EnvironmentalSensor.ino ├── PaperiNode ├── PaperiNode_DevEUI │ ├── AES-128.cpp │ ├── AES-128.h │ ├── DS2401.cpp │ ├── DS2401.h │ ├── Encrypt.cpp │ ├── Encrypt.h │ ├── I2C.cpp │ ├── I2C.h │ ├── LoRaMAC.cpp │ ├── LoRaMAC.h │ ├── LowPower.cpp │ ├── LowPower.h │ ├── PaperiNode_DevEUI.ino │ ├── RFM95.cpp │ ├── RFM95.h │ ├── lorawan_def.h │ ├── paperinode.h │ ├── progmem.h │ ├── spi_functions.cpp │ ├── spi_functions.h │ ├── timers.cpp │ └── timers.h ├── PaperiNode_SCap_Voltage_LoRaWAN │ ├── AES-128.cpp │ ├── AES-128.h │ ├── BMP280.ino │ ├── Cayenne_LPP.cpp │ ├── Cayenne_LPP.h │ ├── DS2401.cpp │ ├── DS2401.h │ ├── Encrypt.cpp │ ├── Encrypt.h │ ├── I2C.cpp │ ├── I2C.h │ ├── LoRaMAC.cpp │ ├── LoRaMAC.h │ ├── LowPower.cpp │ ├── LowPower.h │ ├── PL_microEPD44.cpp │ ├── PL_microEPD44.h │ ├── PaperiNode_SCap_Voltage_LoRaWAN.ino │ ├── PaperiNode_SCap_Voltage_LoRaWAN.zip │ ├── RFM95.cpp │ ├── RFM95.h │ ├── encoder.h │ ├── lorawan_def.h │ ├── mcp7940.cpp │ ├── mcp7940.h │ ├── paperinode.h │ ├── progmem.h │ ├── spi_flash.cpp │ ├── spi_flash.h │ ├── spi_functions.cpp │ ├── spi_functions.h │ ├── timers.cpp │ └── timers.h ├── README.md └── schematics_rev2.pdf ├── Portenta H7 └── PortentaH7_ADC_DAC │ └── PortentaH7_ADC_DAC.ino ├── README.md ├── RP2040 ├── RP2040_Serial │ └── RP2040_Serial.ino └── RP2040_WiFi │ ├── RP2040_WiFi.ino │ ├── arduino_secrets.h │ └── sendMessage.ino ├── SAMD21 └── SAMD21_CO2_Ampel │ └── SAMD21_CO2_Ampel.ino ├── Seeeduino XIAO ├── XIAO_BME680 │ └── XIAO_BME680.ino ├── XIAO_BME680_Bird │ └── XIAO_BME680_Bird.ino ├── XIAO_WaterLevel │ └── XIAO_WaterLevel.ino └── XIAO_WaterSensors │ └── XIAO_WaterSensors.ino ├── UnoWiFiR2 ├── KallistoTestv1 │ └── KallistoTestv1.ino ├── UnoWiFiR2_BLE_Central │ └── UnoWiFiR2_BLE_Central.ino ├── UnoWiFiR2_CoronaTracker │ ├── UnoWiFiR2_CoronaTracker.ino │ └── arduino_secrets.h ├── UnoWiFiR2_DHT11_MQTT │ ├── DHT.ino │ ├── MQTT.ino │ ├── UnoWiFiR2_DHT11_MQTT.ino │ ├── WiFi.ino │ └── arduino_secrets.h ├── UnoWiFiR2_IperfServer │ ├── UnoWiFiR2_IperfServer.ino │ └── arduino_secrets.h ├── UnoWiFiR2_SCD30_dweetio │ ├── UnoWiFiR2_SCD30_dweetio.ino │ ├── arduino_secrets.h │ ├── lcd.ino │ └── reconnectWiFi.ino ├── UnoWiFiR2_Weather │ ├── UnoWiFiR2_Weather.ino │ └── arduino_secrets.h ├── UnoWiFiR2_WebClient │ ├── UnoWiFiR2_WebClient.ino │ └── arduino_secrets.h └── UnoWiFiR2_Webserver │ ├── UnoWiFiR2_Webserver.ino │ ├── arduino_secrets.h │ ├── getValues.ino │ └── printWifiStatus.ino ├── UnoWiFiR2_TimerInterrupt └── UnoWiFiR2_TimerInterrupt.ino ├── UnoWiFiR2_TimerInterrupt_Debug └── UnoWiFiR2_TimerInterrupt_Debug.ino └── UnoWiFiR2_TimerInterrupt_Trace └── UnoWiFiR2_TimerInterrupt_Trace.ino /Arduino M0/M0_BC66_ATtest/M0_BC66_ATtest.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File : M0_BC66_ATtest.ino 3 | * Brief : This example use the serial port to send AT command to control the BC66-Module. 4 | * With initialization completed, we can enter AT command to BC66-Module directly. 5 | * Common AT commands : 6 | * AT+CPIN? : Check SIM card 7 | * AT+CSQ : Check signal quality 8 | * AT+CGATT? : Check net attached state 9 | * AT+COPS? : Check Operator 10 | * AT+QBAND? : Get mobile operation band 11 | * Note : Ihe AT command must end with CRLF 12 | */ 13 | 14 | void setup() 15 | { 16 | SerialUSB.begin(115200); // Serial Interface to PC 17 | Serial1.begin(115200); // Serial Interface to BC66-Module 18 | while(!SerialUSB); 19 | SerialUSB.println("\nSend AT commands to BC66-Module......"); 20 | SerialUSB.println("For example, if you type AT\\r\\n, OK\\r\\n will be responsed!"); 21 | SerialUSB.println("Enter your AT command :"); 22 | } 23 | 24 | void loop() 25 | { 26 | while(Serial1.available()) SerialUSB.write(Serial1.read()); 27 | while(SerialUSB.available()) Serial1.write(SerialUSB.read()); 28 | } 29 | -------------------------------------------------------------------------------- /Arduino M0/README.md: -------------------------------------------------------------------------------- 1 | ## Arduino M0 2 | 3 | Dieses Verzeichnis enthält Programme, die auf einem Arduino M0 getestet wurden. 4 | 5 | Durch die Verwendung von 3.3 V-Peripherie war der Test auf einem M0 erforderlich, um Level Shifter vermeiden zu können. 6 | -------------------------------------------------------------------------------- /Arduino M0/SerialOutBTM0/SerialOutBTM0.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SerialOutBTM0.ino 3 | Serial output via Bluetooth for Arduino M0 4 | (c) Claus Kuehnel 2018-12-16 info@ckuehnel.ch 5 | 6 | Connect 7 | Arduino® HC-10 8 | ---------------- 9 | 5 V VCC 10 | GND GND 11 | D10 Rx 12 | D12 Tx 13 | */ 14 | 15 | // Serial2 pin and pad definitions (in Arduino files Variant.h & Variant.cpp) 16 | #define PIN_SERIAL2_RX (34ul) // Pin description number for PIO_SERCOM on D12 17 | #define PIN_SERIAL2_TX (36ul) // Pin description number for PIO_SERCOM on D10 18 | #define PAD_SERIAL2_TX (UART_TX_PAD_2) // SERCOM pad 2 19 | #define PAD_SERIAL2_RX (SERCOM_RX_PAD_3) // SERCOM pad 3 20 | 21 | // Instantiate the Serial2 class 22 | Uart Serial2(&sercom1, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX); 23 | 24 | void SERCOM1_Handler() // Interrupt handler for SERCOM1 25 | { 26 | Serial2.IrqHandler(); 27 | } 28 | 29 | // define your board here 30 | //#define BOARD "Arduino Leonardo" 31 | #define BOARD "Arduino M0" 32 | 33 | #define Serial SerialUSB // Arduino M0 native port 34 | 35 | void setup() 36 | { 37 | Serial.begin(115200); 38 | while(!Serial); // for native port 39 | // delay(2000); 40 | Serial.print(BOARD); 41 | Serial.println(" starts BT communication..."); 42 | 43 | Serial2.begin(9600); 44 | Serial2.print("This is "); 45 | Serial2.println(BOARD); 46 | } 47 | 48 | void loop() 49 | { 50 | Serial.print("*"); 51 | Serial2.print("*"); 52 | delay(1000); 53 | } 54 | -------------------------------------------------------------------------------- /Arduino MKR/MKR1000_PushOver_Status/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | #define SECRET_SSID "Sunrise_2.4GHz_8AC2A0" 2 | #define SECRET_PASS "u2u7fgzv31Ds" 3 | 4 | // Pushover settings 5 | char pushoversite[] = "api.pushover.net"; 6 | char apitoken[] = "apwspz3j1rqxfxy993o2iwfdd8nidu"; 7 | char userkey [] = "uojfahpyozqtj6gbgccg61e5jngg93"; 8 | -------------------------------------------------------------------------------- /Arduino MKR/MKR1000_PushOver_Status/functions.ino: -------------------------------------------------------------------------------- 1 | // This file contains several functions used in the application 2 | 3 | void heartbeat() 4 | { 5 | digitalWrite(LED_BUILTIN, HIGH); 6 | delay(50); 7 | digitalWrite(LED_BUILTIN, LOW); 8 | delay(250); 9 | 10 | digitalWrite(LED_BUILTIN, HIGH); 11 | delay(50); 12 | digitalWrite(LED_BUILTIN, LOW); 13 | delay(250); 14 | } 15 | 16 | byte pushover(char *pushovermessage, int priority) 17 | { 18 | String message = pushovermessage; 19 | 20 | length = 113 + message.length(); 21 | 22 | if(client.connect(pushoversite,80)) 23 | { 24 | client.println("POST /1/messages.json HTTP/1.1"); 25 | client.println("Host: api.pushover.net"); 26 | client.println("Connection: close\r\nContent-Type: application/x-www-form-urlencoded"); 27 | client.print("Content-Length: "); 28 | client.print(length); 29 | client.println("\r\n");; 30 | client.print("token="); 31 | client.print(apitoken); 32 | client.print("&user="); 33 | client.print(userkey); 34 | client.print("&message="); 35 | client.print(message); 36 | client.print("&priority="); 37 | client.print(priority); 38 | client.print("&retry=60"); 39 | client.print("&expire=3600"); 40 | while(client.connected()) 41 | { 42 | while(client.available()) 43 | { 44 | char ch = client.read(); 45 | Serial.write(ch); 46 | } 47 | } 48 | client.stop(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Arduino MKR/MKR1000_PushOver_Status/send_message.ino: -------------------------------------------------------------------------------- 1 | // This file contains the application code 2 | 3 | void send_message() 4 | { 5 | heartbeat(); 6 | Serial.print("Connecting to WiFi..."); 7 | WiFi.begin(ssid, password); 8 | while (WiFi.status() != WL_CONNECTED) 9 | { 10 | heartbeat(); 11 | } 12 | Serial.println("connected."); 13 | char buf[10]; 14 | long rssi = WiFi.RSSI(); 15 | char * rssi_str; 16 | rssi_str = ltoa(rssi, buf, 10); 17 | 18 | String message = "RSSI = "; 19 | message += rssi_str; 20 | message += " dBm"; 21 | 22 | int len = message.length(); 23 | char charBuf[len+1]; 24 | message.toCharArray(charBuf, len+1); 25 | Serial.println(charBuf); 26 | pushover(charBuf,0); // Priority 0 27 | 28 | WiFi.end(); 29 | } 30 | -------------------------------------------------------------------------------- /Arduino MKR/MKRWAN1300_TTN/buildPacket.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Get SHT31 sensor data & build LoRaWAN data package 3 | */ 4 | 5 | void buildPacket() 6 | { 7 | if (DEBUG) 8 | { 9 | Serial.println("---------------------------------------"); 10 | Serial.println("Get SHT31 sensor data and build package"); 11 | } 12 | float temp = sht31.getTemperature(); 13 | float hum = sht31.getHumidity(); 14 | 15 | if (DEBUG) 16 | { 17 | Serial.print("Temp = "); Serial.print(temp,2); Serial.println(" *C"); 18 | Serial.print("Hum = "); Serial.print(hum,1); Serial.println(" %RH"); 19 | } 20 | 21 | int16_t tmp = (int16_t)((temp * 100) + 0.5); // tmp = temp * 100 22 | uint8_t temp_lo = lowByte(tmp); 23 | uint8_t temp_hi = highByte(tmp); 24 | 25 | uint16_t _hum = (uint16_t)((hum * 10) + 0.5); // _hum = hum * 10 26 | uint8_t hum_lo = lowByte(_hum); 27 | uint8_t hum_hi = highByte(_hum); 28 | 29 | // Tx Package 30 | txBuffer[0] = hum_lo; 31 | txBuffer[1] = hum_hi; 32 | txBuffer[2] = temp_lo; 33 | txBuffer[3] = temp_hi; 34 | } 35 | -------------------------------------------------------------------------------- /Arduino MKR/MKRWAN1300_Vbat/RTC.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Code for RTC WakeUp from DeepSleep 3 | */ 4 | 5 | void initRTC() 6 | { 7 | rtc.begin(); 8 | 9 | rtc.setTime(hours, minutes, seconds); 10 | rtc.setDate(day, month, year); 11 | 12 | rtc.setAlarmTime(hours + wakeupHours, minutes + wakeupMinutes, seconds + wakeupSeconds); 13 | rtc.enableAlarm(rtc.MATCH_HHMMSS); 14 | rtc.attachInterrupt(alarmMatch); 15 | 16 | if (DEBUG) Serial.println("RTC WakeUp initialized."); 17 | } 18 | 19 | void alarmMatch() 20 | { 21 | if (DEBUG) Serial.println("WakeUp from DeepSleep."); 22 | matched = true; 23 | } 24 | -------------------------------------------------------------------------------- /Arduino MKR/MKRWAN1300_Vbat/buildPacket.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Get Vbat & SHT31 sensor data & build LoRaWAN data package 3 | */ 4 | 5 | const float KF = 2.355646355; // Correction factor for volatage divider 6 | 7 | void buildPacket() 8 | { 9 | if (DEBUG) Serial.println("Get VBAT & SHT31 sensor data and build package"); 10 | 11 | float vbat = KF * analogRead(ADC_BATTERY) * 3300./4096; 12 | float temp = sht31.getTemperature(); 13 | float hum = sht31.getHumidity(); 14 | 15 | if (DEBUG) 16 | { 17 | Serial.print("VBat = "); Serial.print(vbat,1); Serial.println(" mV"); 18 | Serial.print("Temp = "); Serial.print(temp,2); Serial.println(" *C"); 19 | Serial.print("Hum = "); Serial.print(hum,1); Serial.println(" %RH"); 20 | } 21 | 22 | uint16_t _vbat = (uint16_t) (vbat + 0.5); 23 | uint8_t vbat_lo = lowByte(_vbat); 24 | uint8_t vbat_hi = highByte(_vbat); 25 | 26 | int16_t tmp = (int16_t)((temp * 100) + 0.5); // tmp = temp * 100 27 | uint8_t temp_lo = lowByte(tmp); 28 | uint8_t temp_hi = highByte(tmp); 29 | 30 | uint16_t _hum = (uint16_t)((hum * 10) + 0.5); // _hum = hum * 10 31 | uint8_t hum_lo = lowByte(_hum); 32 | uint8_t hum_hi = highByte(_hum); 33 | 34 | // Tx Package 35 | txBuffer[0] = vbat_hi; 36 | txBuffer[1] = vbat_lo; 37 | txBuffer[2] = temp_hi; 38 | txBuffer[3] = temp_lo; 39 | } 40 | -------------------------------------------------------------------------------- /Arduino MKR/MKRWAN1300_getEUI/MKRWAN1300_getEUI.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: MKRWAN1300_getEUI.ino 3 | * 4 | * based on https://github.com/gonzalocasas/arduino-mkr-wan-1300 5 | * Claus Kühnel 2020-04-04 info@ckuehnel.ch 6 | */ 7 | #include 8 | 9 | // Select your region (AS923, AU915, EU868, KR920, IN865, US915, US915_HYBRID) 10 | _lora_band region = EU868; 11 | 12 | LoRaModem modem(Serial1); 13 | 14 | void setup() 15 | { 16 | Serial.begin(115200); 17 | while (!Serial); 18 | Serial.println("\nGet the EUI of your Arduino MKR WAN 1300 Board"); 19 | if (!modem.begin(region)) 20 | { 21 | Serial.println("Failed to start module"); 22 | while (1) {} 23 | }; 24 | Serial.print("Your device EUI is: "); 25 | Serial.println(modem.deviceEUI()); 26 | Serial.println("Notify this EUI for integration into LoRaWAN server, like TTN"); 27 | } 28 | 29 | void loop() {} 30 | -------------------------------------------------------------------------------- /Arduino Nano/NanoEvery_Transmit_Serial/NanoEvery_Transmit_Serial.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: NanoEvery_Transmit_Serial.ino 3 | * 4 | * Get SHT31 measuring data to send serial. 5 | * On receiver side use Uno_Receive_Serial.ino to decode 6 | * and print SHT31 data 7 | * Claus Kühnel 2020-03-27 info@ckuehnel.ch 8 | */ 9 | #include 10 | #include 11 | #include 12 | #include "SHT31.h" 13 | 14 | #define DEBUG 1 15 | 16 | float temp, hum; 17 | 18 | SHT31 sht31 = SHT31(); 19 | SoftwareSerial SW_Serial(2, 3); // RX, TX 20 | 21 | // Function prototypes 22 | void sendMessage(); 23 | 24 | void setup() 25 | { 26 | Serial.begin(115200); 27 | while(!Serial); 28 | Serial.println("Read SHT31 measuring data..."); 29 | SW_Serial.begin(19200); 30 | sht31.begin(); 31 | } 32 | 33 | void loop() 34 | { 35 | float temp = sht31.getTemperature(); 36 | float hum = sht31.getHumidity(); 37 | 38 | sendMessage(temp, hum); 39 | delay(1000); 40 | } 41 | -------------------------------------------------------------------------------- /Arduino Nano/NanoEvery_Transmit_Serial/sendMessage.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Build message and send it serially 3 | */ 4 | #define STX 2 5 | #define ETX 3 6 | 7 | // 8 | void sendMessage(float temp, float hum) 9 | { 10 | uint32_t tmp = (uint32_t)(temp * 1000); 11 | uint8_t temp_lo = lowByte(tmp); 12 | uint8_t temp_hi = highByte(tmp); 13 | uint8_t _hum = (byte) hum; 14 | 15 | if (DEBUG) 16 | { 17 | // reconstruct float similar to receiver 18 | float temp = (float) (((temp_hi<<8) + temp_lo)/1000.0); 19 | 20 | Serial.print("Temp = "); Serial.print(temp,3); Serial.println(" *C"); 21 | Serial.print("Hum = "); Serial.print(_hum); Serial.println(" %RH"); 22 | Serial.println(); 23 | } 24 | SW_Serial.write(STX); 25 | SW_Serial.write(_hum); 26 | SW_Serial.write(temp_lo); 27 | SW_Serial.write(temp_hi); 28 | SW_Serial.write(ETX); 29 | } 30 | -------------------------------------------------------------------------------- /Arduino Nano/Nano_Transmit_CAN/Nano_Transmit_CAN.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Nano_Transmit_CAN.ino 3 | * 4 | * Get SHT31 measuring data to send via CAN bus. 5 | * On receiver side use Uno_Receive_CAN.ino to decode 6 | * and print SHT31 data 7 | * Used library: https://github.com/Longan-Labs/Serial_CAN_Arduino 8 | * Claus Kühnel 2020-03-27 info@ckuehnel.ch 9 | */ 10 | #include 11 | #include 12 | #include 13 | #include "SHT31.h" 14 | 15 | Serial_CAN can; 16 | 17 | #define can_tx 2 // tx of serial can module connect to D2 18 | #define can_rx 3 // rx of serial can module connect to D3 19 | 20 | #define DEBUG 1 21 | 22 | SHT31 sht31 = SHT31(); 23 | 24 | // Function prototypes 25 | void sendMessage(); 26 | 27 | void setup() 28 | { 29 | Serial.begin(115200); 30 | while(!Serial); 31 | Serial.println("\nRead SHT31 measuring data..."); 32 | Serial.println("----------------------------"); 33 | can.begin(can_tx, can_rx, 9600); // tx, rx 34 | sht31.begin(); 35 | } 36 | 37 | void loop() 38 | { 39 | float temp = sht31.getTemperature(); 40 | float hum = sht31.getHumidity(); 41 | 42 | sendMessage(temp, hum); 43 | delay(2500); 44 | } 45 | -------------------------------------------------------------------------------- /Arduino Nano/Nano_Transmit_CAN/sendMessage.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Build message and send it serially 3 | */ 4 | #define STX 2 5 | #define ETX 3 6 | 7 | unsigned char msg[8] = {0}; 8 | unsigned long id = 0x56; 9 | 10 | // 11 | void sendMessage(float temp, float hum) 12 | { 13 | 14 | uint32_t tmp = (uint32_t)(temp * 1000); 15 | uint8_t temp_lo = lowByte(tmp); 16 | uint8_t temp_hi = highByte(tmp); 17 | uint8_t _hum = (byte) hum; 18 | 19 | if (DEBUG) 20 | { 21 | // reconstruct float similar to receiver 22 | float temp = (float) (((temp_hi<<8) + temp_lo)/1000.0); 23 | 24 | Serial.print("Temp = "); Serial.print(temp,3); Serial.println(" *C"); 25 | Serial.print("Hum = "); Serial.print(_hum); Serial.println(" %RH"); 26 | Serial.println(); 27 | } 28 | 29 | unsigned long id = random(0x50, 0x60); 30 | Serial.print("Send message with ID: "); Serial.println(id, HEX); 31 | msg[0] = STX; 32 | msg[1] = _hum; 33 | msg[2] = temp_lo; 34 | msg[3] = temp_hi; 35 | msg[4] = ETX; 36 | can.send(id, 0, 0, sizeof(msg), msg); // SEND W/ ID:0X5 - 0x60 37 | Serial.println("----------------------------"); 38 | } 39 | -------------------------------------------------------------------------------- /Arduino Nano/Nano_Transmit_I2C/Nano_Transmit_I2C.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Nano_Transmit_I2C.ino 3 | * 4 | * Get SHT31 measuring data to send via I2C. 5 | * On receiver side use Uno_Receive_I2C.ino to decode 6 | * and print SHT31 data 7 | * Claus Kühnel 2020-03-27 info@ckuehnel.ch 8 | */ 9 | #include 10 | #include 11 | #include "SHT31.h" 12 | 13 | #define DEBUG 1 14 | 15 | SHT31 sht31 = SHT31(); 16 | 17 | // Function prototypes 18 | void sendMessage(); 19 | 20 | void setup() 21 | { 22 | Serial.begin(115200); 23 | while(!Serial); 24 | Serial.println("Read SHT31 measuring data..."); 25 | Wire.begin(); 26 | sht31.begin(); 27 | } 28 | 29 | void loop() 30 | { 31 | float temp = sht31.getTemperature(); 32 | float hum = sht31.getHumidity(); 33 | 34 | sendMessage(temp, hum); 35 | delay(1000); 36 | } 37 | -------------------------------------------------------------------------------- /Arduino Nano/Nano_Transmit_I2C/sendMessage.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Build message and send it serially 3 | */ 4 | #define STX 2 5 | #define ETX 3 6 | #define SlaveAddr 5 7 | 8 | // 9 | void sendMessage(float temp, float hum) 10 | { 11 | uint32_t tmp = (uint32_t)(temp * 1000); 12 | uint8_t temp_lo = lowByte(tmp); 13 | uint8_t temp_hi = highByte(tmp); 14 | uint8_t _hum = (byte) hum; 15 | 16 | if (DEBUG) 17 | { 18 | // reconstruct float similar to receiver 19 | float temp = (float) (((temp_hi<<8) + temp_lo)/1000.0); 20 | 21 | Serial.print("Temp = "); Serial.print(temp,3); Serial.println(" *C"); 22 | Serial.print("Hum = "); Serial.print(_hum); Serial.println(" %RH"); 23 | Serial.println(); 24 | } 25 | Wire.beginTransmission(SlaveAddr); 26 | Wire.write(STX); 27 | Wire.write(_hum); 28 | Wire.write(temp_lo); 29 | Wire.write(temp_hi); 30 | Wire.write(ETX); 31 | Wire.endTransmission(); 32 | } 33 | -------------------------------------------------------------------------------- /Arduino Nano/Nano_Transmit_SPI/Nano_Transmit_SPI.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Nano_Transmit_SPI.ino 3 | * 4 | * Get SHT31 measuring data to send via SPI. 5 | * On receiver side use Uno_Receive_SPI.ino to decode 6 | * and print SHT31 data 7 | * Claus Kühnel 2020-03-27 info@ckuehnel.ch 8 | */ 9 | #include 10 | #include 11 | #include 12 | #include "SHT31.h" 13 | 14 | #define DEBUG 1 15 | 16 | SHT31 sht31 = SHT31(); 17 | 18 | // Function prototypes 19 | void sendMessage(); 20 | 21 | void setup() 22 | { 23 | Serial.begin(115200); 24 | while(!Serial); 25 | Serial.println("Read SHT31 measuring data..."); 26 | sht31.begin(); 27 | digitalWrite(SS,HIGH); 28 | SPI.begin(); 29 | SPI.setClockDivider(SPI_CLOCK_DIV8); 30 | } 31 | 32 | void loop() 33 | { 34 | float temp = sht31.getTemperature(); 35 | float hum = sht31.getHumidity(); 36 | 37 | sendMessage(temp, hum); 38 | delay(1000); 39 | } 40 | -------------------------------------------------------------------------------- /Arduino Nano/Nano_Transmit_SPI/sendMessage.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Build message and send it serially 3 | */ 4 | #define STX 2 5 | #define ETX 3 6 | 7 | // 8 | void sendMessage(float temp, float hum) 9 | { 10 | uint32_t tmp = (uint32_t)(temp * 1000); 11 | uint8_t temp_lo = lowByte(tmp); 12 | uint8_t temp_hi = highByte(tmp); 13 | uint8_t _hum = (byte) hum; 14 | 15 | if (DEBUG) 16 | { 17 | // reconstruct float similar to receiver 18 | float temp = (float) (((temp_hi<<8) + temp_lo)/1000.0); 19 | 20 | Serial.print("Temp = "); Serial.print(temp,3); Serial.println(" *C"); 21 | Serial.print("Hum = "); Serial.print(_hum); Serial.println(" %RH"); 22 | Serial.println(); 23 | } 24 | digitalWrite(SS, LOW); 25 | SPI.transfer(STX); 26 | SPI.transfer(_hum); 27 | SPI.transfer(temp_lo); 28 | SPI.transfer(temp_hi); 29 | SPI.transfer(ETX); 30 | digitalWrite(SS, HIGH); 31 | } 32 | -------------------------------------------------------------------------------- /Arduino Nano/README.md: -------------------------------------------------------------------------------- 1 | ## Arduino Nano & Nano Every 2 | 3 | Dieses Verzeichnis enthält auf dem Arduino Nano resp. Nano Every getestete Programme. 4 | -------------------------------------------------------------------------------- /Arduino Uno/ArduinoUnoTest/ArduinoUnoTest.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Arduino Uno Test 3 | (c) Claus Kuehnel 2019-10-12 info@ckuehnel.ch 4 | */ 5 | 6 | byte count = 0; 7 | 8 | void setup() 9 | { 10 | pinMode(LED_BUILTIN, OUTPUT); 11 | Serial.begin(115200); 12 | delay(1000); // waiting to start the monitor 13 | Serial.print("Hi there, here is Arduino Uno"); 14 | } 15 | 16 | void loop() 17 | { 18 | Serial.print("."); 19 | count++; 20 | if (count == 25) 21 | { 22 | Serial.println(); 23 | count=0; 24 | } 25 | digitalWrite(LED_BUILTIN, HIGH); 26 | delay(500); 27 | digitalWrite(LED_BUILTIN, LOW); 28 | delay(500); 29 | } 30 | -------------------------------------------------------------------------------- /Arduino Uno/ArduinoUnoTest/README.md: -------------------------------------------------------------------------------- 1 | **ArduinoUnoTest.ino** ist ein modifiziertes Blink-Programm. 2 | 3 | Es kann beispielsweise im Arduino Simulator *UnoArduSim* für einen ersten Test eingesetzt werden. 4 | Die erforderlichen Konfigurationsdaten für den Simulator sind in den Dateien *myIODevs.txt* und *myArduPrefs.txt* zu finden. 5 | 6 | Der Arduino Simulator *UnoArduSim* kann von der URL https://www.sites.google.com/site/unoardusim/services heruntergeladen werden. 7 | 8 | Die Bilder *UnoArduSim.png* und *UnoArduSim_lo.png* sind Screenshots der Simulationsumgebung und zeigen (nach dem Start der Simulation) die blinkende LED und die serielle Ausgabe. 9 | -------------------------------------------------------------------------------- /Arduino Uno/ArduinoUnoTest/UnoArduSim.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/ArduinoUnoTest/UnoArduSim.png -------------------------------------------------------------------------------- /Arduino Uno/ArduinoUnoTest/UnoArduSim_lo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/ArduinoUnoTest/UnoArduSim_lo.png -------------------------------------------------------------------------------- /Arduino Uno/ArduinoUnoTest/myArduPrefs.txt: -------------------------------------------------------------------------------- 1 | de 2 | Auto-indent-Format 1 3 | Autoeinsatz Schließ-} 0 4 | Autoeinsatz Semikolons 0 5 | erlauben Experten Syntax 1 6 | erzwingen array Schranken 1 7 | Stichwort logische Operatoren 0 8 | zeigen programm herunterladen 1 9 | font schriftart Nummer 2 10 | font schrifttypgröße Nummer 2 11 | Tabgröße Multiplikator 2 12 | 'Uno' leiterplatte Version 3 13 | TWI Pufferlänge 32 14 | IODevs datei Name myIODevs.txt 15 | -------------------------------------------------------------------------------- /Arduino Uno/ArduinoUnoTest/myIODevs.txt: -------------------------------------------------------------------------------- 1 | Farbige LED 1 verdrahtet pin 13 mit Werte D, Y 2 | USB Serial 1 verdrahtet pins 1, 0 mit Wert 115200 3 | -------------------------------------------------------------------------------- /Arduino Uno/ExternalInterrupts/ExternalInterrupts.ino: -------------------------------------------------------------------------------- 1 | // Test of External Interrupt for Arduino Uno 2 | // 2020-01-26 Claus Kühnel info@ckuehnel.ch 3 | 4 | const int pINT0 = 2; // INT0 at Pin2 5 | const int pINT1 = 3; // INT1 at Pin3 6 | 7 | volatile boolean iflag = true; 8 | 9 | int idx; 10 | 11 | void setup() 12 | { 13 | Serial.begin(115200); 14 | 15 | pinMode(LED_BUILTIN, OUTPUT); 16 | pinMode(pINT0, INPUT_PULLUP); 17 | pinMode(pINT1, INPUT_PULLUP); 18 | 19 | attachInterrupt(digitalPinToInterrupt(pINT0), stop_serial, FALLING); // INT0 stops serial output 20 | Serial.print("EICRA: "); Serial.println(EICRA, HEX); 21 | attachInterrupt(digitalPinToInterrupt(pINT1), resume_serial, FALLING); // INT1 resumes serial output 22 | Serial.print("EICRA: "); Serial.println(EICRA, HEX); 23 | Serial.println("Setup finished."); 24 | } 25 | 26 | void loop() 27 | { 28 | if (iflag) Serial.println(idx); // iflag controls serial output 29 | idx++; 30 | delay(500); 31 | } 32 | 33 | void stop_serial() 34 | { 35 | iflag = false; 36 | digitalWrite(LED_BUILTIN, HIGH); 37 | } 38 | 39 | void resume_serial() 40 | { 41 | iflag = true; 42 | digitalWrite(LED_BUILTIN, LOW); 43 | } 44 | -------------------------------------------------------------------------------- /Arduino Uno/HC_SR04_Proximity/HC_SR04_Proximity.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: HC_SR04_Proximity.ino 3 | * http://wolles-elektronikkiste.de/hc-sr04-und-jsn-sr04t-2-0-abstandssensoren 4 | * 5 | */ 6 | 7 | int triggerPin = 8; 8 | int echoPin = 9; 9 | 10 | int cmDistance, tCorrectedCmDistance; 11 | //int temperature = 0; 12 | unsigned long duration; 13 | 14 | void setup() 15 | { 16 | pinMode(triggerPin, OUTPUT); 17 | pinMode(echoPin, INPUT); 18 | Serial.begin(115200); 19 | delay(10); 20 | } 21 | 22 | void loop() 23 | { 24 | digitalWrite(triggerPin, HIGH); 25 | delayMicroseconds(20); 26 | digitalWrite(triggerPin, LOW); 27 | duration = pulseIn(echoPin, HIGH); 28 | 29 | // Schallgeschwindigkeit in Luft: 343m/S (bei 20°C) 30 | // 343,2 m/S --> 34,32cm / ms --> 0,03432cm / µs 31 | // durch 2 wg. Echo 32 | cmDistance = duration * 0.03432 / 2; 33 | // tCorrectedCmDistance = duration *(0.03315 + 0.00006 * temperature)/2; 34 | Serial.print("Distanz [cm]: "); 35 | Serial.println(cmDistance); 36 | // Serial.print("T-korrigierte Distanz [cm]: "); 37 | // Serial.println(tCorrectedCmDistance); 38 | delay(500); 39 | } 40 | -------------------------------------------------------------------------------- /Arduino Uno/README.md: -------------------------------------------------------------------------------- 1 | ## Arduino Uno 2 | 3 | Dieses Verzeichnis enthält Programme, die auf einem Arduino Uno getestet wurden. 4 | -------------------------------------------------------------------------------- /Arduino Uno/SerialOutBT/SerialOutBT.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SerialOutBT.ino 3 | Serial output via Bluetooth for ATmega328 based Arduinos 4 | (c) Claus Kuehnel 2018-12-16 info@ckuehnel.ch 5 | 6 | Connect 7 | Arduino® HC-05 8 | ---------------- 9 | 5 V VCC 10 | GND GND 11 | D10 Rx 12 | D12 Tx 13 | */ 14 | 15 | #include 16 | 17 | const byte rxPin = 12; 18 | const byte txPin = 10; 19 | 20 | // set up a new serial object 21 | SoftwareSerial BTSerial (rxPin, txPin); 22 | 23 | // define your board here 24 | #define BOARD "Arduino Leonardo" 25 | //#define BOARD "Arduino M0" 26 | 27 | //#define Serial SerialUSB // Arduino M0 native port 28 | 29 | void setup() 30 | { 31 | Serial.begin(115200); 32 | while(!Serial); // for native port 33 | // delay(2000); 34 | Serial.print(BOARD); 35 | Serial.println(" starts BT communication..."); 36 | 37 | BTSerial.begin(9600); 38 | BTSerial.print("This is "); 39 | BTSerial.println(BOARD); 40 | } 41 | 42 | void loop() 43 | { 44 | Serial.print("*"); 45 | BTSerial.print("*"); 46 | delay(1000); 47 | } 48 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_1WireModul/Uno_1WireModul.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: DS2438.ino 3 | * 4 | * Measuring Temperature and voltage @ VAD. 5 | * The voltage @ VAD represents the relavie humidity measured by HIH-4031. 6 | * Based on: https://github.com/TaaraLabs/OneWireHumidityLight-Demo by Märt Maiste, TaaraLabs 2017 7 | */ 8 | #include 9 | #include 10 | 11 | // Data wire is plugged into port 2 on the Arduino 12 | #define ONE_WIRE_BUS 2 13 | 14 | OneWire ds(ONE_WIRE_BUS); // 1-Wire data line @ I/O-Pin 2 15 | 16 | // Pass our oneWire reference to Dallas Temperature. 17 | DallasTemperature sensors(&ds); 18 | 19 | int DS18Count = 0; 20 | 21 | #define DEBUG 0 22 | 23 | void setup(void) 24 | { 25 | Serial.begin(115200); 26 | while(!Serial); 27 | Serial.println("\Read data from DS18B20 and 1-Wire Module w/ DS18B20 und DS2438 & HIH-4031..."); 28 | initDS18B20(); 29 | } 30 | 31 | void loop(void) 32 | { 33 | Serial.print ("----------------------------------"); 34 | Serial.println("----------------------------------"); 35 | readDS18B20(); 36 | readDS2438(); 37 | delay(1000); 38 | } 39 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_1WireModul/readDS18B20.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: readDS18B20.ino 3 | * 4 | * Read all DS18B20 Temperatur Sensors connected to the 1-Wire bus 5 | * 6 | */ 7 | void initDS18B20() 8 | { 9 | sensors.begin(); 10 | Serial.print("1-Wire Device Count: "); Serial.println(sensors.getDeviceCount()); 11 | DS18Count = sensors.getDS18Count(); 12 | Serial.print("DS18B20 on 1-Wire bus: "); Serial.println(DS18Count); 13 | if (DS18Count == 0) 14 | { 15 | Serial.println("No DS18B20 connected!"); 16 | while(true); 17 | } 18 | Serial.print("Global Resolution: "); Serial.println(sensors.getResolution()); 19 | } 20 | 21 | void readDS18B20() 22 | { 23 | if (DEBUG) Serial.print("Requesting temperatures..."); 24 | sensors.requestTemperatures(); // Send the command to get temperatures 25 | if (DEBUG) Serial.println("Done"); 26 | for (int i = 0; i < DS18Count; i++) 27 | { 28 | Serial.print("DS18B20["); Serial.print(i); Serial.print("]: "); 29 | // Serial.print("Temperature for the device 1 (index 0) is: "); 30 | Serial.print(sensors.getTempCByIndex(i)); Serial.println(" *C"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_AirQuality/README.md: -------------------------------------------------------------------------------- 1 | ## Measuring Air Quality with mikroe Click Boards 2 | 3 | Mikroe offers a wealth of sensors, actuators, displays and more in click board format. 4 | These click boards can be used on the Arduino using the Arduino Uno Click shield. 5 | In this program example, the air quality is measured and shown on a bar graph display. 6 | The following components are used 7 | - Air quality click (PID: MIKROE-1630) 8 | - BarGraph Click (PID: MIKROE-1423) on 9 | - Arduino UNO click shield (PID: MIKROE-1581) 10 | 11 | 12 | > Written with [StackEdit](https://stackedit.io/). 13 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_AirQuality/dispBargraph.ino: -------------------------------------------------------------------------------- 1 | void dispBargraph(byte i) 2 | { 3 | LSB = lowByte(bar[i]); 4 | MSB = highByte(bar[i]); 5 | digitalWrite(LATCH, LOW); // blocage du registre de sortie des 74HC595 6 | shiftOut(SDIN, SCLK, MSBFIRST, MSB); // envoi des 8 bits de poids forts sur le second 74HC595 7 | shiftOut(SDIN, SCLK, MSBFIRST, LSB); // envoi des 8 bits de poids faibles sur le premier 74HC595 8 | digitalWrite(LATCH, HIGH); // déblocage du registre de sortie des 74HC595 9 | } 10 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_BLDC/Uno_BLDC.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_BLDC.ino 3 | * 4 | * Controlling BLDC motor by SZ-X11F-1 BLDC controller w/ PWM 5 | * Disconnect jumper on board and close soldering bridge. 6 | * Claus Kühnel 2020-05-01 info@ckuehnel.ch 7 | */ 8 | 9 | const int pwm_ctrl = 6; 10 | const int dir_ctrl = 7; 11 | int val = 0; 12 | 13 | void setup() 14 | { 15 | Serial.begin(9600); 16 | delay(1000); 17 | Serial.println("BLDC Motor Control"); 18 | Serial.setTimeout(10000); 19 | pinMode(pwm_ctrl, OUTPUT); 20 | pinMode(dir_ctrl, OUTPUT); 21 | digitalWrite(dir_ctrl, HIGH); 22 | } 23 | 24 | void loop() 25 | { 26 | Serial.println("Input PWM value (0 - 255, negative inverts direction):"); 27 | val = Serial.parseInt(); 28 | if (val > 255) val = 255; 29 | if (val < 0) 30 | { 31 | val = abs(val); 32 | digitalWrite(dir_ctrl, !digitalRead(dir_ctrl)); 33 | Serial.println("Change direction now."); 34 | } 35 | Serial.print("PWM = "); 36 | Serial.println(val); 37 | analogWrite(pwm_ctrl, val); 38 | } 39 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_DHT11/Uno_DHT11.ino: -------------------------------------------------------------------------------- 1 | /* 2 | File: Uno_DHT11.ino - Testprogram for DHTxx, AM23xx 3 | */ 4 | 5 | #include "DHT.h" 6 | 7 | // Uncomment whatever type you're using! 8 | //#define DHTTYPE DHT11 // DHT 11 9 | #define DHTTYPE DHT22 // DHT 22, AM2302, AM2321 10 | //#define DHTTYPE DHT21 // DHT 21, AM2301 11 | 12 | // DHTxx connection, do not forget PullUp between VCC and signal 13 | #define DHTPIN 10 14 | 15 | DHT dht(DHTPIN, DHTTYPE); 16 | 17 | void setup() 18 | { 19 | Serial.begin(115200); 20 | Serial.println("Testing DHTxx/AM23xx..."); 21 | dht.begin(); 22 | } 23 | 24 | void loop() 25 | { 26 | // Wait a few seconds between measurements. 27 | delay(2000); 28 | 29 | float h = dht.readHumidity(); 30 | float t = dht.readTemperature(); // in C 31 | float f = dht.readTemperature(true); // in F 32 | 33 | // Check if any reads failed and exit early (to try again). 34 | if (isnan(h) || isnan(t) || isnan(f)) 35 | { 36 | Serial.println("Failed to read from DHT sensor!"); 37 | return; 38 | } 39 | 40 | Serial.print("Humidity: "); Serial.print((int) h); Serial.print(" %\t"); 41 | Serial.print("Temperature: "); Serial.print(t,1); Serial.print(" *C; "); 42 | // Serial.print(f); Serial.print(" *F"); 43 | Serial.println(); 44 | } 45 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_DOGS102_Icon/logo_BMP.h: -------------------------------------------------------------------------------- 1 | /* File 'D:\ELECTRONIC ASSEMBLY LCD-Tools Portable\Data\logo.BMP' as include 2 | 3 | the array starts with a 2 byte header: 4 | 1th Byte: Width of image in dots 5 | 2th Byte: Height of image in dots 6 | After that image data will follow */ 7 | 8 | #define Image_logo_BMP_LEN 110 9 | 10 | const unsigned char Image_logo_BMP[Image_logo_BMP_LEN] __attribute__((section(".progmem.data")))= 11 | { 12 | 27, 27, 13 | 0, 0,252,252, 12, 12,204,204,204,204,204,204,204,204,204,204, 14 | 204,204,204,204,204,204,204,204,204, 0, 0, 0, 0,255,255, 0, 15 | 0,255,255, 0, 0,252,252, 12, 12,204,204,204,204,204,204,204, 16 | 204,204,204,204, 0, 0, 0, 0,255,255, 0, 0,255,255, 0, 0, 17 | 255,255, 0, 0,255,255, 0, 0,156,156,156,128,128,252,252, 0, 18 | 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 19 | 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 20 | }; 21 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_DS18B20/Uno_DS18B20.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_DS18B20.ino - DS18B20 Test 3 | * 4 | * based on https://www.hackster.io/TheGadgetBoy/ds18b20-digital-temperature-sensor-and-arduino-9cc806 5 | * 6 | * Hardware Connections: 7 | * DS18B20 ---------------- Arduino 8 | * black ---------------- GND 9 | * red ---------------- 3.3V (VCC) 10 | * yellow ---------------- 10 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | // Data wire is plugged into pin 10 on the Arduino 17 | #define ONE_WIRE_BUS 10 18 | 19 | // Setup a oneWire instance to communicate with any OneWire devices 20 | // (not just Maxim/Dallas temperature ICs) 21 | OneWire oneWire(ONE_WIRE_BUS); 22 | 23 | // Pass our oneWire reference to Dallas Temperature. 24 | DallasTemperature sensors(&oneWire); 25 | 26 | void setup(void) 27 | { 28 | // start serial port 29 | Serial.begin(115200); 30 | delay(2000); // wait for serial monitor 31 | Serial.println("Dallas Temperature IC Control Library Demo"); 32 | 33 | // Start up the library 34 | sensors.begin(); 35 | } 36 | 37 | void loop(void) 38 | { 39 | // call sensors.requestTemperatures() to issue a global temperature 40 | // request to all devices on the bus 41 | Serial.print(" Requesting temperatures..."); 42 | sensors.requestTemperatures(); // Send the command to get temperatures 43 | Serial.print(" Done\t"); 44 | Serial.print("Temperature: "); 45 | Serial.print(sensors.getTempCByIndex(0), 1); // Why "byIndex"? 46 | // You can have more than one IC on the same bus. 47 | // 0 refers to the first IC on the wire 48 | Serial.println(" *C"); 49 | delay(1000); 50 | } 51 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_DotStar/Uno_DotStar.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define NUMPIXELS 3 // Number of LEDs in strip 5 | #define DELAYVAL 100 // Time (in milliseconds) to pause between pixels 6 | 7 | //Adafruit_DotStar strip(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG); 8 | // The last parameter is optional -- this is the color data order of the 9 | // DotStar strip, which has changed over time in different production runs. 10 | // Your code just uses R,G,B colors, the library then reassigns as needed. 11 | // Default is DOTSTAR_BRG, so change this if you have an earlier strip. 12 | 13 | // Hardware SPI is a little faster, but must be wired to specific pins 14 | // (Arduino Uno = pin 11 for data, 13 for clock, other boards are different). 15 | Adafruit_DotStar strip(NUMPIXELS, DOTSTAR_BGR); 16 | 17 | void setup() 18 | { 19 | strip.begin(); // Initialize pins for output 20 | strip.show(); // Turn all LEDs off ASAP 21 | } 22 | 23 | void loop() 24 | { 25 | strip.clear(); // Set all pixel colors to 'off' 26 | strip.show(); // Send the updated pixel colors to the hardware. 27 | delay(DELAYVAL); // Pause before next pass through loop 28 | 29 | for(int i=0; i 10 | 11 | int ival = 123; 12 | float fval = 123.456; 13 | char str[] = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 14 | 15 | void setup() 16 | { 17 | Serial.begin(115200); 18 | delay(1000); // wait for Serial Monitor 19 | Serial.println("\nTest internal EEPROM"); 20 | 21 | int sz = EEPROM.length(); 22 | Serial.print("Size of internal EEPROM = "); 23 | Serial.print(sz); Serial.println(" Byte"); 24 | 25 | Serial.println("\nWrite data to internal EEPROM..."); 26 | int addr = 0x100; 27 | EEPROM.put(addr, ival); // write int 28 | addr += sizeof(int); // incr. addr w/ size of int 29 | EEPROM.put(addr, fval); // write float 30 | addr += sizeof(float); // incr. addr w/ size of float 31 | EEPROM.put(addr, str); // write string 32 | 33 | Serial.println("\nHexdump EEPROM..."); 34 | for (addr = 0x100; addr < 0x100 + sizeof(int) + sizeof(float) + sizeof(str); addr++) 35 | { 36 | byte val = EEPROM[addr]; 37 | if (val < 0x10) Serial.print("0"); 38 | Serial.print(val,HEX); 39 | Serial.print(" "); 40 | } 41 | Serial.println(); 42 | 43 | Serial.println("\nRead data back from internal EEPROM..."); 44 | addr = 0x100; // restore addr 45 | ival = 0; EEPROM.get(addr, ival); // read int back 46 | Serial.print(ival); Serial.print(" "); 47 | addr += sizeof(int); // incr. addr w/ size of int 48 | fval = 0.0; EEPROM.get(addr, fval); // read float back 49 | Serial.print(fval, 3); Serial.print(" "); 50 | addr += sizeof(float); // incr. addr w/ size of float 51 | strcpy(str, ""); EEPROM.get(addr, str); // read string back 52 | Serial.println(str); 53 | } 54 | 55 | void loop() {} 56 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_EasyDriver/Uno_EasyDriver.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_EasyDriver.ino 3 | * 4 | * Testing a stepper motor with an Easy Driver board on Arduino Uno 5 | * 6 | * Claus Kühnel 2020-03-24 info@ckuehnel.ch 7 | * 8 | */ 9 | #include 10 | 11 | // Define a stepper and the pins it will use 12 | AccelStepper stepper(AccelStepper::DRIVER, 2, 5); // stepPin, directionPin 13 | 14 | int pos = 1600; // 200 steps @ 8 microsteps 15 | 16 | void setup() 17 | { 18 | stepper.setEnablePin(8); 19 | stepper.setMaxSpeed(625); // in steps/s (here 1600 steps/3 s) 20 | stepper.setAcceleration(1000); // in steps/s^2 21 | 22 | } 23 | 24 | void loop() 25 | { 26 | if (stepper.distanceToGo() == 0) // true if target position is achieved 27 | { 28 | pos = -pos; 29 | stepper.move(pos); // set the target position relative to the current position 30 | } 31 | stepper.run(); // runs the motor 32 | } 33 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_FastLED/Uno_FastLED.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define NUM_LEDS 3 4 | 5 | #define DATA_PIN 11 6 | #define CLOCK_PIN 13 7 | 8 | #define DELAYVAL 250 // Time (in milliseconds) to pause between pixels 9 | #define BRIGHTNESS 40 // Brightness of NeoPixel 10 | 11 | // Define the array of leds 12 | CRGB leds[NUM_LEDS]; 13 | 14 | void setup() 15 | { 16 | // Uncomment/edit one of the following lines for your leds arrangement. 17 | // ## Clockless types ## 18 | // FastLED.addLeds(leds, NUM_LEDS); // GRB ordering is assumed 19 | // ## Clocked (SPI) types ## 20 | FastLED.addLeds(leds, NUM_LEDS); // BGR ordering is typical 21 | 22 | FastLED.setBrightness(BRIGHTNESS); 23 | FastLED.show(); // Initialize all strip to 'off' 24 | } 25 | 26 | void loop() 27 | { 28 | FastLED.clear(); // Set all pixel colors to 'off' 29 | FastLED.show(); // Send the updated pixel colors to the hardware. 30 | FastLED.delay(DELAYVAL); // Pause before next pass through loop 31 | 32 | for(int i=0; i 19 | 20 | //Create Instance of Si7021 temp and humidity sensor 21 | Weather sensor; 22 | 23 | void setup() 24 | { 25 | Serial.begin(115200); // open serial over USB at 115200 baud 26 | delay(2000); 27 | Serial.println("Read Si7021 sensor..."); 28 | sensor.begin(); //Initialize the I2C sensors and ping them 29 | Serial.println(); 30 | } 31 | 32 | void loop() 33 | { 34 | delay(2000); 35 | getWeather(); 36 | } 37 | 38 | void getWeather() 39 | { 40 | // Measure Relative Humidity from the HTU21D or Si7021 41 | float humi = sensor.getRH(); 42 | 43 | // Measure Temperature from the HTU21D or Si7021 44 | float temp = sensor.getTemp(); 45 | // Temperature is measured every time RH is requested. 46 | // It is faster, therefore, to read it from previous RH 47 | // measurement with getTemp() instead with readTemp() 48 | Serial.print("Humidity: "); Serial.print((int) humi); Serial.print(" %\t"); 49 | Serial.print("Temperature: "); Serial.print(temp, 1); Serial.println(" °C "); 50 | } 51 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Grove_LCD/Uno_Grove_LCD.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Grove_LCD.ino 3 | * 4 | * This program controls the Grove_LCD via I2C-bus 5 | * 6 | * Works with 7 | * Grove - 16x2 LCD (White on Blue) 8 | * Grove - 16x2 LCD (Black on Red) 9 | * Grove - 16x2 LCD (Black on Yellow) 10 | * Grove - LCD RGB Backlight (set color of background) 11 | */ 12 | 13 | #include 14 | #include "rgb_lcd.h" 15 | 16 | rgb_lcd lcd; 17 | 18 | const int colorR = 255; 19 | const int colorG = 0; 20 | const int colorB = 0; 21 | 22 | void setup() 23 | { 24 | // set up the LCD's number of columns and rows: 25 | lcd.begin(16, 2); 26 | // Set up background 27 | lcd.setRGB(colorR, colorG, colorB); 28 | // Print a message to the LCD. 29 | lcd.print("Grove - 16x2 LCD"); 30 | lcd.blinkLED(); 31 | delay(1000); 32 | } 33 | 34 | void loop() 35 | { 36 | // set the cursor to column 0, line 1 37 | lcd.setCursor(0, 1); 38 | String str = "Running "; 39 | str += (millis()/1000); 40 | str += " s"; 41 | lcd.print(str); 42 | delay(250); 43 | } 44 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_HC-SR501/Uno_HC-SR501.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_HC-SR501.ino 3 | * Set delay to minimum (3 s) and sensitivity to middle position. 4 | * Claus Kuehnel 2020-02-11 info@ckuehnel.ch 5 | */ 6 | 7 | const int pPIR = 8; // Input for HC-S501 8 | 9 | int pirValue; // Place to store read PIR Value 10 | int lastValue = 0; 11 | 12 | 13 | void setup() 14 | { 15 | Serial.begin(115200); 16 | delay(2500); 17 | Serial.println("Motion Sensor working..."); 18 | 19 | pinMode(LED_BUILTIN, OUTPUT); 20 | digitalWrite(LED_BUILTIN, LOW); 21 | pinMode(pPIR, INPUT); 22 | } 23 | 24 | void loop() 25 | { 26 | pirValue = digitalRead(pPIR); 27 | digitalWrite(LED_BUILTIN, pirValue); 28 | if (!pirValue) lastValue = 0; 29 | if (pirValue && !lastValue) 30 | { 31 | Serial.print(millis()); 32 | Serial.println(" ms - Motion detected"); 33 | lastValue = pirValue; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Joystick_Test/Uno_Joystick_Test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Jostick_Test.ino 3 | * 4 | * Test of Analog joystick @ Arduino Uno 5 | * Claus Kühnel 2020-02-17 info@ckuehnel.ch 6 | * 7 | * Connections: 8 | * Joystick Arduino Uno 9 | * GND -- GND 10 | * VCC -- 5 V 11 | * VRx -- A0 12 | * VRy -- A1 13 | * S -- A2 14 | */ 15 | #define CONVERT 0 16 | 17 | int x,y,s; // Joystick coordinates 18 | 19 | void readJoystick(int &x, int &y, int &s) 20 | { 21 | x = analogRead(0); 22 | y = analogRead(1); 23 | s = analogRead(2); 24 | } 25 | 26 | void setup() 27 | { 28 | Serial.begin(115200); 29 | delay(2000); // wait for Serial Monitor 30 | } 31 | 32 | void loop() 33 | { 34 | readJoystick(x, y, s); 35 | if (CONVERT) 36 | { 37 | x = map(x, 0, 677, 0, 1023); 38 | y = map(y, 0, 677, 0, 1023); 39 | if (s > 10) s = 1; else s = 0; 40 | } 41 | Serial.print("(x, y, s) = "); 42 | Serial.print(x); 43 | Serial.print("\t"); 44 | Serial.print(y); 45 | Serial.print("\t"); 46 | Serial.println(s); 47 | delay(500); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Keys/Uno_Keys.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Keys.ino 3 | * 4 | * Connections: 5 | * S1 -- IO2 6 | * S2 -- IO3 7 | */ 8 | const int S1 = 2, S2 = 3; 9 | 10 | void setup() 11 | { 12 | Serial.begin(115200); 13 | delay(2000); // wait for Serial Monitor 14 | 15 | pinMode(S1, INPUT_PULLUP); 16 | pinMode(S2, INPUT_PULLUP); 17 | } 18 | 19 | void loop() 20 | { 21 | if (digitalRead(S1)) Serial.print("S1 open "); 22 | else Serial.print("S1 closed "); 23 | if (digitalRead(S2)) Serial.println("- S2 open"); 24 | else Serial.println("- S2 closed"); 25 | delay(500); 26 | } 27 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_L293/Uno_L293.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_L293.ino 3 | * 4 | * Bidirectional Motor Control with L293 H-Bridge using 5 | * L293 library created by Giuseppe Masino, 25 may 2016 6 | * 7 | * Based on MotorControl_Demo.ino 8 | * Adaptions by Claus Kühnel 2020-03-18 info@ckuehnel.ch 9 | */ 10 | #include 11 | 12 | const int pin12EN = 11; // must be a PWM pin for speed control 13 | const int pin1A = 4; // pins for controlling motor state 14 | const int pin2A = 5; 15 | 16 | L293 motor(pin12EN, pin1A, pin2A); // create motor object 17 | 18 | void setup() {} 19 | 20 | void loop() 21 | { 22 | motor.forward(255); // set the direction and maximun speed 23 | delay(1000); // wait for 1 second 24 | motor.stop(); // stop the motor 25 | delay(1000); // wait for 1 second 26 | motor.back(180); // set a new direction and a lower speed 27 | delay(1000); // wait for 1 second 28 | motor.stop(); // stop the motor 29 | delay(1000); // wait for 1 second 30 | } 31 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_L293_MotorShield/Uno_L293_MotorShield.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_L293_MotorShield.ino 3 | * 4 | * Bidirectional Motor Control with L293 H-Bridge using 5 | * Adafruit Motor Shield Library. ased on MotorTest.ino 6 | * Adaptions by Claus Kühnel 2020-03-18 info@ckuehnel.ch 7 | */ 8 | #include 9 | 10 | AF_DCMotor motor(1); // DC motor on M1 11 | 12 | void setup() {} 13 | 14 | void loop() 15 | { 16 | motor.run(FORWARD); // forward 17 | motor.setSpeed(255); // maximum speed 18 | delay(1000); 19 | 20 | motor.run(RELEASE); // Stop 21 | delay(1000); 22 | 23 | motor.run(BACKWARD); // backward 24 | motor.setSpeed(180); // reduced speed 25 | delay(1000); 26 | 27 | motor.run(RELEASE); // stop 28 | delay(1000); 29 | } 30 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_LEDMatrix_Marquee/Uno_LEDMatrix.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_LEDMatrix_Marquee/Uno_LEDMatrix.mp4 -------------------------------------------------------------------------------- /Arduino Uno/Uno_MQ135/Uno_MQ135.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File Uno_MQ135.ino 3 | * Get air quality signal from MQ135 sensor 4 | * (c) Claus Kuehnel 2018-11-27 info@ckuehnel.ch 5 | * 6 | * based on 7 | * http://davidegironi.blogspot.com/2017/05/mq-gas-sensor-correlation-function.html 8 | */ 9 | 10 | int mqInput = A0; //sensor input PIN 11 | int mqR = 22000; //pull-down resistor value 12 | long rO = 41763; //rO sensor value 13 | float minRsRo = 0.358; //min value for Rs/Ro 14 | float maxRsRo = 2.428; //max value for Rs/Ro 15 | float a = 116.6020682; //sensor a coefficient value 16 | float b = -2.769034857; //sensor b coefficient value 17 | 18 | void setup() 19 | { 20 | pinMode(mqInput, INPUT); 21 | pinMode(LED_BUILTIN, OUTPUT); // On-board LED 22 | Serial.begin(115200); 23 | } 24 | 25 | void loop() 26 | { 27 | int adcRaw = analogRead(mqInput); 28 | 29 | if (adcRaw >= 100) digitalWrite(LED_BUILTIN, HIGH); 30 | else digitalWrite(LED_BUILTIN, LOW); 31 | 32 | Serial.print("ADC: "); Serial.println(adcRaw); 33 | long rS = ((1024.0 * mqR) / adcRaw) - mqR; 34 | Serial.print("Rs: "); Serial.println(rS); 35 | float rSrO = (float)rS / (float)rO; 36 | Serial.print("Rs/Ro: "); Serial.println(rSrO); 37 | if(rSrO < maxRsRo && rSrO > minRsRo) 38 | { 39 | float ppm = a * pow((float)rS / (float)rO, b); 40 | Serial.print("ppm: "); Serial.println(ppm); 41 | digitalWrite(LED_BUILTIN, HIGH); 42 | } 43 | if(rSrO < minRsRo) Serial.println("PPM CO2 too high"); 44 | if(rSrO > maxRsRo) Serial.println("PPM CO2 quite low"); 45 | Serial.println(); 46 | 47 | delay(2000); 48 | } 49 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_MotorShield_R3/Uno_MotorShield_R3.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_MotorShield_R3.ino 3 | * 4 | * Bidirectional Motor Control with Arduino Motor Shield R3 using 5 | * ArduinoMotorShieldR3 Library. 6 | * Include the library https://github.com/gallingern/arduino-motor-shield-r3 7 | * Claus Kühnel 2020-03-18 info@ckuehnel.ch 8 | */ 9 | #include "ArduinoMotorShieldR3.h" 10 | 11 | ArduinoMotorShieldR3 md; 12 | 13 | void setup() 14 | { 15 | md.init(); // initialize IO 16 | } 17 | 18 | void loop() 19 | { 20 | md.setM1Speed(400); // M1 forward speed 100% 21 | delay(1000); 22 | 23 | md.setM1Speed(0); // stop 24 | md.setM1Brake(); 25 | delay(1000); 26 | 27 | md.setM1Speed(-400); // M1 backward speed 100% 28 | delay(1000); 29 | 30 | md.setM1Speed(0); // stop 31 | md.setM1Brake(); 32 | delay(1000); 33 | } 34 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_NextionHMI/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_NextionHMI/WS-0C.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_NextionHMI/WS-0C.png -------------------------------------------------------------------------------- /Arduino Uno/Uno_NextionHMI/WS-0F.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_NextionHMI/WS-0F.png -------------------------------------------------------------------------------- /Arduino Uno/Uno_NextionHMI/WS-20C.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_NextionHMI/WS-20C.png -------------------------------------------------------------------------------- /Arduino Uno/Uno_NextionHMI/WS-20F.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_NextionHMI/WS-20F.png -------------------------------------------------------------------------------- /Arduino Uno/Uno_NextionHMI/WS-25C.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_NextionHMI/WS-25C.png -------------------------------------------------------------------------------- /Arduino Uno/Uno_NextionHMI/WS-25F.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_NextionHMI/WS-25F.png -------------------------------------------------------------------------------- /Arduino Uno/Uno_NextionHMI/WS-45C.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_NextionHMI/WS-45C.png -------------------------------------------------------------------------------- /Arduino Uno/Uno_NextionHMI/WS-45F.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_NextionHMI/WS-45F.png -------------------------------------------------------------------------------- /Arduino Uno/Uno_NextionHMI/WS-5C.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_NextionHMI/WS-5C.png -------------------------------------------------------------------------------- /Arduino Uno/Uno_NextionHMI/WS-5F.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_NextionHMI/WS-5F.png -------------------------------------------------------------------------------- /Arduino Uno/Uno_NextionHMI/Weatherstation.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_NextionHMI/Weatherstation.tft -------------------------------------------------------------------------------- /Arduino Uno/Uno_Nextion_Weatherstation/Uno_Nextion_Weatherstation.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Nextion_Weatherstation.ino 3 | * 4 | * This programs simulates a weatherstation and displays data 5 | * on Nextion HMI equipped w/ special firmware Weatherstation.tft. 6 | * You will find the firmware at 7 | * https://github.com/ckuehnel/newArduino/blob/master/Arduino%20Uno/Uno_NextionHMI/Weatherstation.tft 8 | * 9 | * Claus Kühnel 2020-03-12 info@ckuehnel.ch 10 | */ 11 | #include 12 | 13 | // Nextion TX to pin 10 and RX to pin 11 of Arduino 14 | SoftwareSerial HMISerial(10, 11); 15 | 16 | #define DEBUG 1 17 | 18 | void HMIprint(String str) 19 | { 20 | HMISerial.print(str); 21 | HMISerial.write(0xFF); // Each Nextion HMI command is closed by three bytes 0xFF 22 | HMISerial.write(0xFF); 23 | HMISerial.write(0xFF); 24 | } 25 | 26 | void setup() 27 | { 28 | Serial.begin(115200); 29 | delay(1000); // wait for Serial Monitor 30 | Serial.println("\nWeatherstation w/ NEXTION HMI"); 31 | HMISerial.begin(9600); 32 | } 33 | 34 | void loop() 35 | { 36 | char msg[20]; 37 | 38 | float temp = getTemperature(); 39 | float humi = getHumidity(); 40 | 41 | Serial.print(temp); Serial.print(" °C\t"); 42 | Serial.print(humi); Serial.print(" % RH\n"); 43 | 44 | dtostrf(10*temp, 3, 0, msg); //3 is mininum width, 1 is precision 45 | String toHMI = "temp.val="; 46 | toHMI += msg; 47 | if (DEBUG) Serial.println(toHMI); 48 | HMIprint(toHMI); 49 | 50 | dtostrf(humi, 2, 0, msg); //2 is mininum width, 0 is precision 51 | toHMI = "humi.val="; 52 | toHMI += msg; 53 | if (DEBUG) Serial.println(toHMI); 54 | HMIprint(toHMI); 55 | 56 | delay(1000); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Nextion_Weatherstation/Weatherstation.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_Nextion_Weatherstation/Weatherstation.tft -------------------------------------------------------------------------------- /Arduino Uno/Uno_Nextion_Weatherstation/getValue.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Simulation of measuring values for temperature and humidity 3 | * Replace this by real access to the choosen sensor 4 | */ 5 | 6 | float getTemperature() 7 | { 8 | long temp = random(-400, 700); 9 | return (float) temp/10.; 10 | } 11 | 12 | float getHumidity() 13 | { 14 | long humi = random(0, 100); 15 | return (float) humi; 16 | } 17 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Nokia5110/startScreen.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Generate StartScreen w/ Logo 3 | */ 4 | 5 | static const byte LOGO_WIDTH = 27; 6 | static const byte LOGO_HEIGHT = 4; // 4 lines w/ 8 bit = 32 dots 7 | static const byte logo[] = 8 | { 0, 0,252,252, 12, 12,204,204,204,204,204,204,204,204,204,204, 9 | 204,204,204,204,204,204,204,204,204, 0, 0, 0, 0,255,255, 0, 10 | 0,255,255, 0, 0,252,252, 12, 12,204,204,204,204,204,204,204, 11 | 204,204,204,204, 0, 0, 0, 0,255,255, 0, 0,255,255, 0, 0, 12 | 255,255, 0, 0,255,255, 0, 0,156,156,156,128,128,252,252, 0, 13 | 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 14 | 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}; 15 | 16 | void displayStartScreen() 17 | { 18 | // Draw the logo bitmap at the top left corner... 19 | lcd.setCursor(0, 0); 20 | lcd.drawBitmap(logo, LOGO_WIDTH, LOGO_HEIGHT); 21 | lcd.setCursor(0, 5); 22 | lcd.setInverseOutput(true); 23 | lcd.print("Nokia5110 LCD"); 24 | lcd.setInverseOutput(false); 25 | delay(2000); 26 | lcd.clear(); 27 | } 28 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_PPD42NS/Uno_PPD42NS.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_PPD42NS.ino 3 | * 4 | * Reads measuring data from Grove Dust Sensor. 5 | * (c) Claus Kuehnel 2018-11-26 info@ckuehnel.ch 6 | * 7 | * based on: http://wiki.seeedstudio.com/Grove-Dust_Sensor/ 8 | */ 9 | 10 | const int sensor = 8; // Output P1 11 | unsigned long duration; 12 | unsigned long starttime; 13 | unsigned long sampletime_ms = 30000; //sample time = 30 s 14 | unsigned long lowpulseoccupancy = 0; 15 | float ratio = 0; 16 | float concentration = 0; 17 | 18 | #define DEBUG 0 19 | 20 | void setup() 21 | { 22 | Serial.begin(115200); 23 | delay(2000); 24 | Serial.println("Reading Grove Dust Sensor..."); 25 | pinMode(sensor,INPUT); 26 | starttime = millis(); //get the current time; 27 | } 28 | 29 | void loop() 30 | { 31 | duration = pulseIn(sensor, LOW); 32 | lowpulseoccupancy = lowpulseoccupancy + duration; 33 | Serial.print("."); 34 | 35 | if ((millis()-starttime) > sampletime_ms) //if the sample time == 30s 36 | { 37 | ratio = lowpulseoccupancy/(sampletime_ms*10.0); // Integer percentage 0=>100 38 | concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve 39 | Serial.println(); 40 | if (DEBUG) 41 | { 42 | Serial.print(lowpulseoccupancy); 43 | Serial.print(", "); 44 | Serial.print(ratio); 45 | Serial.print(" "); 46 | } 47 | Serial.print("Dust Concentration: "); 48 | Serial.print(3.5 * concentration); 49 | Serial.print(" ppl \t"); 50 | Serial.print(concentration); 51 | Serial.println(" pp 0.01 ft^3"); 52 | lowpulseoccupancy = 0; 53 | starttime = millis(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_RGB/Uno_RGB.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Uno_RGB.ino 3 | 4 | Controlling RGB LED w/ common cathode & single LEDs 5 | Created 1019-09-15 Claus Kühnel info@ckuehnel.ch 6 | */ 7 | 8 | enum{Red = 9, Green, Blue,SingleRed, SingleBlue}; 9 | 10 | void setup() 11 | { 12 | pinMode(Red, OUTPUT); digitalWrite(Red,LOW); 13 | pinMode(Green, OUTPUT); digitalWrite(Green, LOW); 14 | pinMode(Blue, OUTPUT); digitalWrite(Blue, LOW); 15 | pinMode(SingleRed, OUTPUT); digitalWrite(Green, LOW); 16 | pinMode(SingleBlue, OUTPUT); digitalWrite(Blue, LOW); 17 | } 18 | 19 | void loop() 20 | { 21 | blinkLED(Red); 22 | blinkLED(Green); 23 | blinkLED(Blue); 24 | blinkLED(SingleRed); 25 | blinkLED(SingleBlue); 26 | fadeLED(Red); 27 | fadeLED(Green); 28 | fadeLED(Blue); 29 | fadeLED(SingleRed); 30 | fadeLED(SingleBlue); 31 | } 32 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_RGB/Uno_RGB_HD 720p.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_RGB/Uno_RGB_HD 720p.mp4 -------------------------------------------------------------------------------- /Arduino Uno/Uno_RGB/blinkLED.ino: -------------------------------------------------------------------------------- 1 | void blinkLED(int RGB) 2 | { 3 | digitalWrite(RGB, HIGH); 4 | delay(1000); 5 | digitalWrite(RGB, LOW); 6 | delay(1000); 7 | } 8 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_RGB/fadeLED.ino: -------------------------------------------------------------------------------- 1 | void fadeLED(int RGB) 2 | { 3 | int i = 0; 4 | while (i <= 255) 5 | { 6 | analogWrite(RGB, i); 7 | delay(10); 8 | i += 5; 9 | } 10 | 11 | i = 255; 12 | while (i >=0) 13 | { 14 | analogWrite(RGB, i); 15 | delay(10); 16 | i -= 5; 17 | } 18 | delay(1000); 19 | } 20 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_ReadNFCTag/Uno_ReadNFCTag.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_ReadNFCTag.ino 3 | * based on : ReadTag example in NDEF library 4 | * Modifications: Claus Kühnel 2020-02-29 info@ckuehnel.ch 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | PN532_I2C pn532_i2c(Wire); 12 | NfcAdapter nfc = NfcAdapter(pn532_i2c); 13 | 14 | void setup(void) 15 | { 16 | Serial.begin(115200); 17 | Serial.println(F("NDEF Reader")); 18 | nfc.begin(); 19 | } 20 | 21 | void loop(void) 22 | { 23 | Serial.println(F("\nScan a NFC tag\n")); 24 | if (nfc.tagPresent()) 25 | { 26 | NfcTag tag = nfc.read(); 27 | 28 | Serial.print(F("NFC Tag - ")); Serial.println(tag.getTagType()); 29 | Serial.print(F("UID ")); Serial.println(tag.getUidString()); 30 | 31 | if (tag.hasNdefMessage()) // every tag won't have a message 32 | { 33 | NdefMessage message = tag.getNdefMessage(); 34 | 35 | int recordCount = message.getRecordCount(); 36 | Serial.print(F("Number of records = ")); Serial.println(recordCount); 37 | 38 | for (int i = 0; i < recordCount; i++) 39 | { 40 | Serial.print(F("\nNDEF Record "));Serial.println(i+1); 41 | NdefRecord record = message.getRecord(i); 42 | 43 | int payloadLength = record.getPayloadLength(); 44 | byte payload[payloadLength]; 45 | record.getPayload(payload); 46 | 47 | String payloadAsString = ""; 48 | for (int c = 0; c < payloadLength; c++) 49 | { 50 | payloadAsString += (char)payload[c]; 51 | } 52 | 53 | Serial.print(F("Payload (as String): ")); 54 | Serial.println(payloadAsString); 55 | } 56 | } 57 | } 58 | delay(5000); 59 | } 60 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Receive_I2C/Uno_Receive_I2C.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Receive_I2C.ino 3 | * 4 | * Receive SHT31 measuring data from I2C interface. 5 | * On transmitter side use Nano_Transmit_I2C.ino 6 | * to build the message 7 | * Claus Kühnel 2020-03-27 info@ckuehnel.ch 8 | */ 9 | #include 10 | 11 | #define STX 2 12 | #define ETX 3 13 | #define SlaveAddr 5 14 | 15 | char msg[5]; 16 | volatile boolean process_it; 17 | 18 | void receiveEvent() 19 | { 20 | while(Wire.available()) 21 | { 22 | for (int i = 0; i < sizeof(msg); i++) msg[i]= Wire.read(); 23 | } 24 | process_it = true; 25 | } 26 | 27 | void setup (void) 28 | { 29 | Serial.begin (115200); // debugging 30 | while(!Serial); 31 | Serial.println("\Wait for I2C transfer..."); 32 | Wire.begin(SlaveAddr); 33 | Wire.onReceive(receiveEvent); // Event handler for I2C receive 34 | } 35 | 36 | void loop (void) 37 | { 38 | if (process_it) 39 | { 40 | if ((msg[0] == STX) && (msg[4] == ETX)) 41 | { 42 | uint8_t hum = msg[1]; 43 | uint8_t temp_lo = msg[2]; 44 | uint8_t temp_hi = msg[3]; 45 | 46 | float temp = (float) (((temp_hi<<8) + temp_lo)/1000.0); 47 | Serial.print("Temp = "); Serial.print(temp,3); Serial.println(" *C"); 48 | Serial.print("Hum = "); Serial.print(hum); Serial.println(" %RH"); 49 | Serial.println(); 50 | } 51 | process_it = false; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Receive_SPI/Uno_Receive_SPI.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Receive_SPI.ino 3 | * 4 | * Receive SHT31 measuring data from SPI interface. 5 | * On transmitter side use Nano_Transmit_SPI.ino 6 | * to build the message 7 | * Claus Kühnel 2020-03-27 info@ckuehnel.ch 8 | */ 9 | #include 10 | 11 | #define STX 2 12 | #define ETX 3 13 | 14 | volatile boolean process_it; 15 | char msg[5]; 16 | byte pos = 0; 17 | 18 | ISR (SPI_STC_vect) // SPI interrupt routine 19 | { 20 | byte c = SPDR; // grab byte from SPI Data Register 21 | if (pos < (sizeof(msg) - 1)) msg[pos++] = c; 22 | // ETX means message end 23 | if (c == ETX) process_it = true; 24 | } 25 | 26 | void setup (void) 27 | { 28 | Serial.begin (115200); // debugging 29 | while(!Serial); 30 | Serial.println("\Wait for SPI transfer..."); 31 | 32 | // turn on SPI in slave mode 33 | SPCR |= bit (SPE); 34 | // have to send on master in, *slave out* 35 | pinMode(MISO, OUTPUT); 36 | // get ready for an interrupt 37 | pos = 0; // buffer empty 38 | process_it = false; 39 | // now turn on interrupts 40 | SPI.attachInterrupt(); 41 | } 42 | 43 | void loop (void) 44 | { 45 | if (process_it) 46 | { 47 | if (msg[0] == STX) 48 | { 49 | uint8_t hum = msg[1]; 50 | uint8_t temp_lo = msg[2]; 51 | uint8_t temp_hi = msg[3]; 52 | 53 | float temp = (float) (((temp_hi<<8) + temp_lo)/1000.0); 54 | Serial.print("Temp = "); Serial.print(temp,3); Serial.println(" *C"); 55 | Serial.print("Hum = "); Serial.print(hum); Serial.println(" %RH"); 56 | Serial.println(); 57 | } 58 | pos = 0; 59 | process_it = false; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Receive_Serial/Uno_Receive_Serial.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Receive_Serial.ino 3 | * 4 | * Receive SHT31 measuring data from serial interface. 5 | * On transmitter side use NanoEvery_Transmit_Serial.ino 6 | * to build the message 7 | * Claus Kühnel 2020-03-27 info@ckuehnel.ch 8 | */ 9 | #include 10 | 11 | SoftwareSerial SW_Serial(2, 3); // RX, TX 12 | 13 | #define STX 2 14 | #define ETX 3 15 | 16 | void setup() 17 | { 18 | Serial.begin(115200); 19 | while(!Serial); 20 | Serial.println("\nReceiving serial messages..."); 21 | SW_Serial.begin(19200); 22 | } 23 | 24 | void loop() 25 | { 26 | byte val; 27 | 28 | if (SW_Serial.available()) 29 | { 30 | do 31 | { 32 | val = SW_Serial.read(); 33 | } while (val != 0x02); 34 | // Serial.println("\nMessage detected..."); 35 | delay(2); 36 | uint8_t hum = SW_Serial.read(); delay(2); 37 | uint8_t temp_lo = SW_Serial.read(); delay(2); 38 | uint8_t temp_hi = SW_Serial.read(); delay(2); 39 | uint8_t ctrl = SW_Serial.read(); delay(2); 40 | // if (ctrl == ETX) Serial.println("Message received."); 41 | 42 | float temp = (float) (((temp_hi<<8) + temp_lo)/1000.0); 43 | Serial.print("Temp = "); Serial.print(temp,3); Serial.println(" *C"); 44 | Serial.print("Hum = "); Serial.print(hum); Serial.println(" %RH"); 45 | Serial.println(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Relais/Uno_Relais.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Relais.ino 3 | * 4 | * Ansteuerung einer Last durch ein an IO/-Pin 8 5 | * angeschlossenes Relais. 6 | * 7 | * Claus Kühnel 2020-03-14 info@ckuehnel.ch 8 | */ 9 | 10 | const int Relais = 8; // Relais @ Pin 8 11 | 12 | void setup() 13 | { 14 | pinMode(Relais, OUTPUT); 15 | digitalWrite(Relais, LOW); 16 | } 17 | 18 | void loop() 19 | { 20 | digitalWrite(Relais, HIGH); 21 | delay(1000); 22 | digitalWrite(Relais, LOW); 23 | delay(1000); 24 | } 25 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Runtime/Uno_Runtime.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Runtime.ino 3 | * 4 | * Measure runtime of code sequences 5 | * Claus Kühnel 2020-02-17 info@ckuehnel.ch 6 | * 7 | */ 8 | void setup() 9 | { 10 | Serial.begin(115200); 11 | delay(2000); // wait for Serial Monitor 12 | Serial.println("\nRuntime measurment of code sequence in program "); 13 | Serial.println(__FILE__); 14 | 15 | unsigned long starttime = micros(); 16 | // put your code between the comment lines 17 | /***************************************************/ 18 | int x = analogRead(0); 19 | int y = analogRead(1); 20 | int s = analogRead(2); 21 | /***************************************************/ 22 | unsigned long endtime = micros(); 23 | Serial.print("Runtime of code sequence = "); 24 | Serial.print(endtime - starttime); 25 | Serial.println(" us"); 26 | } 27 | 28 | void loop() {} 29 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Runtime_EEPROM/Uno_Runtime_EEPROM.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Runtime.ino 3 | * 4 | * Measure runtime of code sequences 5 | * Claus Kühnel 2020-02-17 info@ckuehnel.ch 6 | * 7 | */ 8 | #include 9 | 10 | #define DEBUG 0 // set to 1 for Hex dump 11 | 12 | void setup() 13 | { 14 | Serial.begin(115200); 15 | delay(2000); // wait for Serial Monitor 16 | Serial.println("\nRuntime measurement of code sequence in program "); 17 | Serial.println(__FILE__); 18 | 19 | unsigned long starttime = micros(); 20 | // put your code between the comment lines 21 | /***************************************************/ 22 | int val = 0; 23 | for (int addr = 0x100; addr < 0x200; addr++) 24 | { 25 | EEPROM.write(addr, val++); 26 | } 27 | /***************************************************/ 28 | unsigned long endtime = micros(); 29 | Serial.print("Runtime of code sequence = "); 30 | Serial.print(endtime - starttime); 31 | Serial.println(" us"); 32 | 33 | if (DEBUG) 34 | { 35 | Serial.println("\nHexdump EEPROM..."); 36 | for (int addr = 0x100; addr < 0x200; addr++) 37 | { 38 | byte val = EEPROM[addr]; 39 | if (addr % 16 == 0) Serial.println(); 40 | if (val < 0x10) Serial.print("0"); 41 | Serial.print(EEPROM[addr],HEX); 42 | Serial.print(" "); 43 | } 44 | Serial.println(); 45 | } 46 | } 47 | 48 | void loop() {} 49 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Runtime_FRAM/Uno_Runtime_FRAM.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Runtime_FRAM.ino 3 | * 4 | * Measure runtime of code sequences 5 | * Claus Kühnel 2020-02-17 info@ckuehnel.ch 6 | * 7 | */ 8 | #include 9 | #include 10 | 11 | MB85_FRAM_Class myFRAM; 12 | 13 | #define DEBUG 0 // set to 1 for Hex dump 14 | 15 | void setup() 16 | { 17 | Serial.begin(115200); 18 | delay(2000); // wait for Serial Monitor 19 | Serial.println("\nRuntime measurement of code sequence in program "); 20 | Serial.println(__FILE__); 21 | 22 | Wire.begin(); 23 | uint8_t chips = myFRAM.begin(I2C_FAST_MODE); // Return number of memories found 24 | 25 | unsigned long starttime = micros(); 26 | // put your code between the comment lines 27 | /***************************************************/ 28 | int val = 0; 29 | for (int addr = 0x100; addr < 0x200; addr++) 30 | { 31 | myFRAM.write(addr, val++); 32 | } 33 | /***************************************************/ 34 | unsigned long endtime = micros(); 35 | Serial.print("Runtime of code sequence = "); 36 | Serial.print(endtime - starttime); 37 | Serial.println(" us"); 38 | 39 | if (DEBUG) 40 | { 41 | Serial.println("\nHexdump FRAM..."); 42 | for (int addr = 0x100; addr < 0x200; addr++) 43 | { 44 | byte val; 45 | myFRAM.read(addr, val); 46 | if (addr % 16 == 0) Serial.println(); 47 | if (val < 0x10) Serial.print("0"); 48 | Serial.print(val, HEX); 49 | Serial.print(" "); 50 | } 51 | Serial.println(); 52 | } 53 | } 54 | 55 | void loop() {} 56 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Runtime_extEEPROM/Uno_Runtime_extEEPROM.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Runtime_extEEPROM.ino 3 | * 4 | * Measure runtime of code sequences 5 | * Claus Kühnel 2020-02-17 info@ckuehnel.ch 6 | * 7 | */ 8 | #include 9 | #include "SparkFun_External_EEPROM.h" 10 | 11 | ExternalEEPROM myEEPROM; 12 | 13 | #define DEBUG 0 // set to 1 for Hex dump 14 | 15 | void setup() 16 | { 17 | Serial.begin(115200); 18 | delay(2000); // wait for Serial Monitor 19 | Serial.println("\nRuntime measurement of code sequence in program "); 20 | Serial.println(__FILE__); 21 | 22 | Wire.begin(); 23 | myEEPROM.begin(); 24 | 25 | unsigned long starttime = micros(); 26 | // put your code between the comment lines 27 | /***************************************************/ 28 | int val = 0; 29 | for (int addr = 0x100; addr < 0x200; addr++) 30 | { 31 | myEEPROM.write(addr, val++); 32 | } 33 | /***************************************************/ 34 | unsigned long endtime = micros(); 35 | Serial.print("Runtime of code sequence = "); 36 | Serial.print(endtime - starttime); 37 | Serial.println(" us"); 38 | 39 | if (DEBUG) 40 | { 41 | Serial.println("\nHexdump FRAM..."); 42 | for (int addr = 0x100; addr < 0x200; addr++) 43 | { 44 | byte val; 45 | val = myEEPROM.read(addr); 46 | if (addr % 16 == 0) Serial.println(); 47 | if (val < 0x10) Serial.print("0"); 48 | Serial.print(val, HEX); 49 | Serial.print(" "); 50 | } 51 | Serial.println(); 52 | } 53 | } 54 | 55 | void loop() {} 56 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_SCD30_Monitor/Uno_SCD30_Monitor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_SCD30_Monitor.ino 3 | * 4 | * Get measuring value from Seeed SCD30 – CO2 & TEMPERATURE & HUMIDITY SENSOR 5 | * Claus Kühnel 2020-04-10 info@ckuehnel.ch 6 | */ 7 | //Include used libraries 8 | #include 9 | #include 10 | #include "SparkFun_SCD30_Arduino_Library.h" 11 | 12 | // select the pins used on the LCD panel 13 | LiquidCrystal lcd(8, 9, 4, 5, 6, 7); 14 | 15 | SCD30 airSensor; 16 | 17 | // define some values used by the panel 18 | const int backlight = 10; // Backlight connected to D10 19 | 20 | void setup() 21 | { 22 | Wire.begin(); 23 | airSensor.begin(); //This will cause readings to occur every two seconds 24 | pinMode(backlight, OUTPUT); 25 | digitalWrite(backlight, HIGH); 26 | lcd.begin(16, 2); // start the library for 2 lines a 16 characters 27 | lcd.setCursor(0,0); 28 | lcd.print("SCD30 Monitoring"); // print a simple message 29 | delay(2000); 30 | lcd.clear(); 31 | } 32 | 33 | void loop() 34 | { 35 | clearLine(0); 36 | lcd.setCursor(0,0); // move cursor to second line "1" and 9 spaces over 37 | lcd.print(" CO2 "); 38 | lcd.print(airSensor.getCO2()); 39 | lcd.print(" ppm"); 40 | 41 | clearLine(1); 42 | lcd.setCursor(0,1); // move to the begining of the second line 43 | lcd.print(airSensor.getTemperature(), 1); 44 | lcd.print(" *C"); 45 | lcd.setCursor(8,1); 46 | lcd.print(airSensor.getHumidity(), 1); 47 | lcd.print(" %rH"); 48 | delay(5000); 49 | } 50 | 51 | void clearLine(byte line) 52 | { 53 | lcd.setCursor(0 ,line); 54 | lcd.print(" "); 55 | } 56 | 57 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Servo/Uno_Servo.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Servo.ino 3 | * 4 | * Direct control of a mini servo 5 | * 6 | * Claus Kühnel 2020-03-14 info@ckuehnel.ch 7 | */ 8 | #include 9 | 10 | Servo myServo; // create servo object to control a servo 11 | 12 | const int pServo = 9; 13 | int pos = 0; // variable to store the servo position 14 | 15 | void setup() 16 | { 17 | Serial.begin(115200); 18 | delay(1000); // wait for Serial Monitor 19 | Serial.println("\nTest Servo..."); 20 | 21 | myServo.attach(pServo, 540, 2400); // attaches the servo to an I/O pin 22 | 23 | myServo.write(0); 24 | delay(2000); // to reach the position 25 | int pulse = myServo.readMicroseconds(); 26 | Serial.print("Initial position ( 0 degrees) - Pulse width = "); 27 | Serial.print(pulse); Serial.println(" us"); 28 | 29 | myServo.write(180); 30 | delay(2000); // to reach the position 31 | pulse = myServo.readMicroseconds(); 32 | Serial.print("Initial position (180 degrees) - Pulse width = "); 33 | Serial.print(pulse); Serial.println(" us"); 34 | } 35 | 36 | void loop() 37 | { 38 | for (pos = 180; pos >= 0; pos -= 1) // goes from 180 degrees to 0 degrees 39 | { 40 | myServo.write(pos); // tell servo to go to position in variable 'pos' 41 | delay(6); // waits 6ms for the servo to reach the position 42 | } 43 | delay(1000); 44 | for (pos = 0; pos <= 180; pos += 1) // goes from 0 degrees to 180 degrees 45 | { 46 | myServo.write(pos); // tell servo to go to position in variable 'pos' 47 | delay(6); // waits 6ms for the servo to reach the position 48 | } 49 | delay(1000); 50 | } 51 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Si7021/Uno_Si7021.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Si7021.ino 3 | * 4 | * Reads measuring data from Si7021 Sensor. 5 | * (c) Claus Kuehnel 2020-02-03 info@ckuehnel.ch 6 | * 7 | * based on: SparkFun Si7021 Breakout Example 8 | * 9 | * Hardware Connections: 10 | * Si7021 ---------------- Arduino 11 | * (-) ------------------- GND 12 | * (+) ------------------- 3.3V (VCC) 13 | * CL ------------------- SCL 14 | * DA ------------------- SDA 15 | */ 16 | 17 | #include "SparkFun_Si7021_Breakout_Library.h" 18 | #include 19 | 20 | //Create Instance of Si7021 temp and humidity sensor 21 | Weather sensor; 22 | 23 | void setup() 24 | { 25 | Serial.begin(115200); // open serial over USB at 115200 baud 26 | delay(2000); 27 | Serial.println("Read Si7021 sensor..."); 28 | sensor.begin(); //Initialize the I2C sensors and ping them 29 | Serial.println(); 30 | } 31 | 32 | void loop() 33 | { 34 | delay(2000); 35 | getWeather(); 36 | } 37 | 38 | void getWeather() 39 | { 40 | // Measure Relative Humidity from the HTU21D or Si7021 41 | float humi = sensor.getRH(); 42 | 43 | // Measure Temperature from the HTU21D or Si7021 44 | float temp = sensor.getTemp(); 45 | // Temperature is measured every time RH is requested. 46 | // It is faster, therefore, to read it from previous RH 47 | // measurement with getTemp() instead with readTemp() 48 | Serial.print("Humidity: "); Serial.print((int) humi); Serial.print(" %\t"); 49 | Serial.print("Temperature: "); Serial.print(temp, 1); Serial.println(" °C "); 50 | } 51 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Stepper/README.md: -------------------------------------------------------------------------------- 1 | **Schrittmotoransteuerung** 2 | 3 | Verwendete Schrittmotortreiber: 4 | - L293D Vier-Kanal Motortreiber Shield (https://www.az-delivery.de/products/4-kanal-l293d-motortreiber-shield-schrittmotortreiber) 5 | - A4988 6 | - TMC2209 7 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Stepper/Stepper_HD 720p.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Arduino Uno/Uno_Stepper/Stepper_HD 720p.mp4 -------------------------------------------------------------------------------- /Arduino Uno/Uno_Stepper/Uno_Stepper.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_Stepper.ino 3 | */ 4 | 5 | #include 6 | 7 | // Number of steps per output rotation 8 | // Change this as per your motor's specification 9 | const int stepsPerRevolution = 200; // NEMA 17 200 steps 10 | 11 | // connect motor to port #2 (M3 and M4) 12 | AF_Stepper motor(stepsPerRevolution, 2); 13 | 14 | void setup() 15 | { 16 | Serial.begin(9600); 17 | Serial.println("Stepper test..."); 18 | 19 | motor.setSpeed(20); // 10 rpm 20 | } 21 | 22 | void loop() 23 | { 24 | Serial.println("Single coil steps"); 25 | motor.step(200, FORWARD, SINGLE); 26 | motor.step(200, BACKWARD, SINGLE); 27 | 28 | Serial.println("Double coil steps"); 29 | motor.step(200, FORWARD, DOUBLE); 30 | motor.step(200, BACKWARD, DOUBLE); 31 | 32 | Serial.println("Interleave coil steps"); 33 | motor.step(400, FORWARD, INTERLEAVE); 34 | motor.step(400, BACKWARD, INTERLEAVE); 35 | 36 | Serial.println("Micrsostep steps"); 37 | motor.step(200, FORWARD, MICROSTEP); 38 | motor.step(200, BACKWARD, MICROSTEP); 39 | } 40 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_TM1637/Uno_TM1637.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_TM1637.ino 3 | * 4 | * Display numeric value on 7-Segment-Display controlled by TM1637 5 | * using library on https://github.com/avishorp/TM1637 6 | * 2020-02-28 Claus Kühnel info@ ckuehnel.ch 7 | */ 8 | #include 9 | 10 | // Module connection pins (Digital Pins) 11 | #define CLK 2 12 | #define DIO 3 13 | 14 | const uint8_t SEG_DEC[] = 15 | { 16 | SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, // d 17 | SEG_A | SEG_D | SEG_E | SEG_F | SEG_G, // E 18 | SEG_A | SEG_D | SEG_E | SEG_F, // C 19 | SEG_D // _ 20 | }; 21 | 22 | const uint8_t SEG_HEX[] = 23 | { 24 | SEG_C | SEG_E | SEG_F | SEG_G, // h 25 | SEG_A | SEG_D | SEG_E | SEG_F | SEG_G, // E 26 | SEG_B | SEG_C | SEG_E | SEG_F | SEG_G, // H 27 | SEG_D // _ 28 | }; 29 | 30 | TM1637Display display(CLK, DIO); 31 | 32 | void setup() 33 | { 34 | display.setBrightness(2); 35 | } 36 | 37 | void loop() 38 | { 39 | // dEC - display decimal numbers 40 | display.setSegments(SEG_DEC); 41 | delay(1000); 42 | 43 | // simulates a display from -40.0 to 75.0 44 | for (int i = -40; i < 80; i +=5) 45 | { 46 | display.showNumberDec(i, false); 47 | delay(500); 48 | } 49 | // heH - display hex numbers 50 | display.setSegments(SEG_HEX); 51 | delay(1000); 52 | 53 | // simulates a display from 0000 to FFFF 54 | unsigned int i = 0; 55 | while (i < 0xF000) 56 | { 57 | if (i < 0x10) i+= 1; 58 | else if (i < 0x100) i+= 0x10; 59 | else if (i < 0x1000) i+= 0x100; 60 | else i+= 0x1000; 61 | display.showNumberHexEx(i, 0, true); 62 | delay(250); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_TMP36/Uno_TMP36.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_TMP36.ino 3 | * 4 | * Measuring temperature by TMP36 sensor @ Arduino Uno 5 | * created 2018-12-20 by Claus Kuehnel (info@ckuehnel.ch 6 | */ 7 | 8 | const int pTMP36 = A0; 9 | const float Vs = 5.0; // VCC, 5 V for Arduino Uno 10 | 11 | void setup() 12 | { 13 | Serial.begin(115200); 14 | delay(2000); // wait for serial monitor 15 | Serial.println("Measuring temperature by TMP36"); 16 | } 17 | 18 | void loop() 19 | { 20 | int raw = analogRead(pTMP36); 21 | float volt = raw * Vs/1024; 22 | Serial.print("Voltage = "); Serial.print(volt, 3); Serial.print(" V\t"); 23 | float temp = (volt - 0.5) * 100; 24 | Serial.print("Temperature = "); 25 | Serial.print(temp, 1); 26 | Serial.println(" °C"); 27 | delay(1000); 28 | } 29 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_TMP36_Thingspeak/TCP.ino: -------------------------------------------------------------------------------- 1 | // Connection to Thingspeak Server via GPRS 2 | 3 | void getResponse() 4 | { 5 | delay(midZ); 6 | while (SIM800_Serial.available()) Serial.write(SIM800_Serial.read()); 7 | } 8 | 9 | void sendUpdate() 10 | { 11 | if (DEBUG) Serial.println("Prepare Connection to Thingspeak..."); 12 | SIM800_Serial.println("at+csq"); 13 | delay(minZ); 14 | getResponse(); 15 | SIM800_Serial.println("at+cipshut"); 16 | delay(maxZ); 17 | getResponse(); 18 | SIM800_Serial.println("at+cstt=\""+ APN +"\",\"\",\"\""); 19 | getResponse(); 20 | SIM800_Serial.println("at+ciicr");//start wireless connection cellular network 21 | getResponse(); 22 | SIM800_Serial.println("at+cifsr");//enquire regarding the IP address allocated 23 | getResponse(); 24 | SIM800_Serial.println("at+cipstart=\"TCP\",\""+ URL +"\",\"80\""); //connect to the ThingSpeak update URL (https://api.thingspeak.com) 25 | getResponse(); 26 | SIM800_Serial.println("at+cipsend=80");//declare the number of bytes (characters) I want to send 27 | getResponse(); 28 | SIM800_Serial.print("GET https://"); //this is a constant beginning for the GET command and is as provided by ThingSpeak 29 | SIM800_Serial.print(URL); 30 | SIM800_Serial.print("/update?"); 31 | SIM800_Serial.print(APIKEY); //the channel API key provided by ThingSpeak 32 | getResponse(); 33 | SIM800_Serial.print("&field1="); 34 | getResponse(); 35 | SIM800_Serial.println(String(temp));//the value to post to field 36 | getResponse(); 37 | SIM800_Serial.println("at+cipack");//ask for acknowledge details 38 | getResponse(); 39 | SIM800_Serial.println("at+cipclose");//close the IP connection 40 | getResponse(); 41 | } 42 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_TMP36_Thingspeak/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // Access data 2 | String APN = "tm"; 3 | String URL = "api.thingspeak.com"; 4 | #define APIKEY "api_key=CFEMR8UKW5AYOGON" 5 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_TMP36_Thingspeak/getValue.ino: -------------------------------------------------------------------------------- 1 | /* Reads TMP36 temperature sensor 2 | 3 | Connections: 4 | 5 | TMP36 | Vs | Vout | GND | 6 | -------------------------------- 7 | Arduino Uno | 5 V | A0 | GND | 8 | 9 | */ 10 | 11 | int raw; 12 | float volt; 13 | 14 | const int pTMP36 = A0; 15 | const float Vs = 5.0; // VCC, 5 V for Arduino Uno 16 | 17 | float getValue() 18 | { 19 | raw = analogRead(pTMP36); 20 | volt = raw * Vs/1024; 21 | temp = (volt - 0.5) * 100; 22 | if (DEBUG) 23 | { 24 | Serial.print("Voltage = "); Serial.print(volt, 3); Serial.print(" V\t"); 25 | Serial.print("Temperature = "); Serial.print(temp, 1); Serial.println(" *C"); 26 | } 27 | return temp; 28 | } 29 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_TouchPanel1/Uno_TouchPanel1.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_TouchPanel1.ino 3 | * 4 | */ 5 | 6 | int X, Y; 7 | #define YP A2 // must be an analog pin, use "An" notation! 8 | #define XM A3 // must be an analog pin, use "An" notation! 9 | const int YM = 8; // can be a digital pin 10 | const int XP = 9; // can be a digital pin 11 | 12 | void setup() 13 | { 14 | Serial.begin(115200); 15 | delay(2000); // wait for Serial Monitor 16 | pinMode(LED_BUILTIN, OUTPUT); 17 | } 18 | 19 | void loop() 20 | { 21 | // Read Y 22 | pinMode(YP, INPUT); 23 | pinMode(YM, INPUT); 24 | pinMode(XP, OUTPUT); 25 | pinMode(XM, OUTPUT); 26 | 27 | digitalWrite(XM, LOW); 28 | digitalWrite(XP, HIGH); 29 | delay(5); // wait for stable voltage 30 | Y = analogRead(YP); 31 | //Y = map(ValueX, 65, 960, 1, 64); 32 | //if(Y < 0 || Y > 64) Y = 0; 33 | //Serial.print(Y); 34 | //Serial.print(";"); 35 | 36 | // Read X 37 | pinMode(XP, INPUT); 38 | pinMode(XM, INPUT); 39 | pinMode(YP, OUTPUT); 40 | pinMode(YM, OUTPUT); 41 | 42 | digitalWrite(YM, LOW); 43 | digitalWrite(YP, HIGH); 44 | delay(5); // wait for stable voltage 45 | X = analogRead(XM); 46 | //X = map(X, 150, 820, 1, 36); 47 | //if(X < 0 || X > 36) X = 0; 48 | // Output 49 | Serial.print("X = "); Serial.print(X); 50 | Serial.print("\tY = "); Serial.print(Y); 51 | // Blink Led 52 | if (X > 0 && Y > 0) digitalWrite(LED_BUILTIN, HIGH); 53 | else digitalWrite(LED_BUILTIN, LOW); 54 | delay(50); 55 | } 56 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_TouchPanel2/Uno_TouchPanel2.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_TouchPanel2.ino 3 | * based on touchscreendemo.ino included in the library 4 | * 5 | * Touch screen library with X Y and Z (pressure) readings as well 6 | * as oversampling to avoid 'bouncing' 7 | * This demo code returns raw readings, public domain 8 | * 9 | */ 10 | 11 | #include 12 | #include "TouchScreen.h" 13 | 14 | #define YP A2 // must be an analog pin, use "An" notation! 15 | #define XM A3 // must be an analog pin, use "An" notation! 16 | #define YM 8 // can be a digital pin 17 | #define XP 9 // can be a digital pin 18 | 19 | // For better pressure precision, we need to know the resistance 20 | // between X+ and X- Use any multimeter to read it 21 | // For the one we're using, its 300 ohms across the X plate 22 | TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); 23 | 24 | void setup(void) 25 | { 26 | Serial.begin(115200); 27 | delay(2000); // wait for Serial Monitor 28 | pinMode(LED_BUILTIN, OUTPUT); 29 | } 30 | 31 | void loop(void) 32 | { 33 | // a point object holds x y and z coordinates 34 | TSPoint p = ts.getPoint(); 35 | 36 | // we have some minimum pressure we consider 'valid' 37 | // pressure of 0 means no pressing! 38 | if (p.z > ts.pressureThreshhold) 39 | { 40 | Serial.print("X = "); Serial.print(p.x); 41 | Serial.print("\tY = "); Serial.print(p.y); 42 | Serial.print("\tPressure = "); Serial.println(p.z); 43 | digitalWrite(LED_BUILTIN, HIGH); 44 | } 45 | else digitalWrite(LED_BUILTIN, LOW); 46 | delay(50); 47 | } 48 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_TouchSensor/Uno_TouchSensor.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Uno_TouchSensor.ino 3 | 4 | Using Touch Sensor Module as input device 5 | https://www.az-delivery.de/products/touch-sensor-modul-1 6 | 7 | 2019-09-23 Claus Kühnel info@ckuehnel.ch 8 | 9 | */ 10 | 11 | const int SIG = 2; // pin for Touch Sensor signal 12 | 13 | void setup() 14 | { 15 | pinMode(SIG, INPUT); 16 | pinMode(LED_BUILTIN, OUTPUT); 17 | digitalWrite(LED_BUILTIN, LOW); 18 | } 19 | 20 | void loop () 21 | { 22 | boolean val = digitalRead(SIG) ; 23 | 24 | if (val == HIGH) digitalWrite (LED_BUILTIN, HIGH); 25 | else digitalWrite (LED_BUILTIN, LOW); 26 | } 27 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Waveshare28_TFT/getValue.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Simulation of measuring values for temperature and humidity 3 | * Replace this by real access to the choosen sensor 4 | */ 5 | 6 | float getTemperature() 7 | { 8 | long temp = random(-400, 700); 9 | return (float) temp/10.; 10 | } 11 | 12 | float getHumidity() 13 | { 14 | long humi = random(0, 100); 15 | return (float) humi; 16 | } 17 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Waveshare28_Touch/point.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Graphic Primitives 3 | */ 4 | 5 | void draw_big_point(uint16_t xpos, uint16_t ypos, uint16_t color) 6 | { 7 | tft.fillRect(xpos-2, ypos-2, 5, 5, color); 8 | tft.drawFastVLine(xpos, ypos-10, 21, color); 9 | tft.drawFastHLine(xpos-10, ypos, 21, color); 10 | } 11 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_Waveshare28_Touch/random.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Simulation of measuring values for temperature and humidity 3 | * Replace this by real access to the choosen sensor 4 | */ 5 | 6 | int getX() 7 | { 8 | return random(10, 310); 9 | } 10 | 11 | int getY() 12 | { 13 | return random(10, 230); 14 | } 15 | -------------------------------------------------------------------------------- /Arduino Uno/Uno_WriteNFCTag/Uno_WriteNFCTag.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Uno_WriteNFCTag.ino 3 | * based on : WriteTag example in NDEF library 4 | * Modifications: Claus Kühnel 2020-02-29 info@ckuehnel.ch 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | PN532_I2C pn532_i2c(Wire); 12 | NfcAdapter nfc = NfcAdapter(pn532_i2c); 13 | 14 | String messagetext = "This is a message written by Arduino Uno"; 15 | String URL = "http://www.rheinwerk-verlag.de"; 16 | 17 | void setup() 18 | { 19 | Serial.begin(115200); 20 | Serial.println("NDEF Writer"); 21 | nfc.begin(); 22 | } 23 | 24 | void loop() 25 | { 26 | boolean success; 27 | 28 | Serial.println(F("\nPlace a NFC tag on the reader.")); 29 | if (nfc.tagPresent()) 30 | { 31 | success = nfc.clean(); 32 | if (success) Serial.println(F("\nSuccess, tag restored to factory state.")); 33 | else Serial.println(F("\nError, unable to clean tag.")); 34 | 35 | NdefMessage message = NdefMessage(); 36 | 37 | Serial.println("\nWrite " + messagetext + " to NFC tag"); 38 | message.addTextRecord(messagetext); 39 | Serial.print(message.getRecordCount()); Serial.println(" records written."); 40 | 41 | Serial.println("\nWrite " + URL + " to NFC tag"); 42 | message.addUriRecord(URL); 43 | Serial.print(message.getRecordCount()); Serial.println(" records written."); 44 | 45 | success = nfc.write(message); 46 | if (success) Serial.println(F("Success. Verify by reading this tag with your phone or Uno_ReadNFCTag.ino.")); 47 | else Serial.println(F("Write failed.")); 48 | } 49 | delay(5000); 50 | } 51 | -------------------------------------------------------------------------------- /Arduino Yun/README.md: -------------------------------------------------------------------------------- 1 | ## Arduino Yún 2 | 3 | Dieses Verzeichnis enthält Programme für den Arduino Yún 4 | 5 | -------------------------------------------------------------------------------- /Arduino Yun/Yun_SHT31/Yun_SHT31.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Yun_SHT31.ino 3 | * 4 | * Get temperatur and humidity from SHT31 for 5 | * Arduino Yún or Dragino Yún shield w/ Arduino Leonardo 6 | * 7 | * created by Claus Kühnel 2020-04-13 info@ckuehnel.ch 8 | */ 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | const unsigned int cycle = 15000; // measuring cycle 15 sec 15 | 16 | SHT31 sht31 = SHT31(); 17 | 18 | void setup() 19 | { 20 | Bridge.begin(); 21 | Console.begin(); 22 | sht31.begin(); 23 | 24 | while (!Console); // wait for Console port to connect. 25 | Console.println("You're connected to the Console"); 26 | } 27 | 28 | void loop() 29 | { 30 | digitalWrite(LED_BUILTIN, HIGH); // sets the LED on 31 | float temp = sht31.getTemperature(); 32 | float hum = sht31.getHumidity(); 33 | Console.print("Temp = "); 34 | Console.print(temp, 1); 35 | Console.println(" *C"); 36 | Console.print("Hum = "); 37 | Console.print(hum, 0); 38 | Console.println(" %RH"); 39 | Console.println(); 40 | digitalWrite(LED_BUILTIN, LOW); // sets the LED off 41 | delay(cycle); 42 | } 43 | -------------------------------------------------------------------------------- /Arduino Yun/Yun_SHT31_FileIO/Yun_SHT31_FileIO.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: Yun_SHT31_FileIO.ino 3 | * 4 | * Get temperatur and humidity from SHT31 for 5 | * Arduino Yún or Dragino Yún shield w/ Arduino Leonardo 6 | * save data to files on Linux-Device 7 | * 8 | * created by Claus Kühnel 2020-04-13 info@ckuehnel.ch 9 | */ 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | const unsigned int cycle = 15000; // measuring cycle 60 sec 17 | 18 | SHT31 sht31 = SHT31(); 19 | 20 | void setup() 21 | { 22 | Bridge.begin(); 23 | Console.begin(); 24 | sht31.begin(); 25 | FileSystem.begin(); 26 | 27 | while (!Console); // wait for Console port to connect. 28 | Console.println("You're connected to the Console"); 29 | } 30 | 31 | void loop() 32 | { 33 | digitalWrite(LED_BUILTIN, HIGH); // sets the LED on 34 | float temp = sht31.getTemperature(); 35 | float hum = sht31.getHumidity(); 36 | Console.print("Temp = "); 37 | Console.print(temp, 1); 38 | Console.println(" C"); 39 | Console.print("Hum = "); 40 | Console.print(hum, 0); 41 | Console.println(" %"); 42 | Console.println(); 43 | File f = FileSystem.open("/tmp/TEMP", FILE_WRITE); 44 | f.print(temp); 45 | f.close(); 46 | File fff = FileSystem.open("/tmp/HUMI", FILE_WRITE); 47 | fff.print(hum); 48 | fff.close(); 49 | digitalWrite(LED_BUILTIN, LOW); // sets the LED off 50 | delay(cycle); 51 | } 52 | -------------------------------------------------------------------------------- /Arduino Yun/openweather.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Reading weather data from openweathermap network 4 | 5 | import urllib2 6 | import json, time 7 | 8 | f = urllib2.urlopen('http://api.openweathermap.org/data/2.5/weather?q=Altendorf,CH&APPID=87286fed489ba6a8afcd81443138d510') 9 | json_string = f.read() 10 | parsed_json = json.loads(json_string) 11 | 12 | #location = parsed_json['location']['city'] 13 | location = parsed_json['name'] 14 | temp_c = parsed_json['main']['temp'] - 273.15 15 | temp = round(10*temp_c)/10 16 | rel_hum = parsed_json['main']['humidity'] 17 | weather = parsed_json['weather'][0]['description'] 18 | station = parsed_json['id'] 19 | updated = parsed_json['dt'] 20 | print("Current temperature in {0:s} is {1:.1f} *C".format(location, temp)) 21 | print("Current relative humidity is {:d} %".format(rel_hum)) 22 | print("Weather is %s " % (weather)) 23 | print("Weather station is %s" % (station)) 24 | print("Last updated: ") 25 | local_time = time.localtime(updated) 26 | print(time.strftime("%Y-%m-%d %H:%M:%S", local_time)) 27 | f.close() 28 | 29 | f = open("/root/TEMP","w") 30 | f.write("{:.1f}".format(temp) + '\r\n') 31 | f.close() 32 | 33 | f = open("/root/HUMI","w") 34 | f.write(str(rel_hum) + '\r\n') 35 | f.close() 36 | -------------------------------------------------------------------------------- /Arduino Yun/thingspeak.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Send data to Thingspeak Server" 4 | 5 | #Thingspeak 6 | api_key='RW34BSSLBODV2HHK' 7 | 8 | DATE="$(date +"%d-%m-%Y")" 9 | read SHT31_TEMP < /tmp/TEMP 10 | echo "SHT31 Temperature = $TEMP *C" 11 | read SHT31_HUMI < /tmp/HUMI 12 | echo "SHT31 Rel. Humidity = $HUMI %RH" 13 | read OWM_TEMP < /root/TEMP 14 | echo "OWM Temperature = $TEMP *C" 15 | read OWM_HUMI < /tmp/HUMI 16 | echo "OWM Rel. Humidity = $HUMI %RH" 17 | 18 | curl --insecure --data \ 19 | "api_key=$api_key&field1=$SHT31_TEMP&field2=$SHT31_HUMI \ 20 | &field3=$OWM_TEMP&field4=$OWM_HUMI&field5=$DATE" \ 21 | https://api.thingspeak.com/update > log 2>&1 22 | -------------------------------------------------------------------------------- /Benchmarks/README.md: -------------------------------------------------------------------------------- 1 | ## Benchmark Programme für die verschiedenen Arduino 2 | 3 | Ein Benchmark hilft, ein entsprechendes Ranking vornehmen zu können. 4 | Es stehen hier verschiedene Benchmarks zur Verfügung, die unterschiedliche Aspekte der Hard- und Software betrachten. 5 | - Sieve of Eratosthenes 6 | - IOLoop 7 | - Dhrystone 8 | - Whetstone 9 | - IOBench 10 | - CoreMark 11 | -------------------------------------------------------------------------------- /CubeCell/Capsule_ChipID/Capsule_ChipID.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | 3 | // ChipID: 53A0FD032715 4 | 5 | void setup() 6 | { 7 | 8 | Serial.begin(115200); 9 | delay(2000); // wait for serial monitor 10 | 11 | Serial.println("\nRead ChipID from Heltec Capsule..."); 12 | 13 | uint64_t chipID=getID(); 14 | Serial.printf("ChipID: %04X%08X\r\n",(uint32_t)(chipID>>32),(uint32_t)chipID); 15 | } 16 | 17 | void loop() {} 18 | -------------------------------------------------------------------------------- /CubeCell/CubeCell-AB02A_LoRaWan/BMP280.ino: -------------------------------------------------------------------------------- 1 | // I2C bus connected BMP280 2 | 3 | #include 4 | 5 | BMP280 bmp; 6 | 7 | void initBMP280() 8 | { 9 | 10 | 11 | if (!bmp.begin(BMP280_ADDRESS_ALT)) // SDO open 12 | { 13 | if (DEBUG) Serial.println(F("Could not find a valid BMP280 sensor, check wiring!")); 14 | while (1); 15 | } 16 | 17 | /* Default settings from datasheet. */ 18 | bmp.setSampling(BMP280::MODE_NORMAL, /* Operating Mode. */ 19 | BMP280::SAMPLING_X2, /* Temp. oversampling */ 20 | BMP280::SAMPLING_X16, /* Pressure oversampling */ 21 | BMP280::FILTER_X16, /* Filtering. */ 22 | BMP280::STANDBY_MS_500); /* Standby time. */ 23 | } 24 | 25 | float getTemperature() 26 | { 27 | float temp = bmp.readTemperature(); 28 | return temp; 29 | } 30 | -------------------------------------------------------------------------------- /CubeCell/CubeCell_ChipID/CubeCell_ChipID.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | 3 | void setup() 4 | { 5 | 6 | Serial.begin(115200); 7 | delay(2000); // wait for serial monitor 8 | 9 | Serial.println("\nRead ChipID from Heltec CubeCell..."); 10 | 11 | uint64_t chipID=getID(); 12 | Serial.printf("ChipID: %04X%08X\r\n",(uint32_t)(chipID>>32),(uint32_t)chipID); 13 | } 14 | 15 | void loop() {} 16 | -------------------------------------------------------------------------------- /CubeCell/CubeCell_LoRaWan/batteryVoltage.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Measuring battery voltage of LiPo connected to CubeCell 3 | * 4 | */ 5 | uint16_t batteryVoltage() 6 | { 7 | pinMode(VBAT_ADC_CTL,OUTPUT); 8 | digitalWrite(VBAT_ADC_CTL,LOW); 9 | uint16_t voltage=analogRead(ADC)*2; 10 | digitalWrite(VBAT_ADC_CTL,HIGH); 11 | Serial.print("VBAT = "); 12 | Serial.print(voltage); 13 | Serial.println(" mV"); 14 | return voltage; 15 | } 16 | -------------------------------------------------------------------------------- /CubeCell/CubeCell_LowPower_WakeUpByTimer/CubeCell_DeepSleep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/CubeCell/CubeCell_LowPower_WakeUpByTimer/CubeCell_DeepSleep.png -------------------------------------------------------------------------------- /CubeCell/CubeCell_LowPower_WakeUpByTimer/CubeCell_LowPower_WakeUpByTimer.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include 3 | 4 | #define pLED GPIO2 // LED signalizes operational mode 5 | #define timetosleep 5000 // wake time 6 | #define timetowake 10000 // sleep time 7 | static TimerEvent_t sleep; 8 | static TimerEvent_t wakeUp; 9 | uint8_t lowpower=1; 10 | 11 | void onSleep() 12 | { 13 | Serial.printf("into lowpower mode, %d ms later wake up.\r\n",timetowake); 14 | digitalWrite(pLED, LOW); 15 | lowpower=1; 16 | //timetosleep ms later wake up; 17 | TimerSetValue( &wakeUp, timetowake ); 18 | TimerStart( &wakeUp ); 19 | } 20 | void onWakeUp() 21 | { 22 | Serial.printf("wake up, %d ms later into lowpower mode.\r\n",timetosleep); 23 | digitalWrite(pLED, HIGH); 24 | lowpower=0; 25 | //timetosleep ms later into lowpower mode; 26 | TimerSetValue( &sleep, timetosleep ); 27 | TimerStart( &sleep ); 28 | } 29 | 30 | void setup() { 31 | // put your setup code here, to run once: 32 | Serial.begin(115200); 33 | delay(2000); // wait for Serial Monitor 34 | 35 | Serial.printf("\nTest Deep Sleep and Timer Wakeup for CubeCell Module...\n"); 36 | Serial.printf("There are %d ms wake time followed by %d ms deep sleep time.\n\n", timetosleep, timetowake); 37 | boardInitMcu(); 38 | Radio.Sleep( ); 39 | pinMode(pLED, OUTPUT); 40 | digitalWrite(pLED, HIGH); 41 | TimerInit( &sleep, onSleep ); 42 | TimerInit( &wakeUp, onWakeUp ); 43 | onSleep(); 44 | } 45 | 46 | void loop() { 47 | if(lowpower){ 48 | //note that lowPowerHandler() run six times the mcu into lowpower mode; 49 | lowPowerHandler(); 50 | } 51 | // put your main code here, to run repeatedly: 52 | } 53 | -------------------------------------------------------------------------------- /CubeCell/CubeCell_RGB/CubeCell_RGB.ino: -------------------------------------------------------------------------------- 1 | #include "Adafruit_NeoPixel.h" 2 | 3 | #define PIN RGB // Pin driving DIN of first NeoPixel 4 | #define NUMPIXELS 3 // Number of NeoPixels in pixels or ring 5 | #define DELAYVAL 100 // Time (in milliseconds) to pause between pixels 6 | #define BRIGHTNESS 50 // Brightness of NeoPixel 7 | 8 | Adafruit_NeoPixel pixels(NUMPIXELS, RGB, NEO_GRB + NEO_KHZ400); 9 | 10 | void setup() 11 | { 12 | Serial.begin(115200); 13 | Serial.println("\nHeltec CubeCell test..."); 14 | 15 | pinMode(Vext,OUTPUT); 16 | digitalWrite(Vext,LOW); //SET POWER 17 | 18 | pixels.begin(); 19 | //pixels.setBrightness(BRIGHTNESS); 20 | pixels.show(); // Initialize all pixels to 'off' 21 | } 22 | 23 | uint8_t i=0, j=0; 24 | 25 | void loop() 26 | { 27 | pixels.setPixelColor(j, pixels.Color(i, 0, 0)); 28 | pixels.show(); // Send the updated pixel colors to the hardware. 29 | delay(200); // Pause before next pass through loop 30 | 31 | pixels.setPixelColor(j, pixels.Color(0, i, 0)); 32 | pixels.show(); // Send the updated pixel colors to the hardware. 33 | delay(200); // Pause before next pass through loop 34 | 35 | pixels.setPixelColor(j, pixels.Color(0, 0, i)); 36 | pixels.show(); // Send the updated pixel colors to the hardware. 37 | delay(200); // Pause before next pass through loop 38 | 39 | pixels.setPixelColor(j, pixels.Color(0, 0, 0)); 40 | 41 | i+=10; j++; if(j>=NUMPIXELS) j=0; 42 | } 43 | -------------------------------------------------------------------------------- /CubeCell/CubeCell_Settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/CubeCell/CubeCell_Settings.png -------------------------------------------------------------------------------- /ESP-NOW/ESP-NOW_Gateway_WiFi/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // This file contains credentials to access several services 2 | 3 | // WiFi 4 | const char* ssid = "Sunrise_2.4GHz_8AC2A0"; 5 | const char* pass = "u2u7fgzv31Ds"; 6 | 7 | // MQTT (CloudMQTT) 8 | /* 9 | const char* BROKER = "ade64e41caa64820a8546270f1a7fdbc.s1.eu.hivemq.cloud"; 10 | uint16_t BRPORT = 1883; 11 | const char* BRUSER = "ckuehnel"; 12 | const char* BRPWD = "Cksz0801"; 13 | const char* CLIENTID = "ESPNOW"; 14 | */ 15 | 16 | // MQTT (Public Broker) 17 | const char* BROKER = "broker.hivemq.com"; 18 | uint16_t BRPORT = 1883; 19 | const char* CLIENTID = "ESPNOW"; 20 | -------------------------------------------------------------------------------- /ESP-NOW/ESP-NOW_Gateway_WiFi/configureMQTT.ino: -------------------------------------------------------------------------------- 1 | void configureMQTT() 2 | { 3 | /* configure the MQTT server with IPaddress and port */ 4 | client.setServer(BROKER, BRPORT); 5 | /* this receivedCallback function will be invoked 6 | when client received subscribed topic */ 7 | client.setCallback(receivedCallback); 8 | } 9 | 10 | void receivedCallback(char* topic, byte* payload, unsigned int length) 11 | { 12 | Serial.print("Message received: "); 13 | Serial.println(topic); 14 | 15 | Serial.print("payload: "); 16 | for (int i = 0; i < length; i++) Serial.print((char)payload[i]); 17 | Serial.println(); 18 | } 19 | 20 | void mqttconnect() { 21 | /* Loop until reconnected */ 22 | while (!client.connected()) { 23 | Serial.println("\nMQTT connecting ..."); 24 | 25 | /* connect now */ 26 | if (client.connect(CLIENTID /*, BRUSER, BRPWD*/)) 27 | { 28 | Serial.println("connected"); 29 | } else { 30 | Serial.print("failed, status code ="); 31 | Serial.print(client.state()); 32 | Serial.println(" try again in 5 seconds"); 33 | /* Wait 5 seconds before retrying */ 34 | delay(5000); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ESP-NOW/ESP-NOW_Gateway_WiFi/connectWiFi.ino: -------------------------------------------------------------------------------- 1 | void connectWiFi() 2 | { 3 | int count = 0; 4 | Serial.print("Connecting to "); 5 | Serial.println(ssid); 6 | WiFi.begin(ssid, pass); 7 | 8 | while (WiFi.status() != WL_CONNECTED) 9 | { 10 | delay(500); 11 | Serial.print("."); 12 | count++; 13 | if (count > 15) ESP.restart(); 14 | } 15 | Serial.println(""); 16 | Serial.println("WiFi connected"); 17 | Serial.print("IP address: "); 18 | Serial.println(WiFi.localIP()); 19 | } 20 | -------------------------------------------------------------------------------- /ESP-NOW/Readme.md: -------------------------------------------------------------------------------- 1 | # Low-Power Sensornetzwerk 2 | 3 | Das im Blogbeitrag https://ckarduino.wordpress.com/2021/10/09/low-power-sensornetzwerk/ beschriebene Sensornetzwerk verwendet batterie- bzw. solarbetriebene Sensorknoten, 4 | die aus *DFRobot FireBeetle ESP32-E* oder *ThingPulse ePulse Low Power ESP32* Boards bestehen. Die erhobenen Messwerte werden über ESP-NOW an ein *ThingPulse ESP-Gateway* gesendet. 5 | 6 | Das *ThingPulse ESP-Gateway* besteht aus zwei ESP32-Wrover-IB-Modulen. Detaillierte Informationen zum *ThingPulse ESP-Gateway* sind unter der URL 7 | https://thingpulse.com/new-product-the-espgateway-design/ zu finden. 8 | 9 | Vom ersten ESP32 werden die über ESP-NOW gesendeten Messages empfangen (ESP-NOW Receiver), aufbereitet und seriell an den zweiten ESP32 im Gateway transferiert. 10 | Dieser übernimmt diese Daten und bereitet sie zum Versenden über MQTT auf. 11 | 12 | Die MQTT Messages sende ich an den Public MQTT Broker von HiveMQ (https://www.hivemq.com/public-mqtt-broker/). Mit einem MQTT Client auf einem PC, Tablet oder Smartphone 13 | können einzelne oder alle MQTT Messages abonniert (subscribed) werden. 14 | -------------------------------------------------------------------------------- /ESP32/ESP-NOW_Gateway_WiFi/configureMQTT.ino: -------------------------------------------------------------------------------- 1 | void configureMQTT() 2 | { 3 | /* configure the MQTT server with IPaddress and port */ 4 | client.setServer(BROKER, BRPORT); 5 | /* this receivedCallback function will be invoked 6 | when client received subscribed topic */ 7 | client.setCallback(receivedCallback); 8 | } 9 | 10 | void receivedCallback(char* topic, byte* payload, unsigned int length) 11 | { 12 | Serial.print("Message received: "); 13 | Serial.println(topic); 14 | 15 | Serial.print("payload: "); 16 | for (int i = 0; i < length; i++) Serial.print((char)payload[i]); 17 | Serial.println(); 18 | } 19 | 20 | void mqttconnect() { 21 | /* Loop until reconnected */ 22 | while (!client.connected()) { 23 | Serial.println("\nMQTT connecting ..."); 24 | 25 | /* connect now */ 26 | if (client.connect(CLIENTID /*, BRUSER, BRPWD*/)) 27 | { 28 | Serial.println("connected"); 29 | } else { 30 | Serial.print("failed, status code ="); 31 | Serial.print(client.state()); 32 | Serial.println(" try again in 5 seconds"); 33 | /* Wait 5 seconds before retrying */ 34 | delay(5000); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ESP32/ESP-NOW_Gateway_WiFi/connectWiFi.ino: -------------------------------------------------------------------------------- 1 | void connectWiFi() 2 | { 3 | int count = 0; 4 | Serial.print("Connecting to "); 5 | Serial.println(ssid); 6 | WiFi.begin(ssid, pass); 7 | 8 | while (WiFi.status() != WL_CONNECTED) 9 | { 10 | delay(500); 11 | Serial.print("."); 12 | count++; 13 | if (count > 15) ESP.restart(); 14 | } 15 | Serial.println(""); 16 | Serial.println("WiFi connected"); 17 | Serial.print("IP address: "); 18 | Serial.println(WiFi.localIP()); 19 | } 20 | -------------------------------------------------------------------------------- /ESP32/ESP32_BLE_Peripheral/getValues.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File getValues.ino 3 | * 4 | * Get measuring value from SHT31 sensor and 5 | * prepare a string for BLE output 6 | * 7 | */ 8 | void getValues(void) 9 | { 10 | float temp = sht31.getTemperature(); 11 | float hum = sht31.getHumidity(); 12 | 13 | temp = ((temp * 1000) + 0.5)/1000.0; 14 | 15 | char buff[10]; 16 | 17 | if (DEBUG) 18 | { 19 | Serial.println("--------------------------------"); 20 | Serial.print("Temp = "); Serial.print(temp,3); Serial.println(" *C"); 21 | Serial.print("Hum = "); Serial.print(hum,1); Serial.println(" %RH"); 22 | Serial.println(); 23 | } 24 | // print as CSV data 25 | values = ""; 26 | dtostrf(temp, 7, 3, buff); //4 is mininum width, 6 is precision // -10.000 27 | values += buff; values += ", "; 28 | dtostrf(hum, 4, 1, buff); //4 is mininum width, 6 is precision // 25.1 29 | values += buff; 30 | values += "\n"; 31 | Serial.print("Send BLE message: "); Serial.print(values); 32 | } 33 | -------------------------------------------------------------------------------- /ESP32/ESP32_BLE_Server/getValues.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File getValues.ino 3 | * 4 | * Get measuring value from SHT31 sensor and 5 | * prepare a string for BLE output 6 | * 7 | */ 8 | void getValues(void) 9 | { 10 | float temp = sht31.getTemperature(); 11 | float hum = sht31.getHumidity(); 12 | 13 | temp = ((temp * 1000) + 0.5)/1000.0; 14 | 15 | char buff[10]; 16 | 17 | if (DEBUG) 18 | { 19 | Serial.println("--------------------------------"); 20 | Serial.print("Temp = "); Serial.print(temp,3); Serial.println(" *C"); 21 | Serial.print("Hum = "); Serial.print(hum,1); Serial.println(" %RH"); 22 | Serial.println(); 23 | } 24 | // print as CSV data 25 | values = ""; 26 | dtostrf(temp, 7, 3, buff); //4 is mininum width, 6 is precision // -10.000 27 | values += buff; values += ", "; 28 | dtostrf(hum, 4, 1, buff); //4 is mininum width, 6 is precision // 25.1 29 | values += buff; 30 | values += "\n"; 31 | Serial.print("Send BLE message: "); Serial.print(values); 32 | } 33 | -------------------------------------------------------------------------------- /ESP32/ESP32_CCS811_ReadEnvData/filter.ino: -------------------------------------------------------------------------------- 1 | // Calculation of Moving Average to suppress noisy measuring values 2 | 3 | const uint8_t WINDOW_SIZE = 5; 4 | 5 | uint8_t idx_eCO2 = 0, idx_TVOC = 0; 6 | uint16_t value = 0; 7 | uint32_t sum_eCO2 = 0, sum_TVOC = 0; 8 | uint16_t readings_eCO2[WINDOW_SIZE], readings_TVOC[WINDOW_SIZE]; 9 | uint16_t average = 0; 10 | 11 | uint16_t movAverage_eCO2(uint16_t value) 12 | { 13 | sum_eCO2 = sum_eCO2 - readings_eCO2[idx_eCO2]; // Remove the oldest entry from the sum 14 | readings_eCO2[idx_eCO2] = value; 15 | sum_eCO2 = sum_eCO2 + value; 16 | idx_eCO2 = (idx_eCO2 + 1) % WINDOW_SIZE; 17 | average = sum_eCO2 / WINDOW_SIZE; 18 | return average; 19 | } 20 | 21 | uint16_t movAverage_TVOC(uint16_t value) 22 | { 23 | sum_TVOC = sum_TVOC - readings_TVOC[idx_TVOC]; // Remove the oldest entry from the sum 24 | readings_TVOC[idx_TVOC] = value; 25 | sum_TVOC = sum_TVOC + value; 26 | idx_TVOC = (idx_TVOC + 1) % WINDOW_SIZE; 27 | average = sum_TVOC / WINDOW_SIZE; 28 | return average; 29 | } 30 | -------------------------------------------------------------------------------- /ESP32/ESP32_CO2_Ampel/CO2 Green.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/ESP32/ESP32_CO2_Ampel/CO2 Green.jpg -------------------------------------------------------------------------------- /ESP32/ESP32_CO2_Ampel/CO2 Red.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/ESP32/ESP32_CO2_Ampel/CO2 Red.jpg -------------------------------------------------------------------------------- /ESP32/ESP32_CO2_Ampel/CO2 Yellow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/ESP32/ESP32_CO2_Ampel/CO2 Yellow.jpg -------------------------------------------------------------------------------- /ESP32/ESP32_CO2_Ampel/tone.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Controlling the buzzer 3 | */ 4 | 5 | #define BUZZER_CHANNEL 0 6 | 7 | void melody() 8 | { 9 | tone(BEEPER, NOTE_C5, 200, BUZZER_CHANNEL); 10 | noTone(BEEPER, BUZZER_CHANNEL); 11 | tone(BEEPER, NOTE_E5, 200, BUZZER_CHANNEL); 12 | noTone(BEEPER, BUZZER_CHANNEL); 13 | tone(BEEPER, NOTE_G5, 200, BUZZER_CHANNEL); 14 | noTone(BEEPER, BUZZER_CHANNEL); 15 | tone(BEEPER, NOTE_C6, 500, BUZZER_CHANNEL); 16 | noTone(BEEPER, BUZZER_CHANNEL); 17 | } 18 | 19 | 20 | void beeps() 21 | { 22 | for (int i = 0; i <3; i++) 23 | { 24 | tone(BEEPER, NOTE_F6, 200, BUZZER_CHANNEL); 25 | noTone(BEEPER, BUZZER_CHANNEL); 26 | delay(200); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ESP32/ESP32_T5_v2.3_Node/BMP280.ino: -------------------------------------------------------------------------------- 1 | // I2C bus connected BMP280 2 | 3 | #include 4 | #include 5 | 6 | Adafruit_BMP280 bmp; // I2C 7 | 8 | void initBMP280() 9 | { 10 | if (!bmp.begin(BMP280_ADDRESS_ALT)) // SDO open 11 | { 12 | if (DEBUG) Serial.println(F("Could not find a valid BMP280 sensor, check wiring!")); 13 | while (1); 14 | } 15 | 16 | /* Default settings from datasheet. */ 17 | bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */ 18 | Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */ 19 | Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */ 20 | Adafruit_BMP280::FILTER_X16, /* Filtering. */ 21 | Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */ 22 | } 23 | 24 | float getTemperature() 25 | { 26 | float temp = bmp.readTemperature(); 27 | return temp; 28 | } 29 | -------------------------------------------------------------------------------- /ESP32/ESP32_T5_v2.3_Node/WiFi.ino: -------------------------------------------------------------------------------- 1 | // Send measuring values to Telegram bot 2 | 3 | void sendMessage() 4 | { 5 | if (DEBUG) 6 | { 7 | // attempt to connect to Wifi network: 8 | Serial.print("Connecting to WiFi: "); 9 | Serial.println(ssid); 10 | } 11 | 12 | WiFi.mode(WIFI_STA); 13 | WiFi.disconnect(); 14 | WiFi.begin("Sunrise_2.4GHz_8AC2A0", "u2u7fgzv31Ds"); 15 | 16 | while (WiFi.status() != WL_CONNECTED) 17 | { 18 | if (DEBUG) Serial.print("."); 19 | delay(500); 20 | } 21 | 22 | if (DEBUG) 23 | { 24 | Serial.println("WiFi connected."); 25 | Serial.print("IP address: "); 26 | Serial.println(WiFi.localIP()); 27 | } 28 | String message = "Vbat: " + String(voltage) + " V\n"; 29 | message += "Temp: " + String(temp) + " *C"; 30 | bot.sendMessage(CHAT_ID, message, ""); 31 | } 32 | -------------------------------------------------------------------------------- /ESP32/ESP32_T5_v2.3_Node/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // This file contains credentials to access several services 2 | 3 | // Initialize Wifi connection to the router 4 | const char* ssid = "Sunrise_2.4GHz_8AC2A0"; 5 | const char* pw = "u2u7fgzv31Ds"; 6 | 7 | // Initialize Telegram BOT 8 | #define BOTtoken "1481753554:AAF8KXCdHyr56LoiaGIka27q5yYCWvkt0WY" // your Bot Token (Get from Botfather) 9 | #define CHAT_ID "929477751" 10 | -------------------------------------------------------------------------------- /ESP32/ESP32_TFT_graphicstest_PDQ/Readme: -------------------------------------------------------------------------------- 1 | The file User_setup.h contains the defines 2 | for the connection of ILI9341 display to ESP32 Dev kit -------------------------------------------------------------------------------- /ESP32/ESP32_ePulse/BMP280.ino: -------------------------------------------------------------------------------- 1 | // I2C bus connected BMP280 2 | 3 | #include 4 | #include 5 | 6 | Adafruit_BMP280 bmp; // I2C 7 | 8 | void initBMP280() 9 | { 10 | Wire.begin(21, 22); 11 | 12 | if (!bmp.begin(BMP280_ADDRESS_ALT)) // SDO open 13 | { 14 | if (DEBUG) Serial.println(F("Could not find a valid BMP280 sensor, check wiring!")); 15 | while (1); 16 | } 17 | 18 | /* Default settings from datasheet. */ 19 | bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */ 20 | Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */ 21 | Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */ 22 | Adafruit_BMP280::FILTER_X16, /* Filtering. */ 23 | Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */ 24 | } 25 | 26 | float getTemperature() 27 | { 28 | float temp = bmp.readTemperature(); 29 | return temp; 30 | } 31 | -------------------------------------------------------------------------------- /ESP32/ESP32_ePulse/WiFi.ino: -------------------------------------------------------------------------------- 1 | // Send measuring values to Telegram bot 2 | 3 | void sendMessage() 4 | { 5 | if (DEBUG) 6 | { 7 | // attempt to connect to Wifi network: 8 | Serial.print("Connecting to WiFi: "); 9 | Serial.println(ssid); 10 | } 11 | 12 | WiFi.mode(WIFI_STA); 13 | WiFi.disconnect(); 14 | WiFi.begin("Sunrise_2.4GHz_8AC2A0", "u2u7fgzv31Ds"); 15 | 16 | while (WiFi.status() != WL_CONNECTED) 17 | { 18 | if (DEBUG) Serial.print("."); 19 | delay(500); 20 | } 21 | 22 | if (DEBUG) 23 | { 24 | Serial.println("WiFi connected."); 25 | Serial.print("IP address: "); 26 | Serial.println(WiFi.localIP()); 27 | } 28 | String message = "Vbat: " + String(voltage) + " V\n"; 29 | message += "Temp: " + String(temp) + " *C"; 30 | bot.sendMessage(CHAT_ID, message, ""); 31 | } 32 | -------------------------------------------------------------------------------- /ESP32/ESP32_ePulse/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // This file contains credentials to access several services 2 | 3 | // Initialize Wifi connection to the router 4 | const char* ssid = "Sunrise_2.4GHz_8AC2A0"; 5 | const char* pw = "u2u7fgzv31Ds"; 6 | 7 | // Initialize Telegram BOT 8 | #define BOTtoken "1481682315:AAEqbGjYlKqLTnA-ZkM5qk-u0eJenDvtyQY" // your Bot Token (Get from Botfather) 9 | #define CHAT_ID "929477751" 10 | -------------------------------------------------------------------------------- /ESP32/Heltec_LoRa32_TTN/getValue.ino: -------------------------------------------------------------------------------- 1 | // This function read a DHT11 sensor 2 | 3 | void getValue() 4 | { 5 | if (DEBUG) 6 | { 7 | Serial.println("---------------------------------------"); 8 | Serial.println("Get DHT11 sensor data and build package"); 9 | } 10 | float temperature = dht.readTemperature(); 11 | float humidity = dht.readHumidity(); 12 | 13 | if (DEBUG) 14 | { 15 | Serial.print("Measured temperature = "); 16 | Serial.print(temperature, 1); 17 | Serial.println(" *C"); 18 | Serial.print("Measured humidity = "); 19 | Serial.print(humidity, 0); 20 | Serial.println(" % rH"); 21 | } 22 | 23 | char buffer[5]; 24 | String s = dtostrf(temperature, 3, 1, buffer); 25 | display.clear(); 26 | display.drawString(0, 0, "Temp = "); 27 | display.drawString(72, 0, s); 28 | display.drawString(104, 0, " °C"); 29 | 30 | s = dtostrf(humidity, 3, 0, buffer); 31 | display.drawString(0, 16, "Hum = "); 32 | display.drawString(72, 16, s); 33 | display.drawString(104, 16, " %"); 34 | 35 | display.display(); 36 | 37 | int16_t temp = (int) ((temperature *100) + .5); 38 | uint16_t humi = (int) humidity * 10; 39 | 40 | // Tx package 41 | mydata[0] = lowByte(humi); 42 | mydata[1] = highByte(humi); 43 | mydata[2] = lowByte(temp); 44 | mydata[3] = highByte(temp); 45 | } 46 | -------------------------------------------------------------------------------- /ESP32/Heltec_LoRa32_Transmit/debug.log: -------------------------------------------------------------------------------- 1 | [0407/112747.565:ERROR:crash_report_database_win.cc(469)] failed to stat report 2 | [0407/113137.423:ERROR:crash_report_database_win.cc(469)] failed to stat report 3 | [0407/113449.189:ERROR:crash_report_database_win.cc(469)] failed to stat report 4 | [0408/002053.311:ERROR:crash_report_database_win.cc(469)] failed to stat report 5 | [0408/002059.986:ERROR:crash_report_database_win.cc(469)] failed to stat report 6 | [0408/102246.509:ERROR:crash_report_database_win.cc(469)] failed to stat report 7 | [0408/102956.740:ERROR:crash_report_database_win.cc(469)] failed to stat report 8 | [0408/104150.300:ERROR:crash_report_database_win.cc(469)] failed to stat report 9 | [0408/111145.833:ERROR:crash_report_database_win.cc(469)] failed to stat report 10 | -------------------------------------------------------------------------------- /ESP32/HiGrowESP32Pushover/README.md: -------------------------------------------------------------------------------- 1 | ## Messung von Umgebungsbedingungen für Pflanzen mit LILYGO®TTGO T-Higrow Sensor 2 | 3 | Programm zum o.a. Blogbeitrag \ 4 | https://ckarduino.wordpress.com/2021/11/16/messung-von-umgebungsbedingungen-fur-pflanzen-mit-lilygottgo-t-higrow-sensor/ 5 | 6 | Ergebnis der Compilation ist im Screenshot dokumentiert. 7 | -------------------------------------------------------------------------------- /ESP32/HiGrowESP32Pushover/Screenshot 2022-07-14 131320.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/ESP32/HiGrowESP32Pushover/Screenshot 2022-07-14 131320.jpg -------------------------------------------------------------------------------- /ESP32/HiGrowESP32Pushover/WiFi.ino: -------------------------------------------------------------------------------- 1 | void connectWiFi() 2 | { 3 | int count = 0; 4 | Serial.print("Connecting to "); 5 | Serial.println(SSID); 6 | WiFi.begin(SSID, PASS); 7 | 8 | while (WiFi.status() != WL_CONNECTED) 9 | { 10 | delay(500); 11 | Serial.print("."); 12 | count++; 13 | if (count > 15) ESP.restart(); 14 | } 15 | Serial.println(""); 16 | Serial.println("WiFi connected"); 17 | Serial.print("IP address: "); 18 | Serial.println(WiFi.localIP()); 19 | } 20 | -------------------------------------------------------------------------------- /ESP32/HiGrowESP32Pushover/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // This file contains credentials to access several services 2 | 3 | // WiFi 4 | const char* SSID = ""; 5 | const char* PASS = ""; 6 | 7 | // Pushover settings 8 | char pushoversite[] = "api.pushover.net"; 9 | char apitoken[] = ""; 10 | char userkey [] = ""; 11 | -------------------------------------------------------------------------------- /ESP32/HiGrowESP32Pushover/pushOver.ino: -------------------------------------------------------------------------------- 1 | void pushover(char *pushovermessage, int priority) 2 | { 3 | String message = pushovermessage; 4 | 5 | int length = 113 + message.length(); 6 | 7 | if(client.connect(pushoversite,80)) 8 | { 9 | client.println("POST /1/messages.json HTTP/1.1"); 10 | client.println("Host: api.pushover.net"); 11 | client.println("Connection: close\r\nContent-Type: application/x-www-form-urlencoded"); 12 | client.print("Content-Length: "); 13 | client.print(length); 14 | client.println("\r\n");; 15 | client.print("token="); 16 | client.print(apitoken); 17 | client.print("&user="); 18 | client.print(userkey); 19 | client.print("&message="); 20 | client.print(message); 21 | client.print("&priority="); 22 | client.print(priority); 23 | client.print("&retry=60"); 24 | client.print("&expire=3600"); 25 | while(client.connected()) 26 | { 27 | while(client.available()) 28 | { 29 | char ch = client.read(); 30 | Serial.write(ch); 31 | } 32 | } 33 | client.stop(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ESP32/HiGrowESP32Pushover/wakeup.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Method to print the reason by which ESP32 3 | * has been awaken from sleep 4 | */ 5 | void print_wakeup_reason() 6 | { 7 | esp_sleep_wakeup_cause_t wakeup_reason; 8 | 9 | wakeup_reason = esp_sleep_get_wakeup_cause(); 10 | 11 | switch(wakeup_reason) 12 | { 13 | case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break; 14 | case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break; 15 | case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break; 16 | case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break; 17 | case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break; 18 | default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ESP32/README.md: -------------------------------------------------------------------------------- 1 | ## ESP-32 2 | 3 | Diese Verzeichnis enthält ESP-32 Programme für WiFi, BLE und LoRaWAN. 4 | Ein erstes Beispiel zu KI ist ebenfalls enhalten. 5 | -------------------------------------------------------------------------------- /ESP32/SineExample/SineExample.ino: -------------------------------------------------------------------------------- 1 | #include 2 | // sine_model.h contains the array you exported from the previous step with xxd or tinymlgen 3 | #include "sine_model.h" 4 | 5 | #define NUMBER_OF_INPUTS 1 6 | #define NUMBER_OF_OUTPUTS 1 7 | // in future projects you may need to tweek this value: it's a trial and error process 8 | #define TENSOR_ARENA_SIZE 2*1024 9 | 10 | Eloquent::TinyML::TfLite ml(sine_model); 11 | 12 | #define PLOT 0 13 | 14 | void setup() { 15 | Serial.begin(115200); 16 | } 17 | 18 | void loop() { 19 | // pick up a random x and predict its sine 20 | float x = PI * random(100) / 100; 21 | float y = sin(x); 22 | float input[1] = { x }; 23 | float predicted = ml.predict(input); 24 | 25 | if (PLOT) 26 | { 27 | Serial.print("Deviation [%] "); 28 | Serial.println((predicted - y)*100); 29 | delay(200); 30 | } 31 | else 32 | { 33 | Serial.print("sin("); 34 | Serial.print(x); 35 | Serial.print(") = "); 36 | Serial.print(y); 37 | Serial.print("\t predicted: "); 38 | Serial.print(predicted); 39 | Serial.print("\t deviation: "); 40 | Serial.println(predicted - y, 4); 41 | delay(1000); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /ESP32/get_ESP_MAC_Address/get_ESP_MAC_Address.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: get_ESP_MAC_Address.ino 3 | * 4 | * Get MAC address of ESP32 or ESP8266 microcontroller board 5 | * 6 | */ 7 | 8 | #ifdef ESP32 9 | #include 10 | #else 11 | #include 12 | #endif 13 | 14 | void setup() 15 | { 16 | Serial.begin(115200); 17 | while(!Serial); 18 | Serial.print("\nESP Board MAC Address: "); 19 | Serial.println(WiFi.macAddress()); 20 | } 21 | 22 | void loop(){} 23 | -------------------------------------------------------------------------------- /ESP32/mi_temp3/config.h: -------------------------------------------------------------------------------- 1 | // here are all non-public data 2 | 3 | char* LYWSD03MMC_ADDR[] = 4 | { 5 | "a4:c1:38:3c:e4:e2", 6 | "a4:c1:38:76:97:b3" 7 | }; 8 | 9 | static int deviceCount = sizeof LYWSD03MMC_ADDR / sizeof LYWSD03MMC_ADDR[0]; 10 | 11 | BLEClient* pClient; 12 | 13 | const char* WIFI_SSID = ""; 14 | const char* WIFI_PASSWORD = ""; 15 | 16 | const char* MQTT_HOST = "broker.hivemq.com"; 17 | const int MQTT_PORT = 1883; 18 | const char* MQTT_CLIENTID = "mi-temp-client"; 19 | const char* MQTT_USERNAME = ""; 20 | const char* MQTT_PASSWORD = ""; 21 | const String MQTT_BASE_TOPIC = "LYWSD03MMC"; 22 | const int MQTT_RETRY_WAIT = 5000; 23 | 24 | // sleep between to runs in seconds 30*60=30min 25 | #define SLEEP_DURATION 30 * 10 // Sleep for 5 min 26 | // emergency hibernate countdown in seconds 27 | #define EMERGENCY_HIBERNATE 3 * 60 28 | // how often should the battery be read - in run count 29 | #define BATTERY_INTERVAL 6 30 | // how often should a device be retried in a run when something fails 31 | #define RETRY 3 32 | -------------------------------------------------------------------------------- /ESP8266/ESP8266_D1Lamp/Menu Tools.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/ESP8266/ESP8266_D1Lamp/Menu Tools.png -------------------------------------------------------------------------------- /ESP8266/ESP8266_D1Lamp/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // This file contains credentials to access several services 2 | 3 | const char* mySSID = "Sunrise_2.4GHz_8AC2A0"; 4 | const char* myPW = "u2u7fgzv31Ds"; 5 | 6 | // MQTT (CloudMQTT) 7 | const char* BROKER = "m20.cloudmqtt.com"; 8 | uint16_t BRPORT = 12394; 9 | const char* BRUSER = "rawyjpid"; 10 | const char* BRPWD = "ah52k3gjd8JS"; 11 | const char* CLIENTID = "D1Lamp"; 12 | -------------------------------------------------------------------------------- /ESP8266/ESP8266_D1Lamp/functions.ino: -------------------------------------------------------------------------------- 1 | void led_set(uint8 R, uint8 G, uint8 B) 2 | { 3 | for (int i = 0; i < LED_NUM; i++) leds.setPixelColor(i, leds.Color(R, G, B)); 4 | leds.show(); 5 | } 6 | 7 | void flash(uint8 R, uint8 G, uint8 B) 8 | { 9 | led_set(R, G, B); 10 | delay(200); 11 | led_set(0, 0, 0); 12 | } 13 | -------------------------------------------------------------------------------- /ESP8266/ESP8266_TH_Webserver/ESP8266_TH_Webserver.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/ESP8266/ESP8266_TH_Webserver/ESP8266_TH_Webserver.jpg -------------------------------------------------------------------------------- /ESP8266/ESP8266_TH_Webserver/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // This file contains credentials to access several services 2 | 3 | const char* ssid = "Sunrise_2.4GHz_8AC2A0"; 4 | const char* password = "u2u7fgzv31Ds"; 5 | -------------------------------------------------------------------------------- /GMC/M5Atom_GMC_Cajoe/WiFi.ino: -------------------------------------------------------------------------------- 1 | // WiFi Initialization 2 | 3 | void initWiFi() 4 | { 5 | WiFi.mode(WIFI_STA); 6 | Serial.print("\nConnecting to "); 7 | Serial.println(ssid); 8 | WiFi.disconnect(); 9 | WiFi.begin(ssid,password); 10 | Serial.print("MAC: " ); Serial.println(WiFi.macAddress()); 11 | while (WiFi.status() != WL_CONNECTED) 12 | { 13 | Serial.print("."); 14 | M5.dis.drawpix(0, 0x0000f0); // BLUE 15 | delay(500); 16 | M5.dis.drawpix(0, 0x000000); // DARK 17 | delay(500); 18 | } 19 | Serial.println("\nWiFi connected"); 20 | M5.dis.drawpix(0, 0x0000f0); // BLUE 21 | Serial.print("IP address: "); 22 | Serial.println(WiFi.localIP()); 23 | } 24 | -------------------------------------------------------------------------------- /GMC/M5Atom_GMC_Cajoe/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // This file contains credentials to access several services 2 | 3 | // WiFi 4 | const char* ssid = "Sunrise_2.4GHz_8AC2A0"; 5 | const char* password = "u2u7fgzv31Ds"; 6 | 7 | // Thingspeak 8 | unsigned long myChannelNumber = 1712033; 9 | const char * myWriteAPIKey = "M3TOPRKY8FUGKN8X"; 10 | -------------------------------------------------------------------------------- /GMC/M5StickC_GMC_Gravity/LCD.ino: -------------------------------------------------------------------------------- 1 | // Display routines 2 | 3 | void initLCD(void) 4 | { 5 | M5.Lcd.setRotation(3); 6 | M5.Lcd.setFreeFont(FF12); // Select the font 7 | M5.Lcd.setTextDatum(BL_DATUM); 8 | M5.Lcd.fillRect(0,0,displayHeight,18, BLUE); 9 | M5.Lcd.setTextColor(TFT_ORANGE, BLUE); 10 | M5.Lcd.setCursor(0, 16); 11 | M5.Lcd.print("GMC Data"); 12 | M5.Lcd.setFreeFont(FF18); 13 | M5.Lcd.setTextColor(WHITE, BLACK); 14 | } 15 | 16 | void dispValue(uint32_t number) 17 | { 18 | M5.Lcd.fillRect(0,40,displayHeight,20, BLACK); 19 | M5.Lcd.setTextColor(WHITE, BLACK); 20 | M5.Lcd.drawString(String(number)+ " CPM", 20, 60, GFXFF); 21 | } 22 | -------------------------------------------------------------------------------- /GMC/M5StickC_GMC_Gravity/WiFi.ino: -------------------------------------------------------------------------------- 1 | // WiFi Initialization 2 | 3 | void initWiFi() 4 | { 5 | WiFi.mode(WIFI_STA); 6 | Serial.print("\nConnecting to "); 7 | Serial.println(ssid); 8 | WiFi.disconnect(); 9 | WiFi.begin(ssid,password); 10 | Serial.print("MAC: " );Serial.println(WiFi.macAddress()); 11 | while (WiFi.status() != WL_CONNECTED) 12 | { 13 | delay(500); 14 | Serial.print("."); 15 | } 16 | Serial.println("\nWiFi connected"); 17 | Serial.print("IP address: "); 18 | Serial.println(WiFi.localIP()); 19 | } 20 | -------------------------------------------------------------------------------- /GMC/M5StickC_GMC_Gravity/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // This file contains credentials to access several services 2 | 3 | // WiFi 4 | const char* ssid = "Sunrise_2.4GHz_8AC2A0"; 5 | const char* password = "u2u7fgzv31Ds"; 6 | 7 | // Thingspeak 8 | unsigned long myChannelNumber = 1710914; 9 | const char * myWriteAPIKey = "DWKKV3AZQK2I2AKV"; 10 | -------------------------------------------------------------------------------- /GMC/M5StickC_GMC_PiGI/LCD.ino: -------------------------------------------------------------------------------- 1 | // Display routines 2 | 3 | void initLCD(void) 4 | { 5 | M5.Lcd.setRotation(3); 6 | M5.Lcd.setFreeFont(FF12); // Select the font 7 | M5.Lcd.setTextDatum(BL_DATUM); 8 | M5.Lcd.fillRect(0,0,displayHeight,18, BLUE); 9 | M5.Lcd.setTextColor(TFT_ORANGE, BLUE); 10 | M5.Lcd.setCursor(0, 16); 11 | M5.Lcd.print("GMC Data FZV75"); 12 | M5.Lcd.setFreeFont(FF18); 13 | M5.Lcd.setTextColor(WHITE, BLACK); 14 | } 15 | 16 | void dispValue(uint32_t number) 17 | { 18 | M5.Lcd.fillRect(0,40,displayHeight,20, BLACK); 19 | M5.Lcd.setTextColor(WHITE, BLACK); 20 | M5.Lcd.drawString(String(number)+ " CPM", 20, 60, GFXFF); 21 | } 22 | -------------------------------------------------------------------------------- /GMC/M5StickC_GMC_PiGI/WiFi.ino: -------------------------------------------------------------------------------- 1 | // WiFi Initialization 2 | 3 | void initWiFi() 4 | { 5 | WiFi.mode(WIFI_STA); 6 | Serial.print("\nConnecting to "); 7 | Serial.println(ssid); 8 | WiFi.disconnect(); 9 | WiFi.begin(ssid,password); 10 | Serial.print("MAC: " );Serial.println(WiFi.macAddress()); 11 | while (WiFi.status() != WL_CONNECTED) 12 | { 13 | delay(500); 14 | Serial.print("."); 15 | } 16 | Serial.println("\nWiFi connected"); 17 | Serial.print("IP address: "); 18 | Serial.println(WiFi.localIP()); 19 | } 20 | -------------------------------------------------------------------------------- /GMC/M5StickC_GMC_PiGI/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // This file contains credentials to access several services 2 | 3 | // WiFi 4 | const char* ssid = "Sunrise_2.4GHz_8AC2A0"; 5 | const char* password = "u2u7fgzv31Ds"; 6 | 7 | // Thingspeak 8 | unsigned long myChannelNumber = 1713372; 9 | const char * myWriteAPIKey = "IJPKON3LZB40J6YD"; 10 | -------------------------------------------------------------------------------- /GMC/M5StickC_GMC_Test/LCD.ino: -------------------------------------------------------------------------------- 1 | // Display routines 2 | 3 | void initLCD(void) 4 | { 5 | M5.Lcd.setRotation(3); 6 | M5.Lcd.setFreeFont(FF12); // Select the font 7 | M5.Lcd.setTextDatum(BL_DATUM); 8 | M5.Lcd.fillRect(0,0,displayHeight,18, BLUE); 9 | M5.Lcd.setTextColor(TFT_ORANGE, BLUE); 10 | M5.Lcd.setCursor(0, 16); 11 | M5.Lcd.print("GMC PulseCount"); 12 | M5.Lcd.setFreeFont(FF18); 13 | M5.Lcd.setTextColor(WHITE, BLACK); 14 | } 15 | 16 | void dispValue(uint32_t number) 17 | { 18 | M5.Lcd.fillRect(0,40,displayHeight,20, BLACK); 19 | M5.Lcd.setTextColor(WHITE, BLACK); 20 | M5.Lcd.drawString(String(number)+ " cpm", 20, 60, GFXFF); 21 | } 22 | -------------------------------------------------------------------------------- /GMC/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Generic/Calculation/Calculation.ino: -------------------------------------------------------------------------------- 1 | #define TEST "Calculation" 2 | 3 | void setup() 4 | { 5 | Serial.begin(115200); 6 | while(!Serial); 7 | Serial.println(TEST); 8 | 9 | Serial.println((1+2/3)*4-5); 10 | Serial.print((1+2./3)*4-5); 11 | } 12 | 13 | void loop() 14 | { 15 | // nothing to do here 16 | } 17 | -------------------------------------------------------------------------------- /Generic/ExternalInterrupts/ExternalInterrupts.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: ExternalInterrupts.ino 3 | * 4 | * Test of External Interrupts for Arduino Uno 5 | * 2020-01-26 Claus Kühnel info@ckuehnel.ch 6 | */ 7 | 8 | const int pINT0 = 2; // INT0 at Pin2 9 | const int pINT1 = 3; // INT1 at Pin3 10 | 11 | volatile boolean iflag = true; 12 | 13 | int idx; 14 | 15 | void setup() 16 | { 17 | Serial.begin(115200); 18 | 19 | pinMode(LED_BUILTIN, OUTPUT); 20 | pinMode(pINT0, INPUT_PULLUP); 21 | pinMode(pINT1, INPUT_PULLUP); 22 | 23 | attachInterrupt(digitalPinToInterrupt(pINT0), stop_serial, FALLING); // INT0 stops serial output 24 | Serial.print("EICRA: "); Serial.println(EICRA, HEX); 25 | attachInterrupt(digitalPinToInterrupt(pINT1), resume_serial, FALLING); // INT1 resumes serial output 26 | Serial.print("EICRA: "); Serial.println(EICRA, HEX); 27 | Serial.println("Setup finished."); 28 | } 29 | 30 | void loop() 31 | { 32 | if (iflag) Serial.println(idx); // iflag controls serial output 33 | idx++; 34 | delay(500); 35 | } 36 | 37 | void stop_serial() 38 | { 39 | iflag = false; 40 | digitalWrite(LED_BUILTIN, HIGH); 41 | } 42 | 43 | void resume_serial() 44 | { 45 | iflag = true; 46 | digitalWrite(LED_BUILTIN, LOW); 47 | } 48 | -------------------------------------------------------------------------------- /Generic/FlipDot/FlipDot.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: FlipDot.ino 3 | * 4 | * Controlling Flip Dot Status Indicator by H-Bridge 5 | * short video: https://youtu.be/UxTjOamWLgs 6 | * 7 | * 2021-12-01 claus Kühnel info@ckuehnel.ch 8 | */ 9 | 10 | #define DEBUG 1 11 | 12 | const int IN1 = 2; 13 | const int IN2 = 3; 14 | 15 | void setup() 16 | { 17 | Serial.begin(115200); 18 | delay(2000); // wait for serial monitor 19 | 20 | pinMode(IN1, OUTPUT); 21 | pinMode(IN2, OUTPUT); 22 | 23 | digitalWrite(IN1, LOW); 24 | digitalWrite(IN2, LOW); 25 | } 26 | 27 | void loop() 28 | { 29 | FlipDotOn(); 30 | delay(2500); 31 | FlipDotOff(); 32 | delay(2500); 33 | } 34 | 35 | bool FlipDotOff(void) 36 | { 37 | if (DEBUG) Serial.println("FlipDot Off"); 38 | digitalWrite(IN1, HIGH); 39 | digitalWrite(IN2, LOW); 40 | delayMicroseconds(1500); 41 | digitalWrite(IN1, LOW); 42 | return true; 43 | } 44 | 45 | bool FlipDotOn(void) 46 | { 47 | if (DEBUG) Serial.println("FlipDot On"); 48 | digitalWrite(IN1, LOW); 49 | digitalWrite(IN2, HIGH); 50 | delayMicroseconds(1500); 51 | digitalWrite(IN2, LOW); 52 | return false; 53 | } 54 | -------------------------------------------------------------------------------- /Generic/HC_SR04_Proximity/HC_SR04_Proximity.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: HC_SR04_Proximity.ino 3 | * http://wolles-elektronikkiste.de/hc-sr04-und-jsn-sr04t-2-0-abstandssensoren 4 | * 5 | */ 6 | 7 | int triggerPin = 8; 8 | int echoPin = 9; 9 | 10 | int cmDistance, tCorrectedCmDistance; 11 | //int temperature = 0; 12 | unsigned long duration; 13 | 14 | void setup() 15 | { 16 | pinMode(triggerPin, OUTPUT); 17 | pinMode(echoPin, INPUT); 18 | Serial.begin(115200); 19 | delay(10); 20 | } 21 | 22 | void loop() 23 | { 24 | digitalWrite(triggerPin, HIGH); 25 | delayMicroseconds(20); 26 | digitalWrite(triggerPin, LOW); 27 | duration = pulseIn(echoPin, HIGH); 28 | 29 | // Schallgeschwindigkeit in Luft: 343m/S (bei 20°C) 30 | // 343,2 m/S --> 34,32cm / ms --> 0,03432cm / µs 31 | // durch 2 wg. Echo 32 | cmDistance = duration * 0.03432 / 2; 33 | // tCorrectedCmDistance = duration *(0.03315 + 0.00006 * temperature)/2; 34 | Serial.print("Distanz [cm]: "); 35 | Serial.println(cmDistance); 36 | // Serial.print("T-korrigierte Distanz [cm]: "); 37 | // Serial.println(tCorrectedCmDistance); 38 | delay(500); 39 | } 40 | -------------------------------------------------------------------------------- /Generic/Progmem/Progmem.ino: -------------------------------------------------------------------------------- 1 | /* File: Progmem.ino 2 | * 3 | * The following code fragments illustrate how to read and write 4 | * unsigned chars (bytes) and ints (2 bytes) from/to PROGMEM. 5 | */ 6 | 7 | // save some unsigned ints 8 | const uint16_t charSet[] PROGMEM = { 1111, 2222, 3333, 4444, 5555}; 9 | 10 | // save some chars 11 | const char signMessage[] PROGMEM = {"This text is saved on Flash"}; 12 | 13 | unsigned int myInt; 14 | char myChar; 15 | 16 | 17 | void setup() 18 | { 19 | Serial.begin(115200); 20 | while (!Serial); // wait for serial port to connect. Needed for native USB 21 | 22 | Serial.println(F("Test of reading from flash memory\n")); 23 | 24 | // read back a 2-byte int 25 | for (byte k = 0; k < 5; k++) 26 | { 27 | myInt = pgm_read_word_near(charSet + k); 28 | Serial.println(myInt); 29 | } 30 | Serial.println(); 31 | 32 | // read back a char 33 | for (byte k = 0; k < strlen_P(signMessage); k++) 34 | { 35 | myChar = pgm_read_byte_near(signMessage + k); 36 | Serial.print(myChar); 37 | } 38 | 39 | Serial.println(); 40 | } 41 | 42 | void loop() {} 43 | -------------------------------------------------------------------------------- /Generic/README.md: -------------------------------------------------------------------------------- 1 | In diesem Verzeichnis sind allgemeine Codebeispiele abgelegt, auf die im Text Bezug genommen wird 2 | -------------------------------------------------------------------------------- /Generic/SerialOutBT/SerialOutBT.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SerialOutBT.ino 3 | Serial output via Bluetooth for ATmega328 based Arduinos 4 | (c) Claus Kuehnel 2018-12-16 info@ckuehnel.ch 5 | 6 | Connect 7 | Arduino® HC-05 8 | ---------------- 9 | 5 V VCC 10 | GND GND 11 | D10 Rx 12 | D12 Tx 13 | */ 14 | 15 | #include 16 | 17 | const byte rxPin = 12; 18 | const byte txPin = 10; 19 | 20 | // set up a new serial object 21 | SoftwareSerial BTSerial (rxPin, txPin); 22 | 23 | // define your board here 24 | #define BOARD "Arduino Leonardo" 25 | //#define BOARD "Arduino M0" 26 | 27 | //#define Serial SerialUSB // Arduino M0 native port 28 | 29 | void setup() 30 | { 31 | Serial.begin(115200); 32 | while(!Serial); // for native port 33 | // delay(2000); 34 | Serial.print(BOARD); 35 | Serial.println(" starts BT communication..."); 36 | 37 | BTSerial.begin(9600); 38 | BTSerial.print("This is "); 39 | BTSerial.println(BOARD); 40 | } 41 | 42 | void loop() 43 | { 44 | Serial.print("*"); 45 | BTSerial.print("*"); 46 | delay(1000); 47 | } 48 | -------------------------------------------------------------------------------- /Generic/SerialOutBTM0/SerialOutBTM0.ino: -------------------------------------------------------------------------------- 1 | /* 2 | SerialOutBTM0.ino 3 | Serial output via Bluetooth for Arduino M0 4 | (c) Claus Kuehnel 2018-12-16 info@ckuehnel.ch 5 | 6 | Connect 7 | Arduino® HC-10 8 | ---------------- 9 | 5 V VCC 10 | GND GND 11 | D10 Rx 12 | D12 Tx 13 | */ 14 | 15 | // Serial2 pin and pad definitions (in Arduino files Variant.h & Variant.cpp) 16 | #define PIN_SERIAL2_RX (34ul) // Pin description number for PIO_SERCOM on D12 17 | #define PIN_SERIAL2_TX (36ul) // Pin description number for PIO_SERCOM on D10 18 | #define PAD_SERIAL2_TX (UART_TX_PAD_2) // SERCOM pad 2 19 | #define PAD_SERIAL2_RX (SERCOM_RX_PAD_3) // SERCOM pad 3 20 | 21 | // Instantiate the Serial2 class 22 | Uart Serial2(&sercom1, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX); 23 | 24 | void SERCOM1_Handler() // Interrupt handler for SERCOM1 25 | { 26 | Serial2.IrqHandler(); 27 | } 28 | 29 | // define your board here 30 | //#define BOARD "Arduino Leonardo" 31 | #define BOARD "Arduino M0" 32 | 33 | #define Serial SerialUSB // Arduino M0 native port 34 | 35 | void setup() 36 | { 37 | Serial.begin(115200); 38 | while(!Serial); // for native port 39 | // delay(2000); 40 | Serial.print(BOARD); 41 | Serial.println(" starts BT communication..."); 42 | 43 | Serial2.begin(9600); 44 | Serial2.print("This is "); 45 | Serial2.println(BOARD); 46 | } 47 | 48 | void loop() 49 | { 50 | Serial.print("*"); 51 | Serial2.print("*"); 52 | delay(1000); 53 | } 54 | -------------------------------------------------------------------------------- /Generic/add/add.ino: -------------------------------------------------------------------------------- 1 | 2 | unsigned int add(unsigned int a, unsigned int b); // Deklaration der Funktion 3 | 4 | void setup() 5 | { 6 | Serial.begin(115200); 7 | 8 | unsigned int a = 35, b = 10; // Deklaration und Initialisierung der Variablen 9 | unsigned int x = add(a, b); // Aufruf der Funktion add(a, b) 10 | Serial.println(x); // serielle Ausgabe des Rückgabewertes der Funktion 11 | } 12 | 13 | void loop() {} 14 | 15 | unsigned int add(unsigned int a, unsigned int b) // Definition der Funktion 16 | { 17 | unsigned int x = a+b; 18 | return x; 19 | } 20 | -------------------------------------------------------------------------------- /Generic/array/array.ino: -------------------------------------------------------------------------------- 1 | // File: array.ino 2 | 3 | void setup() 4 | { 5 | Serial.begin(115200); 6 | 7 | int array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; 8 | for(int i = 0; i < 10; ++i) 9 | { 10 | Serial.println(array[i]); 11 | } 12 | Serial.println(); 13 | Serial.println(array[5]); // Zugriff über Index 14 | Serial.println(*(array + 5)); // Zugriff über Zeiger 15 | Serial.println(); 16 | Serial.print(" Array Size: "); Serial.println(sizeof(array)); 17 | Serial.print(" Element Size: "); Serial.println(sizeof(int)); //array[0])); 18 | Serial.print("Element Number: "); Serial.println(sizeof(array) / sizeof(array[0])); 19 | } 20 | 21 | 22 | void loop() { } 23 | -------------------------------------------------------------------------------- /Generic/bitbyte/bitbyte.ino: -------------------------------------------------------------------------------- 1 | // File: bitbyte.ino 2 | 3 | void setup() 4 | { 5 | Serial.begin(115200); 6 | while(!Serial); 7 | Serial.println("Bitnumber/Bitvalue"); 8 | Serial.print(" i : "); 9 | for (int i = 0; i < 8; i++) 10 | { 11 | Serial.print(i); 12 | Serial.print("\t"); 13 | } 14 | Serial.println(); 15 | Serial.print("bit(i): "); 16 | for (int i = 0; i < 8; i++) 17 | { 18 | Serial.print(bit(i)); 19 | Serial.print("\t"); 20 | } 21 | 22 | Serial.println("\n\nbitClear/bitSet"); 23 | word x = 0xFFFF; Serial.println(x, HEX); 24 | bitClear(x, 3); Serial.println(x, HEX); 25 | bitSet(x, 3); Serial.println(x, HEX); 26 | 27 | Serial.println("\nbitRead/bitWrite"); 28 | x = 0xAAAA; Serial.println(x, HEX); 29 | Serial.println(bitRead(x, 3), HEX); 30 | Serial.println(bitRead(x, 4), HEX); 31 | bitWrite(x, 0, 1); Serial.println(x, HEX); 32 | bitWrite(x, 2, 1); Serial.println(x, HEX); 33 | 34 | Serial.println("\nlowByte/hiByte"); 35 | x = 0xAABB; Serial.println(x, HEX); 36 | Serial.println(lowByte(x), HEX); 37 | Serial.println(highByte(x), HEX); 38 | } 39 | 40 | void loop() {} 41 | -------------------------------------------------------------------------------- /Generic/call/call.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Call-by-value vs. call-by-reference 3 | * (c) Claus Kuehnel 2019-10-12 info@ckuehnel.ch 4 | */ 5 | 6 | void f1(int x) 7 | { 8 | x = 2 * x; 9 | Serial.print("> "); 10 | Serial.println(x); 11 | } 12 | 13 | void f2(int &y) 14 | { 15 | y = 2 * y; 16 | Serial.print("> "); 17 | Serial.println(y); 18 | } 19 | 20 | void setup() 21 | { 22 | Serial.begin(115200); 23 | 24 | int x = 10, y = 20; 25 | 26 | // Call-by-value 27 | Serial.println("Call-by-value"); 28 | Serial.println(x); 29 | f1(x); 30 | Serial.println(x); 31 | Serial.println("-----------------"); 32 | 33 | // Call-by-reference 34 | Serial.println("Call-by-reference"); 35 | Serial.println(y); 36 | f2(y); 37 | Serial.println(y); 38 | 39 | } 40 | 41 | void loop() {} 42 | -------------------------------------------------------------------------------- /Generic/class/class.ino: -------------------------------------------------------------------------------- 1 | // File class.ino 2 | 3 | class Struktur 4 | { 5 | public: 6 | bool a; 7 | int b; 8 | float c; 9 | Struktur(bool x, double z) // Constructor 10 | { 11 | a = x; c = z; 12 | } 13 | void about() 14 | { 15 | Serial.println("This is an object of class Struktur"); 16 | } 17 | }; 18 | 19 | void setup() 20 | { 21 | Serial.begin(115200); 22 | while(!Serial); // wait for serial port to connect. Nedded for native USB only 23 | 24 | Struktur s(true,1.23); // Create an object s 25 | 26 | s.about(); 27 | 28 | // Access to initialized member by constructor 29 | Serial.print("s.c: "); Serial.println(s.c); 30 | 31 | // Access to uninitialized member 32 | Serial.print("s.b: "); Serial.println(s.b); 33 | 34 | // Initialising integer member 35 | s.b = 123; 36 | Serial.print("s.b: "); Serial.println(s.b); 37 | } 38 | 39 | void loop() {} 40 | -------------------------------------------------------------------------------- /Generic/enum/enum.ino: -------------------------------------------------------------------------------- 1 | // File enum.ino 2 | 3 | enum Days{Sun,Mon,tue,Wed,thu,Fri,Sat}; 4 | enum Colors{Red=10, Green, Blue}; 5 | 6 | void setup() 7 | { 8 | Serial.begin(115200); 9 | 10 | Serial.println(Mon); 11 | Serial.println(Fri); 12 | Serial.println(Green); 13 | 14 | Colors myFavorite = Red; 15 | Serial.println(myFavorite); 16 | } 17 | 18 | void loop() {} 19 | -------------------------------------------------------------------------------- /Generic/overload/overload.ino: -------------------------------------------------------------------------------- 1 | int summe(int a, int b, int c, int d) 2 | { 3 | return (a + b + c + d); 4 | } 5 | 6 | int summe(int a, int b, int c) 7 | { 8 | return (a + b + c); 9 | } 10 | 11 | int summe(int a, int b) 12 | { 13 | return(a + b); 14 | } 15 | 16 | void setup() 17 | { 18 | Serial.begin(115200); 19 | Serial.println(summe(2, 3, 4, 5)); 20 | Serial.println(summe(2, 3, 4)); 21 | Serial.println(summe(2, 3)); 22 | } 23 | 24 | void loop() {} 25 | -------------------------------------------------------------------------------- /Generic/pointer/pointer.ino: -------------------------------------------------------------------------------- 1 | // File: pointer.ino 2 | 3 | void setup() 4 | { 5 | Serial.begin(115200); 6 | 7 | int i=0, j=1, k=2; 8 | int *a, *b; // a und b sind Zeiger auf Integer-Variable 9 | a = &i; // die Adresse von i wird dem Zeiger a zugewiesen 10 | b = &k; // die Adresse von k wird dem Zeiger b zugewiesen 11 | Serial.println(*a); // Wert der Variablen i 12 | Serial.println(*b); // Wert der Variablen k 13 | } 14 | 15 | void loop() { } 16 | -------------------------------------------------------------------------------- /Generic/qualifier/qualifier.ino: -------------------------------------------------------------------------------- 1 | const int K = 123; 2 | 3 | void setup() 4 | { 5 | Serial.begin(115200); 6 | 7 | Serial.println(K); 8 | //K = 456; // if you uncomment compiler error: "assignment of read-only variable 'K'" follows 9 | inc(); inc(); inc(); 10 | } 11 | 12 | 13 | void loop() {} 14 | 15 | void inc() 16 | { 17 | int X; 18 | static int Y; 19 | X++; Y++; 20 | Serial.print(X); Serial.print("\t"); Serial.println(Y); 21 | } 22 | -------------------------------------------------------------------------------- /Generic/random/putRandom.ino: -------------------------------------------------------------------------------- 1 | void putRandom() 2 | { 3 | for(int i; i <= 10; i++) 4 | { 5 | Serial.print(random(10)); 6 | Serial.print("\t"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Generic/random/random.ino: -------------------------------------------------------------------------------- 1 | // File: random.ini 2 | 3 | void setup() 4 | { 5 | Serial.begin(115200); 6 | while(!Serial); 7 | 8 | Serial.println("Test Pseudo-Zufallszahlen"); 9 | Serial.println("Initialize randomSeed() by any fix value"); 10 | randomSeed(0); 11 | putRandom(); 12 | Serial.println("\nInitialize randomSeed() by analog value"); 13 | randomSeed(analogRead(A0)); 14 | putRandom(); 15 | Serial.println(); 16 | } 17 | 18 | void loop() {} 19 | -------------------------------------------------------------------------------- /Generic/struct/struct.ino: -------------------------------------------------------------------------------- 1 | // File: struct.ino 2 | 3 | struct Struktur1 4 | { 5 | bool a; 6 | int b; 7 | float c; 8 | }; 9 | 10 | class Struktur2 11 | { 12 | public: 13 | bool a; 14 | int b; 15 | float c; 16 | }; 17 | 18 | void setup() 19 | { 20 | Serial.begin(115200); 21 | while(!Serial); 22 | 23 | Struktur1 s1; 24 | s1.a = true; 25 | s1.b = 123; 26 | s1.c = 1.23; 27 | 28 | Serial.println(s1.a); 29 | Serial.println(s1.b); 30 | Serial.println(s1.c); 31 | 32 | Struktur2 s2; 33 | s2.a = false; 34 | s2.b = 456; 35 | s2.c = 4.56; 36 | 37 | Serial.println(s2.a); 38 | Serial.println(s2.b); 39 | Serial.println(s2.c); 40 | } 41 | 42 | 43 | void loop() { } 44 | -------------------------------------------------------------------------------- /Generic/tone/tone.ino: -------------------------------------------------------------------------------- 1 | // File: tone.ino 2 | 3 | void setup() 4 | { 5 | tone(5, 523); 6 | delay(300); 7 | tone(5, 659); 8 | delay(300); 9 | tone(5, 784); 10 | delay(300); 11 | tone(5, 1047); 12 | delay(600); 13 | noTone(5); 14 | tone(5, 523, 300); 15 | delay(1000); 16 | tone(5, 1047, 1000); // dieser Ton ist nicht hörbar 17 | tone(5, 523, 1000); 18 | } 19 | 20 | void loop() {} 21 | -------------------------------------------------------------------------------- /Generic/union/union.ino: -------------------------------------------------------------------------------- 1 | // File: union.ino 2 | 3 | union Value 4 | { 5 | int i; 6 | double d; 7 | }; 8 | 9 | void setup() 10 | { 11 | Serial.begin(115200); 12 | while(!Serial); 13 | 14 | Value v; 15 | Serial.print("Union v umfasst "); Serial.print(sizeof(v)); Serial.println(" Byte\n"); 16 | 17 | v.d = 987.654; // v holds a double 18 | Serial.print("v.d: "); Serial.println(v.d); 19 | Serial.print("v.i: "); Serial.println(v.i); 20 | Serial.println(); 21 | 22 | v.i = 123; // v holds an int 23 | Serial.print("v.i: "); Serial.println(v.i); 24 | Serial.print("v.d: "); Serial.println(v.d); 25 | } 26 | 27 | void loop() {} 28 | -------------------------------------------------------------------------------- /M5Atom/M5AtomLite_LedSet/M5AtomLite_LedSet.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: M5AtomLite_LedSet.ino 3 | * 4 | * Test button and RGB Led of Atom Lite 5 | * Select ESP32 Pico Kit as Board 6 | */ 7 | #include 8 | 9 | void setup() 10 | { 11 | M5.begin(true, true, true); // Serial, I2C, Display 12 | delay(50); 13 | Serial.println("\nM5Atom Lite test..."); 14 | Serial.println("Initial State Green"); 15 | M5.dis.drawpix(0, 0xf00000); 16 | } 17 | 18 | uint8_t FSM = 0; 19 | 20 | void loop() 21 | { 22 | if (M5.Btn.wasPressed()) 23 | { 24 | switch (FSM) 25 | { 26 | case 0: 27 | Serial.println("Green"); 28 | M5.dis.drawpix(0, 0xf00000); 29 | break; 30 | case 1: 31 | Serial.println("Red"); 32 | M5.dis.drawpix(0, 0x00f000); 33 | break; 34 | case 2: 35 | Serial.println("Blue"); 36 | M5.dis.drawpix(0, 0x0000f0); 37 | break; 38 | case 3: 39 | Serial.println("All colors reduced brightness"); 40 | M5.dis.drawpix(0, 0x707070); 41 | break; 42 | default: 43 | break; 44 | } 45 | FSM++; 46 | if (FSM >= 4) FSM = 0; 47 | } 48 | delay(50); 49 | M5.update(); 50 | } 51 | -------------------------------------------------------------------------------- /M5Atom/M5AtomLite_LedSet/M5AtomLite_LedSet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/M5Atom/M5AtomLite_LedSet/M5AtomLite_LedSet.png -------------------------------------------------------------------------------- /M5Atom/M5Atom_ENV_Unit/DHT12.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | DHT12.cpp - Library for DHT12 sensor. 3 | v0.0.1 Beta 4 | Created by Bobadas, July 30,2016. 5 | Released into the public domain. 6 | */ 7 | #include "DHT12.h" 8 | 9 | DHT12::DHT12(uint8_t scale,uint8_t id) 10 | { 11 | if (id==0 || id>126) _id=0x5c; 12 | else _id=id; 13 | if (scale==0 || scale>3) _scale=CELSIUS; 14 | else _scale=scale; 15 | } 16 | 17 | uint8_t DHT12::read() 18 | { 19 | Wire.beginTransmission(_id); 20 | Wire.write(0); 21 | if (Wire.endTransmission()!=0) return 1; 22 | Wire.requestFrom(_id, (uint8_t)5); 23 | for (int i=0;i<5;i++) { 24 | datos[i]=Wire.read(); 25 | }; 26 | delay(50); 27 | if (Wire.available()!=0) return 2; 28 | if (datos[4]!=(datos[0]+datos[1]+datos[2]+datos[3])) return 3; 29 | return 0; 30 | } 31 | 32 | float DHT12::readTemperature(uint8_t scale) 33 | { 34 | float resultado=0; 35 | uint8_t error=read(); 36 | if (error!=0) return (float)error/100; 37 | if (scale==0) scale=_scale; 38 | switch(scale) { 39 | case CELSIUS: 40 | resultado=(datos[2]+(float)datos[3]/10); 41 | break; 42 | case FAHRENHEIT: 43 | resultado=((datos[2]+(float)datos[3]/10)*1.8+32); 44 | break; 45 | case KELVIN: 46 | resultado=(datos[2]+(float)datos[3]/10)+273.15; 47 | break; 48 | }; 49 | return resultado; 50 | } 51 | 52 | float DHT12::readHumidity() 53 | { 54 | float resultado; 55 | uint8_t error=read(); 56 | if (error!=0) return (float)error/100; 57 | resultado=(datos[0]+(float)datos[1]/10); 58 | return resultado; 59 | } 60 | -------------------------------------------------------------------------------- /M5Atom/M5Atom_ENV_Unit/DHT12.h: -------------------------------------------------------------------------------- 1 | /* 2 | DHT12.h - Library for DHT12 sensor. 3 | v0.0.1 Beta 4 | Created by Bobadas, July 30,2016. 5 | Released into the public domain. 6 | */ 7 | #ifndef DHT12_h 8 | #define DHT12_h 9 | #include "Arduino.h" 10 | #include "Wire.h" 11 | 12 | #define CELSIUS 1 13 | #define KELVIN 2 14 | #define FAHRENHEIT 3 15 | 16 | class DHT12 17 | { 18 | public: 19 | DHT12(uint8_t scale=0,uint8_t id=0); 20 | float readTemperature(uint8_t scale=0); 21 | float readHumidity(); 22 | private: 23 | uint8_t read(); 24 | uint8_t datos[5]; 25 | uint8_t _id; 26 | uint8_t _scale; 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /M5Atom/M5Atom_ENV_Unit/M5Atom_ENV_Unit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/M5Atom/M5Atom_ENV_Unit/M5Atom_ENV_Unit.png -------------------------------------------------------------------------------- /M5Atom/M5Atom_I2C_Test/M5Atom_I2C_Test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: M5Atom_I2C_Test.ino 3 | * Test both I2C busses on M5Atom 4 | 5 | */ 6 | #include 7 | #include 8 | 9 | #define INFO 1 10 | #define DEBUG 1 11 | 12 | void setup() 13 | { 14 | M5.begin(true, true, true); 15 | delay(1000); // wait for serial monitor 16 | if (INFO) printInfo(); 17 | if (DEBUG) Serial.println(F("Initializing...")); 18 | Serial.println("Test I2C Busses..."); 19 | if (DEBUG) Serial.println(F("Running...")); //last line in setup() 20 | } 21 | 22 | void loop() 23 | { 24 | Wire.begin(25,21,10000); 25 | Serial.println("\nScanning internal I2C Bus"); 26 | i2cdetect(1,127); 27 | delay(2000); 28 | 29 | Wire.begin(26,32,10000); 30 | Serial.println("\nScanning I2C Bus@GROVE"); 31 | i2cdetect(1,127); 32 | delay(2000); 33 | } 34 | 35 | /*--------------------------------------------------------------*/ 36 | 37 | void printInfo() 38 | { 39 | // Compile file path (internal file of compilation proccess) 40 | Serial.print("File "); Serial.println(__FILE__); 41 | 42 | String s1 = __DATE__; 43 | String s2 = __TIME__; 44 | 45 | // Date of compilation 46 | Serial.print("Compilation @ "); Serial.println(s1 + " " + s2); 47 | 48 | // Arduino IDE SW version 49 | Serial.print("ARDUINO IDE v"); Serial.println(ARDUINO); 50 | 51 | // Oscillator frequency 52 | Serial.print("CPU Clock in MHz: "); Serial.println(F_CPU/1E6); 53 | } 54 | -------------------------------------------------------------------------------- /M5Atom/M5Atom_Telegram/WiFi_reconnect.ino: -------------------------------------------------------------------------------- 1 | void WiFi_reconnect(void) 2 | { 3 | int wifi_retry = 0; 4 | while(WiFi.status() != WL_CONNECTED && wifi_retry < 5 ) 5 | { 6 | wifi_retry++; 7 | Serial.println("WiFi not connected. Try to reconnect"); 8 | WiFi.disconnect(); 9 | WiFi.mode(WIFI_STA); 10 | WiFi.begin(ssid, pw); 11 | delay(100); 12 | } 13 | if(wifi_retry >= 5) 14 | { 15 | Serial.println("\nReboot"); 16 | ESP.restart(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /M5Atom/M5Atom_Telegram/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // This file contains credentials to access several services 2 | 3 | // Initialize Wifi connection to the router 4 | const char* ssid = "Sunrise_2.4GHz_8AC2A0"; 5 | const char* pw = "u2u7fgzv31Ds"; 6 | 7 | // Initialize Telegram BOT 8 | #define BOTtoken "1399127648:AAGBZMhT6z6zx1JmMe3r_Qn-qGFosxAh8dg" // your Bot Token (Get from Botfather) 9 | -------------------------------------------------------------------------------- /M5Atom/M5Atom_Telegram/display.ino: -------------------------------------------------------------------------------- 1 | // control pixel for signalization 2 | 3 | void MidPoint(uint8_t R, uint8_t G, uint8_t B) 4 | { 5 | M5.dis.drawpix(2, 2, CRGB(G, R, B)); 6 | } 7 | 8 | void InnerCircle(uint8_t R, uint8_t G, uint8_t B) 9 | { 10 | for (int i = 1; i < 4; i++) M5.dis.drawpix(i,1, CRGB(G, R, B)); 11 | M5.dis.drawpix(1, 2, CRGB(G, R, B)); 12 | M5.dis.drawpix(3, 2, CRGB(G, R, B)); 13 | for (int i = 1; i < 4; i++) M5.dis.drawpix(i,3, CRGB(G, R, B)); 14 | } 15 | 16 | void OuterCircle(uint8_t R, uint8_t G, uint8_t B) 17 | { 18 | for (int i = 0; i < 5; i++) M5.dis.drawpix(i,0, CRGB(G, R, B)); 19 | M5.dis.drawpix(0, 1, CRGB(G, R, B)); M5.dis.drawpix(4, 1, CRGB(G, R, B)); 20 | M5.dis.drawpix(0, 2, CRGB(G, R, B)); M5.dis.drawpix(4, 2, CRGB(G, R, B)); 21 | M5.dis.drawpix(0, 3, CRGB(G, R, B)); M5.dis.drawpix(4, 3, CRGB(G, R, B)); 22 | for (int i = 0; i < 5; i++) M5.dis.drawpix(i,4, CRGB(G, R, B)); 23 | } 24 | 25 | void blink(uint8_t R, uint8_t G, uint8_t B) 26 | { 27 | MidPoint(R, G, B); 28 | delay(100); 29 | InnerCircle(R, G, B); 30 | delay(100); 31 | OuterCircle(R, G, B); 32 | delay(200); 33 | OuterCircle(0,0,0); 34 | delay(100); 35 | InnerCircle(0,0,0); 36 | delay(100); 37 | MidPoint(0,0,0); 38 | delay(500); 39 | } 40 | -------------------------------------------------------------------------------- /M5Stack/CoreInk_EnvII_Node/SHT3X.cpp: -------------------------------------------------------------------------------- 1 | #include "SHT3X.h" 2 | 3 | /* Motor() 4 | 5 | */ 6 | SHT3X::SHT3X(uint8_t address) 7 | { 8 | Wire.begin(); 9 | _address=address; 10 | } 11 | 12 | 13 | 14 | byte SHT3X::get() 15 | { 16 | unsigned int data[6]; 17 | 18 | // Start I2C Transmission 19 | Wire.beginTransmission(_address); 20 | // Send measurement command 21 | Wire.write(0x2C); 22 | Wire.write(0x06); 23 | // Stop I2C transmission 24 | if (Wire.endTransmission()!=0) 25 | return 1; 26 | 27 | delay(500); 28 | 29 | // Request 6 bytes of data 30 | Wire.requestFrom(_address, 6); 31 | 32 | // Read 6 bytes of data 33 | // cTemp msb, cTemp lsb, cTemp crc, humidity msb, humidity lsb, humidity crc 34 | for (int i=0;i<6;i++) { 35 | data[i]=Wire.read(); 36 | }; 37 | 38 | delay(50); 39 | 40 | if (Wire.available()!=0) 41 | return 2; 42 | 43 | // Convert the data 44 | cTemp = ((((data[0] * 256.0) + data[1]) * 175) / 65535.0) - 45; 45 | fTemp = (cTemp * 1.8) + 32; 46 | humidity = ((((data[3] * 256.0) + data[4]) * 100) / 65535.0); 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /M5Stack/CoreInk_EnvII_Node/SHT3X.h: -------------------------------------------------------------------------------- 1 | #ifndef __SHT3X_H 2 | #define __HT3X_H 3 | 4 | 5 | #if ARDUINO >= 100 6 | #include "Arduino.h" 7 | #else 8 | #include "WProgram.h" 9 | #endif 10 | 11 | #include "Wire.h" 12 | 13 | class SHT3X{ 14 | public: 15 | SHT3X(uint8_t address=0x44); 16 | byte get(void); 17 | float cTemp=0; 18 | float fTemp=0; 19 | float humidity=0; 20 | 21 | private: 22 | uint8_t _address; 23 | 24 | }; 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /M5Stack/CoreInk_EnvII_Node/WiFi.ino: -------------------------------------------------------------------------------- 1 | // Send measuring values via Telegram bot 2 | 3 | void sendMessage() 4 | { 5 | if (DEBUG) 6 | { 7 | // attempt to connect to Wifi network: 8 | Serial.print("Connecting to WiFi: "); 9 | Serial.println(ssid); 10 | } 11 | 12 | WiFi.mode(WIFI_STA); 13 | WiFi.disconnect(); 14 | WiFi.begin(ssid, pw); 15 | 16 | while (WiFi.status() != WL_CONNECTED) 17 | { 18 | if (DEBUG) Serial.print("."); 19 | delay(500); 20 | } 21 | 22 | if (DEBUG) 23 | { 24 | Serial.println("WiFi connected."); 25 | Serial.print("IP address: "); 26 | Serial.println(WiFi.localIP()); 27 | } 28 | 29 | String message = "Vbat: " + String(voltage,3) + " V\n"; 30 | message += "Temp: " + String(tmp,1) + " *C\n"; 31 | message += "Hum : " + String(hum,1) + " %rH"; 32 | bot.sendMessage(CHAT_ID, message, ""); 33 | } 34 | -------------------------------------------------------------------------------- /M5Stack/CoreInk_EnvII_Node/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // This file contains credentials to access several services 2 | 3 | // Initialize Wifi connection to the router 4 | const char* ssid = "Sunrise_2.4GHz_8AC2A0"; 5 | const char* pw = "u2u7fgzv31Ds"; 6 | 7 | // Initialize Telegram BOT - CoreInk_message_bot 8 | #define BOTtoken "1451513229:AAENuyA14QZi6TIBBRRkIGHTlrzukHz-4gY" // your Bot Token (Get from Botfather) 9 | #define CHAT_ID "929477751" 10 | -------------------------------------------------------------------------------- /M5Stack/CoreInk_EnvII_Node/voltage.ino: -------------------------------------------------------------------------------- 1 | // get voltage of internal battery 2 | 3 | float getVbat(void) 4 | { 5 | analogSetPinAttenuation(35,ADC_11db); 6 | esp_adc_cal_characteristics_t *adc_chars = (esp_adc_cal_characteristics_t *)calloc(1, sizeof(esp_adc_cal_characteristics_t)); 7 | esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_12, 3600, adc_chars); 8 | uint16_t ADCValue = analogRead(35); 9 | 10 | uint32_t BatVolmV = esp_adc_cal_raw_to_voltage(ADCValue,adc_chars); 11 | float BatVol = float(BatVolmV) * 25.1 / 5.1 / 1000; 12 | return BatVol; 13 | } 14 | -------------------------------------------------------------------------------- /M5Stack/CoreInk_PIR/output.ino: -------------------------------------------------------------------------------- 1 | 2 | void displayValues(uint16_t bootCount, float voltage) 3 | { 4 | InkPageSprite.drawString(56, 16, "* PIR Sense *", &AsciiFont8x16); 5 | 6 | sprintf(buffer, "%d", bootCount); 7 | 8 | int x; 9 | if (bootCount < 100000) x = 42; 10 | if (bootCount < 10000) x = 54; 11 | if (bootCount < 1000) x = 66; 12 | if (bootCount < 100) x = 78; 13 | if (bootCount < 10) x = 90; 14 | 15 | InkPageSprite.drawString(x, 80, buffer, &AsciiFont24x48); 16 | sprintf(buffer, "Vbat: %0.3f V", voltage); 17 | 18 | InkPageSprite.drawString(56, 170, buffer, &AsciiFont8x16); 19 | InkPageSprite.pushSprite(); 20 | } 21 | -------------------------------------------------------------------------------- /M5Stack/CoreInk_PIR/voltage.ino: -------------------------------------------------------------------------------- 1 | // get voltage of internal battery 2 | 3 | float getVbat(void) 4 | { 5 | analogSetPinAttenuation(35,ADC_11db); 6 | esp_adc_cal_characteristics_t *adc_chars = (esp_adc_cal_characteristics_t *)calloc(1, sizeof(esp_adc_cal_characteristics_t)); 7 | esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_12, 3600, adc_chars); 8 | uint16_t ADCValue = analogRead(35); 9 | 10 | uint32_t BatVolmV = esp_adc_cal_raw_to_voltage(ADCValue,adc_chars); 11 | float BatVol = float(BatVolmV) * 25.1 / 5.1 / 1000; 12 | return BatVol; 13 | } 14 | -------------------------------------------------------------------------------- /M5Stack/CoreInk_PIR/wakeup.ino: -------------------------------------------------------------------------------- 1 | // Method to print the reason by which ESP32 has been awaken from sleep 2 | 3 | void print_wakeup_reason() 4 | { 5 | esp_sleep_wakeup_cause_t wakeup_reason; 6 | wakeup_reason = esp_sleep_get_wakeup_cause(); 7 | switch(wakeup_reason) 8 | { 9 | case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("\nWakeup caused by external signal using RTC_IO"); break; 10 | case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("\nWakeup caused by external signal using RTC_CNTL"); break; 11 | case ESP_SLEEP_WAKEUP_TIMER : Serial.println("\nWakeup caused by timer"); break; 12 | case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("\nWakeup caused by touchpad"); break; 13 | case ESP_SLEEP_WAKEUP_ULP : Serial.println("\nWakeup caused by ULP program"); break; 14 | default : Serial.printf("\nWakeup was not caused by deep sleep: %d\n",wakeup_reason); break; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /M5Stack/M5Core2_CalibrationValues/M5Core2_CalibrationValues.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: M5Core2_CalibrationValues.ino 3 | * 4 | * Get the calibration value airValue & waterValue for Soil Moisture Sensor 5 | * 6 | * 2021-11-16 Claus Kühnel info@ckuehnel.ch 7 | */ 8 | 9 | #include 10 | 11 | const int soilPin = 36; 12 | 13 | void setup() 14 | { 15 | M5.begin(); //Init M5Stack. 16 | while(!Serial); 17 | Serial.println("Get calibration values for Soil Moisture Sensors"); 18 | Serial.println("Hold the sensor in air to get the airValue and notify it."); 19 | Serial.println("Hold the sensor in water to get the waterValue afterwards and notify it"); 20 | } 21 | 22 | void loop() 23 | { 24 | uint16_t val; 25 | val = analogRead(soilPin); //connect sensor to PortB 26 | Serial.println(val); //print the value to serial port 27 | Serial.print("\t"); 28 | Serial.print(val*3300/4096); 29 | Serial.println(" mV"); 30 | delay(1000); 31 | } 32 | -------------------------------------------------------------------------------- /M5Stack/M5Core2_CalibrationValues/README.md: -------------------------------------------------------------------------------- 1 | **M5Core2_CalibrationValues.ino** 2 | 3 | Einfaches Programm zur Ermittlung der Kalibrierwerte für das Programm *M5Core2_EnvMonitor.ino* 4 | -------------------------------------------------------------------------------- /M5Stack/M5Core2_EnvMonitor/LED.ino: -------------------------------------------------------------------------------- 1 | void LEDsOn() 2 | { 3 | for (int i = 0; i < LEDS_NUM; i++) 4 | { 5 | ledsBuff[i].setRGB(20, 20, 20); 6 | } 7 | FastLED.show(); 8 | } 9 | 10 | void LEDsOff() 11 | { 12 | for (int i = 0; i < LEDS_NUM; i++) 13 | { 14 | ledsBuff[i].setRGB(0, 0, 0); 15 | } 16 | FastLED.show(); 17 | } 18 | -------------------------------------------------------------------------------- /M5Stack/M5Core2_EnvMonitor/WiFi.ino: -------------------------------------------------------------------------------- 1 | // WiFi Initialization 2 | 3 | void initWiFi() 4 | { 5 | WiFi.mode(WIFI_STA); 6 | Serial.print("\nConnecting to "); 7 | Serial.println(ssid); 8 | 9 | WiFi.begin(ssid, password); 10 | while (WiFi.status() != WL_CONNECTED) 11 | { 12 | delay(500); 13 | Serial.print("."); 14 | } 15 | Serial.println("\nWiFi connected"); 16 | Serial.print("IP address: "); 17 | Serial.println(WiFi.localIP()); 18 | } 19 | -------------------------------------------------------------------------------- /M5Stack/M5Core2_EnvMonitor/pushover.ino: -------------------------------------------------------------------------------- 1 | void pushover(char *pushovermessage, int priority) 2 | { 3 | String message = pushovermessage; 4 | 5 | length = 113 + message.length(); 6 | 7 | if(client.connect(pushoversite,80)) 8 | { 9 | client.println("POST /1/messages.json HTTP/1.1"); 10 | client.println("Host: api.pushover.net"); 11 | client.println("Connection: close\r\nContent-Type: application/x-www-form-urlencoded"); 12 | client.print("Content-Length: "); 13 | client.print(length); 14 | client.println("\r\n");; 15 | client.print("token="); 16 | client.print(apitoken); 17 | client.print("&user="); 18 | client.print(userkey); 19 | client.print("&message="); 20 | client.print(message); 21 | client.print("&priority="); 22 | client.print(priority); 23 | client.print("&retry=60"); 24 | client.print("&expire=3600"); 25 | while(client.connected()) 26 | { 27 | while(client.available()) 28 | { 29 | char ch = client.read(); 30 | Serial.write(ch); 31 | } 32 | } 33 | client.stop(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /M5Stack/M5Paper_SHT31/WiFi.ino: -------------------------------------------------------------------------------- 1 | // Send measuring values to Telegram bot 2 | 3 | void sendMessage() 4 | { 5 | if (DEBUG) 6 | { 7 | // attempt to connect to Wifi network: 8 | Serial.print("Connecting to WiFi: "); 9 | Serial.println(ssid); 10 | } 11 | 12 | WiFi.mode(WIFI_STA); 13 | WiFi.disconnect(); 14 | WiFi.begin(ssid, pw); 15 | 16 | while (WiFi.status() != WL_CONNECTED) 17 | { 18 | if (DEBUG) Serial.print("."); 19 | delay(500); 20 | } 21 | 22 | if (DEBUG) 23 | { 24 | Serial.println("WiFi connected."); 25 | Serial.print("IP address: "); 26 | Serial.println(WiFi.localIP()); 27 | } 28 | String message = "Vbat: " + String(voltage) + " V\n"; 29 | message += "Temp: " + String(temp) + " *C\n"; 30 | message += "Hum : " + String(humi) + " %rH"; 31 | bot.sendMessage(CHAT_ID, message, ""); 32 | } 33 | -------------------------------------------------------------------------------- /M5Stack/M5Paper_SHT31/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // This file contains credentials to access several services 2 | 3 | // Initialize Wifi connection to the router 4 | const char* ssid = "Sunrise_2.4GHz_8AC2A0"; 5 | const char* pw = "u2u7fgzv31Ds"; 6 | 7 | // Initialize Telegram BOT 8 | #define BOTtoken "1491308329:AAGGjANhCZGimRExpGisly_eGFdF3T2jO6o" // your Bot Token (Get from Botfather) 9 | #define CHAT_ID "929477751" 10 | -------------------------------------------------------------------------------- /M5StickC/FactoryTest/DHT12.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | DHT12.cpp - Library for DHT12 sensor. 3 | v0.0.1 Beta 4 | Created by Bobadas, July 30,2016. 5 | Released into the public domain. 6 | */ 7 | #include "DHT12.h" 8 | 9 | DHT12::DHT12(uint8_t scale,uint8_t id) 10 | { 11 | if (id==0 || id>126) _id=0x5c; 12 | else _id=id; 13 | if (scale==0 || scale>3) _scale=CELSIUS; 14 | else _scale=scale; 15 | } 16 | 17 | uint8_t DHT12::read() 18 | { 19 | Wire.beginTransmission(_id); 20 | Wire.write(0); 21 | if (Wire.endTransmission()!=0) return 1; 22 | Wire.requestFrom(_id, (uint8_t)5); 23 | for (int i=0;i<5;i++) { 24 | datos[i]=Wire.read(); 25 | }; 26 | delay(50); 27 | if (Wire.available()!=0) return 2; 28 | if (datos[4]!=(datos[0]+datos[1]+datos[2]+datos[3])) return 3; 29 | return 0; 30 | } 31 | 32 | float DHT12::readTemperature(uint8_t scale) 33 | { 34 | float resultado=0; 35 | uint8_t error=read(); 36 | if (error!=0) return (float)error/100; 37 | if (scale==0) scale=_scale; 38 | switch(scale) { 39 | case CELSIUS: 40 | resultado=(datos[2]+(float)datos[3]/10); 41 | break; 42 | case FAHRENHEIT: 43 | resultado=((datos[2]+(float)datos[3]/10)*1.8+32); 44 | break; 45 | case KELVIN: 46 | resultado=(datos[2]+(float)datos[3]/10)+273.15; 47 | break; 48 | }; 49 | return resultado; 50 | } 51 | 52 | float DHT12::readHumidity() 53 | { 54 | float resultado; 55 | uint8_t error=read(); 56 | if (error!=0) return (float)error/100; 57 | resultado=(datos[0]+(float)datos[1]/10); 58 | return resultado; 59 | } 60 | -------------------------------------------------------------------------------- /M5StickC/FactoryTest/DHT12.h: -------------------------------------------------------------------------------- 1 | /* 2 | DHT12.h - Library for DHT12 sensor. 3 | v0.0.1 Beta 4 | Created by Bobadas, July 30,2016. 5 | Released into the public domain. 6 | */ 7 | #ifndef DHT12_h 8 | #define DHT12_h 9 | #include "Arduino.h" 10 | #include "Wire.h" 11 | 12 | #define CELSIUS 1 13 | #define KELVIN 2 14 | #define FAHRENHEIT 3 15 | 16 | class DHT12 17 | { 18 | public: 19 | DHT12(uint8_t scale=0,uint8_t id=0); 20 | float readTemperature(uint8_t scale=0); 21 | float readHumidity(); 22 | private: 23 | uint8_t read(); 24 | uint8_t datos[5]; 25 | uint8_t _id; 26 | uint8_t _scale; 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /M5StickC/FactoryTest/esp32_rmt.h: -------------------------------------------------------------------------------- 1 | #include 2 | //#include "driver/rmt.h" 3 | #include "rmt.h" 4 | 5 | 6 | #ifndef ESP32_RMT_H 7 | #define ESP32_RMT_H 8 | 9 | 10 | #define RMT_TX_CHANNEL 1 /*!< RMT channel for transmitter */ 11 | #define RMT_RX_CHANNEL 0 /*!< RMT channel for receiver */ 12 | #define RMT_RX_GPIO_NUM 19 /*!< GPIO number for receiver */ 13 | #define RMT_INTR_NUM 19 /*!< RMT interrupt number, select from soc.h */ 14 | #define RMT_CLK_DIV 100 /*!< RMT counter clock divider */ 15 | #define RMT_TICK_10_US (80000000/RMT_CLK_DIV/100000) /*!< RMT counter */ 16 | 17 | #define RMT_TX_DATA_NUM 1 /*!< NEC tx test data number */ 18 | #define rmt_item32_tIMEOUT_US 9500 /*!< RMT receiver timeout value(us) */ 19 | 20 | 21 | 22 | class ESP32_RMT 23 | { 24 | public: 25 | ESP32_RMT(); //reserved for future use 26 | void begin(uint8_t, bool); 27 | 28 | //transmit functions 29 | void sendRaw (const uint8_t[], uint8_t, uint8_t); 30 | void send(uint8_t); 31 | 32 | void necSend(uint16_t, uint16_t); 33 | 34 | private: 35 | void rmt_tx_init(); 36 | void nec_fill_item_level(rmt_item32_t* ,int ,int); 37 | void nec_fill_item_header(rmt_item32_t* ); 38 | void nec_fill_item_bit_one(rmt_item32_t* ); 39 | void nec_fill_item_bit_zero(rmt_item32_t*); 40 | void nec_fill_item_end(rmt_item32_t* ); 41 | int nec_build_items(int , rmt_item32_t* , int , uint16_t , uint16_t); 42 | 43 | uint8_t txChannel = 1; 44 | uint8_t rxChannel = 0; 45 | 46 | uint8_t txPin = 16; //default transmit pin 47 | uint8_t rxPin = 19; //default receive pin 48 | 49 | 50 | }; 51 | 52 | 53 | 54 | #endif // ESP32_RMT 55 | -------------------------------------------------------------------------------- /M5StickC/FactoryTest/rc5_rc6.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /M5StickC/M5StickC_EnvHat/DHT12.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | DHT12.cpp - Library for DHT12 sensor. 3 | v0.0.1 Beta 4 | Created by Bobadas, July 30,2016. 5 | Released into the public domain. 6 | */ 7 | #include "DHT12.h" 8 | 9 | DHT12::DHT12(uint8_t scale,uint8_t id) 10 | { 11 | if (id==0 || id>126) _id=0x5c; 12 | else _id=id; 13 | if (scale==0 || scale>3) _scale=CELSIUS; 14 | else _scale=scale; 15 | } 16 | 17 | uint8_t DHT12::read() 18 | { 19 | Wire.beginTransmission(_id); 20 | Wire.write(0); 21 | if (Wire.endTransmission()!=0) return 1; 22 | Wire.requestFrom(_id, (uint8_t)5); 23 | for (int i=0;i<5;i++) { 24 | datos[i]=Wire.read(); 25 | }; 26 | delay(50); 27 | if (Wire.available()!=0) return 2; 28 | if (datos[4]!=(datos[0]+datos[1]+datos[2]+datos[3])) return 3; 29 | return 0; 30 | } 31 | 32 | float DHT12::readTemperature(uint8_t scale) 33 | { 34 | float resultado=0; 35 | uint8_t error=read(); 36 | if (error!=0) return (float)error/100; 37 | if (scale==0) scale=_scale; 38 | switch(scale) { 39 | case CELSIUS: 40 | resultado=(datos[2]+(float)datos[3]/10); 41 | break; 42 | case FAHRENHEIT: 43 | resultado=((datos[2]+(float)datos[3]/10)*1.8+32); 44 | break; 45 | case KELVIN: 46 | resultado=(datos[2]+(float)datos[3]/10)+273.15; 47 | break; 48 | }; 49 | return resultado; 50 | } 51 | 52 | float DHT12::readHumidity() 53 | { 54 | float resultado; 55 | uint8_t error=read(); 56 | if (error!=0) return (float)error/100; 57 | resultado=(datos[0]+(float)datos[1]/10); 58 | return resultado; 59 | } 60 | -------------------------------------------------------------------------------- /M5StickC/M5StickC_EnvHat/DHT12.h: -------------------------------------------------------------------------------- 1 | /* 2 | DHT12.h - Library for DHT12 sensor. 3 | v0.0.1 Beta 4 | Created by Bobadas, July 30,2016. 5 | Released into the public domain. 6 | */ 7 | #ifndef DHT12_h 8 | #define DHT12_h 9 | #include "Arduino.h" 10 | #include "Wire.h" 11 | 12 | #define CELSIUS 1 13 | #define KELVIN 2 14 | #define FAHRENHEIT 3 15 | 16 | class DHT12 17 | { 18 | public: 19 | DHT12(uint8_t scale=0,uint8_t id=0); 20 | float readTemperature(uint8_t scale=0); 21 | float readHumidity(); 22 | private: 23 | uint8_t read(); 24 | uint8_t datos[5]; 25 | uint8_t _id; 26 | uint8_t _scale; 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /M5StickC/M5StickC_EnvHat/M5StickC_EnvHat.ino: -------------------------------------------------------------------------------- 1 | /* 2 | note: need add library Adafruit_BMP280 from library manage 3 | Github: https://github.com/adafruit/Adafruit_BMP280_Library 4 | */ 5 | #include 6 | #include "DHT12.h" 7 | #include 8 | #include "Adafruit_Sensor.h" 9 | #include 10 | 11 | DHT12 dht12; 12 | Adafruit_BMP280 bme; 13 | 14 | void setup() 15 | { 16 | M5.begin(); 17 | Wire.begin(0,26); 18 | M5.Lcd.setRotation(4); 19 | M5.Lcd.fillScreen(BLACK); 20 | M5.Lcd.setCursor(0, 0, 2); 21 | M5.Lcd.setTextColor(BLUE); 22 | M5.Lcd.println(" M5Stick-C ENV Hat"); 23 | M5.Lcd.setTextColor(WHITE,BLACK); 24 | 25 | if (!bme.begin(0x76)){ 26 | Serial.println("Could not find a valid BMP280 sensor, check wiring!"); 27 | while (1); 28 | } 29 | } 30 | 31 | void loop() 32 | { 33 | float tmp = dht12.readTemperature(); 34 | float hum = dht12.readHumidity(); 35 | M5.Lcd.fillRect(0, 50, 160, 16, BLACK); 36 | M5.Lcd.setCursor(0, 50, 4); 37 | if (tmp < 10 && tmp >= 0) M5.Lcd.printf(" "); 38 | M5.Lcd.printf("%2.1f*C", tmp); 39 | M5.Lcd.fillRect(0, 90, 160, 16, BLACK); 40 | M5.Lcd.setCursor(0, 90, 4); 41 | if (hum < 10) M5.Lcd.printf(" "); 42 | M5.Lcd.printf(" %2.0f%%", hum); 43 | 44 | float pressure = bme.readPressure(); 45 | M5.Lcd.fillRect(0, 130, 160, 10, BLACK); 46 | M5.Lcd.setCursor(0, 130, 2); 47 | M5.Lcd.printf(" %2.1f", pressure); 48 | delay(1000); 49 | 50 | if (!bme.begin(0x76)){ 51 | Serial.println("Could not find a valid BMP280 sensor, check wiring!"); 52 | while (1); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /M5StickC/README.md: -------------------------------------------------------------------------------- 1 | ## Anwendungen mit M5StickC 2 | 3 | Informationen zur Messung der Wassertemperatur mit DS18B20 sind unter https://ckblog2016.net/2019/06/15/messung-der-wassertemperatur/ zu finden. -------------------------------------------------------------------------------- /M5StickCPlus/M5StickCPlus_CO2_Monitor/filter.ino: -------------------------------------------------------------------------------- 1 | // Calculation of Moving Average to suppress noisy measuring values 2 | 3 | const uint8_t WINDOW_SIZE = 5; 4 | 5 | uint8_t idx_eCO2 = 0, idx_TVOC = 0; 6 | uint16_t value = 0; 7 | uint32_t sum_eCO2 = 0, sum_TVOC = 0; 8 | uint16_t readings_eCO2[WINDOW_SIZE], readings_TVOC[WINDOW_SIZE]; 9 | uint16_t average = 0; 10 | 11 | uint16_t movAverage_eCO2(uint16_t value) 12 | { 13 | sum_eCO2 = sum_eCO2 - readings_eCO2[idx_eCO2]; // Remove the oldest entry from the sum 14 | readings_eCO2[idx_eCO2] = value; 15 | sum_eCO2 = sum_eCO2 + value; 16 | idx_eCO2 = (idx_eCO2 + 1) % WINDOW_SIZE; 17 | average = sum_eCO2 / WINDOW_SIZE; 18 | return average; 19 | } 20 | 21 | uint16_t movAverage_TVOC(uint16_t value) 22 | { 23 | sum_TVOC = sum_TVOC - readings_TVOC[idx_TVOC]; // Remove the oldest entry from the sum 24 | readings_TVOC[idx_TVOC] = value; 25 | sum_TVOC = sum_TVOC + value; 26 | idx_TVOC = (idx_TVOC + 1) % WINDOW_SIZE; 27 | average = sum_TVOC / WINDOW_SIZE; 28 | return average; 29 | } 30 | -------------------------------------------------------------------------------- /M5StickCPlus/mi_temp3_display/config.h: -------------------------------------------------------------------------------- 1 | // here are all non-public data 2 | 3 | char* LYWSD03MMC_ADDR[] = 4 | { 5 | "a4:c1:38:3c:e4:e2", 6 | "a4:c1:38:76:97:b3" 7 | }; 8 | 9 | static int deviceCount = sizeof LYWSD03MMC_ADDR / sizeof LYWSD03MMC_ADDR[0]; 10 | 11 | BLEClient* pClient; 12 | 13 | // sleep between to runs in seconds 30*60=30min 14 | #define SLEEP_DURATION 30 * 10 // Sleep for 5 min 15 | // emergency hibernate countdown in seconds 16 | #define EMERGENCY_HIBERNATE 3 * 60 17 | // how often should the battery be read - in run count 18 | #define BATTERY_INTERVAL 6 19 | // how often should a device be retried in a run when something fails 20 | #define RETRY 3 21 | -------------------------------------------------------------------------------- /Maduino A6/A6_GPRS_FileDownload/functions.ino: -------------------------------------------------------------------------------- 1 | void poweron() 2 | { 3 | int i=0; 4 | boolean result = false; 5 | digitalWrite(pon, HIGH); 6 | delay(3000); 7 | digitalWrite(pon, LOW); 8 | // SerialAT.flush(); 9 | // SerialAT.setTimeout(3000); 10 | SerialAT.println("AT"); 11 | SerialAT.println("AT"); 12 | SerialAT.println("AT"); 13 | SerialAT.println("AT"); 14 | SerialAT.println("AT"); 15 | result = SerialAT.find("OK"); 16 | } 17 | -------------------------------------------------------------------------------- /Maixduino/CoreMark/README.md: -------------------------------------------------------------------------------- 1 | # CoreMark - CPU Performance Benchmark 2 | 3 | Measures the number for times per second your processor can perform a 4 | variety of common tasks: linked list management, matrix multiply, and 5 | executing state machines. 6 | 7 | | Board | CoreMark | 8 | | ---------------------- | :------: | 9 | | Teensy 4.0 | 2313.57 | 10 | | Adafruit Metro M4 (200MHz overclock, 'dragons' optimization) | 536.35 | 11 | | Adafruit Metro M4 (180MHz overclock, faster optimizations) | 458.19 | 12 | | Teensy 3.6 | 440.72 | 13 | | Sparkfun ESP32 Thing | 351.33 | 14 | | Adafruit HUZZAH 32 | 351.35 | 15 | | Teensy 3.5 | 265.50 | 16 | | Teensy 3.2 (96MHz overclock, faster optimizations) | 218.26 | 17 | | Adafruit Metro M4 (120MHz, smaller code) | 214.85 | 18 | | Teensy 3.2 (72MHz) | 168.62 | 19 | | Teensy 3.2 (72MHz, smaller code) | 126.76 | 20 | | Arduino Due | 94.95 | 21 | | Arduino Zero | 56.86 | 22 | | Arduino Mega | 7.03 | 23 | | Arduino Nano Every | 8.20 | 24 | 25 | (larger numbers are better) 26 | 27 | -------------------------------------------------------------------------------- /Maixduino/Coremark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Maixduino/Coremark.png -------------------------------------------------------------------------------- /Maixduino/README.md: -------------------------------------------------------------------------------- 1 | ## Maixduino Benchmarks 2 | 3 | Um die Performance des Maixduino gegenüber anderen Arduinos resp. Arduino-kompatiblen Mikrocontrollern zu vergleichen, habe ich zwei Benchmarks laufen lassen: 4 | • Sieve of Eratosthenes 5 | • CoreMark 6 | Den ersten Benchmark habe ich zu Vergleichszwecken verwendet, da ich in der Vergan-genheit damit bereits zahlreiche Tests vorgenommen habe. 7 | 8 | Erweiterung der Arduino-Familie: ESP32 – wie gut ist es? 9 | https://www.elektroniknet.de/design-elektronik/embedded/erweiterung-der-arduino-familie-esp32-wie-gut-ist-es-160294.html 10 | 11 | Arduino32: Die jungen Wilden. 12 | http://www.elektroniknet.de/embedded/arduino32-die-jungen-wilden-131502.html 13 | 14 | CoreMark 1.0 hingegen ist ein vom EEMBC empfohlener Test und zudem an die Arduino-Umgebung angepasst (https://www.eembc.org/coremark/). Beide Benchmarks stehen hier zum Download zur Verfügung. 15 | 16 | Die Resultate der beiden Benchmarks zeigen die Abbildungen Sieve.png und Coremark.png.. 17 | Verglichen wurden ein Arduino Due (AT91SAM3X8E@84 MHz), eine ESPduino-32 (ESP-Wroom-32@80 MHz) und ein Maixduino (Kendryte K210 RISC-V@400 MHz). 18 | 19 | -------------------------------------------------------------------------------- /Maixduino/Sieve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/Maixduino/Sieve.png -------------------------------------------------------------------------------- /MicroView/README.md: -------------------------------------------------------------------------------- 1 | ## MicroView OLED 2 | 3 | Microview ist ein Arduino kompatibles Modul mit eingebauten OLED-Display. 4 | 5 | Das On-Board 64×48 Pixel OLED kann sehr einfach zum Anzeigen von Sensordaten, kurzen Mitteilungen u.a.m. eingesetzt werden. 6 | Es passt gut in ein Steckbrett und macht das Prototyping einfach. 7 | 8 | Eine voll funktionsfähige Arduino-Bibliothek erleichtert die Programmierung des Moduls erheblich. 9 | 10 | Ausführliche Informationen sind bei [Sparkfun](https://www.sparkfun.com/products/12923) zu finden. 11 | -------------------------------------------------------------------------------- /MicroView/uView_HelloWorld/uView_HelloWorld.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define BOARD "MicroView" 4 | 5 | void setup() { 6 | uView.begin(); // start MicroView 7 | uView.clear(PAGE); // clear page 8 | uView.print("HelloWorld"); // display HelloWorld 9 | uView.print("This is\n"); 10 | uView.println(BOARD); 11 | uView.print("Clock\n "); 12 | uView.print(F_CPU/1000000); // Oscillator frequency 13 | uView.print(" MHz"); 14 | uView.display(); 15 | } 16 | 17 | void loop () {} 18 | -------------------------------------------------------------------------------- /PaperiNode/PaperiNode_DevEUI/I2C.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C.c 3 | * 4 | * Created: 22-9-2017 08:48:32 5 | * Author: adri 6 | */ 7 | #include 8 | #include "I2C.h" 9 | 10 | 11 | void I2C_init (void) 12 | { 13 | Wire.begin(); 14 | } 15 | 16 | 17 | void I2C_write_register (uint8_t slaveAddress, uint8_t Register, uint8_t data) 18 | { 19 | Wire.beginTransmission(slaveAddress); 20 | Wire.write(Register); 21 | Wire.write(data); 22 | Wire.endTransmission(); 23 | } 24 | 25 | 26 | void I2C_write_array (uint8_t slaveAddress, uint8_t Register, uint8_t *data, uint8_t lenght) 27 | { 28 | Wire.beginTransmission(slaveAddress); 29 | Wire.write(Register); 30 | Wire.write(data, lenght); 31 | Wire.endTransmission(); 32 | } 33 | 34 | 35 | 36 | uint8_t I2C_read_register (uint8_t slaveAddress, uint8_t Register) 37 | { 38 | uint8_t retVal; 39 | 40 | Wire.beginTransmission(slaveAddress); 41 | Wire.write(Register); 42 | Wire.endTransmission(); 43 | Wire.requestFrom(slaveAddress, (uint8_t)1); 44 | retVal = Wire.read(); 45 | Wire.endTransmission(); 46 | return retVal; 47 | } 48 | 49 | 50 | void I2C_read_array (uint8_t slaveAddress, uint8_t Register, uint8_t *data, uint8_t lenght) 51 | { 52 | uint8_t retVal, i; 53 | 54 | Wire.beginTransmission(slaveAddress); 55 | Wire.write(Register); 56 | Wire.endTransmission(); 57 | Wire.requestFrom((uint8_t)slaveAddress, lenght); 58 | 59 | // Read until all bytes have been retrieved. 60 | for( i = 0 ; i < lenght ; i++) 61 | { 62 | data[i] = Wire.read(); 63 | } 64 | 65 | Wire.endTransmission(); 66 | } 67 | -------------------------------------------------------------------------------- /PaperiNode/PaperiNode_DevEUI/I2C.h: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C.h 3 | * 4 | * Created: 22-9-2017 08:48:47 5 | * Author: adri 6 | */ 7 | 8 | 9 | #ifndef I2C_H_ 10 | #define I2C_H_ 11 | 12 | /****************************************************************************************** 13 | INCLUDE FILES 14 | ******************************************************************************************/ 15 | #include 16 | 17 | 18 | /****************************************************************************************** 19 | FUNCTION PROTOTYPES 20 | ******************************************************************************************/ 21 | void I2C_init (void); 22 | void I2C_write_register (uint8_t slaveAddress, uint8_t Register, uint8_t data); 23 | void I2C_write_array (uint8_t slaveAddress, uint8_t Register, uint8_t *data, uint8_t lenght); 24 | uint8_t I2C_read_register (uint8_t slaveAddress, uint8_t Register); 25 | void I2C_read_array (uint8_t slaveAddress, uint8_t Register, uint8_t *data, uint8_t lenght); 26 | 27 | #endif /* I2C_H_ */ 28 | -------------------------------------------------------------------------------- /PaperiNode/PaperiNode_DevEUI/PaperiNode_DevEUI.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: PaperiNode_DevEUI.ino 3 | * 4 | * Prints the DevEUI of PaperiNode to the Console. 5 | * You need the DevEUI for registration at TTN. 6 | * 7 | * Based on https://github.com/RobPo/PaperiNode/tree/master/examples/01_SerialPrintDevEUI 8 | */ 9 | 10 | #include "paperinode.h" 11 | #include "lorawan_def.h" 12 | #include "DS2401.h" 13 | 14 | sLoRaWAN lora; // See the Nexus_Lorawan.h file for the settings 15 | 16 | void setup(void) 17 | { 18 | analogReference(EXTERNAL); // use AREF for reference voltage 19 | SPI.begin(); // Initialize the SPI port 20 | SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0)); 21 | Serial.begin(9600); 22 | 23 | while(DS_Read(&(lora.OTAA.DevEUI[0])) == false) {} 24 | printStringAndHex("DS2401 DEV EUI: ", &(lora.OTAA.DevEUI[0]), 8); 25 | } 26 | 27 | void loop(){} 28 | 29 | 30 | void printStringAndHex(const char *String, uint8_t *data, uint8_t n) 31 | { 32 | uint8_t i; 33 | Serial.print(String); 34 | Serial.flush(); 35 | Serial.print(n, DEC); 36 | Serial.print(" bytes; "); 37 | 38 | for( i = 0 ; i < n ; i++) // Print the data as a hexadecimal string 39 | { 40 | // Print single nibbles, since the Hexadecimal format printed by the Serial.Print function does not print leading zeroes. 41 | Serial.print((unsigned char) ((data[i] & 0xF0) >> 4), HEX); // Print MSB first 42 | Serial.print((unsigned char) ((data[i] & 0x0F) >> 0), HEX); // Print LSB second 43 | Serial.print(' '); 44 | Serial.flush(); 45 | } 46 | Serial.println(); 47 | } 48 | -------------------------------------------------------------------------------- /PaperiNode/PaperiNode_DevEUI/paperinode.h: -------------------------------------------------------------------------------- 1 | #ifndef PAPERINODE_DEMOBOARD_H_ 2 | #define PAPERINODE_DEMOBOARD_H_ 3 | 4 | /****************************************************************************************** 5 | DEFINES 6 | /******************************************************************************************/ 7 | 8 | #include 9 | #include "I2C.h" 10 | #include "spi_functions.h" 11 | #include "progmem.h" 12 | #include "LowPower.h" 13 | 14 | 15 | #define EPD_RST A2 16 | #define EPD_BUSY A1 17 | #define EPD_CS A3 18 | #define HV_BST 9 19 | #define SW_TFT A0 20 | #define DS2401 2 // One wire pin for the DS2401 21 | #define RTC_MFP 3 22 | #define RFM_DIO0 4 23 | #define RFM_DIO1 5 24 | #define RFM_DIO5 6 25 | #define RFM_NSS 10 26 | #define SPI_FLASH_CS 8 27 | 28 | 29 | /****************************************************************************************** 30 | STRUCTURES 31 | ******************************************************************************************/ 32 | typedef struct{ 33 | uint8_t Counter = 0; 34 | uint16_t LoRaWAN_message_interval = 1; // Variable to set the number of Timer2 timer ticks between LoRaWAN messages. 35 | }sAPP; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /PaperiNode/PaperiNode_DevEUI/spi_functions.h: -------------------------------------------------------------------------------- 1 | #ifndef _SPI_Functions_h 2 | #define _SPI_Functions_h 3 | 4 | #if defined(ARDUINO) && ARDUINO >= 100 5 | #include "Arduino.h" 6 | #else 7 | #include "WProgram.h" 8 | #endif 9 | 10 | #include 11 | 12 | void SPI_Write (uint8_t CS_pin, uint8_t register_Address, uint8_t Data); 13 | uint8_t SPI_Read (uint8_t CS_pin, uint8_t register_Address); 14 | void SPI_Write_Array (uint8_t CS_pin, uint8_t register_Address, uint8_t *Data, uint8_t lenght); 15 | void SPI_Read_Array (uint8_t CS_pin, uint8_t register_Address, uint8_t *Data, uint8_t lenght); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /PaperiNode/PaperiNode_SCap_Voltage_LoRaWAN/BMP280.ino: -------------------------------------------------------------------------------- 1 | // SPI Interface to BMP280 2 | 3 | void initBMP280() 4 | { 5 | if (!bmp.begin()) while (1); 6 | 7 | // Default settings from datasheet. 8 | bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */ 9 | Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */ 10 | Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */ 11 | Adafruit_BMP280::FILTER_X16, /* Filtering. */ 12 | Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */ 13 | } 14 | -------------------------------------------------------------------------------- /PaperiNode/PaperiNode_SCap_Voltage_LoRaWAN/I2C.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C.c 3 | * 4 | * Created: 22-9-2017 08:48:32 5 | * Author: adri 6 | */ 7 | #include 8 | #include "I2C.h" 9 | 10 | 11 | void I2C_init (void) 12 | { 13 | Wire.begin(); 14 | } 15 | 16 | 17 | void I2C_write_register (uint8_t slaveAddress, uint8_t Register, uint8_t data) 18 | { 19 | Wire.beginTransmission(slaveAddress); 20 | Wire.write(Register); 21 | Wire.write(data); 22 | Wire.endTransmission(); 23 | } 24 | 25 | 26 | void I2C_write_array (uint8_t slaveAddress, uint8_t Register, uint8_t *data, uint8_t lenght) 27 | { 28 | Wire.beginTransmission(slaveAddress); 29 | Wire.write(Register); 30 | Wire.write(data, lenght); 31 | Wire.endTransmission(); 32 | } 33 | 34 | 35 | 36 | uint8_t I2C_read_register (uint8_t slaveAddress, uint8_t Register) 37 | { 38 | uint8_t retVal; 39 | 40 | Wire.beginTransmission(slaveAddress); 41 | Wire.write(Register); 42 | Wire.endTransmission(); 43 | Wire.requestFrom(slaveAddress, (uint8_t)1); 44 | retVal = Wire.read(); 45 | Wire.endTransmission(); 46 | return retVal; 47 | } 48 | 49 | 50 | void I2C_read_array (uint8_t slaveAddress, uint8_t Register, uint8_t *data, uint8_t lenght) 51 | { 52 | uint8_t retVal, i; 53 | 54 | Wire.beginTransmission(slaveAddress); 55 | Wire.write(Register); 56 | Wire.endTransmission(); 57 | Wire.requestFrom((uint8_t)slaveAddress, lenght); 58 | 59 | // Read until all bytes have been retrieved. 60 | for( i = 0 ; i < lenght ; i++) 61 | { 62 | data[i] = Wire.read(); 63 | } 64 | 65 | Wire.endTransmission(); 66 | } 67 | -------------------------------------------------------------------------------- /PaperiNode/PaperiNode_SCap_Voltage_LoRaWAN/I2C.h: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C.h 3 | * 4 | * Created: 22-9-2017 08:48:47 5 | * Author: adri 6 | */ 7 | 8 | 9 | #ifndef I2C_H_ 10 | #define I2C_H_ 11 | 12 | /****************************************************************************************** 13 | INCLUDE FILES 14 | ******************************************************************************************/ 15 | #include 16 | 17 | 18 | /****************************************************************************************** 19 | FUNCTION PROTOTYPES 20 | ******************************************************************************************/ 21 | void I2C_init (void); 22 | void I2C_write_register (uint8_t slaveAddress, uint8_t Register, uint8_t data); 23 | void I2C_write_array (uint8_t slaveAddress, uint8_t Register, uint8_t *data, uint8_t lenght); 24 | uint8_t I2C_read_register (uint8_t slaveAddress, uint8_t Register); 25 | void I2C_read_array (uint8_t slaveAddress, uint8_t Register, uint8_t *data, uint8_t lenght); 26 | 27 | #endif /* I2C_H_ */ 28 | -------------------------------------------------------------------------------- /PaperiNode/PaperiNode_SCap_Voltage_LoRaWAN/PaperiNode_SCap_Voltage_LoRaWAN.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/PaperiNode/PaperiNode_SCap_Voltage_LoRaWAN/PaperiNode_SCap_Voltage_LoRaWAN.zip -------------------------------------------------------------------------------- /PaperiNode/PaperiNode_SCap_Voltage_LoRaWAN/encoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | // This is the code you will need to add to the 'encoder' section in the TTN backend to let the 3 | // weather forecast demo run properly. 4 | 5 | function Encoder(object, port) { 6 | // Encode downlink messages sent as 7 | // object to an array or buffer of bytes. 8 | var bytes = [9]; 9 | 10 | bytes[0] = parseInt(object.temperature); 11 | bytes[2] = parseInt(object.humidity); 12 | bytes[4] = parseInt(object.date); 13 | bytes[6] = parseInt(object.hour); 14 | bytes[8] = parseInt(object.mins); 15 | bytes[10] = parseInt(object.icon); 16 | 17 | bytes[12] = parseInt(object.rainPrecipProb0); 18 | bytes[14] = parseInt(object.rainPrecipProb1); 19 | bytes[16] = parseInt(object.rainPrecipProb2); 20 | bytes[18] = parseInt(object.rainPrecipProb3); 21 | bytes[20] = parseInt(object.rainPrecipProb4); 22 | bytes[22] = parseInt(object.rainPrecipProb5); 23 | bytes[24] = parseInt(object.rainPrecipProb6); 24 | bytes[26] = parseInt(object.rainPrecipProb7); 25 | bytes[28] = parseInt(object.rainPrecipProb8); 26 | bytes[30] = parseInt(object.rainPrecipProb9); 27 | bytes[32] = parseInt(object.rainPrecipProb10); 28 | bytes[34] = parseInt(object.rainPrecipProb11); 29 | 30 | return bytes; 31 | } 32 | */ 33 | -------------------------------------------------------------------------------- /PaperiNode/PaperiNode_SCap_Voltage_LoRaWAN/paperinode.h: -------------------------------------------------------------------------------- 1 | #ifndef PAPERINODE_DEMOBOARD_H_ 2 | #define PAPERINODE_DEMOBOARD_H_ 3 | 4 | /****************************************************************************************** 5 | DEFINES 6 | /******************************************************************************************/ 7 | 8 | #include 9 | #include "I2C.h" 10 | #include "spi_functions.h" 11 | #include "progmem.h" 12 | #include "LowPower.h" 13 | 14 | 15 | #define EPD_RST A2 16 | #define EPD_BUSY A1 17 | #define EPD_CS A3 18 | #define HV_BST 9 19 | #define SW_TFT A0 20 | #define DS2401 2 // One wire pin for the DS2401 21 | #define RTC_MFP 3 22 | #define RFM_DIO0 4 23 | #define RFM_DIO1 5 24 | #define RFM_DIO5 6 25 | #define RFM_NSS 10 26 | #define SPI_FLASH_CS 8 27 | 28 | 29 | /****************************************************************************************** 30 | STRUCTURES 31 | ******************************************************************************************/ 32 | typedef struct{ 33 | uint8_t Counter = 0; 34 | uint16_t LoRaWAN_message_interval = 1; // Variable to set the number of Timer2 timer ticks between LoRaWAN messages. 35 | }sAPP; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /PaperiNode/PaperiNode_SCap_Voltage_LoRaWAN/spi_functions.h: -------------------------------------------------------------------------------- 1 | #ifndef _SPI_Functions_h 2 | #define _SPI_Functions_h 3 | 4 | #if defined(ARDUINO) && ARDUINO >= 100 5 | #include "Arduino.h" 6 | #else 7 | #include "WProgram.h" 8 | #endif 9 | 10 | #include 11 | 12 | void SPI_Write (uint8_t CS_pin, uint8_t register_Address, uint8_t Data); 13 | uint8_t SPI_Read (uint8_t CS_pin, uint8_t register_Address); 14 | void SPI_Write_Array (uint8_t CS_pin, uint8_t register_Address, uint8_t *Data, uint8_t lenght); 15 | void SPI_Read_Array (uint8_t CS_pin, uint8_t register_Address, uint8_t *Data, uint8_t lenght); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /PaperiNode/README.md: -------------------------------------------------------------------------------- 1 | Hinweise zur Inbetriebnahme und Repository zum PaperiNode unter https://github.com/RobPo/PaperiNode 2 | -------------------------------------------------------------------------------- /PaperiNode/schematics_rev2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ckuehnel/Arduino2020/da8fff00bfc99c9ce0a16a2f77aa332165a3a976/PaperiNode/schematics_rev2.pdf -------------------------------------------------------------------------------- /Portenta H7/PortentaH7_ADC_DAC/PortentaH7_ADC_DAC.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: PortentaH7_ADC_DAC.ino 3 | * 4 | * Arduino Portenta H7 Test of DAC & ADC 5 | * (c) Claus Kuehnel 2021-11-01 info@ckuehnel.ch 6 | * 7 | * Arduino Portenta H7 has 3× ADC with 16-bit max. resolution 8 | * and 2× 12-bit DAC (1 MHz) 9 | * 10 | * Connect A0 & A6 for this test. 11 | */ 12 | 13 | #define MEAN 1 14 | #define DAC A6 15 | #define ADC A0 16 | 17 | uint16_t dacValue, adcValue; 18 | 19 | void setup() 20 | { 21 | analogWriteResolution(12); 22 | analogReadResolution(12); 23 | Serial.begin(115200); 24 | pinMode(LEDG, OUTPUT); digitalWrite(LEDG, LOW); 25 | delay(5000); 26 | Serial.println("Test of Arduino Potenta H7 DAC-ADC-Subsystem"); 27 | Serial.println("\n DAC\tADC\t DIFF"); 28 | } 29 | 30 | void loop() 31 | { 32 | int16_t diff; 33 | 34 | for (dacValue = 0; dacValue < 4096; dacValue += 16) 35 | { 36 | digitalWrite(LEDG, LOW); 37 | delay(100); 38 | analogWrite(DAC, dacValue); 39 | delay(100); 40 | 41 | if (MEAN) adcValue = meanValue(10); 42 | else adcValue = analogRead(ADC); 43 | 44 | diff = dacValue - adcValue; 45 | Serial.print(dacValue); Serial.print("\t"); 46 | Serial.print(adcValue); Serial.print("\t"); 47 | Serial.println(diff); 48 | digitalWrite(LEDG, HIGH); 49 | delay(900); 50 | } 51 | } 52 | 53 | uint16_t meanValue(uint8_t number) 54 | { 55 | uint16_t ivalue = 0; 56 | for (int i = 0; i < number; i++) 57 | { 58 | ivalue +=analogRead(ADC); 59 | } 60 | float fvalue = ivalue / number; 61 | return (uint16_t) (fvalue + .5); 62 | } 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Arduino2020 2 | 3 | Dieses Repository enthält alle Dateien aus dem Buch 4 | 5 | Arduino 6 | Das umfassende Handbuch. 7 | Rheinwerk-Verlag, 2020 8 | ISBN 978-3-8362-7345-9 9 | 10 | Zusätzliche Informationen in deutscher Sprache und Programmbeispiele sind in meinen Blogs 11 | unter https://ckblog2016.net/ und https://ckarduino.wordpress.com/ zu finden. Die dort erwähnten Programmbeispiele sind ebenfalls Bestandteil dieses Repositories. 12 | 13 | Ausserdem enthält das Repository auch Programmbeispiele von Folgeprojekten. 14 | 15 | Bei einigen Projekten sind Zugangsdaten u.a. in einer Headerdatei *arduino_secrets.h* abgelegt. 16 | Diese Dateien sind wegen des Charakters der darin enthaltenen Daten nicht zur Weitergabe gedacht und fehlen deshalb im Repository. 17 | -------------------------------------------------------------------------------- /RP2040/RP2040_Serial/RP2040_Serial.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: RP2040_Serial.ino 3 | * 4 | * Test of Serial1 initialization to connect ESP-01 for WiFi connection later 5 | * using https://github.com/earlephilhower/arduino-pico 6 | * 7 | * 2021-05-17 Claus Kühnel info@ckuehnel.ch 8 | */ 9 | 10 | void setup() 11 | { 12 | Serial.begin(115200); 13 | delay(5000); 14 | Serial.println(F("RP2040 Serial Test")); 15 | 16 | Serial1.setRX(17); 17 | Serial1.setTX(16); 18 | Serial1.begin(115200); 19 | 20 | Serial.println(F("Initialization finished")); 21 | Serial.println(F("Short GPIO16 and GPIO17 to receive characters sent")); 22 | } 23 | 24 | void loop() 25 | { 26 | if (Serial1.available()) Serial.write(Serial1.read()); 27 | if (Serial.available()) Serial1.write(Serial.read()); 28 | } 29 | -------------------------------------------------------------------------------- /RP2040/RP2040_WiFi/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // Access data for services 2 | 3 | // WiFi 4 | const char* ssid = ; 5 | const char* pass = ; 6 | 7 | // Thingspeak 8 | // GET https://api.thingspeak.com/update?api_key=33xxxxxxxxxxxxxxxxZE&field1=0&field2=0 9 | const char* server = "api.thingspeak.com"; 10 | String api_key = ; 11 | -------------------------------------------------------------------------------- /RP2040/RP2040_WiFi/sendMessage.ino: -------------------------------------------------------------------------------- 1 | // Send Message to Thingspeak 2 | 3 | void printWifiStatus() 4 | { 5 | // print the SSID of the network you're attached to 6 | Serial.print("SSID: "); 7 | Serial.println(WiFi.SSID()); 8 | 9 | // print your WiFi shield's IP address 10 | IPAddress ip = WiFi.localIP(); 11 | Serial.print("IP Address: "); 12 | Serial.println(ip); 13 | 14 | // print the received signal strength 15 | long rssi = WiFi.RSSI(); 16 | Serial.print("Signal strength (RSSI):"); 17 | Serial.print(rssi); 18 | Serial.println(" dBm"); 19 | } 20 | 21 | void sendMessage() 22 | { 23 | // close any connection before send a new request 24 | // this will free the socket on the WiFi shield 25 | client.stop(); 26 | 27 | Serial.println("Starting connection to server..."); 28 | // if you get a connection, report back via serial 29 | if (client.connect(server, 80)) 30 | { 31 | Serial.println("Connecting..."); 32 | // Make a HTTP request 33 | client.println("GET /update?api_key=" + api_key + "&field1=" + String(TVOC) + "&field2=" + String(eCO2) + " HTTP/1.1"); 34 | client.println("Host: api.thingspeak.com"); 35 | client.println("Connection: close"); 36 | client.println(); 37 | } 38 | 39 | // if there are incoming bytes available 40 | // from the server, read them and print them 41 | while (client.available()) 42 | { 43 | char c = client.read(); 44 | Serial.write(c); 45 | } 46 | 47 | // if the server's disconnected, stop the client 48 | if (!client.connected()) 49 | { 50 | Serial.println(); 51 | Serial.println("Disconnecting from server..."); 52 | client.stop(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Seeeduino XIAO/XIAO_WaterSensors/XIAO_WaterSensors.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * File: XIAO_WaterSensors.ino 3 | * 4 | * Grove Turbidity & TDS Sensor connected to Seeeduino XIAO 5 | * via Grove Shield for Seeduino XIAO 6 | * 7 | * 2020-07-19 Claus Kühnel info@ckuehnel.ch 8 | */ 9 | 10 | #define pTurbidity A8 11 | #define pTDS A2 12 | 13 | void setup() 14 | { 15 | Serial.begin(115200); 16 | delay(2000); // wait for Serial Monitor 17 | Serial.println("Turbidity\tTDS Sensor"); 18 | } 19 | 20 | void loop() 21 | { 22 | int sensorValue = analogRead(pTurbidity);// read the voltage of Grove Turbidity Sensor 23 | float voltage = sensorValue * (3.3 / 1024.0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): 24 | Serial.print(voltage, 3); // print out the value you read: 25 | Serial.print("\t\t"); 26 | sensorValue = analogRead(pTDS);// read the voltage of Grove TDS Sensor 27 | voltage = sensorValue * (3.3 / 1024.0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): 28 | Serial.println(voltage, 3); // print out the value you read: 29 | delay(1000); 30 | } 31 | -------------------------------------------------------------------------------- /UnoWiFiR2/UnoWiFiR2_CoronaTracker/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | #define SECRET_SSID "Sunrise_2.4GHz_8AC2A0" 2 | #define SECRET_PASS "u2u7fgzv31Ds" 3 | -------------------------------------------------------------------------------- /UnoWiFiR2/UnoWiFiR2_DHT11_MQTT/DHT.ino: -------------------------------------------------------------------------------- 1 | // Access to DHT11 sensor 2 | 3 | void initSensor() 4 | { 5 | dht.begin(); 6 | } 7 | -------------------------------------------------------------------------------- /UnoWiFiR2/UnoWiFiR2_DHT11_MQTT/MQTT.ino: -------------------------------------------------------------------------------- 1 | // MQTT configuration and connection 2 | 3 | void configureMQTT() 4 | { 5 | /* configure the MQTT server with IPaddress and port */ 6 | client.setServer(BROKER, BRPORT); 7 | /* this receivedCallback function will be invoked 8 | when client received subscribed topic */ 9 | client.setCallback(receivedCallback); 10 | if (DEBUG) 11 | { 12 | Serial.println("Node will publish the topics:"); 13 | Serial.print("> "); Serial.println(TEMP_TOPIC); 14 | Serial.print("> "); Serial.println(HUMI_TOPIC); 15 | } 16 | } 17 | 18 | void receivedCallback(char* topic, byte* payload, unsigned int length) 19 | { 20 | Serial.print("Message received: "); 21 | Serial.println(topic); 22 | 23 | Serial.print("payload: "); 24 | for (int i = 0; i < length; i++) Serial.print((char)payload[i]); 25 | } 26 | 27 | void mqttconnect() { 28 | /* Loop until reconnected */ 29 | while (!client.connected()) { 30 | Serial.print("MQTT connecting ..."); 31 | 32 | /* connected now */ 33 | if (client.connect(CLIENTID, BRUSER, BRPWD)) Serial.println("connected"); 34 | else 35 | { 36 | Serial.print("failed, status code = "); 37 | Serial.println(client.state()); 38 | Serial.println("try again in 5 seconds"); 39 | /* Wait 5 seconds before retrying */ 40 | delay(5000); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /UnoWiFiR2/UnoWiFiR2_DHT11_MQTT/WiFi.ino: -------------------------------------------------------------------------------- 1 | // Connecting to WiFi access point 2 | 3 | void connectWiFi() 4 | { 5 | Serial.print("Connecting to "); 6 | Serial.println(mySSID); 7 | WiFi.begin(mySSID, myPW); 8 | 9 | while (WiFi.status() != WL_CONNECTED) 10 | { 11 | delay(500); 12 | Serial.print("."); 13 | } 14 | Serial.println(""); 15 | Serial.println("WiFi connected"); 16 | Serial.print("IP address: "); 17 | Serial.println(WiFi.localIP()); 18 | } 19 | -------------------------------------------------------------------------------- /UnoWiFiR2/UnoWiFiR2_DHT11_MQTT/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | // This file contains credentials to access several services 2 | 3 | const char* mySSID = "Sunrise_2.4GHz_8AC2A0"; 4 | const char* myPW = "u2u7fgzv31Ds"; 5 | 6 | // MQTT (CloudMQTT) 7 | const char* BROKER = "m20.cloudmqtt.com"; 8 | uint16_t BRPORT = 12394; 9 | const char* BRUSER = "rawyjpid"; 10 | const char* BRPWD = "ah52k3gjd8JS"; 11 | const char* CLIENTID = "UnoWiFiR2"; 12 | -------------------------------------------------------------------------------- /UnoWiFiR2/UnoWiFiR2_IperfServer/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | #define SECRET_SSID "Sunrise_2.4GHz_8AC2A0" 2 | #define SECRET_PASS "u2u7fgzv31Ds" 3 | -------------------------------------------------------------------------------- /UnoWiFiR2/UnoWiFiR2_SCD30_dweetio/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | #define SECRET_SSID "Sunrise_2.4GHz_8AC2A0" 2 | #define SECRET_PASS "u2u7fgzv31Ds" 3 | -------------------------------------------------------------------------------- /UnoWiFiR2/UnoWiFiR2_SCD30_dweetio/lcd.ino: -------------------------------------------------------------------------------- 1 | void lcdOutput() 2 | { 3 | clearLine(0); 4 | lcd.setCursor(0,0); // move cursor to second line "1" and 9 spaces over 5 | lcd.print(" CO2 "); 6 | lcd.print(CO2, 0); 7 | lcd.print(" ppm"); 8 | 9 | clearLine(1); 10 | lcd.setCursor(0,1); // move to the begining of the second line 11 | lcd.print(temp, 1); 12 | lcd.print(" *C"); 13 | lcd.setCursor(8,1); 14 | lcd.print(hum, 1); 15 | lcd.print(" %rH"); 16 | delay(5000); 17 | } 18 | 19 | void clearLine(byte line) 20 | { 21 | lcd.setCursor(0 ,line); 22 | lcd.print(" "); 23 | } 24 | -------------------------------------------------------------------------------- /UnoWiFiR2/UnoWiFiR2_SCD30_dweetio/reconnectWiFi.ino: -------------------------------------------------------------------------------- 1 | void reconnectWiFi() 2 | { 3 | while(WiFi.status() != WL_CONNECTED && wifi_retry < 5 ) 4 | { 5 | wifi_retry++; 6 | Serial.println("WiFi not connected. Try to reconnect"); 7 | WiFi.disconnect(); 8 | WiFi.begin(ssid, pass); 9 | delay(500); Serial.print("."); 10 | } 11 | Serial.println(""); 12 | 13 | if(wifi_retry >= 5) 14 | { 15 | Serial.println("\nReboot"); 16 | resetFunc(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /UnoWiFiR2/UnoWiFiR2_Weather/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | #define SECRET_SSID "Sunrise_2.4GHz_8AC2A0" 2 | #define SECRET_PASS "u2u7fgzv31Ds" 3 | #define SECRET_APPID "87286fed489ba6a8afcd81443138d510" 4 | -------------------------------------------------------------------------------- /UnoWiFiR2/UnoWiFiR2_WebClient/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | #define SECRET_SSID "Sunrise_2.4GHz_8AC2A0" 2 | #define SECRET_PASS "u2u7fgzv31Ds" 3 | -------------------------------------------------------------------------------- /UnoWiFiR2/UnoWiFiR2_Webserver/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | #define SECRET_SSID "Sunrise_2.4GHz_8AC2A0" 2 | #define SECRET_PASS "u2u7fgzv31Ds" 3 | -------------------------------------------------------------------------------- /UnoWiFiR2/UnoWiFiR2_Webserver/getValues.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Get measuring vaule from SHT31 sensor 3 | */ 4 | void getValues() 5 | { 6 | temp = sht31.getTemperature(); 7 | hum = sht31.getHumidity(); 8 | 9 | if (DEBUG) 10 | { 11 | Serial.print("Temp = "); 12 | Serial.print(temp, 1); 13 | Serial.println(" *C"); 14 | Serial.print("Hum = "); 15 | Serial.print(hum, 0); 16 | Serial.println(" %RH"); 17 | Serial.println(); 18 | } 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /UnoWiFiR2/UnoWiFiR2_Webserver/printWifiStatus.ino: -------------------------------------------------------------------------------- 1 | void printWifiStatus() 2 | { 3 | // print the SSID of the network you're attached to: 4 | Serial.print("\nSSID: "); 5 | Serial.println(WiFi.SSID()); 6 | 7 | // print your board's IP address: 8 | IPAddress ip = WiFi.localIP(); 9 | Serial.print("IP Address: "); 10 | Serial.println(ip); 11 | 12 | // print the received signal strength: 13 | long rssi = WiFi.RSSI(); 14 | Serial.print("signal strength (RSSI):"); 15 | Serial.print(rssi); 16 | Serial.println(" dBm"); 17 | } 18 | --------------------------------------------------------------------------------