├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── examples ├── 2.4G_RF │ ├── BLE_WiFi │ │ └── BLE_WiFi.ino │ └── TimeNTP_ESP32WiFi │ │ └── TimeNTP_ESP32WiFi.ino ├── ESP32 │ ├── ADC_Read_Voltage │ │ ├── ADC_Read_Accurate │ │ │ └── ADC_Read_Accurate.ino │ │ ├── ADC_Read_Simple │ │ │ └── ADC_Read_Simple.ino │ │ ├── Battery_power │ │ │ └── Battery_power.ino │ │ └── README.md │ ├── ESP32_Dual_Core │ │ ├── README.md │ │ ├── examples │ │ │ ├── Movecore │ │ │ │ └── Movecore.ino │ │ │ ├── Showcore │ │ │ │ └── Showcore.ino │ │ │ └── SpeedTest │ │ │ │ └── SpeedTest.ino │ │ └── resources │ │ │ ├── MoveCore.png │ │ │ ├── Result.png │ │ │ ├── SpeedTest.png │ │ │ ├── Task_Synchronization.png │ │ │ └── print_core.png │ ├── ExternalWakeUp │ │ └── ExternalWakeUp.ino │ ├── GetChipID │ │ └── GetChipID.ino │ ├── I2C_Scanner │ │ └── I2C_Scanner.ino │ ├── PSRAM_Test │ │ └── PSRAM_Test.ino │ ├── RTC_counter │ │ └── RTC_counter.ino │ ├── Serial2 │ │ └── Serial2.ino │ ├── ULP │ │ └── HoldPinStatus │ │ │ └── HoldPinStatus.ino │ ├── VextControl │ │ └── VextControl.ino │ └── WiFiLoRa32_battery_read │ │ └── WiFiLoRa32_battery_read.ino ├── Factory_Test │ ├── Vision_Master_E290_FactoryTest │ │ ├── Vision_Master_E290_FactoryTest.ino │ │ ├── checklicense.cpp │ │ └── images.h │ ├── Vision_Master_T190_FactoryTest │ │ ├── Vision_Master_T190_FactoryTest.ino │ │ ├── checklicense.cpp │ │ └── images.h │ ├── Vsion_Master_E0213A367_FactoryTest │ │ ├── Vsion_Master_E0213A367_FactoryTest.ino │ │ ├── checklicense.cpp │ │ └── images.h │ ├── Vsion_Master_E213_FactoryTest │ │ ├── Vsion_Master_E213_FactoryTest.ino │ │ ├── checklicense.cpp │ │ └── images.h │ ├── WIFI_Kit_32_FactoryTest │ │ ├── WIFI_Kit_32_FactoryTest.ino │ │ └── images.h │ ├── WIRELESS_MINI_SHELL_FactoryTest │ │ ├── WIRELESS_MINI_SHELL_FactoryTest.ino │ │ └── images.h │ ├── WiFi_Kit_32_V3_FactoryTest │ │ ├── WiFi_Kit_32_V3_FactoryTest.ino │ │ └── images.h │ ├── WiFi_LoRa_32_V2_FactoryTest │ │ ├── WiFi_LoRa_32_V2_FactoryTest.ino │ │ └── images.h │ ├── WiFi_LoRa_32_V3 │ │ ├── WiFi_LoRa_32_V3_FactoryTest_V1 │ │ │ ├── WiFi_LoRa_32_V3_FactoryTest_V1.ino │ │ │ └── images.h │ │ └── WiFi_LoRa_32_V3_FactoryTest_V2 │ │ │ ├── WiFi_LoRa_32_V3_FactoryTest_V2.ino │ │ │ └── images.h │ ├── Wireless_Paper_E0213A367_FactoryTest │ │ ├── Wireless_Paper_E0213A367_FactoryTest.ino │ │ └── images.h │ ├── Wireless_Paper_V1.0_FactoryTest │ │ ├── Wireless_Paper_V1.0_FactoryTest.ino │ │ └── images.h │ ├── Wireless_Paper_V1.1_FactoryTest │ │ ├── Wireless_Paper_V1.1_FactoryTest.ino │ │ └── images.h │ ├── Wireless_Shell_FactoryTest │ │ ├── Wireless_Shell_FactoryTest.ino │ │ └── images.h │ ├── Wireless_Shell_V3_FactoryTest │ │ ├── Wireless_Shell_V3_FactoryTest.ino │ │ └── images.h │ ├── Wireless_Stick_Lite_FactoryTest │ │ ├── Wireless_Stick_Lite_FactoryTest.ino │ │ └── images.h │ ├── Wireless_Stick_Lite_V3_FactoryTest │ │ ├── Wireless_Stick_Lite_V3_FactoryTest.ino │ │ └── images.h │ ├── Wireless_Stick_V3_FactoryTest │ │ └── Wireless_Stick_V3_FactoryTest.ino │ ├── Wireless_Tracker_V1.0_FactoryTest │ │ └── Wireless_Tracker_V1.0_FactoryTest.ino │ └── Wireless_Tracker_V1.1_FactoryTest │ │ └── Wireless_Tracker_V1.1_FactoryTest.ino ├── GPS │ ├── GPSDisplayOnTFT │ │ └── GPSDisplayOnTFT.ino │ └── GPSToUart │ │ └── GPSToUart.ino ├── LoRaBasic │ ├── LoRaReceiver │ │ └── LoRaReceiver.ino │ ├── LoRaSender │ │ └── LoRaSender.ino │ ├── README.md │ ├── TxPowerTest │ │ └── TxPowerTest.ino │ └── pingpong │ │ └── pingpong.ino ├── LoRaWAN │ ├── LoRaWAN_GHTV3_Battery │ │ └── LoRaWAN_GHTV3_Battery.ino │ ├── LoRaWAN_GHTV3_Uplink │ │ └── LoRaWAN_GHTV3_Uplink.ino │ ├── LoRaWAN_Hallsensor_Door_Detection │ │ └── LoRaWAN_Hallsensor_Door_Detection.ino │ ├── LoRaWan │ │ └── LoRaWan.ino │ ├── LoRaWanDownlinkDatahandle │ │ └── LoRaWanDownlinkDatahandle.ino │ ├── LoRaWanGPSLocation │ │ ├── LoRaWanGPSLocation.ino │ │ └── TTNDecoder.js │ ├── LoRaWanGPSTime │ │ ├── LoRaWanGPSTime.ino │ │ └── TTNDecoder.js │ ├── LoRaWanInterrupt │ │ └── LoRaWanInterrupt.ino │ ├── LoRaWanMulticast │ │ └── LoRaWanMulticast.ino │ ├── LoRaWanOLED │ │ └── LoRaWanOLED.ino │ ├── LoRaWanTimeReq │ │ └── LoRaWanTimeReq.ino │ ├── LoRaWanWiFi │ │ └── LoRaWanWiFi.ino │ └── LoRaWan_Monitor_heartrate │ │ └── LoRaWan_Monitor_heartrate.ino ├── OLED │ ├── DrawingDemo │ │ └── DrawingDemo.ino │ ├── OLED_rotate │ │ └── OLED_rotate.ino │ ├── OTA_OLED │ │ └── OTA_OLED.ino │ ├── SimpleDemo │ │ ├── SimpleDemo.ino │ │ └── images.h │ └── UiDemo │ │ ├── UiDemo.ino │ │ └── images.h ├── SD │ ├── SD.JPG │ └── SD_Time │ │ ├── SD_Time.ino │ │ └── TestInfo.png ├── Sensor │ ├── BH1750_test │ │ └── BH1750_test.ino │ ├── BMP180basic │ │ ├── BMP180basic.ino │ │ └── images.h │ ├── DHT11_LoRa_sender │ │ └── DHT11_LoRa_sender.ino │ ├── GXHTC_read │ │ └── GXHTC_read.ino │ ├── Sensor_OLED │ │ └── Sensor_OLED.ino │ ├── bmp280 │ │ └── bmp280.ino │ └── da217_read_xyz │ │ └── da217_read_xyz.ino ├── TFT │ └── ST7735_SPI │ │ └── ST7735_SPI.ino ├── VME213 │ ├── Deepsleep │ │ └── Deepsleep.ino │ ├── Global_Simple │ │ ├── Global_Simple.ino │ │ └── images.h │ ├── HT_lCMEN2R13EFC1 │ │ ├── HT_lCMEN2R13EFC1.ino │ │ └── images.h │ ├── LorawanEink │ │ ├── LorawanEink.ino │ │ └── img.h │ ├── Part_Simple │ │ ├── Part_Simple.ino │ │ └── images.h │ ├── sensor_th │ │ ├── img.h │ │ └── sensor_th.ino │ └── weather_station │ │ ├── images.h │ │ ├── readme.md │ │ └── weather_station.ino ├── VME290 │ ├── DEPG0290BxS800FxX_BW │ │ ├── DEPG0290BxS800FxX_BW.ino │ │ └── images.h │ ├── GHXTC_Sensor_Display │ │ ├── images.h │ │ └── sensor_th.ino │ ├── deepsleep │ │ └── deepsleep.ino │ ├── lorawaneink_GHXTC │ │ ├── img.h │ │ └── lorawaneink_GHXTC.ino │ └── weather_station │ │ ├── images.h │ │ ├── readme.md │ │ └── weather_station.ino ├── VMT190 │ ├── Sensor_LoRaWAN │ │ ├── Sensor_LoRaWAN.ino │ │ └── img.h │ └── tft1_9 │ │ ├── img_data.h │ │ ├── pic.h │ │ └── tft1_9.ino └── Wireless_paper │ ├── Wireless_Paper_V1.0 │ ├── Wireless_Paper_V1.0.ino │ ├── html.h │ └── images.h │ ├── Wireless_Paper_V1.1 │ ├── Wireless_Paper_V1.1.ino │ ├── html.h │ └── images.h │ ├── img │ ├── image-1.png │ ├── image-2.png │ ├── image-3.png │ ├── image-4.png │ ├── image-5.png │ └── image.png │ └── readme.md ├── img ├── 01.png ├── 02.png ├── location.png └── location_cn.png ├── keywords.txt ├── library.json ├── library.properties └── src ├── BH1750.cpp ├── BH1750.h ├── BMP180.cpp ├── BMP180.h ├── BMP280.cpp ├── BMP280.h ├── ESP32_LoRaWan_102.h ├── ESP32_Mcu.h ├── GXHTC.cpp ├── GXHTC.h ├── HT_DEPG0290BxS800FxX_BW.h ├── HT_Display.cpp ├── HT_Display.h ├── HT_DisplayFonts.h ├── HT_DisplayUi.cpp ├── HT_DisplayUi.h ├── HT_E0213A367.h ├── HT_QYEG0213RWS800_BWR.h ├── HT_SH1107Wire.h ├── HT_SSD1306Spi.h ├── HT_SSD1306Wire.h ├── HT_TinyGPS++.cpp ├── HT_TinyGPS++.h ├── HT_lCMEN2R13EFC1.h ├── HT_lCMEN2R13EFC1_LUT.h ├── HT_st7735.cpp ├── HT_st7735.h ├── HT_st7735_fonts.cpp ├── HT_st7735_fonts.h ├── HT_st7736.cpp ├── HT_st7736.h ├── HT_st7789spi.cpp ├── HT_st7789spi.h ├── LoRaWan_APP.cpp ├── LoRaWan_APP.h ├── clk.c ├── da217.cpp ├── da217.h ├── driver ├── board-config.h ├── board.c ├── board.h ├── debug.h ├── delay.c ├── delay.h ├── gpio-board.c ├── gpio-board.h ├── gpio.c ├── gpio.h ├── lorawan_spi.h ├── rtc-board.h ├── sx1262-board.c ├── sx126x-board.h ├── sx126x.c ├── sx126x.h ├── sx1276-board.c ├── sx1276-board.h ├── sx1276.c ├── sx1276.h ├── sx1276Regs-Fsk.h ├── sx1276Regs-LoRa.h └── timer.h ├── esp32 └── liblorawan.a ├── esp32c3 ├── liblorawan-espidf4.a ├── liblorawan-espidf5.a ├── liblorawan.a └── liblorawan2.a ├── esp32s3 └── liblorawan.a ├── esp_clk_internal.h ├── heltec.cpp ├── heltec.h ├── lora ├── API.md ├── LoRa.cpp └── LoRa.h ├── loramac ├── Commissioning.h ├── LoRaMac.c ├── LoRaMac.h ├── LoRaMacClassB.c ├── LoRaMacClassB.h ├── LoRaMacClassBConfig.h ├── LoRaMacConfirmQueue.c ├── LoRaMacConfirmQueue.h ├── LoRaMacCrypto.c ├── LoRaMacCrypto.h ├── LoRaMacTest.h ├── aes.c ├── aes.h ├── cmac.c ├── cmac.h ├── region │ ├── Region.c │ ├── Region.h │ ├── RegionAS923.c │ ├── RegionAS923.h │ ├── RegionAU915.c │ ├── RegionAU915.h │ ├── RegionCN470.c │ ├── RegionCN470.h │ ├── RegionCN779.c │ ├── RegionCN779.h │ ├── RegionCommon.c │ ├── RegionCommon.h │ ├── RegionEU433.c │ ├── RegionEU433.h │ ├── RegionEU868.c │ ├── RegionEU868.h │ ├── RegionIN865.c │ ├── RegionIN865.h │ ├── RegionKR920.c │ ├── RegionKR920.h │ ├── RegionUS915-Hybrid.c │ ├── RegionUS915-Hybrid.h │ ├── RegionUS915.c │ └── RegionUS915.h ├── utilities.c └── utilities.h └── radio ├── radio.c ├── radio.h └── radio_sx127x.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | .vscode 11 | 12 | # Windows Installer files 13 | *.cab 14 | *.msi 15 | *.msm 16 | *.msp 17 | 18 | # Windows shortcuts 19 | *.lnk 20 | 21 | # Text editor backup files 22 | .*.swp 23 | .*.swo 24 | *~ 25 | 26 | # CMake build folder 27 | /build 28 | 29 | # ========================= 30 | # Operating System Files 31 | # ========================= 32 | 33 | # OSX 34 | # ========================= 35 | 36 | .DS_Store 37 | .AppleDouble 38 | .LSOverride 39 | 40 | # Thumbnails 41 | ._* 42 | 43 | # Files that might appear in the root of a volume 44 | .DocumentRevisions-V100 45 | .fseventsd 46 | .Spotlight-V100 47 | .TemporaryItems 48 | .Trashes 49 | .VolumeIcon.icns 50 | 51 | # Directories potentially created on remote AFP share 52 | .AppleDB 53 | .AppleDesktop 54 | Network Trash Folder 55 | Temporary Items 56 | .apdisk 57 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(srcs 2 | src/BMP180.cpp 3 | src/oled/OLEDDisplay.cpp 4 | src/oled/OLEDDisplayUi.cpp 5 | src/heltec.cpp 6 | src/lora/LoRa.cpp 7 | ) 8 | 9 | set(includedirs 10 | src 11 | src/lora 12 | src/oled 13 | ) 14 | 15 | set(priv_includes ) 16 | set(requires arduino) 17 | set(priv_requires ) 18 | 19 | idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires}) 20 | 21 | function(maybe_add_component component_name) 22 | idf_build_get_property(components BUILD_COMPONENTS) 23 | if (${component_name} IN_LIST components) 24 | idf_component_get_property(lib_name ${component_name} COMPONENT_LIB) 25 | target_link_libraries(${COMPONENT_LIB} PUBLIC ${lib_name}) 26 | endif() 27 | endfunction() 28 | 29 | maybe_add_component(arduino) 30 | 31 | target_compile_options(${COMPONENT_TARGET} PUBLIC 32 | -DESP32) 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Heltec Automation(TM) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | See more at http://www.heltec.cn 24 | -------------------------------------------------------------------------------- /examples/ESP32/ADC_Read_Voltage/ADC_Read_Accurate/ADC_Read_Accurate.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ADC read voltage via GPIO13 with 1% accuracy. 3 | 4 | by Aaron.Lee from HelTec AutoMation, ChengDu, China 5 | 成都惠利特自动化科技有限公司 6 | www.heltec.cn 7 | */ 8 | 9 | void setup() { 10 | Serial.begin(115200); 11 | } 12 | 13 | void loop() { 14 | Serial.println(ReadVoltage(13),3); 15 | Serial.println(analogRead(13)); 16 | delay(1000); 17 | } 18 | 19 | double ReadVoltage(byte pin){ 20 | double reading = analogRead(pin); // Reference voltage is 3v3 so maximum reading is 3v3 = 4095 in range 0 to 4095 21 | if(reading < 1 || reading >= 4095) 22 | //return 0; 23 | // return -0.000000000009824 * pow(reading,3) + 0.000000016557283 * pow(reading,2) + 0.000854596860691 * reading + 0.065440348345433; 24 | return -0.000000000000016 * pow(reading,4) + 0.000000000118171 * pow(reading,3)- 0.000000301211691 * pow(reading,2)+ 0.001109019271794 * reading + 0.034143524634089; 25 | } // Added an improved polynomial, use either, comment out as required 26 | 27 | //See more APIs about ADC here: https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/esp32/cores/esp32/esp32-hal-adc.h 28 | 29 | /* ADC readings v voltage 30 | * y = -0.000000000009824x3 + 0.000000016557283x2 + 0.000854596860691x + 0.065440348345433 31 | // Polynomial curve match, based on raw data thus: 32 | * 464 0.5 33 | * 1088 1.0 34 | * 1707 1.5 35 | * 2331 2.0 36 | * 2951 2.5 37 | * 3775 3.0 38 | * 39 | */ 40 | -------------------------------------------------------------------------------- /examples/ESP32/ADC_Read_Voltage/ADC_Read_Simple/ADC_Read_Simple.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ADC read voltage via GPIO13 simple test. 3 | 4 | by Aaron.Lee from HelTec AutoMation, ChengDu, China 5 | 成都惠利特自动化科技有限公司 6 | www.heltec.cn 7 | */ 8 | 9 | void setup() { 10 | Serial.begin(115200); 11 | /* 12 | analogReadResolution(12); // Sets the sample bits and read resolution, default is 12-bit (0 - 4095), range is 9 - 12 bits 13 | analogSetWidth(12); // Sets the sample bits and read resolution, default is 12-bit (0 - 4095), range is 9 - 12 bits 14 | // 9-bit gives an ADC range of 0-511 15 | // 10-bit gives an ADC range of 0-1023 16 | // 11-bit gives an ADC range of 0-2047 17 | // 12-bit gives an ADC range of 0-4095 18 | analogSetCycles(8); // Set number of cycles per sample, default is 8 and provides an optimal result, range is 1 - 255 19 | analogSetSamples(1); // Set number of samples in the range, default is 1, it has an effect on sensitivity has been multiplied 20 | analogSetClockDiv(1); // Set the divider for the ADC clock, default is 1, range is 1 - 255 21 | analogSetAttenuation(ADC_11db); // Sets the input attenuation for ALL ADC inputs, default is ADC_11db, range is ADC_0db, ADC_2_5db, ADC_6db, ADC_11db 22 | analogSetPinAttenuation(VP,ADC_11db); // Sets the input attenuation, default is ADC_11db, range is ADC_0db, ADC_2_5db, ADC_6db, ADC_11db 23 | // ADC_0db provides no attenuation so IN/OUT = 1 / 1 an input of 3 volts remains at 3 volts before ADC measurement 24 | // ADC_2_5db provides an attenuation so that IN/OUT = 1 / 1.34 an input of 3 volts is reduced to 2.238 volts before ADC measurement 25 | // ADC_6db provides an attenuation so that IN/OUT = 1 / 2 an input of 3 volts is reduced to 1.500 volts before ADC measurement 26 | // ADC_11db provides an attenuation so that IN/OUT = 1 / 3.6 an input of 3 volts is reduced to 0.833 volts before ADC measurement 27 | adcAttachPin(VP); // Attach a pin to ADC (also clears any other analog mode that could be on), returns TRUE/FALSE result 28 | adcStart(VP); // Starts an ADC conversion on attached pin's bus 29 | adcBusy(VP); // Check if conversion on the pin's ADC bus is currently running, returns TRUE/FALSE result 30 | adcEnd(VP); // Get the result of the conversion (will wait if it have not finished), returns 16-bit integer result 31 | */ 32 | adcAttachPin(13); 33 | analogSetClockDiv(255); // 1338mS 34 | } 35 | 36 | void loop() { 37 | int timer = micros(); 38 | Serial.print(analogRead(13)); 39 | Serial.print(" "); 40 | Serial.println(micros() - timer); 41 | } 42 | 43 | //See more APIs about ADC here: https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/esp32/cores/esp32/esp32-hal-adc.h 44 | 45 | -------------------------------------------------------------------------------- /examples/ESP32/ADC_Read_Voltage/README.md: -------------------------------------------------------------------------------- 1 | # ADC_Read_Voltage_Simple 2 | Basic ADC example read voltage. 3 | 4 | # ADC_Read_Voltage_Accurate 5 | A function that improves the defaulot ADC reading accuracy to within 1% 6 | -------------------------------------------------------------------------------- /examples/ESP32/ESP32_Dual_Core/README.md: -------------------------------------------------------------------------------- 1 | ## Contents 2 | 3 | - [The Overview](#the-overview) 4 | - [ShowCore](#showcore) 5 | - [MoveCore](#movecore) 6 | - [SpeedTest](#speedtest) 7 | - [Information](#information) 8 | 9 | # The Overview 10 | 11 | - The ESP32 chip has three cores. 12 | - Two cores are fast cores and one core is a low-power core. 13 | - Which is an example of ESP32 Dual Core on Arduino IDE including Data Passing and Task Synchronization. 14 | 15 | 16 | ## ShowCore 17 | 18 | In the first step, we need to know which core the current program is running on. 19 | We need a code to print the current core from the serial port. 20 | 21 | ``` 22 | Serial.println(xPortGetCoreID()); 23 | ``` 24 | 25 | ![](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/esp32/libraries/ESP32/examples/ESP32_Dual_Core/resources/print_core.png) 26 | 27 | We prepared an [example](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/tree/master/esp32/libraries/ESP32/examples/ESP32_Dual_Core/examples/Showcore) for you. 28 | 29 | ## MoveCore 30 | 31 | Run the program with the specified core. 32 | ![](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/esp32/libraries/ESP32/examples/ESP32_Dual_Core/resources/MoveCore.png) 33 | 34 | - We use the following code to perform core switching 35 | ``` 36 | xTaskCreatePinnedToCore( 37 | codeForTask1, /*Task Function. */ 38 | "Task_1", /*name of task. */ 39 | 1000, /*Stack size of task. */ 40 | NULL, /* parameter of the task. */ 41 | 1, /* proiority of the task. */ 42 | &Task1, /* Task handel to keep tra ck of created task. */ 43 | 0); /* choose Core */ 44 | ``` 45 | 46 | Check this [example](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/tree/master/esp32/libraries/ESP32/examples/ESP32_Dual_Core/examples/Movecore) to see how you can switch the core. 47 | 48 | ## SpeedTest 49 | 50 | Test the speed of the two cores under different conditions. 51 | ![](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/esp32/libraries/ESP32/examples/ESP32_Dual_Core/resources/SpeedTest.png) 52 | 53 | In this [example](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/tree/master/esp32/libraries/ESP32/examples/ESP32_Dual_Core/examples/SpeedTest) the program is running as follows: 54 | 55 | ![](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/esp32/libraries/ESP32/examples/ESP32_Dual_Core/resources/Task_Synchronization.png) 56 | 57 | The result of the operation is as follows: 58 | ![](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/esp32/libraries/ESP32/examples/ESP32_Dual_Core/resources/Result.png) 59 | At this time, 0 core and 1 core full speed synchronous processing independent tasks. 60 | 61 | ## Information 62 | 63 | ![](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/InstallGuide/win-screenshots/WIFI_LoRa_32.png) 64 | 65 | - [PinoutDiagram](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/PinoutDiagram/WIFI%20LoRa%2032(V2)%20.pdf) 66 | - node: [WIFI LoRa 32 V2](https://item.taobao.com/item.htm?spm=a1z10.1-c.w4004-17008247508.4.7bdf1d6f2XG3ID&id=575190433694) 67 | - Arduino 18.04 68 | -------------------------------------------------------------------------------- /examples/ESP32/ESP32_Dual_Core/examples/Movecore/Movecore.ino: -------------------------------------------------------------------------------- 1 | #define LED1 25 2 | TaskHandle_t Task1; 3 | 4 | void codeForTask1( void * parameter ) 5 | { 6 | for(;;) { 7 | Serial.print("This Task run on Core: "); 8 | Serial.println(xPortGetCoreID()); 9 | 10 | digitalWrite(LED1,HIGH); 11 | delay(1000); 12 | digitalWrite(LED1,LOW); 13 | delay(1000); 14 | } 15 | } 16 | 17 | 18 | void setup() { 19 | Serial.begin(115200); 20 | pinMode(LED1,OUTPUT); 21 | 22 | xTaskCreatePinnedToCore( 23 | codeForTask1, /*Task Function. */ 24 | "Task_1", /*name of task. */ 25 | 1000, /*Stack size of task. */ 26 | NULL, /* parameter of the task. */ 27 | 1, /* proiority of the task. */ 28 | &Task1, /* Task handel to keep tra ck of created task. */ 29 | 0); /* choose Core */ 30 | } 31 | 32 | void loop() { 33 | 34 | } 35 | -------------------------------------------------------------------------------- /examples/ESP32/ESP32_Dual_Core/examples/Showcore/Showcore.ino: -------------------------------------------------------------------------------- 1 | #define LED1 25 2 | 3 | void setup() { 4 | Serial.begin(115200); 5 | pinMode(LED1,OUTPUT); 6 | } 7 | 8 | void loop() { 9 | Serial.print("This loop Task run on Core: "); 10 | Serial.println(xPortGetCoreID()); /*print the current core*/ 11 | digitalWrite(LED1,HIGH); 12 | delay(1000); 13 | digitalWrite(LED1,LOW); 14 | delay(1000); 15 | } 16 | -------------------------------------------------------------------------------- /examples/ESP32/ESP32_Dual_Core/examples/SpeedTest/SpeedTest.ino: -------------------------------------------------------------------------------- 1 | #define LED1 25 2 | long loops1 = 1000; 3 | long loops2 = 1000; 4 | long qq; 5 | float t1; 6 | int t2,t3; 7 | 8 | TaskHandle_t Task1, Task2; 9 | SemaphoreHandle_t baton; 10 | 11 | 12 | void artificialLoad () { 13 | for ( long i = 0;i < loops1; i++){ 14 | for ( long j = 1; j < loops2; j++) { 15 | qq++; 16 | t1 = 5000.0 * i; 17 | t2 = 150 * 1234 * i; 18 | t3 = j % 554 ; 19 | } 20 | } 21 | } 22 | void blink(){ 23 | digitalWrite(LED1,HIGH); 24 | delay(1000); 25 | digitalWrite(LED1,LOW); 26 | delay(1000); 27 | } 28 | 29 | void codeForTask1( void * parameter ) 30 | { 31 | for(;;){ 32 | long start = millis(); 33 | artificialLoad(); 34 | Serial.print("Finish loop Task run on Core: "); 35 | Serial.print(xPortGetCoreID()); 36 | Serial.print(" Time "); 37 | Serial.println(millis() - start); 38 | // blink(); 39 | } 40 | } 41 | 42 | 43 | void codeForTask2( void * parameter ) 44 | { 45 | for(;;){ 46 | // long start = millis(); 47 | // artificialLoad(); 48 | // Serial.print(" Finish loop Task run on Core: "); 49 | // Serial.print(xPortGetCoreID()); 50 | // Serial.print(" Time "); 51 | // Serial.println(millis() - start); 52 | delay(1000); 53 | } 54 | } 55 | void setup() { 56 | Serial.begin(115200); 57 | pinMode(LED1,OUTPUT); 58 | baton = xSemaphoreCreateMutex(); 59 | 60 | xTaskCreatePinnedToCore( 61 | codeForTask1, 62 | "Task_1", 63 | 1000, 64 | NULL, 65 | 1, 66 | &Task1, 67 | 0); 68 | 69 | delay(500); 70 | 71 | xTaskCreatePinnedToCore( 72 | codeForTask2, 73 | "Task_2", 74 | 1000, 75 | NULL, 76 | 1, 77 | &Task2, 78 | 1); 79 | } 80 | 81 | void loop() { 82 | long start = millis(); 83 | artificialLoad(); 84 | Serial.print(" Finish loop Task run on Core: "); 85 | Serial.print(xPortGetCoreID()); 86 | Serial.print(" Time "); 87 | Serial.println(millis() - start); 88 | delay(10); 89 | // delay(5000); 90 | } 91 | -------------------------------------------------------------------------------- /examples/ESP32/ESP32_Dual_Core/resources/MoveCore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/examples/ESP32/ESP32_Dual_Core/resources/MoveCore.png -------------------------------------------------------------------------------- /examples/ESP32/ESP32_Dual_Core/resources/Result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/examples/ESP32/ESP32_Dual_Core/resources/Result.png -------------------------------------------------------------------------------- /examples/ESP32/ESP32_Dual_Core/resources/SpeedTest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/examples/ESP32/ESP32_Dual_Core/resources/SpeedTest.png -------------------------------------------------------------------------------- /examples/ESP32/ESP32_Dual_Core/resources/Task_Synchronization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/examples/ESP32/ESP32_Dual_Core/resources/Task_Synchronization.png -------------------------------------------------------------------------------- /examples/ESP32/ESP32_Dual_Core/resources/print_core.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/examples/ESP32/ESP32_Dual_Core/resources/print_core.png -------------------------------------------------------------------------------- /examples/ESP32/ExternalWakeUp/ExternalWakeUp.ino: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * *******************HelTec AutoMation WiFi_Kit_series Example****************** 4 | Deep Sleep with External Wake Up 5 | ===================================== 6 | This code displays how to use deep sleep with 7 | an external trigger as a wake up source and how 8 | to store data in RTC memory to use it over reboots 9 | 10 | This code is under Public Domain License. 11 | 12 | Hardware Connections 13 | ====================== 14 | Push Button(PRG) to GPIO 0 pulled down with a 10K Ohm 15 | resistor 16 | 17 | NOTE: 18 | ====== 19 | Only RTC IO can be used as a source for external wake 20 | source. They are pins: 0,2,4,12-15,25-27,32-39. 21 | 22 | Author: 23 | Pranav Cherukupalli 24 | */ 25 | 26 | #include "driver/rtc_io.h" 27 | #define BUTTON_PIN_BITMASK 0x200000000 // 2^33 in hex 28 | 29 | RTC_DATA_ATTR int bootCount = 0; 30 | 31 | /* 32 | Method to print the reason by which ESP32 33 | has been awaken from sleep 34 | */ 35 | void print_wakeup_reason(){ 36 | esp_sleep_wakeup_cause_t wakeup_reason; 37 | 38 | wakeup_reason = esp_sleep_get_wakeup_cause(); 39 | 40 | switch(wakeup_reason) 41 | { 42 | case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break; 43 | case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break; 44 | case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break; 45 | case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break; 46 | case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break; 47 | default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break; 48 | } 49 | } 50 | 51 | void setup(){ 52 | rtc_gpio_deinit(GPIO_NUM_0); 53 | Serial.begin(115200); 54 | delay(1000); //Take some time to open up the Serial Monitor 55 | 56 | //Increment boot number and print it every reboot 57 | ++bootCount; 58 | Serial.println("Boot number: " + String(bootCount)); 59 | 60 | //Print the wakeup reason for ESP32 61 | print_wakeup_reason(); 62 | 63 | /* 64 | First we configure the wake up source 65 | We set our ESP32 to wake up for an external trigger. 66 | There are two types for ESP32, ext0 and ext1 . 67 | ext0 uses RTC_IO to wakeup thus requires RTC peripherals 68 | to be on while ext1 uses RTC Controller so doesnt need 69 | peripherals to be powered on. 70 | Note that using internal pullups/pulldowns also requires 71 | RTC peripherals to be turned on. 72 | */ 73 | rtc_gpio_pulldown_en(GPIO_NUM_0); 74 | esp_sleep_enable_ext0_wakeup(GPIO_NUM_0,0); //1 = High, 0 = Low 75 | 76 | //If you were to use ext1, you would use it like 77 | //esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH); 78 | 79 | //Go to sleep now 80 | Serial.println("Going to sleep now"); 81 | esp_deep_sleep_start(); 82 | Serial.println("This will never be printed"); 83 | } 84 | 85 | void loop(){ 86 | //This is not going to be called 87 | } 88 | -------------------------------------------------------------------------------- /examples/ESP32/GetChipID/GetChipID.ino: -------------------------------------------------------------------------------- 1 | /* The true ESP32 chip ID is essentially its MAC address.*/ 2 | 3 | uint64_t chipId = 0; 4 | 5 | void setup() { 6 | Serial.begin(115200); 7 | } 8 | 9 | void loop() { 10 | chipId=ESP.getEfuseMac(); 11 | Serial.printf("ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision()); 12 | Serial.printf("This chip has %d cores\n", ESP.getChipCores()); 13 | Serial.printf("ESP32ChipID=%04X",(uint16_t)(chipId>>32));//print High 2bytes 14 | Serial.printf("%08X\r\n",(uint32_t)chipId);//print Low 4bytes. 15 | delay(3000); 16 | } 17 | -------------------------------------------------------------------------------- /examples/ESP32/I2C_Scanner/I2C_Scanner.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation I2C scanner example (also it's a basic example how to use I2C1) 2 | * 3 | * ESP32 have two I2C (I2C0 and I2C1) bus 4 | * 5 | * OLED is connected to I2C0, so if scan with Wire (I2C0), the return address should be 0x3C. 6 | * 7 | * If you need scan other device address in I2C1... 8 | * - Comment all Wire.***() codes; 9 | * - Uncomment all Wire1.***() codes; 10 | * 11 | * I2C scan example and I2C0 12 | * 13 | * HelTec AutoMation, Chengdu, China 14 | * 成都惠利特自动化科技有限公司 15 | * www.heltec.org 16 | * 17 | * this project also realess in GitHub: 18 | * https://github.com/HelTecAutomation/Heltec_ESP32 19 | * */ 20 | 21 | #include "Arduino.h" 22 | #include "heltec.h" 23 | 24 | #if defined( WIRELESS_STICK_LITE ) 25 | #include 26 | #include "oled/SSD1306Wire.h" 27 | 28 | static const uint8_t SCL_OLED = 15; 29 | static const uint8_t SDA_OLED = 4; 30 | #endif 31 | 32 | void setup() 33 | { 34 | Heltec.begin(true, false, true); 35 | Wire.begin(SDA_OLED, SCL_OLED); //Scan OLED's I2C address via I2C0 36 | //Wire1.begin(SDA, SCL); //If there have other device on I2C1, scan the device address via I2C1 37 | } 38 | 39 | void loop() 40 | { 41 | byte error, address; 42 | int nDevices; 43 | 44 | Serial.println("Scanning..."); 45 | 46 | nDevices = 0; 47 | for(address = 1; address < 127; address++ ) 48 | { 49 | Wire.beginTransmission(address); 50 | error = Wire.endTransmission(); 51 | 52 | // Wire1.beginTransmission(address); 53 | // error = Wire1.endTransmission(); 54 | 55 | if (error == 0) 56 | { 57 | Serial.print("I2C device found at address 0x"); 58 | if (address<16) 59 | Serial.print("0"); 60 | Serial.print(address,HEX); 61 | Serial.println(" !"); 62 | 63 | nDevices++; 64 | } 65 | else if (error==4) 66 | { 67 | Serial.print("Unknown error at address 0x"); 68 | if (address<16) 69 | Serial.print("0"); 70 | Serial.println(address,HEX); 71 | } 72 | } 73 | if (nDevices == 0) 74 | Serial.println("No I2C devices found\n"); 75 | else 76 | Serial.println("done\n"); 77 | 78 | delay(5000); 79 | } 80 | -------------------------------------------------------------------------------- /examples/ESP32/PSRAM_Test/PSRAM_Test.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation ESP32 external PSRAM read/write example 2 | * 3 | * Must have external PSRAM connected. 4 | * 5 | * HelTec AutoMation, Chengdu, China 6 | * 成都惠利特自动化科技有限公司 7 | * https://heltec.org 8 | * 9 | * this project also realess in GitHub: 10 | * https://github.com/HelTecAutomation/Heltec_ESP32 11 | */ 12 | 13 | 14 | #include 15 | 16 | void setup() { 17 | Serial.begin(115200); 18 | 19 | Serial.printf("Total heap: %d\r\n", ESP.getHeapSize()); 20 | Serial.printf("Free heap: %d\r\n", ESP.getFreeHeap()); 21 | Serial.printf("Total PSRAM: %d\r\n", ESP.getPsramSize()); 22 | byte* psdRamBuffer = (byte*)ps_malloc(4000000); 23 | Serial.printf("Free PSRAM: %d\r\n", ESP.getFreePsram()); 24 | } 25 | 26 | void loop() {} 27 | -------------------------------------------------------------------------------- /examples/ESP32/RTC_counter/RTC_counter.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "soc/rtc.h" 3 | 4 | /*rtc_time_get() return the RTC counters 5 | * the board using internal 150KHz RTC, but it's not accurate. 6 | */ 7 | void setup() { 8 | // put your setup code here, to run once: 9 | Serial.begin(115200); 10 | } 11 | 12 | void loop() { 13 | uint64_t rtc_counter1 = rtc_time_get(); 14 | delay(1000); 15 | uint64_t rtc_counter2 = rtc_time_get(); 16 | 17 | Serial.println((uint32_t)(rtc_counter2-rtc_counter1)); 18 | } -------------------------------------------------------------------------------- /examples/ESP32/Serial2/Serial2.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Heltec Automation ESP32 Serial 1 & 2 example. 3 | * shows the usage of all 3 hardware uarts 4 | * work with ESP32's IO MUX 5 | * 6 | * to test the software and hardware 7 | * wire Rx1 to Tx1 and Rx2 to Tx2 8 | * type text in serial monitor 9 | * text will walk trough all 2 serials 10 | * result is echoed to serial (usb) 11 | */ 12 | 13 | 14 | void setup() { 15 | Serial.begin(115200); 16 | 17 | // Serial1.begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert) 18 | // Serial2.begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert) 19 | // The txPin & rxPin can set to any output pin 20 | 21 | Serial1.begin(115200, SERIAL_8N1, 2, 17); 22 | Serial2.begin(115200, SERIAL_8N1, 22, 23); 23 | } 24 | 25 | void loop() { 26 | 27 | if(Serial.available()) { 28 | int ch = Serial.read(); 29 | Serial1.write(ch); 30 | } 31 | 32 | if(Serial2.available()) { 33 | int ch = Serial2.read(); 34 | Serial2.write(ch); 35 | } 36 | 37 | if(Serial2.available()) { 38 | int ch = Serial2.read(); 39 | Serial.write(ch); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/ESP32/ULP/HoldPinStatus/HoldPinStatus.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Hold GPIO status in deep sleep mode, use ESP32's ULP (Ultra Low Power) coprocessor 3 | * 4 | * HelTec AutoMation, Chengdu, China. 5 | * 成都惠利特自动化科技有限公司 6 | * www.heltec.cn 7 | * support@heltec.cn 8 | * 9 | *this project also release in GitHub: 10 | *https://github.com/HelTecAutomation/ESP32_LoRaWAN 11 | */ 12 | #include "soc/rtc_io_reg.h" 13 | #include "driver/rtc_io.h" 14 | 15 | #define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */ 16 | #define TIME_TO_SLEEP 5 /* Time ESP32 will go to sleep (in seconds) */ 17 | 18 | RTC_DATA_ATTR int bootCount = 0; 19 | 20 | void setup(){ 21 | rtc_gpio_hold_dis(GPIO_NUM_35); 22 | pinMode(35,OUTPUT); 23 | digitalWrite(35,LOW);//The on board LED will be OFF in wake up period 24 | 25 | Serial.begin(115200); 26 | delay(1000); //Take some time to open up the Serial Monitor 27 | 28 | //Increment boot number and print it every reboot 29 | ++bootCount; 30 | Serial.println("Boot number: " + String(bootCount)); 31 | delay(2); 32 | 33 | esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR); 34 | Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) + 35 | " Seconds"); 36 | delay(10); 37 | 38 | Serial.println("Going to sleep now"); 39 | delay(2); 40 | 41 | rtc_gpio_init(GPIO_NUM_35); 42 | pinMode(35,OUTPUT); 43 | digitalWrite(35,HIGH);//The on board LED will be ON in deep sleep period 44 | rtc_gpio_hold_en(GPIO_NUM_35); 45 | 46 | esp_deep_sleep_start(); 47 | Serial.println("This will never be printed"); 48 | } 49 | 50 | void loop(){ 51 | //This is not going to be called 52 | } -------------------------------------------------------------------------------- /examples/ESP32/VextControl/VextControl.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * HelTec Automation(TM) Vext control example. 3 | * 4 | * Function summary: 5 | * 6 | * - Vext connected to 3.3V via a MOS-FET, the gate pin connected to GPIO21; 7 | * 8 | * - OLED display and PE4259(RF switch) use Vext as power supply; 9 | * 10 | * - WIFI Kit series V1 don't have Vext control function; 11 | * 12 | * HelTec AutoMation, Chengdu, China. 13 | * 成都惠利特自动化科技有限公司 14 | * www.heltec.cn 15 | * support@heltec.cn 16 | * 17 | * this project also release in GitHub: 18 | * https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series 19 | */ 20 | 21 | #include "Arduino.h" 22 | #include "heltec.h" 23 | void setup() 24 | { 25 | //WIFI Kit series V1 not support Vext control 26 | Heltec.begin(true /*DisplayEnable Enable*/, false /*LoRa Disable*/, true /*Serial Enable*/); 27 | //OLED use Vext power supply, Vext must be turn ON before OLED initialition. 28 | Heltec.display->init(); 29 | 30 | Heltec.display->flipScreenVertically(); 31 | Heltec.display->setFont(ArialMT_Plain_10); 32 | Heltec.display->drawString(0, 0, "Hello, I'm happy today"); 33 | Heltec.display->display(); 34 | delay(1000); 35 | } 36 | 37 | void loop() 38 | { 39 | Heltec.display->sleep();//OLED sleep 40 | Heltec.VextON(); 41 | Serial.println("Turn OFF Vext"); 42 | delay(5000); 43 | 44 | Heltec.VextOFF(); 45 | Serial.println("Turn ON Vext"); 46 | Heltec.display->wakeup(); 47 | delay(5000); 48 | } 49 | -------------------------------------------------------------------------------- /examples/ESP32/WiFiLoRa32_battery_read/WiFiLoRa32_battery_read.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ADC read voltage via GPIO1 simple test. 3 | Base on Wi_Fi LoRa 32 V3.2 4 | by Aaron.Lee from HelTec AutoMation, ChengDu, China 5 | 成都惠利特自动化科技有限公司 6 | www.heltec.cn 7 | */ 8 | 9 | void setup() { 10 | // Initialize serial communication at 115200 bits per second: 11 | Serial.begin(115200); 12 | 13 | // Set the resolution of the analog-to-digital converter (ADC) to 12 bits (0-4095): 14 | analogReadResolution(12); 15 | 16 | // Set pin 37 as an output pin (used for ADC control): 17 | pinMode(37, OUTPUT); 18 | 19 | // Set pin 37 to HIGH (enable ADC control): 20 | digitalWrite(37, HIGH); 21 | } 22 | 23 | void loop() { 24 | // Read the raw analog value from pin 1 (range: 0-4095 for 12-bit resolution): 25 | int analogValue = analogRead(1); 26 | 27 | // Read the analog voltage in millivolts from pin 1: 28 | int analogVolts = analogReadMilliVolts(1); 29 | 30 | // Print the scaled analog value (scaled by a factor of 490/100): 31 | Serial.printf("ADC analog value = %d\n", analogValue * 490 / 100); 32 | 33 | // Print the scaled millivolts value (scaled by a factor of 490/100): 34 | Serial.printf("ADC millivolts value = %d\n", analogVolts * 490 / 100); 35 | 36 | // Add a delay of 1 second between readings for clear serial output: 37 | delay(1000); 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /examples/Factory_Test/Vision_Master_E290_FactoryTest/checklicense.cpp: -------------------------------------------------------------------------------- 1 | #include "LoRaWan_APP.h" 2 | 3 | 4 | extern void getLicenseAddress(uint8_t board_type); 5 | RTC_DATA_ATTR static bool licenseok=false; 6 | extern void readlicense(uint8_t board_type); 7 | extern uint32_t storedlicense[4]; 8 | extern void writelicense(uint32_t * license,uint8_t board_type); 9 | extern int calRTC(uint32_t * license); 10 | extern void check_input_license(); 11 | // extern uint32_t ex_32k_start_cnt; 12 | 13 | void checklicense() 14 | { 15 | if(licenseok==false) 16 | { 17 | getLicenseAddress(HELTEC_BOARD); 18 | readlicense(HELTEC_BOARD); 19 | if(calRTC(storedlicense)!=1) 20 | { 21 | uint64_t chipid=ESP.getEfuseMac(); 22 | lora_printf("Please provide a correct license! For more information:\r\n"); 23 | lora_printf("http://www.heltec.cn/search/\r\n"); 24 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes 25 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes. 26 | 27 | //read cdkey from uart 28 | uint32_t print_timestart; 29 | print_timestart = millis(); 30 | 31 | for(;;) 32 | { 33 | if(millis() -print_timestart > 3000 ) 34 | { 35 | print_timestart = millis(); 36 | lora_printf("Please provide a correct license! For more information:\r\n"); 37 | lora_printf("http://www.heltec.cn/search/\r\n"); 38 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes 39 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes. 40 | } 41 | 42 | check_input_license(); 43 | if(calRTC(storedlicense)==1) 44 | { 45 | writelicense(storedlicense,HELTEC_BOARD); 46 | lora_printf("The board is actived\r\n"); 47 | break; 48 | } 49 | } 50 | } 51 | else 52 | { 53 | licenseok=true; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /examples/Factory_Test/Vision_Master_T190_FactoryTest/checklicense.cpp: -------------------------------------------------------------------------------- 1 | #include "LoRaWan_APP.h" 2 | 3 | 4 | extern void getLicenseAddress(uint8_t board_type); 5 | RTC_DATA_ATTR static bool licenseok=false; 6 | extern void readlicense(uint8_t board_type); 7 | extern uint32_t storedlicense[4]; 8 | extern void writelicense(uint32_t * license,uint8_t board_type); 9 | extern int calRTC(uint32_t * license); 10 | extern void check_input_license(); 11 | extern uint32_t ex_32k_start_cnt; 12 | 13 | void checklicense() 14 | { 15 | if(licenseok==false) 16 | { 17 | getLicenseAddress(HELTEC_BOARD); 18 | readlicense(HELTEC_BOARD); 19 | if(calRTC(storedlicense)!=1) 20 | { 21 | uint64_t chipid=ESP.getEfuseMac(); 22 | lora_printf("Please provide a correct license! For more information:\r\n"); 23 | lora_printf("http://www.heltec.cn/search/\r\n"); 24 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes 25 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes. 26 | 27 | //read cdkey from uart 28 | uint32_t print_timestart; 29 | print_timestart = millis(); 30 | 31 | for(;;) 32 | { 33 | if(millis() -print_timestart > 3000 ) 34 | { 35 | print_timestart = millis(); 36 | lora_printf("Please provide a correct license! For more information:\r\n"); 37 | lora_printf("http://www.heltec.cn/search/\r\n"); 38 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes 39 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes. 40 | } 41 | 42 | check_input_license(); 43 | if(calRTC(storedlicense)==1) 44 | { 45 | writelicense(storedlicense,HELTEC_BOARD); 46 | lora_printf("The board is actived\r\n"); 47 | break; 48 | } 49 | } 50 | } 51 | else 52 | { 53 | licenseok=true; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /examples/Factory_Test/Vsion_Master_E0213A367_FactoryTest/checklicense.cpp: -------------------------------------------------------------------------------- 1 | #include "LoRaWan_APP.h" 2 | 3 | 4 | extern void getLicenseAddress(uint8_t board_type); 5 | RTC_DATA_ATTR static bool licenseok=false; 6 | extern void readlicense(uint8_t board_type); 7 | extern uint32_t storedlicense[4]; 8 | extern void writelicense(uint32_t * license,uint8_t board_type); 9 | extern int calRTC(uint32_t * license); 10 | extern void check_input_license(); 11 | extern uint32_t ex_32k_start_cnt; 12 | 13 | void checklicense() 14 | { 15 | if(licenseok==false) 16 | { 17 | getLicenseAddress(HELTEC_BOARD); 18 | readlicense(HELTEC_BOARD); 19 | if(calRTC(storedlicense)!=1) 20 | { 21 | uint64_t chipid=ESP.getEfuseMac(); 22 | lora_printf("Please provide a correct license! For more information:\r\n"); 23 | lora_printf("http://www.heltec.cn/search/\r\n"); 24 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes 25 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes. 26 | 27 | //read cdkey from uart 28 | uint32_t print_timestart; 29 | print_timestart = millis(); 30 | 31 | for(;;) 32 | { 33 | if(millis() -print_timestart > 3000 ) 34 | { 35 | print_timestart = millis(); 36 | lora_printf("Please provide a correct license! For more information:\r\n"); 37 | lora_printf("http://www.heltec.cn/search/\r\n"); 38 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes 39 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes. 40 | } 41 | 42 | check_input_license(); 43 | if(calRTC(storedlicense)==1) 44 | { 45 | writelicense(storedlicense,HELTEC_BOARD); 46 | lora_printf("The board is actived\r\n"); 47 | break; 48 | } 49 | } 50 | } 51 | else 52 | { 53 | licenseok=true; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /examples/Factory_Test/Vsion_Master_E213_FactoryTest/checklicense.cpp: -------------------------------------------------------------------------------- 1 | #include "LoRaWan_APP.h" 2 | 3 | 4 | extern void getLicenseAddress(uint8_t board_type); 5 | RTC_DATA_ATTR static bool licenseok=false; 6 | extern void readlicense(uint8_t board_type); 7 | extern uint32_t storedlicense[4]; 8 | extern void writelicense(uint32_t * license,uint8_t board_type); 9 | extern int calRTC(uint32_t * license); 10 | extern void check_input_license(); 11 | extern uint32_t ex_32k_start_cnt; 12 | 13 | void checklicense() 14 | { 15 | if(licenseok==false) 16 | { 17 | getLicenseAddress(HELTEC_BOARD); 18 | readlicense(HELTEC_BOARD); 19 | if(calRTC(storedlicense)!=1) 20 | { 21 | uint64_t chipid=ESP.getEfuseMac(); 22 | lora_printf("Please provide a correct license! For more information:\r\n"); 23 | lora_printf("http://www.heltec.cn/search/\r\n"); 24 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes 25 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes. 26 | 27 | //read cdkey from uart 28 | uint32_t print_timestart; 29 | print_timestart = millis(); 30 | 31 | for(;;) 32 | { 33 | if(millis() -print_timestart > 3000 ) 34 | { 35 | print_timestart = millis(); 36 | lora_printf("Please provide a correct license! For more information:\r\n"); 37 | lora_printf("http://www.heltec.cn/search/\r\n"); 38 | lora_printf("ESP32ChipID=%04X",(uint16_t)(chipid>>32));//print High 2 bytes 39 | lora_printf("%08X\r\n",(uint32_t)chipid);//print Low 4bytes. 40 | } 41 | 42 | check_input_license(); 43 | if(calRTC(storedlicense)==1) 44 | { 45 | writelicense(storedlicense,HELTEC_BOARD); 46 | lora_printf("The board is actived\r\n"); 47 | break; 48 | } 49 | } 50 | } 51 | else 52 | { 53 | licenseok=true; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /examples/Factory_Test/Wireless_Paper_V1.1_FactoryTest/images.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGES_H 2 | #define IMAGES_H 3 | 4 | #define logo_width 60 5 | #define logo_height 36 6 | const uint8_t logo_bits[] = { 7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 9 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 10 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 11 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 12 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 13 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF, 14 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00, 15 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C, 16 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00, 17 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C, 18 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00, 19 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 20 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 21 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C, 22 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00, 23 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F, 24 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00, 25 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 26 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 27 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 28 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | }; 32 | 33 | const char activeSymbol[] PROGMEM = { 34 | B00000000, 35 | B00000000, 36 | B00011000, 37 | B00100100, 38 | B01000010, 39 | B01000010, 40 | B00100100, 41 | B00011000 42 | }; 43 | 44 | const char inactiveSymbol[] PROGMEM = { 45 | B00000000, 46 | B00000000, 47 | B00000000, 48 | B00000000, 49 | B00011000, 50 | B00011000, 51 | B00000000, 52 | B00000000 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /examples/GPS/GPSDisplayOnTFT/GPSDisplayOnTFT.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "HT_st7735.h" 3 | #include "HT_TinyGPS++.h" 4 | 5 | 6 | TinyGPSPlus GPS; 7 | HT_st7735 st7735; 8 | 9 | #define VGNSS_CTRL 3 10 | 11 | 12 | void GPS_test(void) 13 | { 14 | pinMode(VGNSS_CTRL,OUTPUT); 15 | digitalWrite(VGNSS_CTRL,HIGH); 16 | Serial1.begin(115200,SERIAL_8N1,33,34); 17 | Serial.println("GPS_test"); 18 | st7735.st7735_fill_screen(ST7735_BLACK); 19 | delay(100); 20 | st7735.st7735_write_str(0, 0, (String)"GPS_test"); 21 | 22 | while(1) 23 | { 24 | if(Serial1.available()>0) 25 | { 26 | if(Serial1.peek()!='\n') 27 | { 28 | GPS.encode(Serial1.read()); 29 | } 30 | else 31 | { 32 | Serial1.read(); 33 | if(GPS.time.second()==0) 34 | { 35 | continue; 36 | } 37 | st7735.st7735_fill_screen(ST7735_BLACK); 38 | st7735.st7735_write_str(0, 0, (String)"GPS_test"); 39 | String time_str = (String)GPS.time.hour() + ":" + (String)GPS.time.minute() + ":" + (String)GPS.time.second()+ ":"+(String)GPS.time.centisecond(); 40 | st7735.st7735_write_str(0, 20, time_str); 41 | String latitude = "LAT: " + (String)GPS.location.lat(); 42 | st7735.st7735_write_str(0, 40, latitude); 43 | String longitude = "LON: "+ (String)GPS.location.lng(); 44 | st7735.st7735_write_str(0, 60, longitude); 45 | 46 | 47 | delay(5000); 48 | while(Serial1.read()>0); 49 | } 50 | } 51 | } 52 | } 53 | 54 | void setup(){ 55 | delay(100); 56 | st7735.st7735_init(); 57 | GPS_test(); 58 | } 59 | 60 | void loop(){ 61 | delay(100); 62 | } 63 | -------------------------------------------------------------------------------- /examples/GPS/GPSToUart/GPSToUart.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "HT_TinyGPS++.h" 3 | 4 | 5 | TinyGPSPlus GPS; 6 | 7 | #define VGNSS_CTRL 3 8 | 9 | 10 | void GPS_test(void) 11 | { 12 | pinMode(VGNSS_CTRL,OUTPUT); 13 | digitalWrite(VGNSS_CTRL,HIGH); 14 | Serial1.begin(115200,SERIAL_8N1,33,34); 15 | Serial.println("GPS_test"); 16 | 17 | delay(100); 18 | 19 | while(1) 20 | { 21 | if(Serial1.available()>0) 22 | { 23 | if(Serial1.peek()!='\n') 24 | { 25 | GPS.encode(Serial1.read()); 26 | } 27 | else 28 | { 29 | Serial1.read(); 30 | if(GPS.time.second()==0) 31 | { 32 | continue; 33 | } 34 | Serial.printf(" %02d:%02d:%02d.%02d",GPS.time.hour(),GPS.time.minute(),GPS.time.second(),GPS.time.centisecond()); 35 | Serial.print("LAT: "); 36 | Serial.print(GPS.location.lat(), 6); 37 | Serial.print(", LON: "); 38 | Serial.print(GPS.location.lng(), 6); 39 | Serial.println(); 40 | 41 | delay(5000); 42 | while(Serial1.read()>0); 43 | } 44 | } 45 | } 46 | } 47 | 48 | void setup(){ 49 | Serial.begin(115200); 50 | Serial.println("GPS_test"); 51 | delay(1000); 52 | GPS_test(); 53 | } 54 | 55 | void loop(){ 56 | delay(100); 57 | } 58 | -------------------------------------------------------------------------------- /examples/LoRaBasic/LoRaReceiver/LoRaReceiver.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation Receive communication test example 2 | * 3 | * Function: 4 | * 1. Receive the same frequency band lora signal program 5 | * 6 | * Description: 7 | * 8 | * HelTec AutoMation, Chengdu, China 9 | * 成都惠利特自动化科技有限公司 10 | * www.heltec.org 11 | * 12 | * this project also realess in GitHub: 13 | * https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series 14 | * */ 15 | 16 | #include "LoRaWan_APP.h" 17 | #include "Arduino.h" 18 | 19 | 20 | #define RF_FREQUENCY 915000000 // Hz 21 | 22 | #define TX_OUTPUT_POWER 14 // dBm 23 | 24 | #define LORA_BANDWIDTH 0 // [0: 125 kHz, 25 | // 1: 250 kHz, 26 | // 2: 500 kHz, 27 | // 3: Reserved] 28 | #define LORA_SPREADING_FACTOR 7 // [SF7..SF12] 29 | #define LORA_CODINGRATE 1 // [1: 4/5, 30 | // 2: 4/6, 31 | // 3: 4/7, 32 | // 4: 4/8] 33 | #define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx 34 | #define LORA_SYMBOL_TIMEOUT 0 // Symbols 35 | #define LORA_FIX_LENGTH_PAYLOAD_ON false 36 | #define LORA_IQ_INVERSION_ON false 37 | 38 | 39 | #define RX_TIMEOUT_VALUE 1000 40 | #define BUFFER_SIZE 30 // Define the payload size here 41 | 42 | char txpacket[BUFFER_SIZE]; 43 | char rxpacket[BUFFER_SIZE]; 44 | 45 | static RadioEvents_t RadioEvents; 46 | 47 | int16_t txNumber; 48 | 49 | int16_t rssi,rxSize; 50 | 51 | bool lora_idle = true; 52 | 53 | void setup() { 54 | Serial.begin(115200); 55 | Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE); 56 | 57 | txNumber=0; 58 | rssi=0; 59 | 60 | RadioEvents.RxDone = OnRxDone; 61 | Radio.Init( &RadioEvents ); 62 | Radio.SetChannel( RF_FREQUENCY ); 63 | Radio.SetRxConfig( MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR, 64 | LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH, 65 | LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON, 66 | 0, true, 0, 0, LORA_IQ_INVERSION_ON, true ); 67 | } 68 | 69 | 70 | 71 | void loop() 72 | { 73 | if(lora_idle) 74 | { 75 | lora_idle = false; 76 | Serial.println("into RX mode"); 77 | Radio.Rx(0); 78 | } 79 | Radio.IrqProcess( ); 80 | } 81 | 82 | void OnRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr ) 83 | { 84 | rssi=rssi; 85 | rxSize=size; 86 | memcpy(rxpacket, payload, size ); 87 | rxpacket[size]='\0'; 88 | Radio.Sleep( ); 89 | Serial.printf("\r\nreceived packet \"%s\" with rssi %d , length %d\r\n",rxpacket,rssi,rxSize); 90 | lora_idle = true; 91 | } -------------------------------------------------------------------------------- /examples/LoRaBasic/LoRaSender/LoRaSender.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation send communication test example 2 | * 3 | * Function: 4 | * 1. Send data from a esp32 device over hardware 5 | * 6 | * Description: 7 | * 8 | * HelTec AutoMation, Chengdu, China 9 | * 成都惠利特自动化科技有限公司 10 | * www.heltec.org 11 | * 12 | * this project also realess in GitHub: 13 | * https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series 14 | * */ 15 | 16 | #include "LoRaWan_APP.h" 17 | #include "Arduino.h" 18 | 19 | 20 | #define RF_FREQUENCY 915000000 // Hz 21 | 22 | #define TX_OUTPUT_POWER 5 // dBm 23 | 24 | #define LORA_BANDWIDTH 0 // [0: 125 kHz, 25 | // 1: 250 kHz, 26 | // 2: 500 kHz, 27 | // 3: Reserved] 28 | #define LORA_SPREADING_FACTOR 7 // [SF7..SF12] 29 | #define LORA_CODINGRATE 1 // [1: 4/5, 30 | // 2: 4/6, 31 | // 3: 4/7, 32 | // 4: 4/8] 33 | #define LORA_PREAMBLE_LENGTH 8 // Same for Tx and Rx 34 | #define LORA_SYMBOL_TIMEOUT 0 // Symbols 35 | #define LORA_FIX_LENGTH_PAYLOAD_ON false 36 | #define LORA_IQ_INVERSION_ON false 37 | 38 | 39 | #define RX_TIMEOUT_VALUE 1000 40 | #define BUFFER_SIZE 30 // Define the payload size here 41 | 42 | char txpacket[BUFFER_SIZE]; 43 | char rxpacket[BUFFER_SIZE]; 44 | 45 | double txNumber; 46 | 47 | bool lora_idle=true; 48 | 49 | static RadioEvents_t RadioEvents; 50 | void OnTxDone( void ); 51 | void OnTxTimeout( void ); 52 | 53 | void setup() { 54 | Serial.begin(115200); 55 | Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE); 56 | 57 | txNumber=0; 58 | 59 | RadioEvents.TxDone = OnTxDone; 60 | RadioEvents.TxTimeout = OnTxTimeout; 61 | 62 | Radio.Init( &RadioEvents ); 63 | Radio.SetChannel( RF_FREQUENCY ); 64 | Radio.SetTxConfig( MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH, 65 | LORA_SPREADING_FACTOR, LORA_CODINGRATE, 66 | LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON, 67 | true, 0, 0, LORA_IQ_INVERSION_ON, 3000 ); 68 | } 69 | 70 | 71 | 72 | void loop() 73 | { 74 | if(lora_idle == true) 75 | { 76 | delay(1000); 77 | txNumber += 0.01; 78 | sprintf(txpacket,"Hello world number %0.2f",txNumber); //start a package 79 | 80 | Serial.printf("\r\nsending packet \"%s\" , length %d\r\n",txpacket, strlen(txpacket)); 81 | 82 | Radio.Send( (uint8_t *)txpacket, strlen(txpacket) ); //send the package out 83 | lora_idle = false; 84 | } 85 | Radio.IrqProcess( ); 86 | } 87 | 88 | void OnTxDone( void ) 89 | { 90 | Serial.println("TX done......"); 91 | lora_idle = true; 92 | } 93 | 94 | void OnTxTimeout( void ) 95 | { 96 | Radio.Sleep( ); 97 | Serial.println("TX Timeout......"); 98 | lora_idle = true; 99 | } -------------------------------------------------------------------------------- /examples/LoRaBasic/README.md: -------------------------------------------------------------------------------- 1 | # LoRaBasic Folder 2 | 3 | All examples in this path, just directly call the SX1262 hardware layer to transmit LoRa signals, and do not include any operations with protocol layer. -------------------------------------------------------------------------------- /examples/LoRaBasic/TxPowerTest/TxPowerTest.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation txpower test example 2 | * 3 | * Function: 4 | * 1. Lora transmission power test. 5 | * 6 | * 7 | * this project also realess in GitHub: 8 | * https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series 9 | * */ 10 | 11 | #include "LoRaWan_APP.h" 12 | #include "Arduino.h" 13 | 14 | #define RF_FREQUENCY 868000000 // Hz 15 | #define TX_OUTPUT_POWER 10 // 20 dBm 16 | #define TX_TIMEOUT 10 // seconds (MAX value) 17 | static RadioEvents_t RadioEvents; 18 | 19 | void OnRadioTxTimeout( void ) 20 | { 21 | // Restarts continuous wave transmission when timeout expires 22 | Radio.SetTxContinuousWave( RF_FREQUENCY, TX_OUTPUT_POWER, TX_TIMEOUT ); 23 | } 24 | void setup() { 25 | // put your setup code here, to run once: 26 | Serial.begin(115200); 27 | Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE); 28 | RadioEvents.TxTimeout = OnRadioTxTimeout; 29 | Radio.Init( &RadioEvents ); 30 | 31 | Radio.SetTxContinuousWave( RF_FREQUENCY, TX_OUTPUT_POWER, TX_TIMEOUT ); 32 | } 33 | 34 | void loop() { 35 | // put your main code here, to run repeatedly: 36 | Radio.IrqProcess( ); 37 | } -------------------------------------------------------------------------------- /examples/LoRaWAN/LoRaWan/LoRaWan.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation LoRaWAN communication example 2 | * 3 | * Function: 4 | * 1. Upload node data to the server using the standard LoRaWAN protocol. 5 | * 6 | * Description: 7 | * 1. Communicate using LoRaWAN protocol. 8 | * 9 | * HelTec AutoMation, Chengdu, China 10 | * 成都惠利特自动化科技有限公司 11 | * www.heltec.org 12 | * 13 | * */ 14 | 15 | #include "LoRaWan_APP.h" 16 | 17 | /* OTAA para*/ 18 | uint8_t devEui[] = { 0x70, 0xB3, 0xD5, 0x7E, 0xD0, 0x06, 0x53, 0xC8 }; 19 | uint8_t appEui[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 20 | uint8_t appKey[] = { 0x74, 0xD6, 0x6E, 0x63, 0x45, 0x82, 0x48, 0x27, 0xFE, 0xC5, 0xB7, 0x70, 0xBA, 0x2B, 0x50, 0x45 }; 21 | 22 | /* ABP para*/ 23 | uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 }; 24 | uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 }; 25 | uint32_t devAddr = ( uint32_t )0x007e6ae1; 26 | 27 | /*LoraWan channelsmask, default channels 0-7*/ 28 | uint16_t userChannelsMask[6]={ 0x00FF,0x0000,0x0000,0x0000,0x0000,0x0000 }; 29 | 30 | /*LoraWan region, select in arduino IDE tools*/ 31 | LoRaMacRegion_t loraWanRegion = ACTIVE_REGION; 32 | 33 | /*LoraWan Class, Class A and Class C are supported*/ 34 | DeviceClass_t loraWanClass = CLASS_A; 35 | 36 | /*the application data transmission duty cycle. value in [ms].*/ 37 | uint32_t appTxDutyCycle = 15000; 38 | 39 | /*OTAA or ABP*/ 40 | bool overTheAirActivation = true; 41 | 42 | /*ADR enable*/ 43 | bool loraWanAdr = true; 44 | 45 | /* Indicates if the node is sending confirmed or unconfirmed messages */ 46 | bool isTxConfirmed = true; 47 | 48 | /* Application port */ 49 | uint8_t appPort = 2; 50 | /*! 51 | * Number of trials to transmit the frame, if the LoRaMAC layer did not 52 | * receive an acknowledgment. The MAC performs a datarate adaptation, 53 | * according to the LoRaWAN Specification V1.0.2, chapter 18.4, according 54 | * to the following table: 55 | * 56 | * Transmission nb | Data Rate 57 | * ----------------|----------- 58 | * 1 (first) | DR 59 | * 2 | DR 60 | * 3 | max(DR-1,0) 61 | * 4 | max(DR-1,0) 62 | * 5 | max(DR-2,0) 63 | * 6 | max(DR-2,0) 64 | * 7 | max(DR-3,0) 65 | * 8 | max(DR-3,0) 66 | * 67 | * Note, that if NbTrials is set to 1 or 2, the MAC will not decrease 68 | * the datarate, in case the LoRaMAC layer did not receive an acknowledgment 69 | */ 70 | uint8_t confirmedNbTrials = 4; 71 | 72 | /* Prepares the payload of the frame */ 73 | static void prepareTxFrame( uint8_t port ) 74 | { 75 | /*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h". 76 | *appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE. 77 | *if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure. 78 | *if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF. 79 | *for example, if use REGION_CN470, 80 | *the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h". 81 | */ 82 | appDataSize = 4; 83 | appData[0] = 0x00; 84 | appData[1] = 0x01; 85 | appData[2] = 0x02; 86 | appData[3] = 0x03; 87 | } 88 | 89 | //if true, next uplink will add MOTE_MAC_DEVICE_TIME_REQ 90 | 91 | 92 | void setup() { 93 | Serial.begin(115200); 94 | Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE); 95 | } 96 | 97 | void loop() 98 | { 99 | switch( deviceState ) 100 | { 101 | case DEVICE_STATE_INIT: 102 | { 103 | #if(LORAWAN_DEVEUI_AUTO) 104 | LoRaWAN.generateDeveuiByChipID(); 105 | #endif 106 | LoRaWAN.init(loraWanClass,loraWanRegion); 107 | //both set join DR and DR when ADR off 108 | LoRaWAN.setDefaultDR(3); 109 | break; 110 | } 111 | case DEVICE_STATE_JOIN: 112 | { 113 | LoRaWAN.join(); 114 | break; 115 | } 116 | case DEVICE_STATE_SEND: 117 | { 118 | prepareTxFrame( appPort ); 119 | LoRaWAN.send(); 120 | deviceState = DEVICE_STATE_CYCLE; 121 | break; 122 | } 123 | case DEVICE_STATE_CYCLE: 124 | { 125 | // Schedule next packet transmission 126 | txDutyCycleTime = appTxDutyCycle + randr( -APP_TX_DUTYCYCLE_RND, APP_TX_DUTYCYCLE_RND ); 127 | LoRaWAN.cycle(txDutyCycleTime); 128 | deviceState = DEVICE_STATE_SLEEP; 129 | break; 130 | } 131 | case DEVICE_STATE_SLEEP: 132 | { 133 | LoRaWAN.sleep(loraWanClass); 134 | break; 135 | } 136 | default: 137 | { 138 | deviceState = DEVICE_STATE_INIT; 139 | break; 140 | } 141 | } 142 | } -------------------------------------------------------------------------------- /examples/LoRaWAN/LoRaWanGPSLocation/TTNDecoder.js: -------------------------------------------------------------------------------- 1 | function bytesToInt(by) { 2 | f = by[0] | by[1]<<8 | by[2]<<16 | by[3]<<24; 3 | return f; 4 | } 5 | 6 | function bytesToFloat(by) { 7 | var bits = by[3]<<24 | by[2]<<16 | by[1]<<8 | by[0]; 8 | var sign = (bits>>>31 === 0) ? 1.0 : -1.0; 9 | var e = bits>>>23 & 0xff; 10 | var m = (e === 0) ? (bits & 0x7fffff)<<1 : (bits & 0x7fffff) | 0x800000; 11 | var f = sign * m * Math.pow(2, e - 150); 12 | return f; 13 | } 14 | 15 | function Decoder(bytes, port) { 16 | 17 | var decoded = {}; 18 | i = 0; 19 | 20 | decoded.latitude = bytesToFloat(bytes.slice(i,i+=4)); 21 | decoded.longitude = bytesToFloat(bytes.slice(i,i+=4)); 22 | decoded.altitude = bytesToFloat(bytes.slice(i,i+=4)); 23 | decoded.course = bytesToFloat(bytes.slice(i,i+=4)); 24 | decoded.speed = bytesToFloat(bytes.slice(i,i+=4)); 25 | decoded.hdop = bytesToFloat(bytes.slice(i,i+=4)); 26 | 27 | decoded.battery = ((bytes[i++] << 8) | bytes[i++]); 28 | 29 | return decoded; 30 | } -------------------------------------------------------------------------------- /examples/LoRaWAN/LoRaWanGPSTime/TTNDecoder.js: -------------------------------------------------------------------------------- 1 | function bytesTouInt8(by) { 2 | f = by[0] | by[1]<<8 ; 3 | return f; 4 | } 5 | 6 | function bytesToFloat(by) { 7 | var bits = by[3]<<24 | by[2]<<16 | by[1]<<8 | by[0]; 8 | var sign = (bits>>>31 === 0) ? 1.0 : -1.0; 9 | var e = bits>>>23 & 0xff; 10 | var m = (e === 0) ? (bits & 0x7fffff)<<1 : (bits & 0x7fffff) | 0x800000; 11 | var f = sign * m * Math.pow(2, e - 150); 12 | return f; 13 | } 14 | 15 | function Decoder(bytes, port) { 16 | 17 | var decoded = {}; 18 | i = 0; 19 | 20 | decoded.hour = bytesToInt(bytes.slice(i,i+=2)); 21 | decoded.minute = bytesToInt(bytes.slice(i,i+=2)); 22 | decoded.second = bytesToFloat(bytes.slice(i,i+=2)); 23 | decoded.centisecond = bytesToFloat(bytes.slice(i,i+=2)); 24 | 25 | 26 | // decoded.battery = ((bytes[i++] << 8) | bytes[i++]); 27 | 28 | return decoded; 29 | } -------------------------------------------------------------------------------- /examples/OLED/OLED_rotate/OLED_rotate.ino: -------------------------------------------------------------------------------- 1 | 2 | #include "HT_SSD1306Wire.h" 3 | #include "Arduino.h" 4 | 5 | //rotate only for GEOMETRY_128_64 6 | static SSD1306Wire display(0x3c, 500000, SDA_OLED, SCL_OLED, GEOMETRY_128_64, RST_OLED); // addr , freq , i2c group , resolution , rst 7 | 8 | void VextON(void) 9 | { 10 | pinMode(Vext,OUTPUT); 11 | digitalWrite(Vext, LOW); 12 | } 13 | 14 | void VextOFF(void) //Vext default OFF 15 | { 16 | pinMode(Vext,OUTPUT); 17 | digitalWrite(Vext, HIGH); 18 | } 19 | 20 | void setup() { 21 | 22 | VextON(); 23 | delay(100); 24 | 25 | display.init(); 26 | display.clear(); 27 | display.display(); 28 | 29 | display.setContrast(255); 30 | 31 | display.setTextAlignment(TEXT_ALIGN_CENTER); 32 | display.clear(); 33 | display.display(); 34 | display.screenRotate(ANGLE_0_DEGREE); 35 | display.setFont(ArialMT_Plain_16); 36 | display.drawString(64, 32-16/2, "ROTATE_0"); 37 | display.display(); 38 | delay(2000); 39 | 40 | display.clear(); 41 | display.display(); 42 | display.screenRotate(ANGLE_90_DEGREE); 43 | display.setFont(ArialMT_Plain_10); 44 | display.drawString(32, 64-10/2, "ROTATE_90"); 45 | display.display(); 46 | delay(2000); 47 | 48 | display.clear(); 49 | display.display(); 50 | display.screenRotate(ANGLE_180_DEGREE); 51 | display.setFont(ArialMT_Plain_16); 52 | display.drawString(64, 32-16/2, "ROTATE_180"); 53 | display.display(); 54 | delay(2000); 55 | 56 | display.clear(); 57 | display.display(); 58 | display.screenRotate(ANGLE_270_DEGREE); 59 | display.setFont(ArialMT_Plain_10); 60 | display.drawString(32, 64-10/2, "ROTATE_270"); 61 | display.display(); 62 | delay(2000); 63 | } 64 | 65 | void loop() { } -------------------------------------------------------------------------------- /examples/OLED/SimpleDemo/SimpleDemo.ino: -------------------------------------------------------------------------------- 1 | // For a connection via I2C using the Arduino Wire include: 2 | #include 3 | #include "HT_SSD1306Wire.h" 4 | #include "images.h" 5 | 6 | static SSD1306Wire display(0x3c, 500000, SDA_OLED, SCL_OLED, GEOMETRY_128_64, RST_OLED); // addr , freq , i2c group , resolution , rst 7 | 8 | #define DEMO_DURATION 3000 9 | typedef void (*Demo)(void); 10 | 11 | int demoMode = 0; 12 | int counter = 1; 13 | 14 | void setup() { 15 | Serial.begin(115200); 16 | Serial.println(); 17 | Serial.println(); 18 | VextON(); 19 | delay(100); 20 | 21 | // Initialising the UI will init the display too. 22 | display.init(); 23 | 24 | display.setFont(ArialMT_Plain_10); 25 | 26 | } 27 | 28 | void drawFontFaceDemo() { 29 | // Font Demo1 30 | // create more fonts at http://oleddisplay.squix.ch/ 31 | display.setTextAlignment(TEXT_ALIGN_LEFT); 32 | display.setFont(ArialMT_Plain_10); 33 | display.drawString(0, 0, "Hello world"); 34 | display.setFont(ArialMT_Plain_16); 35 | display.drawString(0, 10, "Hello world"); 36 | display.setFont(ArialMT_Plain_24); 37 | display.drawString(0, 26, "Hello world"); 38 | } 39 | 40 | void drawTextFlowDemo() { 41 | display.setFont(ArialMT_Plain_10); 42 | display.setTextAlignment(TEXT_ALIGN_LEFT); 43 | display.drawStringMaxWidth(0, 0, 128, 44 | "Lorem ipsum\n dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore." ); 45 | } 46 | 47 | void drawTextAlignmentDemo() { 48 | // Text alignment demo 49 | char str[30]; 50 | int x = 0; 51 | int y = 0; 52 | display.setFont(ArialMT_Plain_10); 53 | // The coordinates define the left starting point of the text 54 | display.setTextAlignment(TEXT_ALIGN_LEFT); 55 | display.drawString(x, y, "Left aligned (0,0)"); 56 | 57 | // The coordinates define the center of the text 58 | display.setTextAlignment(TEXT_ALIGN_CENTER); 59 | x = display.width()/2; 60 | y = display.height()/2-5; 61 | sprintf(str,"Center aligned (%d,%d)",x,y); 62 | display.drawString(x, y, str); 63 | 64 | // The coordinates define the right end of the text 65 | display.setTextAlignment(TEXT_ALIGN_RIGHT); 66 | x = display.width(); 67 | y = display.height()-12; 68 | sprintf(str,"Right aligned (%d,%d)",x,y); 69 | display.drawString(x, y, str); 70 | } 71 | 72 | void drawRectDemo() { 73 | // Draw a pixel at given position 74 | for (int i = 0; i < 10; i++) { 75 | display.setPixel(i, i); 76 | display.setPixel(10 - i, i); 77 | } 78 | display.drawRect(12, 12, 20, 20); 79 | 80 | // Fill the rectangle 81 | display.fillRect(14, 14, 17, 17); 82 | 83 | // Draw a line horizontally 84 | display.drawHorizontalLine(0, 40, 20); 85 | 86 | // Draw a line horizontally 87 | display.drawVerticalLine(40, 0, 20); 88 | } 89 | 90 | void drawCircleDemo() { 91 | for (int i=1; i < 8; i++) { 92 | display.setColor(WHITE); 93 | display.drawCircle(32, 32, i*3); 94 | if (i % 2 == 0) { 95 | display.setColor(BLACK); 96 | } 97 | display.fillCircle(96, 32, 32 - i* 3); 98 | } 99 | } 100 | 101 | void drawProgressBarDemo() { 102 | int progress = (counter / 5) % 100; 103 | // draw the progress bar 104 | display.drawProgressBar(0, 32, 120, 10, progress); 105 | 106 | // draw the percentage as String 107 | display.setTextAlignment(TEXT_ALIGN_CENTER); 108 | display.drawString(64, 15, String(progress) + "%"); 109 | } 110 | 111 | void drawImageDemo() { 112 | // see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html 113 | // on how to create xbm files 114 | display.drawXbm(34, 14, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits); 115 | } 116 | 117 | void VextON(void) 118 | { 119 | pinMode(Vext,OUTPUT); 120 | digitalWrite(Vext, LOW); 121 | } 122 | 123 | void VextOFF(void) //Vext default OFF 124 | { 125 | pinMode(Vext,OUTPUT); 126 | digitalWrite(Vext, HIGH); 127 | } 128 | 129 | 130 | Demo demos[] = {drawFontFaceDemo, drawTextFlowDemo, drawTextAlignmentDemo, drawRectDemo, drawCircleDemo, drawProgressBarDemo, drawImageDemo}; 131 | int demoLength = (sizeof(demos) / sizeof(Demo)); 132 | long timeSinceLastModeSwitch = 0; 133 | 134 | void loop() { 135 | // clear the display 136 | display.clear(); 137 | // draw the current demo method 138 | demos[demoMode](); 139 | 140 | display.setTextAlignment(TEXT_ALIGN_RIGHT); 141 | display.drawString(10, 128, String(millis())); 142 | // write the buffer to the display 143 | display.display(); 144 | 145 | if (millis() - timeSinceLastModeSwitch > DEMO_DURATION) { 146 | demoMode = (demoMode + 1) % demoLength; 147 | timeSinceLastModeSwitch = millis(); 148 | } 149 | counter++; 150 | delay(10); 151 | } 152 | -------------------------------------------------------------------------------- /examples/OLED/SimpleDemo/images.h: -------------------------------------------------------------------------------- 1 | #define WiFi_Logo_width 60 2 | #define WiFi_Logo_height 36 3 | const uint8_t WiFi_Logo_bits[] PROGMEM = { 4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF, 11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00, 12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C, 13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00, 14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C, 15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00, 16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C, 19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00, 20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F, 21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00, 22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | }; 29 | -------------------------------------------------------------------------------- /examples/OLED/UiDemo/images.h: -------------------------------------------------------------------------------- 1 | #define WiFi_Logo_width 60 2 | #define WiFi_Logo_height 36 3 | const uint8_t WiFi_Logo_bits[] PROGMEM = { 4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF, 11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00, 12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C, 13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00, 14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C, 15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00, 16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C, 19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00, 20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F, 21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00, 22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | }; 29 | 30 | const uint8_t activeSymbol[] PROGMEM = { 31 | 0B00000000, 32 | 0B00000000, 33 | 0B00011000, 34 | 0B00100100, 35 | 0B01000010, 36 | 0B01000010, 37 | 0B00100100, 38 | 0B00011000 39 | }; 40 | 41 | const uint8_t inactiveSymbol[] PROGMEM = { 42 | 0B00000000, 43 | 0B00000000, 44 | 0B00000000, 45 | 0B00000000, 46 | 0B00011000, 47 | 0B00011000, 48 | 0B00000000, 49 | 0B00000000 50 | }; -------------------------------------------------------------------------------- /examples/SD/SD.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/examples/SD/SD.JPG -------------------------------------------------------------------------------- /examples/SD/SD_Time/SD_Time.ino: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/examples/SD/SD_Time/SD_Time.ino -------------------------------------------------------------------------------- /examples/SD/SD_Time/TestInfo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/examples/SD/SD_Time/TestInfo.png -------------------------------------------------------------------------------- /examples/Sensor/BH1750_test/BH1750_test.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation BH1750 Sensors test example 2 | * 3 | * Function: 4 | * Light intensity 5 | * 6 | * HelTec AutoMation, Chengdu, China 7 | * www.heltec.org 8 | * 9 | * this project also realess in GitHub: 10 | * https://github.com/HelTecAutomation/Heltec_ESP32 11 | * 12 | */ 13 | #include 14 | #include 15 | 16 | BH1750 lightMeter; 17 | 18 | 19 | void setup(){ 20 | 21 | Serial.begin(115200); 22 | 23 | lightMeter.begin(); 24 | 25 | Serial.println(F("BH1750 Test begin")); 26 | 27 | } 28 | 29 | 30 | void loop() { 31 | 32 | float lux = lightMeter.readLightLevel(); 33 | Serial.print("Light: "); 34 | Serial.print(lux); 35 | Serial.println(" lx"); 36 | delay(1000); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /examples/Sensor/BMP180basic/BMP180basic.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation BMP180 Sensors test example 2 | * 3 | * Function: 4 | * Air pressure sensor 5 | * 6 | * HelTec AutoMation, Chengdu, China 7 | * www.heltec.org 8 | * 9 | * this project also realess in GitHub: 10 | * https://github.com/HelTecAutomation/Heltec_ESP32 11 | * 12 | */ 13 | #include "Arduino.h" 14 | #include "heltec.h" 15 | #include 16 | #include 17 | #include "string.h" 18 | 19 | BMP085 bmp; 20 | 21 | uint8_t T[20] = {"Temperature"}; 22 | 23 | void setup() { 24 | Serial.begin(115200); 25 | } 26 | void drawFontFaceDemo(double T,double P,double A,double R) { 27 | Heltec.begin(true /*DisplayEnable Enable*/, false /*LoRa Disable*/, true /*Serial Enable*/); 28 | // Heltec.display->flipScreenVertically(); 29 | Heltec.display->clear(); 30 | Heltec.display->setTextAlignment(TEXT_ALIGN_LEFT); 31 | Heltec.display->setFont(ArialMT_Plain_10); 32 | Heltec.display->drawString(0 , 0 , "Temperature ="); 33 | Heltec.display->drawString(76 , 0 , (String)T); 34 | Heltec.display->drawString(106 , 0 , " *C"); 35 | Heltec.display->drawString(0 , 16 , "Pressure ="); 36 | Heltec.display->drawString(56 , 16 , (String)P); 37 | Heltec.display->drawString(100 , 16 , "Pa"); 38 | Heltec.display->drawString(0 , 32 , "Altitude ="); 39 | Heltec.display->drawString(56 , 32 , (String)A); 40 | Heltec.display->drawString(86 , 32 , " m"); 41 | Heltec.display->drawString(0 , 48 , "Real altitude ="); 42 | Heltec.display->drawString(76 , 48 , (String)R); 43 | Heltec.display->drawString(106 , 48 , " m"); 44 | Heltec.display->display(); 45 | } 46 | void loop() { 47 | if (!bmp.begin()) { 48 | Serial.println("Could not find a valid BMP085 sensor, check wiring!"); 49 | while (1) {} 50 | } 51 | double T =bmp.readTemperature(); 52 | Serial.print("Temperature = "); 53 | Serial.print(T); 54 | Serial.println(" *C"); 55 | 56 | double P = bmp.readPressure(); 57 | Serial.print("Pressure = "); 58 | Serial.print(bmp.readPressure()); 59 | Serial.println(" Pa"); 60 | 61 | double A = bmp.readAltitude(); 62 | // Calculate altitude assuming 'standard' barometric 63 | // pressure of 1013.25 millibar = 101325 Pascal 64 | Serial.print("Altitude = "); 65 | Serial.print(bmp.readAltitude()); 66 | Serial.println(" meters"); 67 | 68 | 69 | Serial.print("Pressure at sealevel (calculated) = "); 70 | Serial.print(bmp.readSealevelPressure()); 71 | Serial.println(" Pa"); 72 | 73 | double R = bmp.readAltitude(101500); 74 | // you can get a more precise measurement of altitude 75 | // if you know the current sea level pressure which will 76 | // vary with weather and such. If it is 1015 millibars 77 | // that is equal to 101500 Pascals. 78 | Serial.print("Real altitude = "); 79 | Serial.print(bmp.readAltitude(101500)); 80 | Serial.println(" meters"); 81 | 82 | Serial.println(); 83 | delay(500); 84 | drawFontFaceDemo(T, P, A, R) ; 85 | delay(5000); 86 | } 87 | -------------------------------------------------------------------------------- /examples/Sensor/DHT11_LoRa_sender/DHT11_LoRa_sender.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "LoRaWan_APP.h" 3 | #include "Arduino.h" 4 | 5 | // DHT11 Configuration 6 | #define DHT_PIN 1 // GPIO1 connected to DHT11 (avoid using GPIO1) 7 | DHTesp dht; 8 | 9 | // LoRa Configuration 10 | #define RF_FREQUENCY 915000000 // Hz (adjust according to your region) 11 | #define TX_OUTPUT_POWER 14 // dBm (increase power to extend transmission range) 12 | #define LORA_BANDWIDTH 0 // 125 kHz 13 | #define LORA_SPREADING_FACTOR 7 // SF7 14 | #define LORA_CODINGRATE 1 // 4/5 15 | #define LORA_PREAMBLE_LENGTH 8 // Preamble length 16 | #define LORA_FIX_LENGTH_PAYLOAD_ON false 17 | #define LORA_IQ_INVERSION_ON false 18 | 19 | #define BUFFER_SIZE 50 // Data buffer size 20 | char txpacket[BUFFER_SIZE]; // Transmission buffer 21 | bool lora_idle = true; // LoRa idle state flag 22 | 23 | // LoRa event callbacks 24 | static RadioEvents_t RadioEvents; 25 | void OnTxDone(void); 26 | void OnTxTimeout(void); 27 | 28 | void setup() { 29 | Serial.begin(115200); 30 | 31 | // Initialize DHT11 32 | dht.setup(DHT_PIN, DHTesp::DHT11); 33 | Serial.println("DHT11 Initialized"); 34 | 35 | // Initialize LoRa 36 | Mcu.begin(HELTEC_BOARD, SLOW_CLK_TPYE); // Adjust parameters according to your board 37 | RadioEvents.TxDone = OnTxDone; 38 | RadioEvents.TxTimeout = OnTxTimeout; 39 | 40 | Radio.Init(&RadioEvents); 41 | Radio.SetChannel(RF_FREQUENCY); 42 | Radio.SetTxConfig(MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH, 43 | LORA_SPREADING_FACTOR, LORA_CODINGRATE, 44 | LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON, 45 | true, 0, 0, LORA_IQ_INVERSION_ON, 3000); 46 | } 47 | 48 | void loop() { 49 | if (lora_idle) { 50 | delay(2000); // DHT11 requires at least 1-second sampling interval 51 | 52 | // Read temperature and humidity data 53 | TempAndHumidity data = dht.getTempAndHumidity(); 54 | if (dht.getStatus() != DHTesp::ERROR_NONE) { 55 | Serial.println("DHT11 read failed: " + String(dht.getStatusString())); 56 | return; 57 | } 58 | 59 | // Format data as JSON string (example: {"t":25.5,"h":50.0}) 60 | snprintf(txpacket, BUFFER_SIZE, 61 | "{\"t\":%.1f,\"h\":%.1f}", 62 | data.temperature, 63 | data.humidity); 64 | 65 | Serial.printf("Sending data: %s\n", txpacket); 66 | 67 | // Transmit data via LoRa 68 | Radio.Send((uint8_t *)txpacket, strlen(txpacket)); 69 | lora_idle = false; 70 | } 71 | Radio.IrqProcess(); // Process LoRa events 72 | } 73 | 74 | // LoRa transmission complete callback 75 | void OnTxDone(void) { 76 | Serial.println("LoRa transmission successful"); 77 | lora_idle = true; 78 | } 79 | 80 | // LoRa transmission timeout callback 81 | void OnTxTimeout(void) { 82 | Radio.Sleep(); 83 | Serial.println("LoRa transmission timeout"); 84 | lora_idle = true; 85 | } -------------------------------------------------------------------------------- /examples/Sensor/GXHTC_read/GXHTC_read.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation GXHTC Sensors test example 2 | * 3 | * Function: 4 | * temperature and humidity sensor 5 | * 6 | * HelTec AutoMation, Chengdu, China 7 | * www.heltec.org 8 | * 9 | * this project also realess in GitHub: 10 | * https://github.com/HelTecAutomation/Heltec_ESP32 11 | * 12 | */ 13 | #include "Wire.h" 14 | #include "GXHTC.h" 15 | 16 | GXHTC gxhtc; 17 | void setup() { 18 | Serial.begin(115200); 19 | gxhtc.begin(1,2); 20 | } 21 | 22 | void loop() { 23 | gxhtc.read_data(); 24 | Serial.print("Temperature:"); 25 | Serial.print(gxhtc.g_temperature); 26 | Serial.print(" Humidity:"); 27 | Serial.println(gxhtc.g_humidity); 28 | Serial.printf("id = %X\r\n",gxhtc.read_id()); 29 | 30 | delay(3000); 31 | } -------------------------------------------------------------------------------- /examples/Sensor/Sensor_OLED/Sensor_OLED.ino: -------------------------------------------------------------------------------- 1 | // Example of Dual I2C Interface Configuration 2 | // When using LoRa32 boards with built-in OLED displays (typically occupying I2C-0), connecting additional I2C sensors requires secondary interface initialization. 3 | #include // I2C communication 4 | #include // BMP280 sensor 5 | #include "HT_SSD1306Wire.h" // OLED display 6 | 7 | // I2C instance for BMP280 8 | TwoWire Wire2(1); 9 | 10 | // Sensor and display objects 11 | BMP280 bmp(&Wire2); 12 | static SSD1306Wire display(0x3c, 500000, SDA_OLED, SCL_OLED, GEOMETRY_128_64, RST_OLED); 13 | 14 | void setup() { 15 | Serial.begin(115200); // Start serial for debugging 16 | delay(500); // Stabilization delay 17 | 18 | Wire2.begin(42,41); // Initialize I2C on pins 42(SDA),41(SCL) 19 | 20 | if(!bmp.begin()) { // Initialize BMP280 21 | Serial.println("Sensor not found!"); 22 | while(1); // Halt if failed 23 | } 24 | 25 | delay(500); 26 | 27 | // Configure BMP280 settings 28 | bmp.setSampling( 29 | BMP280::MODE_NORMAL, // Continuous measurement 30 | BMP280::SAMPLING_X2, // Temp oversampling x2 31 | BMP280::SAMPLING_X16, // Pressure oversampling x16 32 | BMP280::FILTER_X16, // Filter coefficient x16 33 | BMP280::STANDBY_MS_500 // 500ms standby 34 | ); 35 | 36 | // OLED setup 37 | display.init(); 38 | display.clear(); 39 | display.display(); 40 | display.setContrast(255); 41 | display.setFont(ArialMT_Plain_10); 42 | display.setTextAlignment(TEXT_ALIGN_LEFT); 43 | display.drawString(0, 0, "BMP280 Sensor Test"); 44 | display.display(); 45 | } 46 | 47 | void loop() { 48 | // Read sensor data 49 | float temp = bmp.readTemperature(); // Celsius 50 | float pressure = (float)bmp.readPressure() / 100.0; // hPa 51 | 52 | // Serial output 53 | Serial.print("Temperature: "); 54 | Serial.print(temp); 55 | Serial.print(" C, Pressure: "); 56 | Serial.print(pressure); 57 | Serial.println(" hPa"); 58 | 59 | // OLED output 60 | display.clear(); 61 | display.drawString(0, 20, "Temperature: " + String(temp) + " C"); 62 | display.drawString(0, 40, "Pressure: " + String(pressure) + " hPa"); 63 | display.display(); 64 | 65 | delay(3000); // Update every 3 seconds 66 | } -------------------------------------------------------------------------------- /examples/Sensor/bmp280/bmp280.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include 3 | #include 4 | 5 | BMP280 bmp; 6 | 7 | void setup() { 8 | Serial.begin(115200); 9 | delay(500); 10 | Wire.begin(42,41); 11 | bmp.begin(); 12 | delay(500); 13 | bmp.setSampling(BMP280::MODE_NORMAL, /* Operating Mode. */ 14 | BMP280::SAMPLING_X2, /* Temp. oversampling */ 15 | BMP280::SAMPLING_X16, /* Pressure oversampling */ 16 | BMP280::FILTER_X16, /* Filtering. */ 17 | BMP280::STANDBY_MS_500); /* Standby time. */ 18 | } 19 | 20 | void loop() 21 | { 22 | float temp = bmp.readTemperature(); 23 | float Pressure = (float)bmp.readPressure() / 100.0; 24 | Serial.print("Temperature: "); 25 | Serial.print(temp); 26 | Serial.print(" C, Pressure: "); 27 | Serial.print(Pressure); 28 | Serial.println(" hPa"); 29 | delay(1000); 30 | } -------------------------------------------------------------------------------- /examples/Sensor/da217_read_xyz/da217_read_xyz.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation da217 Sensors test example 2 | * 3 | * Function: 4 | * Three axis acceleration sensor 5 | * 6 | * HelTec AutoMation, Chengdu, China 7 | * www.heltec.org 8 | * 9 | * this project also realess in GitHub: 10 | * https://github.com/HelTecAutomation/Heltec_ESP32 11 | * 12 | */ 13 | 14 | #include "Arduino.h" 15 | #include "da217.h" 16 | 17 | DA217 da217; 18 | uint16_t step_num; 19 | float x_data,y_data,z_data,sum_gravity; 20 | void setup() 21 | { 22 | Serial.begin(115200); 23 | 24 | da217.da217_gravity_init(); 25 | } 26 | 27 | void loop() 28 | { 29 | da217.da217_get_xyz_gravity(&x_data,&y_data,&z_data); 30 | da217.da217_get_vector_sum_gravity(&sum_gravity); 31 | Serial.printf("x_data=%f y_data=%f z_data=%f %f\r\n",x_data,y_data,z_data,sum_gravity); 32 | delay(3000); 33 | } -------------------------------------------------------------------------------- /examples/TFT/ST7735_SPI/ST7735_SPI.ino: -------------------------------------------------------------------------------- 1 | #include "HT_st7735.h" 2 | #include "Arduino.h" 3 | HT_st7735 st7735; 4 | void setup() 5 | { 6 | Serial.begin(115200); 7 | st7735.st7735_init(); 8 | Serial.printf("Ready!\r\n"); 9 | } 10 | 11 | void loop() { 12 | // Check border 13 | st7735.st7735_fill_screen(ST7735_BLACK); 14 | 15 | for(int x = 0; x < ST7735_WIDTH; x++) { 16 | st7735.st7735_draw_pixel(x, 0, ST7735_RED); 17 | st7735.st7735_draw_pixel(x, ST7735_HEIGHT-1, ST7735_RED); 18 | } 19 | 20 | for(int y = 0; y < ST7735_HEIGHT; y++) { 21 | st7735.st7735_draw_pixel(0, y, ST7735_RED); 22 | st7735.st7735_draw_pixel(ST7735_WIDTH-1, y, ST7735_RED); 23 | } 24 | 25 | delay(3000); 26 | 27 | // Check fonts 28 | st7735.st7735_fill_screen(ST7735_BLACK); 29 | st7735.st7735_write_str(0, 0, "Font_7x10, red on black, lorem ipsum dolor sit amet", Font_7x10, ST7735_RED, ST7735_BLACK); 30 | st7735.st7735_write_str(0, 3*10, "Font_11x18, green, lorem ipsum", Font_11x18, ST7735_GREEN, ST7735_BLACK); 31 | st7735.st7735_write_str(0, 3*10+3*18, "Font_16x26", Font_16x26, ST7735_BLUE, ST7735_BLACK); 32 | delay(2000); 33 | 34 | // Check colors 35 | st7735.st7735_fill_screen(ST7735_BLACK); 36 | st7735.st7735_write_str(0, 0, "BLACK", Font_11x18, ST7735_WHITE, ST7735_BLACK); 37 | delay(500); 38 | 39 | st7735.st7735_fill_screen(ST7735_BLUE); 40 | st7735.st7735_write_str(0, 0, "BLUE", Font_11x18, ST7735_BLACK, ST7735_BLUE); 41 | delay(500); 42 | 43 | st7735.st7735_fill_screen(ST7735_RED); 44 | st7735.st7735_write_str(0, 0, "RED", Font_11x18, ST7735_BLACK, ST7735_RED); 45 | delay(500); 46 | 47 | st7735.st7735_fill_screen(ST7735_GREEN); 48 | st7735.st7735_write_str(0, 0, "GREEN", Font_11x18, ST7735_BLACK, ST7735_GREEN); 49 | delay(500); 50 | 51 | st7735.st7735_fill_screen(ST7735_CYAN); 52 | st7735.st7735_write_str(0, 0, "CYAN", Font_11x18, ST7735_BLACK, ST7735_CYAN); 53 | delay(500); 54 | 55 | st7735.st7735_fill_screen(ST7735_MAGENTA); 56 | st7735.st7735_write_str(0, 0, "MAGENTA", Font_11x18, ST7735_BLACK, ST7735_MAGENTA); 57 | delay(500); 58 | 59 | st7735.st7735_fill_screen(ST7735_YELLOW); 60 | st7735.st7735_write_str(0, 0, "YELLOW", Font_11x18, ST7735_BLACK, ST7735_YELLOW); 61 | delay(500); 62 | 63 | st7735.st7735_fill_screen(ST7735_WHITE); 64 | st7735.st7735_write_str(0, 0, "WHITE", Font_11x18, ST7735_BLACK, ST7735_WHITE); 65 | delay(500); 66 | } -------------------------------------------------------------------------------- /examples/VME213/Deepsleep/Deepsleep.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation adc example 2 | * 3 | * Function: 4 | * 1.ESP32 deep sleep achieves low power consumption 5 | * 6 | * * Description: 7 | * 1.Pin states can be set to achieve stable deep sleep. 8 | * 9 | * Library url: https://github.com/HelTecAutomation/Heltec_ESP32 10 | * Support: support@heltec.cn 11 | * 12 | * HelTec AutoMation, Chengdu, China 13 | * 成都惠利特自动化科技有限公司 14 | * https://www.heltec.org 15 | * 16 | * */ 17 | 18 | #include "Arduino.h" 19 | #include "LoRaWan_APP.h" 20 | #include "driver/rtc_io.h" 21 | #include 22 | 23 | #define wakeuptime 10 * 1000 * (uint64_t)1000 //Sleep time 24 | 25 | void intodeepsleep() 26 | { 27 | Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE); 28 | pinMode(18,OUTPUT); 29 | digitalWrite(18, LOW); 30 | Radio.Sleep(); 31 | SPI.end(); 32 | pinMode(14,ANALOG); 33 | pinMode(8, OUTPUT); 34 | digitalWrite(8, HIGH); 35 | rtc_gpio_hold_en(gpio_num_t(8)); 36 | pinMode(12,ANALOG); 37 | pinMode(13,ANALOG); 38 | pinMode(9,ANALOG); 39 | pinMode(11,ANALOG); 40 | pinMode(10,ANALOG); 41 | } 42 | 43 | void setup() 44 | { 45 | intodeepsleep(); 46 | esp_sleep_enable_timer_wakeup(wakeuptime); 47 | delay(4000); 48 | esp_deep_sleep_start(); 49 | } 50 | void loop() 51 | { 52 | } -------------------------------------------------------------------------------- /examples/VME213/Global_Simple/images.h: -------------------------------------------------------------------------------- 1 | #define WiFi_Logo_width 60 2 | #define WiFi_Logo_height 36 3 | const uint8_t WiFi_Logo_bits[] PROGMEM = { 4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF, 11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00, 12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C, 13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00, 14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C, 15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00, 16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C, 19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00, 20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F, 21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00, 22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | }; 29 | -------------------------------------------------------------------------------- /examples/VME213/HT_lCMEN2R13EFC1/images.h: -------------------------------------------------------------------------------- 1 | #define WiFi_Logo_width 60 2 | #define WiFi_Logo_height 36 3 | const uint8_t WiFi_Logo_bits[] PROGMEM = { 4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF, 11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00, 12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C, 13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00, 14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C, 15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00, 16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C, 19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00, 20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F, 21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00, 22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | }; 29 | -------------------------------------------------------------------------------- /examples/VME213/LorawanEink/img.h: -------------------------------------------------------------------------------- 1 | const uint8_t hum[] = { 2 | 0x20, 0x00, 0x70, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0xFC, 0x01, 0xFC, 0x01, 3 | 0xFE, 0x03, 0xFE, 0x03, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 4 | 0xFF, 0x07, 0xFF, 0x07, 0xFE, 0x03, 0xFC, 0x01, }; 5 | const uint8_t temp[] = { 6 | 0x78, 0x00, 0xFC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 7 | 0xCC, 0x00, 0xFC, 0x00, 0xFE, 0x01, 0xB7, 0x03, 0x33, 0x03, 0x7B, 0x03, 8 | 0x7B, 0x03, 0x03, 0x03, 0x87, 0x03, 0xFE, 0x01, 0xFC, 0x00, }; -------------------------------------------------------------------------------- /examples/VME213/Part_Simple/Part_Simple.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation Eink partial refresh example 2 | * 3 | * Function: 4 | * 1.Ink screen partial refresh demonstration. 5 | * 6 | * Description: 7 | * 1.Using an external Lut waveform file to achieve partial refresh 8 | * 9 | * Note: 10 | * This example is compatible with Wireless Paper and requires you to change the pin Settings in your code and change the order in which the VextCtrl pin HIGH and LOW. 11 | * Library url: https://github.com/HelTecAutomation/Heltec_ESP32 12 | * Support: support@heltec.cn 13 | * 14 | * HelTec AutoMation, Chengdu, China 15 | * 成都惠利特自动化科技有限公司 16 | * https://www.heltec.org 17 | * */ 18 | #include "HT_lCMEN2R13EFC1.h" 19 | #include "images.h" 20 | // Initialize the display 21 | HT_ICMEN2R13EFC1 display(3, 2, 5, 1, 4, 6, -1, 6000000); // rst,dc,cs,busy,sck,mosi,miso,frequency 22 | uint8_t num = 0; 23 | typedef void (*Demo)(void); 24 | 25 | /* screen rotation 26 | * ANGLE_0_DEGREE 27 | * ANGLE_90_DEGREE 28 | * ANGLE_180_DEGREE 29 | * ANGLE_270_DEGREE 30 | */ 31 | #define DIRECTION ANGLE_0_DEGREE 32 | 33 | int width, height; 34 | int demoMode = 0; 35 | 36 | void setup() 37 | { 38 | Serial.begin(115200); 39 | if (DIRECTION == ANGLE_0_DEGREE || DIRECTION == ANGLE_180_DEGREE) 40 | { 41 | width = display._width; 42 | height = display._height; 43 | } 44 | else 45 | { 46 | width = display._height; 47 | height = display._width; 48 | } 49 | VextON(); 50 | delay(100); 51 | // Initialising the UI will init the display too. 52 | display.init(); 53 | display.screenRotate(DIRECTION); 54 | display.setFont(ArialMT_Plain_10); 55 | } 56 | 57 | void part_ref(uint8_t _num) 58 | { 59 | switch (_num) 60 | { 61 | case 0: 62 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num0); // dis_img_Partial_Refresh(x,y,img_width,img_lenth) 63 | // The second parameter, the fourth parameter, takes an integer multiple of 8 64 | break; 65 | case 1: 66 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num1); 67 | break; 68 | case 2: 69 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num2); 70 | break; 71 | case 3: 72 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num3); 73 | break; 74 | case 4: 75 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num4); 76 | break; 77 | case 5: 78 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num5); 79 | break; 80 | case 6: 81 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num6); 82 | break; 83 | case 7: 84 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num7); 85 | break; 86 | case 8: 87 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num8); 88 | break; 89 | case 9: 90 | display.dis_img_Partial_Refresh(100, 32, 14, 4, num9); 91 | break; 92 | default: 93 | break; 94 | } 95 | } 96 | 97 | void VextON(void) 98 | { 99 | pinMode(18, OUTPUT); 100 | digitalWrite(18, HIGH); 101 | } 102 | 103 | void VextOFF(void) // Vext default OFF 104 | { 105 | pinMode(18, OUTPUT); 106 | digitalWrite(18, LOW); 107 | } 108 | 109 | void loop() 110 | { 111 | part_ref(num++); 112 | } 113 | -------------------------------------------------------------------------------- /examples/VME213/Part_Simple/images.h: -------------------------------------------------------------------------------- 1 | //Image usage https://resource.heltec.cn/image-to-hex Conversion, open Mirror, Rotation angle 270 2 | //Try to have the length and width of the image as multiples of 8 as much as possible 3 | //Set the image height to be divided by 8, In this example, 32/8=4,由于旋转270° 4 | 5 | // width: 32, height: 14 6 | const unsigned char num0[] PROGMEM = { 7 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x3f, 0xfe, 0x7f, 0xff, 0x3f, 0xfe, 0x3f, 0xfe, 0x3f, 0xff, 0x00, 0x00, 0x7f, 0xff, 0x80, 0x00, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff}; 8 | // width: 32, height: 14 9 | const unsigned char num1[] PROGMEM = { 10 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, 0xcf, 0xff, 0x3f, 0xff, 0xcf, 0xff, 0x3f, 0xff, 0x80, 0x00, 0x3f, 0xff, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 11 | const unsigned char num2[] PROGMEM = { 12 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xfe, 0x3f, 0xff, 0x87, 0xfc, 0x3f, 0xff, 0x1f, 0xf8, 0x3f, 0xff, 0x3f, 0xf0, 0x3f, 0xfe, 0x3f, 0xe4, 0x3f, 0xfe, 0x3f, 0xcc, 0x3f, 0xfe, 0x1f, 0x1c, 0x3f, 0xfe, 0x00, 0x3c, 0x3f, 0xff, 0x00, 0x7c, 0x3f, 0xff, 0x80, 0xfc, 0x3f, 0xff, 0xc3, 0xf0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 13 | // width: 32, height: 14 14 | const unsigned char num3[] PROGMEM = { 15 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0x8f, 0xfc, 0x7f, 0xff, 0x3f, 0xfc, 0x3f, 0xff, 0x3e, 0x7e, 0x3f, 0xfe, 0x3c, 0x7f, 0x3f, 0xfe, 0x38, 0x7f, 0x3f, 0xfe, 0x00, 0x3e, 0x7f, 0xfe, 0x00, 0x00, 0x7f, 0xff, 0x06, 0x00, 0xff, 0xff, 0xde, 0x01, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 16 | // width: 32, height: 14 17 | const unsigned char num4[] PROGMEM = { 18 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0x87, 0xff, 0xff, 0xfe, 0x27, 0xff, 0xff, 0xfc, 0xe7, 0xff, 0xff, 0xf1, 0xe7, 0xff, 0xff, 0xe7, 0xe7, 0xff, 0xff, 0x80, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff}; 19 | // width: 32, height: 14 20 | const unsigned char num5[] PROGMEM = { 21 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x00, 0x7c, 0x7f, 0xff, 0x00, 0x7c, 0x3f, 0xff, 0x1c, 0x7e, 0x3f, 0xff, 0x1c, 0x7f, 0x3f, 0xff, 0x1c, 0x7f, 0x3f, 0xff, 0x1c, 0x3f, 0x7f, 0xff, 0x1c, 0x00, 0x7f, 0xfe, 0x1c, 0x00, 0x7f, 0xfe, 0x3e, 0x00, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 22 | // width: 32, height: 14 23 | const unsigned char num6[] PROGMEM = { 24 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x03, 0xff, 0xff, 0xf0, 0x00, 0xff, 0xff, 0xe0, 0x00, 0x7f, 0xff, 0xc0, 0x00, 0x7f, 0xff, 0x80, 0xfe, 0x7f, 0xff, 0x0c, 0xff, 0x3f, 0xff, 0x1c, 0xff, 0x3f, 0xff, 0x3c, 0x7e, 0x3f, 0xfe, 0x7c, 0x00, 0x7f, 0xfe, 0x7e, 0x00, 0x7f, 0xff, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xff, 0xff}; 25 | // width: 32, height: 14 26 | const unsigned char num7[] PROGMEM = { 27 | 0xff, 0xff, 0xff, 0xff, 0xfe, 0x07, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xfe, 0x1f, 0xff, 0xff, 0xfe, 0x1f, 0xfc, 0x3f, 0xfe, 0x1f, 0xf0, 0x3f, 0xfe, 0x1f, 0xc0, 0x7f, 0xfe, 0x1e, 0x01, 0xff, 0xfe, 0x18, 0x0f, 0xff, 0xfe, 0x00, 0x3f, 0xff, 0xfe, 0x01, 0xff, 0xff, 0xfe, 0x0f, 0xff, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 28 | // width: 32, height: 14 29 | const unsigned char num8[] PROGMEM = { 30 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xe1, 0xff, 0xff, 0x81, 0xc0, 0xff, 0xff, 0x00, 0x80, 0x7f, 0xfe, 0x00, 0x00, 0x7f, 0xfe, 0x78, 0x3f, 0x3f, 0xfe, 0xfc, 0x3f, 0x3f, 0xfe, 0x7c, 0x1f, 0x3f, 0xfe, 0x7c, 0x1f, 0x3f, 0xff, 0x00, 0x06, 0x7f, 0xff, 0x01, 0x00, 0x7f, 0xff, 0x83, 0x80, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xff}; 31 | // width: 32, height: 14 32 | const unsigned char num9[] PROGMEM = { 33 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0x80, 0x7f, 0xff, 0xff, 0x00, 0x3f, 0x3f, 0xff, 0x00, 0x3f, 0x7f, 0xfe, 0x7f, 0x1e, 0x7f, 0xfe, 0xff, 0x9c, 0x7f, 0xfe, 0x7f, 0xb0, 0xff, 0xfe, 0x3f, 0x01, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0x00, 0x03, 0xff, 0xff, 0x80, 0x0f, 0xff, 0xff, 0xe0, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff}; -------------------------------------------------------------------------------- /examples/VME213/sensor_th/img.h: -------------------------------------------------------------------------------- 1 | const uint8_t hum[] = { 2 | 0x20, 0x00, 0x70, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0xFC, 0x01, 0xFC, 0x01, 3 | 0xFE, 0x03, 0xFE, 0x03, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 4 | 0xFF, 0x07, 0xFF, 0x07, 0xFE, 0x03, 0xFC, 0x01, }; 5 | const uint8_t temp[] = { 6 | 0x78, 0x00, 0xFC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 7 | 0xCC, 0x00, 0xFC, 0x00, 0xFE, 0x01, 0xB7, 0x03, 0x33, 0x03, 0x7B, 0x03, 8 | 0x7B, 0x03, 0x03, 0x03, 0x87, 0x03, 0xFE, 0x01, 0xFC, 0x00, }; -------------------------------------------------------------------------------- /examples/VME213/sensor_th/sensor_th.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation GXHTC Sensors test example 2 | * 3 | * Function: 4 | * Read the temperature, humidity, and time displayed on the screen 5 | * 6 | * Description: 7 | * 1. This example use a quick link cable to connect gxhtv3 and read temperature and humidity through iic 8 | * 9 | * Library url: https://github.com/HelTecAutomation/Heltec_ESP32 10 | * Support: support@heltec.cn 11 | * 12 | * HelTec AutoMation, Chengdu, China 13 | * 成都惠利特自动化科技有限公司 14 | * https://www.heltec.org 15 | */ 16 | #include "Wire.h" 17 | #include "GXHTC.h" 18 | #include "HT_lCMEN2R13EFC1.h" 19 | #include "img.h" 20 | #include 21 | #include "time.h" 22 | #include 23 | // Initialize the display 24 | HT_ICMEN2R13EFC1 display(3, 2, 5, 1, 4, 6, -1, 6000000); // rst,dc,cs,busy,sck,mosi,miso,frequency 25 | GXHTC gxhtc; 26 | 27 | char buffer[256]; 28 | const char *ntpServer = "ntp.aliyun.com"; 29 | const long gmtOffset_sec = 28800; // time offset 30 | const int daylightOffset_sec = 0; 31 | const char *ssid = "Your Wi-Fi SSID"; 32 | const char *password = "Your Wi-Fi password"; 33 | 34 | void printLocalTime() 35 | { 36 | struct tm timeinfo; 37 | if (!getLocalTime(&timeinfo)) 38 | { 39 | Serial.println("Failed to obtain time"); 40 | return; 41 | } 42 | display.setFont(ArialMT_Plain_10); 43 | char buffer[256]; 44 | display.setFont(ArialMT_Plain_10); 45 | Serial.println(timeinfo.tm_hour); 46 | sprintf(buffer, "%d", timeinfo.tm_hour); 47 | display.drawString(10, 0, buffer); 48 | display.drawString(25, 0, ": "); 49 | sprintf(buffer, "%d", timeinfo.tm_min); 50 | Serial.println(timeinfo.tm_min); 51 | display.drawString(30, 0, buffer); 52 | Serial.println(timeinfo.tm_mon); 53 | display.setFont(ArialMT_Plain_16); 54 | sprintf(buffer, "%d", timeinfo.tm_year + 1900); 55 | display.drawString(160, 100, buffer); 56 | display.drawString(195, 100, "/"); 57 | sprintf(buffer, "%d", timeinfo.tm_mon + 1); 58 | display.drawString(200, 100, buffer); 59 | display.drawString(210, 100, "/"); 60 | sprintf(buffer, "%d", timeinfo.tm_mday); 61 | Serial.println(timeinfo.tm_mday); 62 | display.drawString(215, 100, buffer); 63 | Serial.println(timeinfo.tm_mday); 64 | } 65 | 66 | void GetNetTime() 67 | { 68 | configTime(gmtOffset_sec, daylightOffset_sec, ntpServer); 69 | printLocalTime(); 70 | } 71 | 72 | void read_th() 73 | { 74 | gxhtc.read_data(); 75 | Serial.print("Temperature:"); 76 | Serial.print(gxhtc.g_temperature); 77 | display.setFont(ArialMT_Plain_24); 78 | sprintf(buffer, "%.2f", gxhtc.g_temperature); 79 | display.drawXbm(18, 55, 10, 17, temp); 80 | display.drawString(30, 50, "28.2 C"); 81 | Serial.print(" Humidity:"); 82 | Serial.println(gxhtc.g_humidity); 83 | sprintf(buffer, "%.2f", gxhtc.g_humidity); 84 | display.drawXbm(128, 55, 11, 16, hum); 85 | display.drawString(142, 50, "69 %"); 86 | Serial.printf("id = %X\r\n", gxhtc.read_id()); 87 | } 88 | 89 | void setup() 90 | { 91 | Serial.begin(115200); 92 | pinMode(18, OUTPUT); 93 | digitalWrite(18, HIGH); 94 | gxhtc.begin(39, 38); 95 | display.init(); 96 | display.clear(); 97 | display.update(COLOR_BUFFER); 98 | display.drawString(0, 0, "init >>> "); 99 | Serial.print("Connecting to "); 100 | display.drawString(0, 20, "Connecting to ... "); 101 | Serial.println(ssid); 102 | display.drawString(100, 20, ssid); 103 | WiFi.begin(ssid, password); 104 | uint8_t i = 0; 105 | while (WiFi.status() != WL_CONNECTED) 106 | { 107 | delay(500); 108 | Serial.print("."); 109 | display.drawString(i, 40, "."); 110 | i = i + 10; 111 | } 112 | Serial.println(""); 113 | Serial.println("WiFi connected"); 114 | display.drawString(0, 60, "WiFi connected"); 115 | Serial.println("IP address: "); 116 | display.drawString(0, 90, "IP address: "); 117 | display.drawString(60, 90, WiFi.localIP().toString().c_str()); 118 | Serial.println(WiFi.localIP()); 119 | Serial.println(""); 120 | Serial.println("WiFi Conected!"); 121 | display.update(COLOR_BUFFER); 122 | display.display(); 123 | delay(1000); 124 | } 125 | 126 | void loop() 127 | { 128 | display.clear(); 129 | display.drawLine(0, 15, 250, 15); 130 | read_th(); 131 | GetNetTime(); 132 | display.update(COLOR_BUFFER); 133 | display.display(); 134 | delay(30000); 135 | } 136 | -------------------------------------------------------------------------------- /examples/VME213/weather_station/readme.md: -------------------------------------------------------------------------------- 1 | # WEATHER STATION 2 | 3 | This example demonstrates how to obtain weather, time, etc. from the internet and display them on an ink screen. 4 | 5 | # Supported Targets 6 | 7 | At present, this example only supports Vison Master Eink213, which uses the ESP32-S3 chip. 8 | 9 | ## How to Use Example 10 | 11 | Flash this example and observe the screen display. 12 | 13 | ### Configure the Project 14 | 15 | Change `SSID` and `password` to connect to your WiFi. 16 | Default values will allow you to use this example without any changes. If you want to use your own Weather server and you don't have one already follow these steps: 17 | 18 | * Create an account on [Weather server](https://www.seniverse.com/). 19 | * After logging in, click on the "immediate use" button to create a new product for your data. You can create a free or paid product, then obtain its private key and fill it in the 'privateKey' field. 20 | * This example uses a free API to obtain weather parameters for 3 days. The weather parameters for one week should have an interface. The author's city of residence does not have special weather conditions, and currently only supports three common weather conditions: sunny, rainy, and cloudy. Other weather interfaces are reserved. 21 | * This instance obtains the time from the [time server](ntp.aliyun.com), and you can modify 'ntpServe' to use a server that is convenient for you to use 22 | 23 | #### Config example: 24 | 25 | You can find the data to be changed at the top of the file: 26 | 27 | ```cpp 28 | const char *ntpServer = "ntp.aliyun.com";// time server 29 | const long gmtOffset_sec = 28800; // time offset,UTC/GMT +8 30 | const int daylightOffset_sec = 0;// Timing started in 1990 31 | const char *ssid = "Your Wi-Fi SSID"; 32 | const char *password = "Your Wi-Fi password"; 33 | 34 | const char *host = "api.seniverse.com";//Weather server 35 | const char *privateKey = "Sfv1t8EYrow1Zi-5o";//Product privateKey 36 | const char *city = "chengdu";//The city to be queried 37 | const char *language = "en";//language preference 38 | //The following is the API splicing method 39 | String getUrl = "/v3/weather/daily.json?key="; 40 | getUrl += privateKey; 41 | getUrl += "&location="; 42 | getUrl += city; 43 | getUrl += "&language="; 44 | getUrl += language; 45 | client.print(String("GET ") + getUrl + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"); 46 | 47 | #### Using Arduino IDE 48 | 49 | To get more information about the Espressif boards see [heltec.org](https://heltec.org). 50 | 51 | * Before Compile/Verify, select the correct board: `Tools -> Board`. 52 | * Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port. 53 | 54 | -------------------------------------------------------------------------------- /examples/VME290/DEPG0290BxS800FxX_BW/DEPG0290BxS800FxX_BW.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation Ink screen example 2 | * 3 | * Function: 4 | * 1. Ink screen full brush demonstration 5 | * 6 | * Description: 7 | * 1.Inherited from ssd1306 for drawing points, lines, and functions 8 | * 9 | * Library url: https://github.com/HelTecAutomation/Heltec_ESP32 10 | * Support: support@heltec.cn 11 | * 12 | * HelTec AutoMation, Chengdu, China 13 | * 成都惠利特自动化科技有限公司 14 | * https://www.heltec.org 15 | * */ 16 | #include "HT_DEPG0290BxS800FxX_BW.h" 17 | #include "images.h" 18 | // Initialize the display 19 | DEPG0290BxS800FxX_BW display(5, 4, 3,6, 2,1,-1, 6000000);//rst,dc,cs,busy,sck,mosi,miso,frequency 20 | typedef void (*Demo)(void); 21 | /* screen rotation 22 | * ANGLE_0_DEGREE 23 | * ANGLE_90_DEGREE 24 | * ANGLE_180_DEGREE 25 | * ANGLE_270_DEGREE 26 | */ 27 | #define DIRECTION ANGLE_0_DEGREE 28 | int demoMode = 0; 29 | void setup() { 30 | Serial.begin(115200); 31 | Serial.println(); 32 | Serial.println(); 33 | VextON(); 34 | delay(100); 35 | // Initialising the UI will init the display too. 36 | display.init(); 37 | display.screenRotate(DIRECTION); 38 | display.setFont(ArialMT_Plain_10); 39 | 40 | } 41 | void drawFontFaceDemo() { 42 | // Font Demo1 43 | // create more fonts at http://oleddisplay.squix.ch/ 44 | display.setTextAlignment(TEXT_ALIGN_LEFT); 45 | display.setFont(ArialMT_Plain_10); 46 | display.drawString(0, 0, "Hello world"); 47 | display.setFont(ArialMT_Plain_16); 48 | display.drawString(0, 10, "Hello world"); 49 | display.setFont(ArialMT_Plain_24); 50 | display.drawString(0, 26, "Hello world"); 51 | } 52 | void drawTextFlowDemo() { 53 | display.setFont(ArialMT_Plain_10); 54 | display.setTextAlignment(TEXT_ALIGN_LEFT); 55 | display.drawStringMaxWidth(0, 0, 128, 56 | "Lorem ipsum\n dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore." ); 57 | } 58 | void drawTextAlignmentDemo() { 59 | // Text alignment demo 60 | char str[30]; 61 | int x = 0; 62 | int y = 0; 63 | display.setFont(ArialMT_Plain_10); 64 | // The coordinates define the left starting point of the text 65 | display.setTextAlignment(TEXT_ALIGN_LEFT); 66 | display.drawString(x, y, "Left aligned (0,0)"); 67 | // The coordinates define the center of the text 68 | display.setTextAlignment(TEXT_ALIGN_CENTER); 69 | x = display.width()/2; 70 | y = display.height()/2-5; 71 | sprintf(str,"Center aligned (%d,%d)",x,y); 72 | display.drawString(x, y, str); 73 | // The coordinates define the right end of the text 74 | display.setTextAlignment(TEXT_ALIGN_RIGHT); 75 | x = display.width(); 76 | y = display.height()-12; 77 | sprintf(str,"Right aligned (%d,%d)",x,y); 78 | display.drawString(x, y, str); 79 | } 80 | void drawRectDemo() { 81 | // Draw a pixel at given position 82 | for (int i = 0; i < 10; i++) { 83 | display.setPixel(i, i); 84 | display.setPixel(10 - i, i); 85 | } 86 | display.drawRect(12, 12, 20, 20); 87 | // Fill the rectangle 88 | display.fillRect(14, 14, 17, 17); 89 | // Draw a line horizontally 90 | display.drawHorizontalLine(0, 40, 20); 91 | // Draw a line horizontally 92 | display.drawVerticalLine(40, 0, 20); 93 | } 94 | void drawCircleDemo() { 95 | int x = display.width()/4; 96 | int y = display.height()/2; 97 | for (int i=1; i < 8; i++) { 98 | display.setColor(WHITE); 99 | display.drawCircle(x, y, i*3); 100 | if (i % 2 == 0) { 101 | display.setColor(BLACK); 102 | } 103 | int x = display.width()/4*3; 104 | display.fillCircle(x, y, 32 - i* 3); 105 | } 106 | } 107 | void drawImageDemo() { 108 | // see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html 109 | // on how to create xbm files 110 | int x = display.width()/2-WiFi_Logo_width/2; 111 | int y = display.height()/2-WiFi_Logo_height/2; 112 | display.drawXbm(x ,y , WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits); 113 | } 114 | void VextON(void) 115 | { 116 | pinMode(18,OUTPUT); 117 | digitalWrite(18, HIGH); 118 | } 119 | void VextOFF(void) //Vext default OFF 120 | { 121 | pinMode(18,OUTPUT); 122 | digitalWrite(18, LOW); 123 | } 124 | Demo demos[] = {drawFontFaceDemo, drawTextFlowDemo, drawTextAlignmentDemo, drawRectDemo, drawCircleDemo, drawImageDemo}; 125 | int demoLength = (sizeof(demos) / sizeof(Demo)); 126 | long timeSinceLastModeSwitch = 0; 127 | void loop() { 128 | // clear the display 129 | display.clear(); 130 | // draw the current demo method 131 | demos[demoMode](); 132 | display.display(); 133 | demoMode = (demoMode + 1) % demoLength; 134 | delay(5000); 135 | } -------------------------------------------------------------------------------- /examples/VME290/DEPG0290BxS800FxX_BW/images.h: -------------------------------------------------------------------------------- 1 | #define WiFi_Logo_width 60 2 | #define WiFi_Logo_height 36 3 | const uint8_t WiFi_Logo_bits[] PROGMEM = { 4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF, 11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00, 12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C, 13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00, 14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C, 15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00, 16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C, 19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00, 20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F, 21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00, 22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | }; 29 | -------------------------------------------------------------------------------- /examples/VME290/GHXTC_Sensor_Display/images.h: -------------------------------------------------------------------------------- 1 | #define WiFi_Logo_width 60 2 | #define WiFi_Logo_height 36 3 | const uint8_t WiFi_Logo_bits[] PROGMEM = { 4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF, 11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00, 12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C, 13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00, 14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C, 15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00, 16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C, 19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00, 20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F, 21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00, 22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | }; 29 | // w 10 h 17 30 | const uint8_t hum[] = { 31 | 0x20, 0x00, 0x70, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0xFC, 0x01, 0xFC, 0x01, 32 | 0xFE, 0x03, 0xFE, 0x03, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 33 | 0xFF, 0x07, 0xFF, 0x07, 0xFE, 0x03, 0xFC, 0x01, }; 34 | // w 11 h 16 35 | const uint8_t temp[] = { 36 | 0x78, 0x00, 0xFC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 37 | 0xCC, 0x00, 0xFC, 0x00, 0xFE, 0x01, 0xB7, 0x03, 0x33, 0x03, 0x7B, 0x03, 38 | 0x7B, 0x03, 0x03, 0x03, 0x87, 0x03, 0xFE, 0x01, 0xFC, 0x00,}; 39 | -------------------------------------------------------------------------------- /examples/VME290/GHXTC_Sensor_Display/sensor_th.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation GXHTC Sensors test example 2 | * 3 | * Function: 4 | * Read the temperature, humidity, and time displayed on the screen 5 | * 6 | * Description: 7 | * 1. This example use a quick link cable to connect gxhtv3 and read temperature and humidity through iic 8 | * 9 | * Library url: https://github.com/HelTecAutomation/Heltec_ESP32 10 | * Support: support@heltec.cn 11 | * 12 | * HelTec AutoMation, Chengdu, China 13 | * 成都惠利特自动化科技有限公司 14 | * https://www.heltec.org 15 | */ 16 | #include "Wire.h" 17 | #include "GXHTC.h" 18 | #include "HT_DEPG0290BxS800FxX_BW.h" 19 | #include "images.h" 20 | #include 21 | #include "time.h" 22 | #include 23 | 24 | // Initialize the display 25 | DEPG0290BxS800FxX_BW display(5, 4, 3, 6, 2, 1, -1, 6000000); // rst,dc,cs,busy,sck,mosi,miso,frequency 26 | GXHTC gxhtc; 27 | char buffer[256]; 28 | const char *ntpServer = "ntp.aliyun.com"; 29 | const long gmtOffset_sec = 28800; // Time offset UTC+8 30 | const int daylightOffset_sec = 0; 31 | const char *ssid = "Your Wi-Fi SSID"; 32 | const char *password = "Your Wi-Fi password"; 33 | 34 | void setup() { 35 | Serial.begin(115200); 36 | pinMode(18, OUTPUT); 37 | digitalWrite(18, HIGH); 38 | gxhtc.begin(39, 38); 39 | display.init(); 40 | display.clear(); 41 | display.drawString(0, 0, "init >>> "); 42 | Serial.print("Connecting to "); 43 | display.drawString(0, 20, "Connecting to ... "); 44 | Serial.println(ssid); 45 | display.drawString(100, 20, ssid); 46 | WiFi.begin(ssid, password); 47 | uint8_t i = 0; 48 | while (WiFi.status() != WL_CONNECTED) { 49 | delay(500); 50 | Serial.print("."); 51 | display.drawString(i, 40, "."); 52 | i = i + 10; 53 | } 54 | Serial.println(""); 55 | Serial.println("WiFi connected"); 56 | display.drawString(0, 60, "WiFi connected"); 57 | Serial.println("IP address: "); 58 | display.drawString(0, 90, "IP address: "); 59 | display.drawString(60, 90, WiFi.localIP().toString().c_str()); 60 | Serial.println(WiFi.localIP()); 61 | Serial.println(""); 62 | Serial.println("WiFi Conected!"); 63 | display.display(); 64 | delay(1000); 65 | } 66 | 67 | void printLocalTime() { 68 | struct tm timeinfo; 69 | if (!getLocalTime(&timeinfo)) { 70 | Serial.println("Failed to obtain time"); 71 | return; 72 | } 73 | display.setFont(ArialMT_Plain_10); 74 | char buffer[256]; 75 | display.setFont(ArialMT_Plain_10); 76 | Serial.println(timeinfo.tm_hour); 77 | sprintf(buffer, "%d", timeinfo.tm_hour); 78 | display.drawString(10, 0, buffer); 79 | display.drawString(25, 0, ": "); 80 | sprintf(buffer, "%d", timeinfo.tm_min); 81 | Serial.println(timeinfo.tm_min); 82 | display.drawString(30, 0, buffer); 83 | Serial.println(timeinfo.tm_mon); 84 | display.setFont(ArialMT_Plain_16); 85 | sprintf(buffer, "%d", timeinfo.tm_year + 1900); 86 | display.drawString(190, 110, buffer); 87 | display.drawString(225, 110, "/"); 88 | sprintf(buffer, "%d", timeinfo.tm_mon + 1); 89 | display.drawString(230, 110, buffer); 90 | display.drawString(240, 110, "/"); 91 | sprintf(buffer, "%d", timeinfo.tm_mday); 92 | Serial.println(timeinfo.tm_mday); 93 | display.drawString(245, 110, buffer); 94 | Serial.println(timeinfo.tm_mday); 95 | } 96 | 97 | void GetNetTime() { 98 | configTime(gmtOffset_sec, daylightOffset_sec, ntpServer); 99 | printLocalTime(); 100 | } 101 | 102 | void read_th() { 103 | gxhtc.read_data(); 104 | Serial.print("Temperature:"); 105 | Serial.print(gxhtc.g_temperature); 106 | display.setFont(ArialMT_Plain_24); 107 | sprintf(buffer, "%.2f", gxhtc.g_temperature); 108 | display.drawXbm(42, 55,10,17,temp); 109 | display.drawString(53, 50, buffer); 110 | Serial.print(" Humidity:"); 111 | Serial.println(gxhtc.g_humidity); 112 | sprintf(buffer, "%.2f", gxhtc.g_humidity); 113 | display.drawXbm(151, 55,11,16,hum); 114 | display.drawString(167, 50, buffer); 115 | Serial.printf("id = %X\r\n", gxhtc.read_id()); 116 | } 117 | 118 | void loop() { 119 | display.clear(); 120 | display.drawLine(0, 15, 296, 15); 121 | read_th(); 122 | GetNetTime(); 123 | display.display(); 124 | delay(30000); 125 | } 126 | -------------------------------------------------------------------------------- /examples/VME290/deepsleep/deepsleep.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation adc example 2 | * 3 | * Function: 4 | * 1.ESP32 deep sleep achieves low power consumption 5 | * 6 | * * Description: 7 | * 1.Pin states can be set to achieve stable deep sleep. 8 | * 2.If equipped with Lora module, please use this low-power instance 9 | * 10 | * Library url: https://github.com/HelTecAutomation/Heltec_ESP32 11 | * Support: support@heltec.cn 12 | * 13 | * HelTec AutoMation, Chengdu, China 14 | * 成都惠利特自动化科技有限公司 15 | * https://www.heltec.org 16 | * 17 | * */ 18 | 19 | #include "Arduino.h" 20 | #include "LoRaWan_APP.h" 21 | #include "driver/rtc_io.h" 22 | #include 23 | 24 | #define wakeuptime 10 * 1000 * (uint64_t)1000 //Sleep time 25 | 26 | void intodeepsleep() 27 | { 28 | Mcu.begin(HELTEC_BOARD,SLOW_CLK_TPYE); 29 | pinMode(18,OUTPUT); 30 | digitalWrite(18, LOW); 31 | Radio.Sleep(); 32 | SPI.end(); 33 | pinMode(14,ANALOG); 34 | pinMode(8, OUTPUT); 35 | digitalWrite(8, HIGH); 36 | rtc_gpio_hold_en(gpio_num_t(8)); 37 | pinMode(12,ANALOG); 38 | pinMode(13,ANALOG); 39 | pinMode(9,ANALOG); 40 | pinMode(11,ANALOG); 41 | pinMode(10,ANALOG); 42 | } 43 | 44 | void setup() 45 | { 46 | intodeepsleep(); 47 | esp_sleep_enable_timer_wakeup(wakeuptime); 48 | delay(4000); 49 | esp_deep_sleep_start(); 50 | } 51 | 52 | void loop() 53 | { 54 | } -------------------------------------------------------------------------------- /examples/VME290/lorawaneink_GHXTC/img.h: -------------------------------------------------------------------------------- 1 | const uint8_t hum[] = { 2 | 0x20, 0x00, 0x70, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0xFC, 0x01, 0xFC, 0x01, 3 | 0xFE, 0x03, 0xFE, 0x03, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 4 | 0xFF, 0x07, 0xFF, 0x07, 0xFE, 0x03, 0xFC, 0x01, }; 5 | const uint8_t temp[] = { 6 | 0x78, 0x00, 0xFC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 0xCC, 0x00, 7 | 0xCC, 0x00, 0xFC, 0x00, 0xFE, 0x01, 0xB7, 0x03, 0x33, 0x03, 0x7B, 0x03, 8 | 0x7B, 0x03, 0x03, 0x03, 0x87, 0x03, 0xFE, 0x01, 0xFC, 0x00, }; -------------------------------------------------------------------------------- /examples/VME290/weather_station/readme.md: -------------------------------------------------------------------------------- 1 | # WEATHER STATION 2 | 3 | This example demonstrates how to obtain weather, time, etc. from the internet and display them on an ink screen. 4 | 5 | # Supported Targets 6 | 7 | At present, this example only supports Vison Master Eink213, which uses the ESP32-S3 chip. 8 | 9 | ## How to Use Example 10 | 11 | Flash this example and observe the screen display. 12 | 13 | ### Configure the Project 14 | 15 | Change `SSID` and `password` to connect to your WiFi. 16 | Default values will allow you to use this example without any changes. If you want to use your own Weather server and you don't have one already follow these steps: 17 | 18 | * Create an account on [Weather server](https://www.seniverse.com/). 19 | * After logging in, click on the "immediate use" button to create a new product for your data. You can create a free or paid product, then obtain its private key and fill it in the 'privateKey' field. 20 | * This example uses a free API to obtain weather parameters for 3 days. The weather parameters for one week should have an interface. The author's city of residence does not have special weather conditions, and currently only supports three common weather conditions: sunny, rainy, and cloudy. Other weather interfaces are reserved. 21 | * This instance obtains the time from the [time server](ntp.aliyun.com), and you can modify 'ntpServe' to use a server that is convenient for you to use 22 | 23 | #### Config example: 24 | 25 | You can find the data to be changed at the top of the file: 26 | 27 | ```cpp 28 | const char *ntpServer = "ntp.aliyun.com";// time server 29 | const long gmtOffset_sec = 28800; // time offset,UTC/GMT +8 30 | const int daylightOffset_sec = 0;// Timing started in 1990 31 | const char *ssid = "Your Wi-Fi SSID"; 32 | const char *password = "Your Wi-Fi password"; 33 | 34 | const char *host = "api.seniverse.com";//Weather server 35 | const char *privateKey = "Sfv1t8EYrow1Zi-5o";//Product privateKey 36 | const char *city = "chengdu";//The city to be queried 37 | const char *language = "en";//language preference 38 | //The following is the API splicing method 39 | String getUrl = "/v3/weather/daily.json?key="; 40 | getUrl += privateKey; 41 | getUrl += "&location="; 42 | getUrl += city; 43 | getUrl += "&language="; 44 | getUrl += language; 45 | client.print(String("GET ") + getUrl + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"); 46 | 47 | #### Using Arduino IDE 48 | 49 | To get more information about the Espressif boards see [heltec.org](https://heltec.org). 50 | 51 | * Before Compile/Verify, select the correct board: `Tools -> Board`. 52 | * Select the COM port: `Tools -> Port: xxx` where the `xxx` is the detected COM port. 53 | 54 | -------------------------------------------------------------------------------- /examples/Wireless_paper/Wireless_Paper_V1.0/Wireless_Paper_V1.0.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation Wireless_Paper_V1.0 Sensors test example 2 | * 3 | * Function: 4 | * - Build a web page and refresh e-paper through Wi-Fi. 5 | * - With DHCP function. 6 | * 7 | * HelTec AutoMation, Chengdu, China 8 | * www.heltec.org 9 | * 10 | * Operation instance: Only work with Heltec Wireless Paper V1.0 hardware 11 | * 12 | * this project also realess in GitHub: 13 | * https://github.com/HelTecAutomation/Heltec_ESP32 14 | */ 15 | 16 | #include 17 | #include 18 | #include "HT_QYEG0213RWS800_BWR.h" 19 | #include "images.h" 20 | #include "html.h" 21 | #include 22 | 23 | QYEG0213RWS800_BWR display(6, 5, 4, 7, 3, 2, -1, 6000000); // rst,dc,cs,busy,sck,mosi,miso,frequency 24 | 25 | uint8_t width, height; 26 | String HTTP_Payload; 27 | 28 | WebServer server(80); // Create WebServer object with port number 80 29 | // By using port number 80, you can directly enter the IP address for access, while using other ports requires entering the IP: port number for access 30 | 31 | const char *ssid = "your_ssid"; 32 | const char *password = "your_password"; 33 | 34 | // Distribute processing callback function 35 | 36 | void Config_Callback() 37 | { 38 | 39 | String Payload; 40 | const char *buff; 41 | 42 | Payload = server.arg("value"); // Obtain the data delivered 43 | buff = Payload.c_str(); 44 | 45 | delay(100); 46 | int i = 0; 47 | char *token; 48 | token = strtok((char *)buff, ","); 49 | 50 | while (token != NULL) 51 | { 52 | int num = atoi(token); 53 | WiFi_Logo_bits[i] = num; 54 | token = strtok(NULL, ","); 55 | Serial.print(WiFi_Logo_bits[i]); 56 | i++; 57 | } 58 | drawImageDemo(); 59 | Serial.println("dd"); 60 | } 61 | 62 | void setup() 63 | { 64 | 65 | Serial.begin(115200); 66 | Serial.println(); 67 | 68 | VextON(); 69 | delay(100); 70 | display.init(); 71 | 72 | WiFi.mode(WIFI_STA); 73 | WiFi.setSleep(false); 74 | WiFi.begin(ssid, password); 75 | while (WiFi.status() != WL_CONNECTED) 76 | { 77 | delay(500); 78 | Serial.print("."); 79 | } 80 | Serial.println("Connected"); 81 | Serial.print("IP Address:"); 82 | Serial.println(WiFi.localIP()); 83 | server.on("/", []() 84 | { server.send(200, "text/html", index_html); }); 85 | 86 | server.on("/set", HTTP_GET, Config_Callback); // Bind the handler that is configured to deliver the function 87 | server.begin(); 88 | } 89 | void drawImageDemo() 90 | { 91 | // see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html 92 | // on how to create xbm files 93 | display.clear(); 94 | display.update(BLACK_BUFFER); 95 | 96 | display.clear(); 97 | int x = width / 2 - WiFi_Logo_width / 2; 98 | int y = height / 2 - WiFi_Logo_height / 2; 99 | display.drawXbm(0, 0, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits); 100 | display.update(BLACK_BUFFER); 101 | display.display(); 102 | } 103 | void VextON(void) 104 | { 105 | pinMode(45, OUTPUT); 106 | digitalWrite(45, LOW); 107 | } 108 | 109 | void VextOFF(void) // Vext default OFF 110 | { 111 | pinMode(45, OUTPUT); 112 | digitalWrite(45, HIGH); 113 | } 114 | void loop() 115 | { 116 | server.handleClient(); // Handle requests from clients 117 | } 118 | -------------------------------------------------------------------------------- /examples/Wireless_paper/Wireless_Paper_V1.0/images.h: -------------------------------------------------------------------------------- 1 | #define WiFi_Logo_width 250 2 | #define WiFi_Logo_height 122 3 | uint8_t WiFi_Logo_bits[10000] PROGMEM = { 4 | }; 5 | -------------------------------------------------------------------------------- /examples/Wireless_paper/Wireless_Paper_V1.1/Wireless_Paper_V1.1.ino: -------------------------------------------------------------------------------- 1 | /* Heltec Automation Wireless_Paper_V1.0 Sensors test example 2 | * 3 | * Function: 4 | * - Build a web page and refresh e-paper through Wi-Fi. 5 | * - With DHCP function. 6 | * 7 | * HelTec AutoMation, Chengdu, China 8 | * www.heltec.org 9 | * 10 | * Operation instance: Only work with Heltec Wireless Paper V1.1 hardware 11 | * 12 | * this project also realess in GitHub: 13 | * https://github.com/HelTecAutomation/Heltec_ESP32 14 | */ 15 | 16 | #include 17 | #include 18 | #include "HT_lCMEN2R13EFC1.h" 19 | #include "images.h" 20 | #include "html.h" 21 | #include 22 | 23 | HT_ICMEN2R13EFC1 display(6, 5, 4, 7, 3, 2, -1, 6000000); // rst,dc,cs,busy,sck,mosi,miso,frequency 24 | 25 | int width, height; 26 | String HTTP_Payload; 27 | WebServer server(80); // Create WebServer object with port number 80 28 | // By using port number 80, you can directly enter the IP address for access, while using other ports requires entering the IP: port number for access 29 | 30 | const char *ssid = "your-ssid"; 31 | const char *password = "your-password"; 32 | 33 | // Distribute processing callback function 34 | void Config_Callback() 35 | { 36 | 37 | String Payload; 38 | const char *buff; 39 | 40 | Payload = server.arg("value"); // Obtain the data delivered 41 | buff = Payload.c_str(); 42 | 43 | delay(100); 44 | int i = 0; 45 | char *token; 46 | token = strtok((char *)buff, ","); 47 | 48 | while (token != NULL) 49 | { 50 | int num = atoi(token); 51 | WiFi_Logo_bits[i] = num; 52 | token = strtok(NULL, ","); 53 | Serial.print(WiFi_Logo_bits[i]); 54 | i++; 55 | } 56 | drawImageDemo(); 57 | Serial.println("dd"); 58 | } 59 | 60 | void setup() 61 | { 62 | 63 | Serial.begin(115200); 64 | Serial.println(); 65 | 66 | VextON(); 67 | delay(100); 68 | display.init(); 69 | 70 | WiFi.mode(WIFI_STA); 71 | WiFi.setSleep(false); 72 | WiFi.begin(ssid, password); 73 | while (WiFi.status() != WL_CONNECTED) 74 | { 75 | delay(500); 76 | Serial.print("."); 77 | } 78 | Serial.println("Connected"); 79 | Serial.print("IP Address:"); 80 | Serial.println(WiFi.localIP()); 81 | server.on("/", []() 82 | { server.send(200, "text/html", index_html); }); 83 | 84 | server.on("/set", HTTP_GET, Config_Callback); // Bind the handler that is configured to deliver the function 85 | server.begin(); 86 | } 87 | void drawImageDemo() 88 | { 89 | // see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html 90 | // on how to create xbm files 91 | display.clear(); 92 | display.update(BLACK_BUFFER); 93 | 94 | display.clear(); 95 | int x = width / 2 - WiFi_Logo_width / 2; 96 | int y = height / 2 - WiFi_Logo_height / 2; 97 | display.drawXbm(0, 0, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits); 98 | display.update(BLACK_BUFFER); 99 | display.display(); 100 | 101 | } 102 | void VextON(void) 103 | { 104 | pinMode(45, OUTPUT); //For HT-VME213,choose "18, OUTPUT" 105 | digitalWrite(45, LOW); //For HT-VME213,choose "18, HIGH" 106 | } 107 | 108 | void VextOFF(void) // Vext default OFF 109 | { 110 | pinMode(45, OUTPUT); //For HT-VME213,choose "18, OUTPUT" 111 | digitalWrite(45, HIGH); //For HT-VME213,choose "18, LOW" 112 | } 113 | void loop() 114 | { 115 | server.handleClient(); // Handle requests from clients 116 | 117 | } 118 | -------------------------------------------------------------------------------- /examples/Wireless_paper/Wireless_Paper_V1.1/html.h: -------------------------------------------------------------------------------- 1 | //An array for storing web pages 2 | 3 | const char index_html[] PROGMEM = R"rawliteral( 4 | 5 | 6 | 7 | 8 | 9 | 10 |

wireless_paper

11 | 12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | )rawliteral"; 132 | -------------------------------------------------------------------------------- /examples/Wireless_paper/Wireless_Paper_V1.1/images.h: -------------------------------------------------------------------------------- 1 | #define WiFi_Logo_width 250 2 | #define WiFi_Logo_height 122 3 | uint8_t WiFi_Logo_bits[10000] PROGMEM = { 4 | }; 5 | -------------------------------------------------------------------------------- /examples/Wireless_paper/img/image-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/examples/Wireless_paper/img/image-1.png -------------------------------------------------------------------------------- /examples/Wireless_paper/img/image-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/examples/Wireless_paper/img/image-2.png -------------------------------------------------------------------------------- /examples/Wireless_paper/img/image-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/examples/Wireless_paper/img/image-3.png -------------------------------------------------------------------------------- /examples/Wireless_paper/img/image-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/examples/Wireless_paper/img/image-4.png -------------------------------------------------------------------------------- /examples/Wireless_paper/img/image-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/examples/Wireless_paper/img/image-5.png -------------------------------------------------------------------------------- /examples/Wireless_paper/img/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/examples/Wireless_paper/img/image.png -------------------------------------------------------------------------------- /examples/Wireless_paper/readme.md: -------------------------------------------------------------------------------- 1 | 1.Modifying the program 2 | 3 | ​ 4 | 5 | Connect to WiFi. 6 | 7 | Compile and burn programs 8 | 9 | 2.After initialization is completed, access the wireless_paper IP address, which can be viewed on the serial port 10 | 11 | ![Alt text](img/image.png) 12 | 13 | 3.The following page appears![](img/image-2.png)Click![](img/image-3.png) Select an image, and to ensure a refresh effect, it is best to choose a black and white BMP format image. The image size should be set to 250 x 122. 14 | 15 | The button will display the file address, as shown in the picture![](img/image-4.png) 16 | 17 | 4.Click the Get image data button to obtain image data, which will be displayed on the canvas. The effect is as follows:![](img/image-5.png) 18 | 5.Click the refresh button to refresh the image on the ink screen. 19 | 20 | -------------------------------------------------------------------------------- /img/01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/img/01.png -------------------------------------------------------------------------------- /img/02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/img/02.png -------------------------------------------------------------------------------- /img/location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/img/location.png -------------------------------------------------------------------------------- /img/location_cn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/img/location_cn.png -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Heltec_ESP32 3 | ####################################### 4 | 5 | ####################################### 6 | # Library (KEYWORD3) 7 | ####################################### 8 | 9 | Heltec KEYWORD3 10 | 11 | ####################################### 12 | # Datatypes (KEYWORD1) 13 | ####################################### 14 | 15 | LoRa KEYWORD1 16 | display KEYWORD1 17 | 18 | ####################################### 19 | # Methods and Functions (KEYWORD2) 20 | ####################################### 21 | 22 | begin KEYWORD2 23 | end KEYWORD2 24 | write KEYWORD2 25 | sleep KEYWORD2 26 | 27 | beginPacket KEYWORD2 28 | endPacket KEYWORD2 29 | parsePacket KEYWORD2 30 | packetRssi KEYWORD2 31 | packetSnr KEYWORD2 32 | available KEYWORD2 33 | peek KEYWORD2 34 | flush KEYWORD2 35 | onReceive KEYWORD2 36 | receive KEYWORD2 37 | read KEYWORD2 38 | idle KEYWORD2 39 | setTxPower KEYWORD2 40 | setTxPowerMax KEYWORD2 41 | setFrequency KEYWORD2 42 | setSpreadingFactor KEYWORD2 43 | setSignalBandwidth KEYWORD2 44 | setCodingRate4 KEYWORD2 45 | setPreambleLength KEYWORD2 46 | setSyncWord KEYWORD2 47 | enableCrc KEYWORD2 48 | disableCrc KEYWORD2 49 | crc KEYWORD2 50 | noCrc KEYWORD2 51 | random KEYWORD2 52 | setpins KEYWORD2 53 | setSPIFrequency KEYWORD2 54 | dumpRegisters KEYWORD2 55 | enableLowDataRate KEYWORD2 56 | disableLowDataRate KEYWORD2 57 | 58 | drawString KEYWORD2 59 | display KEYWORD2 60 | wakeup KEYWORD2 61 | resetDisplay KEYWORD2 62 | setColor KEYWORD2 63 | getColor KEYWORD2 64 | setPixel KEYWORD2 65 | drawLine KEYWORD2 66 | drawRect KEYWORD2 67 | fillRect KEYWORD2 68 | drawCircle KEYWORD2 69 | drawCircleQuads KEYWORD2 70 | fillCircle KEYWORD2 71 | drawHorizontalLine KEYWORD2 72 | drawVerticalLine KEYWORD2 73 | drawProgressBar KEYWORD2 74 | drawFastImage KEYWORD2 75 | drawXbm KEYWORD2 76 | drawStringMaxWidth KEYWORD2 77 | getStringWidth KEYWORD2 78 | getStringWidth KEYWORD2 79 | setTextAlignment KEYWORD2 80 | setFont KEYWORD2 81 | setFontTableLookupFunction KEYWORD2 82 | displayOn KEYWORD2 83 | displayOff KEYWORD2 84 | invertDisplay KEYWORD2 85 | normalDisplay KEYWORD2 86 | setContrast KEYWORD2 87 | setBrightness KEYWORD2 88 | resetOrientation KEYWORD2 89 | flipScreenVertically KEYWORD2 90 | mirrorScreen KEYWORD2 91 | clear KEYWORD2 92 | setLogBuffer KEYWORD2 93 | drawLogBuffer KEYWORD2 94 | getWidth KEYWORD2 95 | getHeight KEYWORD2 96 | 97 | -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Heltec ESP32 Dev-Boards", 3 | "keywords": "heltec, esp32, lora, wifi kit, oled", 4 | "description": "A library for Heltec ESP32 (or ESP32+LoRa) based board", 5 | "repository":{ 6 | "type": "git", 7 | "url": "https://github.com/HelTecAutomation/Heltec_ESP32.git" 8 | }, 9 | "authors":{ 10 | "name": "Heltec Automation(TM)", 11 | "email": "support@heltec.cn" 12 | }, 13 | "version": "2.1.4", 14 | "frameworks": "arduino", 15 | "platforms": "espressif32" 16 | } 17 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=Heltec ESP32 Dev-Boards 2 | version=2.1.4 3 | author= Heltec Automation 4 | maintainer=HelTec 5 | sentence=Library for Heltec ESP32 (or ESP32+LoRa) based boards 6 | paragraph=Includes: WiFi Kit 32, WiFi LoRa 32, Wireless Stick Lite, Wireless Shell, Vision Master, HT-CT62, Wireless tracker,wireless paper, HT-VME213, HT-VME290, HT-VMT190 see more on http://heltec.cn 7 | category=Device Control 8 | url=https://github.com/HelTecAutomation/Heltec_ESP32.git 9 | architectures=esp32 10 | includes=heltec.h 11 | precompiled=true 12 | ldflags=-llorawan 13 | depends=Adafruit GFX Library, Adafruit BusIO -------------------------------------------------------------------------------- /src/BH1750.h: -------------------------------------------------------------------------------- 1 | #ifndef __BH1750_H__ 2 | #define __BH1750_H__ 3 | 4 | 5 | #include 6 | #include "Wire.h" 7 | 8 | 9 | #define BH1750_SDA (1) 10 | #define BH1750_SCL (2) 11 | #define BH1750_RST (6) 12 | #define BH1750_AVERAGE_NUM (5) 13 | 14 | // Uncomment, to enable debug messages 15 | // #define BH1750_DEBUG 16 | 17 | // No active state 18 | #define BH1750_POWER_DOWN 0x00 19 | 20 | // Waiting for measurement command 21 | #define BH1750_POWER_ON 0x01 22 | 23 | // Reset data register value - not accepted in POWER_DOWN mode 24 | #define BH1750_RESET 0x07 25 | 26 | // Default MTreg value 27 | #define BH1750_DEFAULT_MTREG 69 28 | 29 | class BH1750 { 30 | 31 | public: 32 | 33 | enum Mode 34 | { 35 | UNCONFIGURED = 0, 36 | // Measurement at 1 lux resolution. Measurement time is approx 120ms. 37 | CONTINUOUS_HIGH_RES_MODE = 0x10, 38 | // Measurement at 0.5 lux resolution. Measurement time is approx 120ms. 39 | CONTINUOUS_HIGH_RES_MODE_2 = 0x11, 40 | // Measurement at 4 lux resolution. Measurement time is approx 16ms. 41 | CONTINUOUS_LOW_RES_MODE = 0x13, 42 | // Measurement at 1 lux resolution. Measurement time is approx 120ms. 43 | ONE_TIME_HIGH_RES_MODE = 0x20, 44 | // Measurement at 0.5 lux resolution. Measurement time is approx 120ms. 45 | ONE_TIME_HIGH_RES_MODE_2 = 0x21, 46 | // Measurement at 4 lux resolution. Measurement time is approx 16ms. 47 | ONE_TIME_LOW_RES_MODE = 0x23 48 | }; 49 | 50 | BH1750(byte addr = 0x23); 51 | bool begin(int sda=BH1750_SDA, int scl=BH1750_SCL,int rst=BH1750_RST,Mode mode = CONTINUOUS_HIGH_RES_MODE); 52 | void end(); 53 | bool configure(Mode mode); 54 | bool setMTreg(byte MTreg); 55 | float readLightLevel(bool maxWait = false); 56 | 57 | private: 58 | int _rst; 59 | byte BH1750_I2CADDR; 60 | byte BH1750_MTreg = (byte)BH1750_DEFAULT_MTREG; 61 | // Correction factor used to calculate lux. Typical value is 1.2 but can 62 | // range from 0.96 to 1.44. See the data sheet (p.2, Measurement Accuracy) 63 | // for more information. 64 | const float BH1750_CONV_FACTOR = 1.2; 65 | Mode BH1750_MODE = UNCONFIGURED; 66 | }; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/BMP180.h: -------------------------------------------------------------------------------- 1 | #ifndef BMP180_H 2 | #define BMP180_H 3 | 4 | #include "Arduino.h" 5 | #include "Wire.h" 6 | 7 | #define BMP085_DEBUG 0 8 | 9 | #define BMP085_I2CADDR 0x77 10 | 11 | #define BMP085_ULTRALOWPOWER 0 12 | #define BMP085_STANDARD 1 13 | #define BMP085_HIGHRES 2 14 | #define BMP085_ULTRAHIGHRES 3 15 | #define BMP085_CAL_AC1 0xAA // R Calibration data (16 bits) 16 | #define BMP085_CAL_AC2 0xAC // R Calibration data (16 bits) 17 | #define BMP085_CAL_AC3 0xAE // R Calibration data (16 bits) 18 | #define BMP085_CAL_AC4 0xB0 // R Calibration data (16 bits) 19 | #define BMP085_CAL_AC5 0xB2 // R Calibration data (16 bits) 20 | #define BMP085_CAL_AC6 0xB4 // R Calibration data (16 bits) 21 | #define BMP085_CAL_B1 0xB6 // R Calibration data (16 bits) 22 | #define BMP085_CAL_B2 0xB8 // R Calibration data (16 bits) 23 | #define BMP085_CAL_MB 0xBA // R Calibration data (16 bits) 24 | #define BMP085_CAL_MC 0xBC // R Calibration data (16 bits) 25 | #define BMP085_CAL_MD 0xBE // R Calibration data (16 bits) 26 | 27 | #define BMP085_CONTROL 0xF4 28 | #define BMP085_TEMPDATA 0xF6 29 | #define BMP085_PRESSUREDATA 0xF6 30 | #define BMP085_READTEMPCMD 0x2E 31 | #define BMP085_READPRESSURECMD 0x34 32 | 33 | 34 | class BMP085 { 35 | public: 36 | BMP085(); 37 | boolean begin(uint8_t mode = BMP085_ULTRAHIGHRES); // by default go highres 38 | float readTemperature(void); 39 | int32_t readPressure(void); 40 | int32_t readSealevelPressure(float altitude_meters = 0); 41 | float readAltitude(float sealevelPressure = 101325); // std atmosphere 42 | uint16_t readRawTemperature(void); 43 | uint32_t readRawPressure(void); 44 | 45 | private: 46 | int32_t computeB5(int32_t UT); 47 | uint8_t read8(uint8_t addr); 48 | uint16_t read16(uint8_t addr); 49 | void write8(uint8_t addr, uint8_t data); 50 | 51 | uint8_t oversampling; 52 | 53 | int16_t ac1, ac2, ac3, b1, b2, mb, mc, md; 54 | uint16_t ac4, ac5, ac6; 55 | }; 56 | 57 | 58 | #endif // _BMP085_H 59 | -------------------------------------------------------------------------------- /src/ESP32_LoRaWan_102.h: -------------------------------------------------------------------------------- 1 | #if !defined(HT_DE01)&&!defined(WIFI_Kit_32)&&!defined(WIFI_Kit_32_V3) 2 | #ifndef __LORAWAN_102_H__ 3 | #define __LORAWAN_102_H__ 4 | 5 | #include "loramac/LoRaMac.h" 6 | #include "loramac/Commissioning.h" 7 | #include "loramac/region/Region.h" 8 | 9 | #endif 10 | 11 | #endif -------------------------------------------------------------------------------- /src/ESP32_Mcu.h: -------------------------------------------------------------------------------- 1 | 2 | #if defined(HT_DE01)||defined(WIFI_Kit_32)||defined(WIFI_Kit_32_V3) 3 | #else 4 | 5 | #ifndef McuSet_H 6 | #define McuSet_H 7 | 8 | #include 9 | #include "SPI.h" 10 | #include "driver/rtc-board.h" 11 | #include "driver/board-config.h" 12 | #include "driver/lorawan_spi.h" 13 | #include "driver/sx126x.h" 14 | 15 | /* HELTEC_BOARD 16 | * 17 | * ESP32S3 CHIP 18 | * WIFI_LORA_32_V3 30 19 | * WIRELESS_STICK_V3 31 20 | * WIRELESS_STICK_LITE_V3 32 21 | * WIRELESS_SHELL_V3 33 22 | * WIRELESS_TRACKER 34 23 | * WIFI_KIT_32_V3 35 24 | * Vision_Master_E_213 36 25 | * Vision_Master_E290 37 26 | * Vision_Master_T190 38 27 | * 28 | * If value come to 49, next one should be 61 29 | * CAPSULE_SENSOR_V3 50 30 | * WIRELESS_PAPER 60 31 | * 32 | * 33 | * ESP32C3 CHIP 34 | * WIRELESS_MINI_SHELL 70 35 | * 36 | * 37 | * ESP32D0 CHIP 38 | * 39 | * WIFI_LORA_32_V2 0 40 | * WIFI_LORA_32 1 41 | * WIRELESS_STICK 2 42 | * WIRELESS_STICK_LITE //WIRELESS_SHELL 3 43 | * WIRELESS_BRIDGE 4 44 | * WIFI_KIT_32 5 45 | */ 46 | 47 | 48 | 49 | #define LORA_DEFAULT_NSS_PIN 18 50 | #define LORA_DEFAULT_RESET_PIN 14 51 | #define LORA_DEFAULT_DIO0_PIN 26 52 | #define LORA_DEFAULT_DIO1_PIN 33 53 | #define Timer_DEFAULT_DIV 80 54 | extern uint8_t mcuStarted; 55 | class McuClass{ 56 | public: 57 | McuClass(); 58 | void setlicense(uint32_t * license,uint8_t board_type); 59 | int begin(uint8_t board_type,uint8_t ex_32k); 60 | void addwakeio(uint8_t gpio); 61 | void setSPIFrequency(uint32_t frequency); 62 | void timerhandler(); 63 | void sleep(uint8_t classMode,uint8_t debugLevel,uint8_t board_type,uint8_t ex_32k); 64 | SPISettings _spiSettings; 65 | private: 66 | 67 | }; 68 | extern TimerEvent_t TxNextPacketTimer; 69 | 70 | #ifdef __cplusplus 71 | extern "C" uint8_t SpiInOut(Spi_t *obj, uint8_t outData ); 72 | extern "C" uint64_t timercheck(); 73 | extern "C" uint64_t getID(); 74 | extern "C" void SX126xIoInit( void ); 75 | extern "C" void SX126xIoIrqInit( DioIrqHandler dioIrq ); 76 | extern "C" void RadioOnDioIrq( void ); 77 | extern "C" void SX126xIoInit( void ); 78 | extern "C" void SX126xReset( void ); 79 | extern "C" void sx126xSleep( void ); 80 | extern "C" void calrtc(); 81 | extern "C" void lora_printf(const char *format, ...); 82 | #ifdef RADIO_CHIP_SX127X 83 | extern "C" void SX1276IoInit( void ); 84 | extern "C" void SX1276IoIrqInit( DioIrqHandler **irqHandlers ); 85 | extern DioIrqHandler *DioIrq[]; 86 | #endif 87 | 88 | #endif 89 | 90 | extern McuClass Mcu; 91 | #endif 92 | #endif -------------------------------------------------------------------------------- /src/GXHTC.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "GXHTC.h" 3 | 4 | 5 | GXHTC::GXHTC() 6 | { 7 | } 8 | 9 | void GXHTC::begin(int sda,int scl,uint8_t address) 10 | { 11 | _address = address; 12 | Wire.begin(sda,scl); 13 | } 14 | 15 | void GXHTC::end() 16 | { 17 | Wire.end(); 18 | } 19 | 20 | uint16_t GXHTC::read_id(void) 21 | { 22 | uint8_t buff[2]; 23 | uint16_t chip_id; 24 | Wire.beginTransmission(_address); 25 | Wire.write(0xEF); 26 | Wire.write(0xC8); 27 | Wire.endTransmission(); 28 | 29 | Wire.requestFrom(_address, (uint8_t)2); 30 | buff[0] = Wire.read(); 31 | buff[1] = Wire.read(); 32 | 33 | uint16_t tem,hum; 34 | 35 | chip_id = ((buff[0]<<8) | buff[1]); 36 | return chip_id; 37 | } 38 | void GXHTC::read_data() 39 | { 40 | uint8_t buff[6]; 41 | Wire.beginTransmission(_address); 42 | Wire.write(0x35); 43 | Wire.write(0x17); 44 | Wire.endTransmission(); 45 | 46 | Wire.beginTransmission(_address); 47 | Wire.write(0x7C); 48 | Wire.write(0xA2); 49 | Wire.endTransmission(); 50 | 51 | Wire.requestFrom(_address, (uint8_t)6); 52 | buff[0] = Wire.read(); 53 | buff[1] = Wire.read(); 54 | buff[2] = Wire.read(); 55 | buff[3] = Wire.read(); 56 | buff[4] = Wire.read(); 57 | buff[5] = Wire.read(); 58 | 59 | uint16_t tem,hum; 60 | 61 | tem = ((buff[0]<<8) | buff[1]);//�¶�ƴ�� 62 | hum = ((buff[3]<<8) | buff[4]);//ʪ��ƴ�� 63 | 64 | g_temperature= (175.0*(float)tem/65535.0-45.0) ;// T = -45 + 175 * tem / (2^16-1) 65 | g_humidity= (100.0*(float)hum/65535.0);// RH = hum*100 / (2^16-1) 66 | 67 | Wire.beginTransmission(_address); 68 | Wire.write(0xb0); 69 | Wire.write(0x98); 70 | Wire.endTransmission(); 71 | } 72 | 73 | float GXHTC::findAverage(float arr[], int size) 74 | { 75 | float max = arr[0]; 76 | float min = arr[0]; 77 | float sum = 0; 78 | int count = 0; 79 | for (int i = 0; i < size; i++) { 80 | if (arr[i] > max) 81 | max = arr[i]; 82 | if (arr[i] < min) 83 | min = arr[i]; 84 | sum += arr[i]; 85 | count++; 86 | } 87 | count -= 2; 88 | sum = sum - max - min; 89 | float average = (float)sum / count; 90 | 91 | return average; 92 | } 93 | -------------------------------------------------------------------------------- /src/GXHTC.h: -------------------------------------------------------------------------------- 1 | #ifndef __GXHTC_H__ 2 | #define __GXHTC_H__ 3 | #include 4 | 5 | 6 | #define GXHTC_SDA (1) 7 | #define GXHTC_SCL (2) 8 | #define GXHTC_ADDRESS (0x70) 9 | #define GXHTC_AVERAGE_NUM (5) 10 | #define GXHTC_CHIP_ID (0x0887) 11 | 12 | class GXHTC { 13 | public: 14 | GXHTC(); 15 | void begin(int sda =GXHTC_SDA,int scl =GXHTC_SCL ,uint8_t address=GXHTC_ADDRESS); 16 | void end(); 17 | float g_temperature=0; 18 | float g_humidity=0; 19 | void read_data(); 20 | uint16_t read_id(void); 21 | 22 | private: 23 | uint8_t _address; 24 | float findAverage(float arr[], int size); 25 | }; 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /src/HT_lCMEN2R13EFC1_LUT.h: -------------------------------------------------------------------------------- 1 | const unsigned char LUT_VCOM[] = { 2 | 0x00, 3 | 0x00, 4 | 0x00, 5 | 0x00, 6 | 0x00, 7 | 0x00, 8 | 0x00, 9 | 0x00, 10 | 0x00, 11 | 0x00, 12 | 0x00, 13 | 0x00, 14 | 0x00, 15 | 0x00, 16 | 0x00, 17 | 0x00, 18 | 0x00, 19 | 0x00, 20 | 0x00, 21 | 0x00, 22 | 0x00, 23 | 0x01, 24 | 0x00, 25 | 0x00, 26 | 0x00, 27 | 0x00, 28 | 0x00, 29 | 0x00, 30 | 0x01, 31 | 0x83, 32 | 0x82, 33 | 0x43, 34 | 0x42, 35 | 0x01, 36 | 0x01, 37 | 0x01, 38 | 0x03, 39 | 0x03, 40 | 0x00, 41 | 0x00, 42 | 0x01, 43 | 0x01, 44 | }; 45 | const unsigned char LUT_WW[] = { 46 | 0x00, 47 | 0x00, 48 | 0x00, 49 | 0x00, 50 | 0x00, 51 | 0x00, 52 | 0x00, 53 | 0x00, 54 | 0x00, 55 | 0x00, 56 | 0x00, 57 | 0x00, 58 | 0x00, 59 | 0x00, 60 | 0x00, 61 | 0x00, 62 | 0x00, 63 | 0x00, 64 | 0x00, 65 | 0x00, 66 | 0x00, 67 | 0x01, 68 | 0x00, 69 | 0x00, 70 | 0x00, 71 | 0x00, 72 | 0x00, 73 | 0x00, 74 | 0x01, 75 | 0x83, 76 | 0x82, 77 | 0x83, 78 | 0x82, 79 | 0x01, 80 | 0x01, 81 | 0x01, 82 | 0x03, 83 | 0x83, 84 | 0x00, 85 | 0x00, 86 | 0x01, 87 | 0x01, 88 | }; 89 | const unsigned char LUT_BW[] = { 90 | 0x00, 91 | 0x00, 92 | 0x00, 93 | 0x00, 94 | 0x00, 95 | 0x00, 96 | 0x00, 97 | 0x00, 98 | 0x00, 99 | 0x00, 100 | 0x00, 101 | 0x00, 102 | 0x00, 103 | 0x00, 104 | 0x00, 105 | 0x00, 106 | 0x00, 107 | 0x00, 108 | 0x00, 109 | 0x00, 110 | 0x00, 111 | 0x01, 112 | 0x00, 113 | 0x00, 114 | 0x00, 115 | 0x00, 116 | 0x00, 117 | 0x00, 118 | 0x01, 119 | 0x83, 120 | 0x82, 121 | 0x83, 122 | 0x82, 123 | 0x01, 124 | 0x01, 125 | 0x01, 126 | 0x03, 127 | 0x83, 128 | 0x00, 129 | 0x00, 130 | 0x01, 131 | 0x01, 132 | }; 133 | const unsigned char LUT_WB[] = { 134 | 0x00, 135 | 0x00, 136 | 0x00, 137 | 0x00, 138 | 0x00, 139 | 0x00, 140 | 0x00, 141 | 0x00, 142 | 0x00, 143 | 0x00, 144 | 0x00, 145 | 0x00, 146 | 0x00, 147 | 0x00, 148 | 0x00, 149 | 0x00, 150 | 0x00, 151 | 0x00, 152 | 0x00, 153 | 0x00, 154 | 0x00, 155 | 0x01, 156 | 0x00, 157 | 0x00, 158 | 0x00, 159 | 0x00, 160 | 0x00, 161 | 0x00, 162 | 0x01, 163 | 0x43, 164 | 0x42, 165 | 0x43, 166 | 0x42, 167 | 0x01, 168 | 0x01, 169 | 0x01, 170 | 0x43, 171 | 0x03, 172 | 0x00, 173 | 0x00, 174 | 0x01, 175 | 0x01, 176 | }; // 0.32 177 | const unsigned char LUT_BB[] = { 178 | 0x00, 179 | 0x00, 180 | 0x00, 181 | 0x00, 182 | 0x00, 183 | 0x00, 184 | 0x00, 185 | 0x00, 186 | 0x00, 187 | 0x00, 188 | 0x00, 189 | 0x00, 190 | 0x00, 191 | 0x00, 192 | 0x00, 193 | 0x00, 194 | 0x00, 195 | 0x00, 196 | 0x00, 197 | 0x00, 198 | 0x00, 199 | 0x01, 200 | 0x00, 201 | 0x00, 202 | 0x00, 203 | 0x00, 204 | 0x00, 205 | 0x00, 206 | 0x01, 207 | 0x43, 208 | 0x42, 209 | 0x43, 210 | 0x42, 211 | 0x01, 212 | 0x01, 213 | 0x01, 214 | 0x43, 215 | 0x03, 216 | 0x00, 217 | 0x00, 218 | 0x01, 219 | 0x01, 220 | }; 221 | const unsigned char CMD_USER[] = { 222 | 0x00, 223 | 0x3F, 224 | 0x3F, 225 | 0x10, 226 | 0X09, 227 | 0x13, 228 | }; 229 | -------------------------------------------------------------------------------- /src/HT_st7735_fonts.h: -------------------------------------------------------------------------------- 1 | /* vim: set ai et ts=4 sw=4: */ 2 | #ifndef __HT_ST7735_FONTS_H__ 3 | #define __HT_ST7735_FONTS_H__ 4 | 5 | #include 6 | 7 | typedef struct { 8 | const uint8_t width; 9 | uint8_t height; 10 | const uint16_t *data; 11 | } FontDef; 12 | 13 | 14 | extern FontDef Font_7x10; 15 | extern FontDef Font_11x18; 16 | extern FontDef Font_16x26; 17 | 18 | #endif // __HT_ST7735_FONTS_H__ 19 | -------------------------------------------------------------------------------- /src/HT_st7789spi.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | This is a library for several Adafruit displays based on ST77* drivers. 3 | 4 | Works with the Adafruit 1.8" TFT Breakout w/SD card 5 | ----> http://www.adafruit.com/products/358 6 | The 1.8" TFT shield 7 | ----> https://www.adafruit.com/product/802 8 | The 1.44" TFT breakout 9 | ----> https://www.adafruit.com/product/2088 10 | as well as Adafruit raw 1.8" TFT display 11 | ----> http://www.adafruit.com/products/618 12 | 13 | Check out the links above for our tutorials and wiring diagrams. 14 | These displays use SPI to communicate, 4 or 5 pins are required to 15 | interface (RST is optional). 16 | 17 | Adafruit invests time and resources providing this open source code, 18 | please support Adafruit and open-source hardware by purchasing 19 | products from Adafruit! 20 | 21 | Written by Limor Fried/Ladyada for Adafruit Industries. 22 | MIT license, all text above must be included in any redistribution 23 | **************************************************************************/ 24 | 25 | #ifndef _HT_ST7789SPI_H_ 26 | #define _HT_ST7789SPI_H_ 27 | 28 | #include "Arduino.h" 29 | #include "Print.h" 30 | #include 31 | #include 32 | #include 33 | 34 | #define ST_CMD_DELAY 0x80 // special signifier for command lists 35 | 36 | #define ST7789_NOP 0x00 37 | #define ST7789_SWRESET 0x01 38 | #define ST7789_RDDID 0x04 39 | #define ST7789_RDDST 0x09 40 | 41 | #define ST7789_SLPIN 0x10 42 | #define ST7789_SLPOUT 0x11 43 | #define ST7789_PTLON 0x12 44 | #define ST7789_NORON 0x13 45 | 46 | #define ST7789_INVOFF 0x20 47 | #define ST7789_INVON 0x21 48 | #define ST7789_DISPOFF 0x28 49 | #define ST7789_DISPON 0x29 50 | #define ST7789_CASET 0x2A 51 | #define ST7789_RASET 0x2B 52 | #define ST7789_RAMWR 0x2C 53 | #define ST7789_RAMRD 0x2E 54 | 55 | #define ST7789_PTLAR 0x30 56 | #define ST7789_TEOFF 0x34 57 | #define ST7789_TEON 0x35 58 | #define ST7789_MADCTL 0x36 59 | #define ST7789_COLMOD 0x3A 60 | 61 | #define ST7789_MADCTL_MY 0x80 62 | #define ST7789_MADCTL_MX 0x40 63 | #define ST7789_MADCTL_MV 0x20 64 | #define ST7789_MADCTL_ML 0x10 65 | #define ST7789_MADCTL_RGB 0x00 66 | 67 | #define ST7789_RDID1 0xDA 68 | #define ST7789_RDID2 0xDB 69 | #define ST7789_RDID3 0xDC 70 | #define ST7789_RDID4 0xDD 71 | 72 | // Some ready-made 16-bit ('565') color settings: 73 | #define ST7789_BLACK 0x0000 74 | #define ST7789_WHITE 0xFFFF 75 | #define ST7789_RED 0xF800 76 | #define ST7789_GREEN 0x07E0 77 | #define ST7789_BLUE 0x001F 78 | #define ST7789_CYAN 0x07FF 79 | #define ST7789_MAGENTA 0xF81F 80 | #define ST7789_YELLOW 0xFFE0 81 | #define ST7789_ORANGE 0xFC00 82 | 83 | /// Subclass of SPITFT for ST7789 displays (lots in common!) 84 | class HT_ST7789 : public Adafruit_SPITFT { 85 | public: 86 | HT_ST7789(uint16_t w, uint16_t h, int8_t _CS, int8_t _DC, int8_t _MOSI, 87 | int8_t _SCLK, int8_t _RST = -1, int8_t _MISO = -1); 88 | HT_ST7789(uint16_t w, uint16_t h, int8_t CS, int8_t RS, 89 | int8_t RST = -1); 90 | #if !defined(ESP8266) 91 | HT_ST7789(uint16_t w, uint16_t h, SPIClass *spiClass, int8_t CS, 92 | int8_t RS, int8_t RST = -1); 93 | #endif // end !ESP8266 94 | void init(uint16_t width, uint16_t height, uint8_t spiMode = SPI_MODE0); 95 | void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h); 96 | void setRotation(uint8_t r); 97 | void enableDisplay(boolean enable); 98 | void enableTearing(boolean enable); 99 | void enableSleep(boolean enable); 100 | int LCD_Set_Scroll_Area(uint16_t tfa, uint16_t vsa, uint16_t bta); 101 | void LCD_Set_Scroll_Start_Address(uint16_t vsp); 102 | protected: 103 | uint16_t _colstart = 0, ///< Some displays need this changed to offset 104 | _rowstart = 0, ///< Some displays need this changed to offset 105 | _colstart2 = 0, ///< Some displays need this changed to offset 106 | _rowstart2 = 0, ///< Some displays need this changed to offset 107 | spiMode = SPI_MODE0; ///< Certain display needs MODE3 instead 108 | uint16_t windowWidth; 109 | uint16_t windowHeight; 110 | void begin(uint32_t freq = 0); 111 | void commonInit(const uint8_t *cmdList); 112 | void displayInit(const uint8_t *addr); 113 | void setColRowStart(int8_t col, int8_t row); 114 | void sleep(); 115 | }; 116 | 117 | #endif // _HT_ST7789H_ 118 | -------------------------------------------------------------------------------- /src/LoRaWan_APP.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #ifndef LoRaWan_APP_H 5 | #define LoRaWan_APP_H 6 | #include "Arduino.h" 7 | #if !defined(HT_DE01)&&!defined(WIFI_Kit_32)&&!defined(WIFI_Kit_32_V3) 8 | #include "ESP32_Mcu.h" 9 | #include 10 | #include "loramac/LoRaMac.h" 11 | #include "loramac/utilities.h" 12 | #include "ESP32_LoRaWan_102.h" 13 | #include "HardwareSerial.h" 14 | #include "driver/board.h" 15 | #include "driver/debug.h" 16 | 17 | #if defined(__asr650x__) 18 | #include "board.h" 19 | #include "gpio.h" 20 | #include "hw.h" 21 | #include "low_power.h" 22 | #include "spi-board.h" 23 | #include "rtc-board.h" 24 | #include "asr_timer.h" 25 | #include "board-config.h" 26 | #include "hw_conf.h" 27 | #include 28 | #endif 29 | 30 | enum eDeviceState_LoraWan 31 | { 32 | DEVICE_STATE_INIT, 33 | DEVICE_STATE_JOIN, 34 | DEVICE_STATE_SEND, 35 | DEVICE_STATE_CYCLE, 36 | DEVICE_STATE_SLEEP 37 | }; 38 | 39 | enum eDeviceState_Lora 40 | { 41 | LORA_INIT, 42 | LORA_SEND, 43 | LORA_RECEIVE, 44 | LORA_CAD, 45 | MCU_SLEEP, 46 | }; 47 | 48 | 49 | extern uint8_t devEui[]; 50 | extern uint8_t appEui[]; 51 | extern uint8_t appKey[]; 52 | extern uint8_t nwkSKey[]; 53 | extern uint8_t appSKey[]; 54 | extern uint32_t devAddr; 55 | extern uint8_t appData[LORAWAN_APP_DATA_MAX_SIZE]; 56 | extern uint8_t appDataSize; 57 | extern uint8_t appPort; 58 | extern uint32_t txDutyCycleTime; 59 | extern bool overTheAirActivation; 60 | extern LoRaMacRegion_t loraWanRegion; 61 | extern bool loraWanAdr; 62 | extern bool isTxConfirmed; 63 | extern uint32_t appTxDutyCycle; 64 | extern DeviceClass_t loraWanClass; 65 | extern bool passthroughMode; 66 | extern uint8_t confirmedNbTrials; 67 | extern bool modeLoraWan; 68 | extern bool keepNet; 69 | extern uint16_t userChannelsMask[6]; 70 | 71 | /*! 72 | * Defines a random delay for application data transmission duty cycle. 1s, 73 | * value in [ms]. 74 | */ 75 | #define APP_TX_DUTYCYCLE_RND 1000 76 | 77 | class LoRaWanClass{ 78 | public: 79 | void init(DeviceClass_t lorawanClass,LoRaMacRegion_t region); 80 | void join(); 81 | void send(); 82 | void cycle(uint32_t dutyCycle); 83 | void sleep(DeviceClass_t classMode); 84 | void setDefaultDR(int8_t dataRate); 85 | void ifskipjoin(); 86 | void generateDeveuiByChipID(); 87 | 88 | #if defined(WIFI_LORA_32_V3)||defined(WIFI_LORA_32_V2)||defined(WIRELESS_STICK_V3)||defined( WIFI_LORA_32 )||defined(WIRELESS_STICK) 89 | void displayJoining(); 90 | void displayJoined(); 91 | void displaySending(); 92 | void displayAck(); 93 | void displayMcuInit(); 94 | #endif 95 | }; 96 | 97 | extern enum eDeviceState_LoraWan deviceState; 98 | 99 | extern "C" bool SendFrame( void ); 100 | extern "C" void turnOnRGB(uint32_t color,uint32_t time); 101 | extern "C" void turnOffRGB(void); 102 | extern "C" bool checkUserAt(char * cmd, char * content); 103 | extern "C" void downLinkAckHandle(); 104 | extern "C" void downLinkDataHandle(McpsIndication_t *mcpsIndication); 105 | extern "C" void lwan_dev_params_update( void ); 106 | extern "C" void dev_time_updated( void ); 107 | extern "C" void lora_printf(const char *format, ...); 108 | 109 | extern LoRaWanClass LoRaWAN; 110 | 111 | #endif 112 | #endif -------------------------------------------------------------------------------- /src/driver/board-config.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file board-config.h 3 | * 4 | * \brief Board configuration 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Gregory Cristian ( Semtech ) 28 | * 29 | * \author Daniel Jaeckle ( STACKFORCE ) 30 | * 31 | * \author Johannes Bruder ( STACKFORCE ) 32 | */ 33 | 34 | 35 | #ifndef __BOARD_CONFIG_H__ 36 | #define __BOARD_CONFIG_H__ 37 | 38 | /*! 39 | * Defines the time required for the TCXO to wakeup [ms]. 40 | */ 41 | 42 | #define BOARD_TCXO_WAKEUP_TIME 5 43 | 44 | #if defined(WIFI_LORA_32_V3)||defined(WIRELESS_TRACKER)||defined(WIRELESS_STICK_V3)||defined(WIRELESS_STICK_LITE_V3)||defined(WIRELESS_PAPER)||defined(CAPSULE_SENSOR_V3)||defined(WIRELESS_SHELL_V3)||defined(Vision_Master_E_213)||defined(Vision_Master_E290)||defined(Vision_Master_T190) 45 | 46 | #define RADIO_DIO_1 14 47 | #define RADIO_NSS 8 48 | #define RADIO_RESET 12 49 | #define RADIO_BUSY 13 50 | 51 | #define LORA_CLK 9 52 | #define LORA_MISO 11 53 | #define LORA_MOSI 10 54 | 55 | #elif defined(WIFI_LORA_32_V2)||defined(WIRELESS_STICK)||defined(WIRELESS_STICK_LITE)||defined(WIRELESS_BRIDGE) 56 | #define RADIO_RESET 14 57 | 58 | #define LORA_MOSI 27 59 | #define LORA_MISO 19 60 | #define LORA_CLK 5 61 | #define RADIO_NSS 18 62 | 63 | #define RADIO_DIO_0 26 64 | #define RADIO_DIO_1 35 // GPIO35 -- SX127x's IRQ(Interrupt Request) V2 65 | 66 | 67 | #elif defined(WIFI_LORA_32_SX1262) 68 | #define RADIO_DIO_1 35 69 | #define RADIO_NSS 14 70 | #define RADIO_RESET 5 71 | #define RADIO_BUSY 34 72 | 73 | #define LORA_CLK 12 74 | #define LORA_MISO 15 75 | #define LORA_MOSI 13 76 | 77 | #elif defined(WIFI_LORA_32) 78 | #define RADIO_RESET 14 79 | 80 | #define LORA_MOSI 27 81 | #define LORA_MISO 19 82 | #define LORA_CLK 5 83 | #define RADIO_NSS 18 84 | 85 | #define RADIO_DIO_0 26 86 | #define RADIO_DIO_1 33 // GPIO35 -- SX127x's IRQ(Interrupt Request) V2 87 | #elif defined(WIRELESS_MINI_SHELL) 88 | #define RADIO_DIO_1 3 89 | #define RADIO_NSS 8 90 | #define RADIO_RESET 5 91 | #define RADIO_BUSY 4 92 | 93 | #define LORA_CLK 10 94 | #define LORA_MISO 6 95 | #define LORA_MOSI 7 96 | #endif 97 | 98 | 99 | #endif // __BOARD_CONFIG_H__ 100 | -------------------------------------------------------------------------------- /src/driver/board.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file board.h 3 | * 4 | * \brief Target board general functions implementation 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * \endcode 18 | * 19 | * \author Miguel Luis ( Semtech ) 20 | * 21 | * \author Gregory Cristian ( Semtech ) 22 | */ 23 | 24 | #if !defined(HT_DE01)||defined(WIFI_Kit_32)||defined(WIFI_Kit_32_V3) 25 | #ifndef __BOARD_H__ 26 | #define __BOARD_H__ 27 | 28 | #include 29 | #include "../driver/timer.h" 30 | 31 | #ifdef __cplusplus 32 | extern "C"{ 33 | #endif 34 | 35 | /*! 36 | * Possible power sources 37 | */ 38 | enum BoardPowerSources 39 | { 40 | USB_POWER = 0, 41 | BATTERY_POWER, 42 | }; 43 | 44 | /*! 45 | * Board Version 46 | */ 47 | typedef union BoardVersion_u 48 | { 49 | struct BoardVersion_s 50 | { 51 | uint8_t Rfu; 52 | uint8_t Revision; 53 | uint8_t Minor; 54 | uint8_t Major; 55 | }Fields; 56 | uint32_t Value; 57 | }BoardVersion_t; 58 | 59 | /*! 60 | * \brief Disable interrupts 61 | * 62 | * \remark IRQ nesting is managed 63 | */ 64 | void BoardDisableIrq( void ); 65 | 66 | /*! 67 | * \brief Enable interrupts 68 | * 69 | * \remark IRQ nesting is managed 70 | */ 71 | void BoardEnableIrq( void ); 72 | 73 | /*! 74 | * \brief Initializes the mcu. 75 | */ 76 | void BoardInitMcu( void ); 77 | 78 | /*! 79 | * \brief Resets the mcu. 80 | */ 81 | void BoardResetMcu( void ); 82 | 83 | /*! 84 | * \brief Initializes the boards peripherals. 85 | */ 86 | void BoardInitPeriph( void ); 87 | 88 | /*! 89 | * \brief De-initializes the target board peripherals to decrease power 90 | * consumption. 91 | */ 92 | void BoardDeInitMcu( void ); 93 | 94 | /*! 95 | * \brief Gets the current potentiometer level value 96 | * 97 | * \retval value Potentiometer level ( value in percent ) 98 | */ 99 | uint8_t BoardGetPotiLevel( void ); 100 | 101 | /*! 102 | * \brief Measure the Battery voltage 103 | * 104 | * \retval value battery voltage in volts 105 | */ 106 | uint32_t BoardGetBatteryVoltage( void ); 107 | 108 | /*! 109 | * \brief Get the current battery level 110 | * 111 | * \retval value battery level [ 0: USB, 112 | * 1: Min level, 113 | * x: level 114 | * 254: fully charged, 115 | * 255: Error] 116 | */ 117 | uint8_t BoardGetBatteryLevel( void ); 118 | 119 | /*! 120 | * Returns a pseudo random seed generated using the MCU Unique ID 121 | * 122 | * \retval seed Generated pseudo random seed 123 | */ 124 | uint32_t BoardGetRandomSeed( void ); 125 | 126 | /*! 127 | * \brief Gets the board 64 bits unique ID 128 | * 129 | * \param [IN] id Pointer to an array that will contain the Unique ID 130 | */ 131 | void BoardGetUniqueId( uint8_t *id ); 132 | 133 | /*! 134 | * \brief Get the board power source 135 | * 136 | * \retval value power source [0: USB_POWER, 1: BATTERY_POWER] 137 | */ 138 | uint8_t GetBoardPowerSource( void ); 139 | 140 | /*! 141 | * \brief Get the board version 142 | * 143 | * \retval value Version 144 | */ 145 | BoardVersion_t BoardGetVersion( void ); 146 | 147 | 148 | #ifdef __cplusplus 149 | } // extern "C" 150 | #endif 151 | 152 | #endif // __BOARD_H__ 153 | #endif -------------------------------------------------------------------------------- /src/driver/delay.c: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Delay functions implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #include "../driver/board.h" 16 | #include "Arduino.h" 17 | 18 | void DelayMs( uint32_t ms ) 19 | { 20 | delay(ms); 21 | } 22 | -------------------------------------------------------------------------------- /src/driver/delay.h: -------------------------------------------------------------------------------- 1 | /* 2 | / _____) _ | | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 5 | _____) ) ____| | | || |_| ____( (___| | | | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 7 | (C)2013 Semtech 8 | 9 | Description: Delay functions implementation 10 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project 12 | 13 | Maintainer: Miguel Luis and Gregory Cristian 14 | */ 15 | #ifndef __DELAY_H__ 16 | #define __DELAY_H__ 17 | 18 | #ifdef __cplusplus 19 | extern "C"{ 20 | #endif 21 | /*! 22 | * Blocking delay of "s" seconds 23 | */ 24 | void Delay( float s ); 25 | 26 | /*! 27 | * Blocking delay of "ms" milliseconds 28 | */ 29 | void DelayMs( uint32_t ms ); 30 | 31 | #ifdef __cplusplus 32 | } // extern "C" 33 | #endif 34 | 35 | #endif // __DELAY_H__ 36 | 37 | -------------------------------------------------------------------------------- /src/driver/gpio-board.c: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file gpio-board.c 3 | * 4 | * \brief Target board GPIO driver implementation 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * \endcode 18 | * 19 | * \author Miguel Luis ( Semtech ) 20 | * 21 | * \author Gregory Cristian ( Semtech ) 22 | */ 23 | 24 | 25 | #include "../loramac/utilities.h" 26 | #include "../driver/rtc-board.h" 27 | #include "../driver/gpio-board.h" 28 | #include "../driver/gpio-board.h" 29 | #include "board-config.h" 30 | #if !defined(HT_DE01)&&!defined(WIFI_Kit_32)&&!defined(WIFI_Kit_32_V3) 31 | static GpioIrqHandler *GpioIrq[16]; 32 | 33 | void GpioMcuInit( Gpio_t *obj, uint8_t pin, uint8_t mode, PinConfigs config, PinTypes type, uint32_t value ) 34 | { 35 | obj->pin = pin; 36 | pinMode(pin,mode); 37 | if( mode == OUTPUT ) 38 | { 39 | GpioMcuWrite( obj, value ); 40 | } 41 | } 42 | 43 | bool radio_nss_inited=false; 44 | void GpioMcuSetInterrupt( Gpio_t *obj, int irqMode, IrqPriorities irqPriority, GpioIrqHandler *irqHandler ) 45 | { 46 | attachInterrupt(obj->pin,irqHandler,RISING); 47 | } 48 | 49 | void GpioMcuRemoveInterrupt( Gpio_t *obj ) 50 | { 51 | detachInterrupt(obj->pin); 52 | } 53 | 54 | void GpioMcuWrite( Gpio_t *obj, uint32_t value ) 55 | { 56 | if(obj->pin==RADIO_NSS && radio_nss_inited==false) 57 | { 58 | pinMode(obj->pin,OUTPUT); 59 | radio_nss_inited=true; 60 | } 61 | digitalWrite(obj->pin,value); 62 | } 63 | 64 | void GpioMcuToggle( Gpio_t *obj ) 65 | { 66 | 67 | } 68 | 69 | uint32_t GpioMcuRead( Gpio_t *obj ) 70 | { 71 | return digitalRead(obj->pin); 72 | } 73 | 74 | #endif -------------------------------------------------------------------------------- /src/driver/gpio-board.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file gpio-board.h 3 | * 4 | * \brief Target board GPIO driver implementation 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * \endcode 18 | * 19 | * \author Miguel Luis ( Semtech ) 20 | * 21 | * \author Gregory Cristian ( Semtech ) 22 | */ 23 | 24 | 25 | 26 | #ifndef __GPIO_BOARD_H__ 27 | #define __GPIO_BOARD_H__ 28 | 29 | #include "gpio.h" 30 | 31 | /*! 32 | * \brief Initializes the given GPIO object 33 | * 34 | * \param [IN] obj Pointer to the GPIO object 35 | * \param [IN] pin Pin name ( please look in pinName-board.h file ) 36 | * \param [IN] mode Pin mode [PIN_INPUT, PIN_OUTPUT, 37 | * PIN_ALTERNATE_FCT, PIN_ANALOGIC] 38 | * \param [IN] config Pin config [PIN_PUSH_PULL, PIN_OPEN_DRAIN] 39 | * \param [IN] type Pin type [PIN_NO_PULL, PIN_PULL_UP, PIN_PULL_DOWN] 40 | * \param [IN] value Default output value at initialization 41 | */ 42 | void GpioMcuInit( Gpio_t *obj, uint8_t pin, uint8_t mode, PinConfigs config, PinTypes type, uint32_t value ); 43 | 44 | /*! 45 | * \brief GPIO IRQ Initialization 46 | * 47 | * \param [IN] obj Pointer to the GPIO object 48 | * \param [IN] irqMode IRQ mode [NO_IRQ, IRQ_RISING_EDGE, 49 | * IRQ_FALLING_EDGE, IRQ_RISING_FALLING_EDGE] 50 | * \param [IN] irqPriority IRQ priority [IRQ_VERY_LOW_PRIORITY, IRQ_LOW_PRIORITY 51 | * IRQ_MEDIUM_PRIORITY, IRQ_HIGH_PRIORITY 52 | * IRQ_VERY_HIGH_PRIORITY] 53 | * \param [IN] irqHandler Callback function pointer 54 | */ 55 | void GpioMcuSetInterrupt( Gpio_t *obj, int irqMode, IrqPriorities irqPriority, GpioIrqHandler *irqHandler ); 56 | 57 | /*! 58 | * \brief Removes the interrupt from the object 59 | * 60 | * \param [IN] obj Pointer to the GPIO object 61 | */ 62 | void GpioMcuRemoveInterrupt( Gpio_t *obj ); 63 | 64 | /*! 65 | * \brief Writes the given value to the GPIO output 66 | * 67 | * \param [IN] obj Pointer to the GPIO object 68 | * \param [IN] value New GPIO output value 69 | */ 70 | void GpioMcuWrite( Gpio_t *obj, uint32_t value ); 71 | 72 | /*! 73 | * \brief Toggle the value to the GPIO output 74 | * 75 | * \param [IN] obj Pointer to the GPIO object 76 | */ 77 | void GpioMcuToggle( Gpio_t *obj ); 78 | 79 | /*! 80 | * \brief Reads the current GPIO input value 81 | * 82 | * \param [IN] obj Pointer to the GPIO object 83 | * \retval value Current GPIO input value 84 | */ 85 | uint32_t GpioMcuRead( Gpio_t *obj ); 86 | 87 | #endif //# 88 | -------------------------------------------------------------------------------- /src/driver/gpio.c: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file gpio.c 3 | * 4 | * \brief GPIO driver implementation 5 | * 6 | * \remark: Relies on the specific board GPIO implementation as well as on 7 | * IO expander driver implementation if one is available on the target 8 | * board. 9 | * 10 | * \copyright Revised BSD License, see section \ref LICENSE. 11 | * 12 | * \code 13 | * ______ _ 14 | * / _____) _ | | 15 | * ( (____ _____ ____ _| |_ _____ ____| |__ 16 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 17 | * _____) ) ____| | | || |_| ____( (___| | | | 18 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 19 | * (C)2013-2017 Semtech 20 | * 21 | * \endcode 22 | * 23 | * \author Miguel Luis ( Semtech ) 24 | * 25 | * \author Gregory Cristian ( Semtech ) 26 | */ 27 | 28 | #include "../driver/gpio-board.h" 29 | 30 | void GpioInit( Gpio_t *obj, uint8_t pin, uint8_t mode, PinConfigs config, PinTypes type, uint32_t value ) 31 | { 32 | GpioMcuInit( obj, pin, mode, config, type, value ); 33 | } 34 | 35 | void GpioSetInterrupt( Gpio_t *obj, IrqModes irqMode, IrqPriorities irqPriority, GpioIrqHandler *irqHandler ) 36 | { 37 | GpioMcuSetInterrupt( obj, irqMode, irqPriority, irqHandler ); 38 | } 39 | 40 | void GpioRemoveInterrupt( Gpio_t *obj ) 41 | { 42 | GpioMcuRemoveInterrupt( obj ); 43 | } 44 | 45 | void GpioWrite( Gpio_t *obj, uint32_t value ) 46 | { 47 | GpioMcuWrite( obj, value ); 48 | } 49 | 50 | void GpioToggle( Gpio_t *obj ) 51 | { 52 | GpioMcuToggle( obj ); 53 | } 54 | 55 | uint32_t GpioRead( Gpio_t *obj ) 56 | { 57 | return GpioMcuRead( obj ); 58 | } 59 | -------------------------------------------------------------------------------- /src/driver/gpio.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file gpio.h 3 | * 4 | * \brief GPIO driver implementation 5 | * 6 | * \remark: Relies on the specific board GPIO implementation as well as on 7 | * IO expander driver implementation if one is available on the target 8 | * board. 9 | * 10 | * \copyright Revised BSD License, see section \ref LICENSE. 11 | * 12 | * \code 13 | * ______ _ 14 | * / _____) _ | | 15 | * ( (____ _____ ____ _| |_ _____ ____| |__ 16 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 17 | * _____) ) ____| | | || |_| ____( (___| | | | 18 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 19 | * (C)2013-2017 Semtech 20 | * 21 | * \endcode 22 | * 23 | * \author Miguel Luis ( Semtech ) 24 | * 25 | * \author Gregory Cristian ( Semtech ) 26 | */ 27 | 28 | #ifndef __GPIO_H__ 29 | #define __GPIO_H__ 30 | 31 | #include 32 | 33 | 34 | /*! 35 | * Add a pull-up, a pull-down or nothing on the GPIO line 36 | */ 37 | typedef enum 38 | { 39 | PIN_NO_PULL = 0, 40 | PIN_PULL_UP, 41 | PIN_PULL_DOWN 42 | }PinTypes; 43 | 44 | /*! 45 | * Define the GPIO as Push-pull type or Open Drain 46 | */ 47 | typedef enum 48 | { 49 | PIN_PUSH_PULL = 0, 50 | PIN_OPEN_DRAIN 51 | }PinConfigs; 52 | 53 | /*! 54 | * Define the GPIO IRQ on a rising, falling or both edges 55 | */ 56 | typedef enum 57 | { 58 | NO_IRQ = 0, 59 | IRQ_RISING_EDGE, 60 | IRQ_FALLING_EDGE, 61 | IRQ_RISING_FALLING_EDGE 62 | }IrqModes; 63 | 64 | /*! 65 | * Define the IRQ priority on the GPIO 66 | */ 67 | typedef enum 68 | { 69 | IRQ_VERY_LOW_PRIORITY = 0, 70 | IRQ_LOW_PRIORITY, 71 | IRQ_MEDIUM_PRIORITY, 72 | IRQ_HIGH_PRIORITY, 73 | IRQ_VERY_HIGH_PRIORITY 74 | }IrqPriorities; 75 | 76 | /*! 77 | * Structure for the GPIO 78 | */ 79 | typedef struct 80 | { 81 | uint8_t pin; 82 | uint16_t pinIndex; 83 | void *port; 84 | uint16_t portIndex; 85 | PinTypes pull; 86 | }Gpio_t; 87 | 88 | /*! 89 | * GPIO IRQ handler function prototype 90 | */ 91 | typedef void( GpioIrqHandler )( void ); 92 | 93 | /*! 94 | * GPIO Expander IRQ handler function prototype 95 | */ 96 | typedef void( GpioIoeIrqHandler )( void ); 97 | 98 | /*! 99 | * \brief Initializes the given GPIO object 100 | * 101 | * \param [IN] obj Pointer to the GPIO object 102 | * \param [IN] pin Pin name ( please look in pinName-board.h file ) 103 | * \param [IN] mode Pin mode [PIN_INPUT, PIN_OUTPUT, 104 | * PIN_ALTERNATE_FCT, PIN_ANALOGIC] 105 | * \param [IN] config Pin config [PIN_PUSH_PULL, PIN_OPEN_DRAIN] 106 | * \param [IN] type Pin type [PIN_NO_PULL, PIN_PULL_UP, PIN_PULL_DOWN] 107 | * \param [IN] value Default output value at initialization 108 | */ 109 | void GpioInit( Gpio_t *obj, uint8_t pin, uint8_t mode, PinConfigs config, PinTypes type, uint32_t value ); 110 | 111 | /*! 112 | * \brief GPIO IRQ Initialization 113 | * 114 | * \param [IN] obj Pointer to the GPIO object 115 | * \param [IN] irqMode IRQ mode [NO_IRQ, IRQ_RISING_EDGE, 116 | * IRQ_FALLING_EDGE, IRQ_RISING_FALLING_EDGE] 117 | * \param [IN] irqPriority IRQ priority [IRQ_VERY_LOW_PRIORITY, IRQ_LOW_PRIORITY 118 | * IRQ_MEDIUM_PRIORITY, IRQ_HIGH_PRIORITY 119 | * IRQ_VERY_HIGH_PRIORITY] 120 | * \param [IN] irqHandler Callback function pointer 121 | */ 122 | void GpioSetInterrupt( Gpio_t *obj, IrqModes irqMode, IrqPriorities irqPriority, GpioIrqHandler *irqHandler ); 123 | 124 | /*! 125 | * \brief Removes the interrupt from the object 126 | * 127 | * \param [IN] obj Pointer to the GPIO object 128 | */ 129 | void GpioRemoveInterrupt( Gpio_t *obj ); 130 | 131 | /*! 132 | * \brief Writes the given value to the GPIO output 133 | * 134 | * \param [IN] obj Pointer to the GPIO object 135 | * \param [IN] value New GPIO output value 136 | */ 137 | void GpioWrite( Gpio_t *obj, uint32_t value ); 138 | 139 | /*! 140 | * \brief Toggle the value to the GPIO output 141 | * 142 | * \param [IN] obj Pointer to the GPIO object 143 | */ 144 | void GpioToggle( Gpio_t *obj ); 145 | 146 | /*! 147 | * \brief Reads the current GPIO input value 148 | * 149 | * \param [IN] obj Pointer to the GPIO object 150 | * \retval value Current GPIO input value 151 | */ 152 | uint32_t GpioRead( Gpio_t *obj ); 153 | 154 | #endif // __GPIO_H__ 155 | -------------------------------------------------------------------------------- /src/driver/lorawan_spi.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file spi-board.h 3 | * 4 | * \brief SPI driver implementation 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * \endcode 18 | * 19 | * \author Miguel Luis ( Semtech ) 20 | * 21 | * \author Gregory Cristian ( Semtech ) 22 | */ 23 | #ifndef __Lorawan_SPI_H__ 24 | #define __Lorawan_SPI_H__ 25 | 26 | #include "../driver/gpio.h" 27 | 28 | /*! 29 | * SPI peripheral ID 30 | */ 31 | typedef enum 32 | { 33 | SPI_1, 34 | SPI_2, 35 | }SpiId_t; 36 | 37 | /*! 38 | * SPI object type definition 39 | */ 40 | typedef struct Spi_s 41 | { 42 | SpiId_t SpiId; 43 | Gpio_t Mosi; 44 | Gpio_t Miso; 45 | Gpio_t Sclk; 46 | Gpio_t Nss; 47 | }Spi_t; 48 | 49 | /*! 50 | * \brief Initializes the SPI object and MCU peripheral 51 | * 52 | * \remark When NSS pin is software controlled set the pin name to NC otherwise 53 | * set the pin name to be used. 54 | * 55 | * \param [IN] obj SPI object 56 | * \param [IN] mosi SPI MOSI pin name to be used 57 | * \param [IN] miso SPI MISO pin name to be used 58 | * \param [IN] sclk SPI SCLK pin name to be used 59 | * \param [IN] nss SPI NSS pin name to be used 60 | */ 61 | void SpiInit( Spi_t *obj, SpiId_t spiId, uint8_t mosi, uint8_t miso, uint8_t sclk, uint8_t nss ); 62 | 63 | /*! 64 | * \brief De-initializes the SPI object and MCU peripheral 65 | * 66 | * \param [IN] obj SPI object 67 | */ 68 | void SpiDeInit( Spi_t *obj ); 69 | 70 | /*! 71 | * \brief Configures the SPI peripheral 72 | * 73 | * \remark Slave mode isn't currently handled 74 | * 75 | * \param [IN] obj SPI object 76 | * \param [IN] bits Number of bits to be used. [8 or 16] 77 | * \param [IN] cpol Clock polarity 78 | * \param [IN] cpha Clock phase 79 | * \param [IN] slave When set the peripheral acts in slave mode 80 | */ 81 | void SpiFormat( Spi_t *obj, int8_t bits, int8_t cpol, int8_t cpha, int8_t slave ); 82 | 83 | /*! 84 | * \brief Sets the SPI speed 85 | * 86 | * \param [IN] obj SPI object 87 | * \param [IN] hz SPI clock frequency in hz 88 | */ 89 | void SpiFrequency( Spi_t *obj, uint32_t hz ); 90 | 91 | 92 | #endif // __SPI_H__ 93 | -------------------------------------------------------------------------------- /src/driver/rtc-board.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file rtc-board.h 3 | * 4 | * \brief Target board RTC timer and low power modes management 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * \endcode 18 | * 19 | * \author Miguel Luis ( Semtech ) 20 | * 21 | * \author Gregory Cristian ( Semtech ) 22 | */ 23 | #ifndef __RTC_BOARD_H__ 24 | #define __RTC_BOARD_H__ 25 | 26 | #ifdef __cplusplus 27 | extern "C"{ 28 | #endif 29 | 30 | #include 31 | #include 32 | #include "../driver/timer.h" 33 | #include "Arduino.h" 34 | 35 | extern uint64_t alarmTime; 36 | 37 | /*! 38 | * \brief Timer time variable definition 39 | */ 40 | //#ifndef TimerTime_t 41 | //typedef uint64_t TimerTime_t; 42 | //#endif 43 | 44 | /*! 45 | * \brief Initializes the RTC timer 46 | * 47 | * \remark The timer is based on the RTC 48 | */ 49 | void RtcInit( void ); 50 | 51 | /*! 52 | * \brief Start the RTC timer 53 | * 54 | * \remark The timer is based on the RTC Alarm running at 32.768KHz 55 | * 56 | * \param[IN] timeout Duration of the Timer 57 | */ 58 | void RtcSetTimeout( uint32_t timeout ); 59 | 60 | void RtcStopTimeout( void ); 61 | 62 | TimerTime_t RtcGetTimerContext( void ); 63 | 64 | TimerTime_t RtcSetTimerContext( void ); 65 | 66 | TimerTime_t RtcGetElapsedTime( void ); 67 | 68 | 69 | /*! 70 | * \brief Adjust the value of the timeout to handle wakeup time from Alarm and GPIO irq 71 | * 72 | * \param[IN] timeout Duration of the Timer without compensation for wakeup time 73 | * \retval new value for the Timeout with compensations 74 | */ 75 | TimerTime_t RtcGetAdjustedTimeoutValue( uint32_t timeout ); 76 | 77 | /*! 78 | * \brief Get the RTC timer value 79 | * 80 | * \retval RTC Timer value 81 | */ 82 | TimerTime_t RtcGetTimerValue( void ); 83 | 84 | /*! 85 | * \brief Get the RTC timer elapsed time since the last Alarm was set 86 | * 87 | * \retval RTC Elapsed time since the last alarm 88 | */ 89 | TimerTime_t RtcGetElapsedAlarmTime( void ); 90 | 91 | /*! 92 | * \brief Compute the timeout time of a future event in time 93 | * 94 | * \param[IN] futureEventInTime Value in time 95 | * \retval time Time between now and the futureEventInTime 96 | */ 97 | TimerTime_t RtcComputeFutureEventTime( TimerTime_t futureEventInTime ); 98 | 99 | /*! 100 | * \brief Compute the elapsed time since a fix event in time 101 | * 102 | * \param[IN] eventInTime Value in time 103 | * \retval elapsed Time since the eventInTime 104 | */ 105 | TimerTime_t RtcComputeElapsedTime( TimerTime_t eventInTime ); 106 | 107 | /*! 108 | * \brief This function blocks the MCU from going into low power mode 109 | * 110 | * \param [IN] status [true: Enable, false: Disable 111 | */ 112 | void BlockLowPowerDuringTask ( bool status ); 113 | 114 | /*! 115 | * \brief Sets the MCU into low power STOP mode 116 | */ 117 | void lowPowerHandler( void ); 118 | 119 | /*! 120 | * \brief Restore the MCU to its normal operation mode 121 | */ 122 | void RtcRecoverMcuStatus( void ); 123 | 124 | /*! 125 | * \brief Processes pending timer events 126 | */ 127 | void RtcProcess( void ); 128 | 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | 133 | #endif // __RTC_BOARD_H__ 134 | -------------------------------------------------------------------------------- /src/driver/sx1276-board.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file sx1276-board.h 3 | * 4 | * \brief Target board SX1276 driver implementation 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * \endcode 18 | * 19 | * \author Miguel Luis ( Semtech ) 20 | * 21 | * \author Gregory Cristian ( Semtech ) 22 | */ 23 | #ifndef __SX1276_BOARD_H__ 24 | #define __SX1276_BOARD_H__ 25 | 26 | #include 27 | #include 28 | #include "../driver/sx1276.h" 29 | 30 | /*! 31 | * \brief Radio hardware registers initialization definition 32 | * 33 | * \remark Can be automatically generated by the SX1276 GUI (not yet implemented) 34 | */ 35 | #define RADIO_INIT_REGISTERS_VALUE \ 36 | { \ 37 | { MODEM_FSK , REG_LNA , 0x23 },\ 38 | { MODEM_FSK , REG_RXCONFIG , 0x1E },\ 39 | { MODEM_FSK , REG_RSSICONFIG , 0xD2 },\ 40 | { MODEM_FSK , REG_AFCFEI , 0x01 },\ 41 | { MODEM_FSK , REG_PREAMBLEDETECT , 0xAA },\ 42 | { MODEM_FSK , REG_OSC , 0x07 },\ 43 | { MODEM_FSK , REG_SYNCCONFIG , 0x12 },\ 44 | { MODEM_FSK , REG_SYNCVALUE1 , 0xC1 },\ 45 | { MODEM_FSK , REG_SYNCVALUE2 , 0x94 },\ 46 | { MODEM_FSK , REG_SYNCVALUE3 , 0xC1 },\ 47 | { MODEM_FSK , REG_PACKETCONFIG1 , 0xD8 },\ 48 | { MODEM_FSK , REG_FIFOTHRESH , 0x8F },\ 49 | { MODEM_FSK , REG_IMAGECAL , 0x02 },\ 50 | { MODEM_FSK , REG_DIOMAPPING1 , 0x00 },\ 51 | { MODEM_FSK , REG_DIOMAPPING2 , 0x30 },\ 52 | { MODEM_LORA, REG_LR_PAYLOADMAXLENGTH, 0xFF },\ 53 | } \ 54 | 55 | #define RF_MID_BAND_THRESH 525000000 56 | 57 | /*! 58 | * \brief Initializes the radio I/Os pins interface 59 | */ 60 | void SX1276IoInit( void ); 61 | 62 | /*! 63 | * \brief Initializes DIO IRQ handlers 64 | * 65 | * \param [IN] irqHandlers Array containing the IRQ callback functions 66 | */ 67 | void SX1276IoIrqInit( DioIrqHandler **irqHandlers ); 68 | 69 | /*! 70 | * \brief De-initializes the radio I/Os pins interface. 71 | * 72 | * \remark Useful when going in MCU low power modes 73 | */ 74 | void SX1276IoDeInit( void ); 75 | 76 | /*! 77 | * \brief Resets the radio 78 | */ 79 | void SX1276Reset( void ); 80 | 81 | /*! 82 | * \brief Sets the radio output power. 83 | * 84 | * \param [IN] power Sets the RF output power 85 | */ 86 | void SX1276SetRfTxPower( int8_t power ); 87 | 88 | /*! 89 | * \brief Gets the board PA selection configuration 90 | * 91 | * \param [IN] channel Channel frequency in Hz 92 | * \retval PaSelect RegPaConfig PaSelect value 93 | */ 94 | uint8_t SX1276GetPaSelect( uint32_t channel ); 95 | 96 | /*! 97 | * \brief Set the RF Switch I/Os pins in low power mode 98 | * 99 | * \param [IN] status enable or disable 100 | */ 101 | void SX1276SetAntSwLowPower( bool status ); 102 | 103 | /*! 104 | * \brief Initializes the RF Switch I/Os pins interface 105 | */ 106 | void SX1276AntSwInit( void ); 107 | 108 | /*! 109 | * \brief De-initializes the RF Switch I/Os pins interface 110 | * 111 | * \remark Needed to decrease the power consumption in MCU low power modes 112 | */ 113 | void SX1276AntSwDeInit( void ); 114 | 115 | /*! 116 | * \brief Controls the antenna switch if necessary. 117 | * 118 | * \remark see errata note 119 | * 120 | * \param [IN] opMode Current radio operating mode 121 | */ 122 | void SX1276SetAntSw( uint8_t opMode ); 123 | 124 | /*! 125 | * \brief Checks if the given RF frequency is supported by the hardware 126 | * 127 | * \param [IN] frequency RF frequency to be checked 128 | * \retval isSupported [true: supported, false: unsupported] 129 | */ 130 | bool SX1276CheckRfFrequency( uint32_t frequency ); 131 | 132 | /*! 133 | * \brief Gets the Defines the time required for the TCXO to wakeup [ms]. 134 | * 135 | * \retval time Board TCXO wakeup time in ms. 136 | */ 137 | uint32_t SX1276GetBoardTcxoWakeupTime( void ); 138 | 139 | /*! 140 | * Radio hardware and global parameters 141 | */ 142 | extern SX1276_t SX1276; 143 | 144 | #endif // __SX1276_BOARD_H__ 145 | -------------------------------------------------------------------------------- /src/esp32/liblorawan.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/src/esp32/liblorawan.a -------------------------------------------------------------------------------- /src/esp32c3/liblorawan-espidf4.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/src/esp32c3/liblorawan-espidf4.a -------------------------------------------------------------------------------- /src/esp32c3/liblorawan-espidf5.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/src/esp32c3/liblorawan-espidf5.a -------------------------------------------------------------------------------- /src/esp32c3/liblorawan.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/src/esp32c3/liblorawan.a -------------------------------------------------------------------------------- /src/esp32c3/liblorawan2.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/src/esp32c3/liblorawan2.a -------------------------------------------------------------------------------- /src/esp32s3/liblorawan.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HelTecAutomation/Heltec_ESP32/daf2edc283a8c0652a28596db494066e61c152b2/src/esp32s3/liblorawan.a -------------------------------------------------------------------------------- /src/esp_clk_internal.h: -------------------------------------------------------------------------------- 1 | #ifdef MCU_ESP32_S3 2 | // Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | #pragma once 17 | 18 | /** 19 | * @file esp_clk_internal.h 20 | * 21 | * Private clock-related functions 22 | */ 23 | 24 | /** 25 | * @brief Initialize clock-related settings 26 | * 27 | * Called from cpu_start.c, not intended to be called from other places. 28 | * This function configures the CPU clock, RTC slow and fast clocks, and 29 | * performs RTC slow clock calibration. 30 | */ 31 | void esp_clk_init(void); 32 | 33 | 34 | /** 35 | * @brief Disables clock of some peripherals 36 | * 37 | * Called from cpu_start.c, not intended to be called from other places. 38 | * This function disables clock of useless peripherals when cpu starts. 39 | */ 40 | void esp_perip_clk_init(void); 41 | 42 | /* Selects an external clock source (32 kHz) for RTC. 43 | * Only internal use in unit test. 44 | */ 45 | //void rtc_clk_select_rtc_slow_clk(void); 46 | #endif -------------------------------------------------------------------------------- /src/heltec.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Heltec Automation. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | #include "heltec.h" 5 | 6 | 7 | Heltec_ESP32::Heltec_ESP32(){ 8 | 9 | #if defined( Class_Wifi_Kit ) || defined( Class_Wifi_LoRa ) 10 | display = new SSD1306Wire(0x3c, SDA_OLED, SCL_OLED, RST_OLED, GEOMETRY_128_64); 11 | #elif defined( WIRELESS_STICK ) 12 | display = new SSD1306Wire(0x3c, SDA_OLED, SCL_OLED, RST_OLED, GEOMETRY_64_32); 13 | #endif 14 | } 15 | 16 | Heltec_ESP32::~Heltec_ESP32(){ 17 | #ifdef Heltec_Screen 18 | delete display; 19 | #endif 20 | } 21 | 22 | void Heltec_ESP32::begin(bool DisplayEnable, bool LoRaEnable, bool SerialEnable, bool PABOOST, long BAND) { 23 | 24 | #ifdef Heltec_Vext 25 | VextON(); 26 | #endif 27 | 28 | // UART 29 | if (SerialEnable) { 30 | Serial.begin(115200); 31 | Serial.flush(); 32 | delay(50); 33 | Serial.print("Serial initial done\r\n"); 34 | } 35 | 36 | // OLED 37 | if (DisplayEnable) 38 | { 39 | #ifndef Heltec_Screen 40 | if(SerialEnable) 41 | { 42 | Serial.print("Board does not have an on board display, Display option must be FALSE!!!\r\n"); 43 | } 44 | #endif 45 | 46 | #ifdef Heltec_Screen 47 | display->init(); 48 | //display->flipScreenVertically(); 49 | display->setFont(ArialMT_Plain_10); 50 | display->drawString(0, 0, "OLED initial done!"); 51 | display->display(); 52 | 53 | if (SerialEnable){ 54 | Serial.print("you can see OLED printed OLED initial done!\r\n"); 55 | } 56 | #endif 57 | } 58 | 59 | // LoRa INIT 60 | if (LoRaEnable) 61 | { 62 | #ifndef Heltec_LoRa 63 | if (SerialEnable) { 64 | Serial.print("Board does not have LoRa function, LoRa option must be FALSE!!!\r\n"); 65 | } 66 | #endif 67 | 68 | 69 | #ifdef Heltec_LoRa 70 | //LoRaClass LoRa; 71 | 72 | SPI.begin(SCK,MISO,MOSI,SS); 73 | LoRa.setPins(SS,RST_LoRa,DIO0); 74 | if (!LoRa.begin(BAND,PABOOST)) 75 | { 76 | if (SerialEnable){ 77 | Serial.print("Starting LoRa failed!\r\n"); 78 | } 79 | #ifdef Heltec_Screen 80 | if(DisplayEnable){ 81 | display->clear(); 82 | display->drawString(0, 0, "Starting LoRa failed!"); 83 | display->display(); 84 | delay(300); 85 | } 86 | #endif 87 | while (1); 88 | } 89 | if (SerialEnable){ 90 | Serial.print("LoRa Initial success!\r\n"); 91 | } 92 | #ifdef Heltec_Screen 93 | if(DisplayEnable){ 94 | display->clear(); 95 | display->drawString(0, 0, "LoRa Initial success!"); 96 | display->display(); 97 | delay(300); 98 | } 99 | #endif 100 | 101 | #endif 102 | } 103 | #ifdef LED 104 | pinMode(LED,OUTPUT); 105 | #endif 106 | } 107 | 108 | #ifdef Heltec_Vext 109 | void Heltec_ESP32::VextON(void) 110 | { 111 | pinMode(Vext,OUTPUT); 112 | digitalWrite(Vext, LOW); 113 | } 114 | 115 | void Heltec_ESP32::VextOFF(void) //Vext default OFF 116 | { 117 | pinMode(Vext,OUTPUT); 118 | digitalWrite(Vext, HIGH); 119 | } 120 | #endif 121 | 122 | Heltec_ESP32 Heltec; 123 | -------------------------------------------------------------------------------- /src/heltec.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef _HELTEC_H_ 4 | #define _HELTEC_H_ 5 | 6 | #if defined(ESP32) 7 | 8 | #include 9 | 10 | /* Define board classes */ 11 | #if defined( WIFI_Kit_32 ) || defined( WIFI_Kit_32_V3 ) 12 | #define Class_Wifi_Kit 13 | #endif 14 | 15 | #if defined( WIFI_LORA_32 ) || defined( WIFI_LORA_32_V2 ) || defined( WIFI_LORA_32_V3 ) 16 | #define Class_WIFI_LORA 17 | #endif 18 | 19 | #if defined( WIRELESS_STICK ) || defined( WIRELESS_STICK_LITE ) || defined( WIRELESS_STICK_V3 ) || defined( WIRELESS_STICK_LITE_V3 ) 20 | #define Class_WIRELESS_STICK 21 | #endif 22 | 23 | 24 | /* Define board capabilities */ 25 | #if defined( Class_Wifi_Kit ) || defined( Class_WIFI_LORA ) || defined( Class_WIRELESS_STICK ) || defined( WIRELESS_BRIDGE ) 26 | #define Heltec_Wifi 27 | #endif 28 | 29 | #if defined( Class_WIFI_LORA ) || defined( Class_WIRELESS_STICK ) || defined( WIRELESS_BRIDGE ) 30 | #define Heltec_LoRa 31 | #endif 32 | 33 | #if defined( Class_Wifi_Kit ) || defined( Class_WIFI_LORA ) || defined( WIRELESS_STICK ) 34 | #define Heltec_Screen 35 | #endif 36 | 37 | /* wifi kit 32 and WiFi LoRa 32(V1) do not have vext */ 38 | #if defined( WIFI_Kit_32_V3 ) || defined( WIFI_LORA_32_V2 ) || defined( WIFI_LORA_32_V3 ) || defined( Class_WIRELESS_STICK ) || defined( WIRELESS_BRIDGE ) 39 | #define Heltec_Vext 40 | #endif 41 | 42 | 43 | #ifdef Heltec_Screen 44 | #include 45 | #include "HT_SSD1306Wire.h" 46 | #endif 47 | 48 | #ifdef Heltec_LoRa 49 | #include 50 | #include "lora/LoRa.h" 51 | #endif 52 | 53 | 54 | class Heltec_ESP32 { 55 | 56 | public: 57 | Heltec_ESP32(); 58 | ~Heltec_ESP32(); 59 | 60 | void begin(bool DisplayEnable=true, bool LoRaEnable=true, bool SerialEnable=true, bool PABOOST=true, long BAND=470E6); 61 | #ifdef Heltec_LoRa 62 | LoRaClass LoRa; 63 | #endif 64 | 65 | #ifdef Heltec_Screen 66 | SSD1306Wire *display; 67 | #endif 68 | 69 | /*wifi kit 32 and WiFi LoRa 32(V1) do not have vext*/ 70 | #ifdef Heltec_Vext 71 | void VextON(void); 72 | void VextOFF(void); 73 | #endif 74 | }; 75 | 76 | extern Heltec_ESP32 Heltec; 77 | 78 | #else 79 | #error "This library only supports boards with ESP32 processor." 80 | #endif 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /src/lora/LoRa.h: -------------------------------------------------------------------------------- 1 | #ifndef LORA_H 2 | #define LORA_H 3 | 4 | #include 5 | #include 6 | 7 | #define LORA_DEFAULT_SS_PIN 18 8 | #define LORA_DEFAULT_RESET_PIN 14 9 | #define LORA_DEFAULT_DIO0_PIN 26 10 | 11 | #define PA_OUTPUT_PA_BOOST_PIN 1 12 | #define PA_OUTPUT_RFO_PIN 0 13 | 14 | /*! 15 | * RegPaConfig 16 | */ 17 | #define RF_PACONFIG_PASELECT_MASK 0x7F 18 | #define RF_PACONFIG_PASELECT_PABOOST 0x80 19 | #define RF_PACONFIG_PASELECT_RFO 0x00 // Default 20 | 21 | #define RF_PACONFIG_MAX_POWER_MASK 0x8F 22 | 23 | #define RF_PACONFIG_OUTPUTPOWER_MASK 0xF0 24 | 25 | /*! 26 | * RegPaDac 27 | */ 28 | #define RF_PADAC_20DBM_MASK 0xF8 29 | #define RF_PADAC_20DBM_ON 0x07 30 | #define RF_PADAC_20DBM_OFF 0x04 // Default 31 | 32 | 33 | 34 | #if defined (__STM32F1__) 35 | inline unsigned char digitalPinToInterrupt(unsigned char Interrupt_pin) { return Interrupt_pin; } //This isn't included in the stm32duino libs (yet) 36 | #define portOutputRegister(port) (volatile byte *)( &(port->regs->ODR) ) //These are defined in STM32F1/variants/generic_stm32f103c/variant.h but return a non byte* value 37 | #define portInputRegister(port) (volatile byte *)( &(port->regs->IDR) ) //These are defined in STM32F1/variants/generic_stm32f103c/variant.h but return a non byte* value 38 | #endif 39 | 40 | class LoRaClass : public Stream { 41 | public: 42 | LoRaClass(); 43 | 44 | int begin(long frequency,bool PABOOST); 45 | void end(); 46 | 47 | int beginPacket(int implicitHeader = false); 48 | int endPacket(bool async = false); 49 | 50 | int parsePacket(int size = 0); 51 | int packetRssi(); 52 | float packetSnr(); 53 | 54 | // from Print 55 | virtual size_t write(uint8_t byte); 56 | virtual size_t write(const uint8_t *buffer, size_t size); 57 | 58 | // from Stream 59 | virtual int available(); 60 | virtual int read(); 61 | virtual int peek(); 62 | virtual void flush(); 63 | 64 | void onReceive(void(*callback)(int)); 65 | 66 | void receive(int size = 0); 67 | void idle(); 68 | void sleep(); 69 | 70 | void setTxPower(int8_t power, int8_t outputPin); 71 | void setTxPowerMax(int level); 72 | void setFrequency(long frequency); 73 | void setSpreadingFactor(int sf); 74 | void setSignalBandwidth(long sbw); 75 | void setCodingRate4(int denominator); 76 | void setPreambleLength(long length); 77 | void setSyncWord(int sw); 78 | void enableCrc(); 79 | void disableCrc(); 80 | void enableTxInvertIQ(); 81 | void enableRxInvertIQ(); 82 | void enableInvertIQ(); 83 | void disableInvertIQ(); 84 | 85 | // deprecated 86 | void crc() { enableCrc(); } 87 | void noCrc() { disableCrc(); } 88 | 89 | byte random(); 90 | 91 | void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN); 92 | void setSPIFrequency(uint32_t frequency); 93 | 94 | void dumpRegisters(Stream& out); 95 | 96 | void enableLowDataRate(); 97 | void disableLowDataRate(); 98 | 99 | private: 100 | void explicitHeaderMode(); 101 | void implicitHeaderMode(); 102 | 103 | void handleDio0Rise(); 104 | 105 | uint8_t readRegister(uint8_t address); 106 | void writeRegister(uint8_t address, uint8_t value); 107 | uint8_t singleTransfer(uint8_t address, uint8_t value); 108 | 109 | static void onDio0Rise(); 110 | 111 | private: 112 | SPISettings _spiSettings; 113 | int _ss; 114 | int _reset; 115 | int _dio0; 116 | int _frequency; 117 | int _packetIndex; 118 | int _implicitHeaderMode; 119 | void (*_onReceive)(int); 120 | }; 121 | 122 | extern LoRaClass LoRa; 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /src/loramac/Commissioning.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file Commissioning.h 3 | * 4 | * \brief End device commissioning parameters 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * \endcode 18 | * 19 | * \author Miguel Luis ( Semtech ) 20 | * 21 | * \author Gregory Cristian ( Semtech ) 22 | */ 23 | #ifndef __LORA_COMMISSIONING_H__ 24 | #define __LORA_COMMISSIONING_H__ 25 | 26 | /*! 27 | * User application data buffer size 28 | */ 29 | 30 | #define LORAWAN_APP_DATA_MAX_SIZE 255 31 | 32 | /*! 33 | * Indicates if the end-device is to be connected to a private or public network 34 | */ 35 | #define LORAWAN_PUBLIC_NETWORK true 36 | 37 | /*! 38 | * Current network ID 39 | */ 40 | #define LORAWAN_NETWORK_ID ( uint32_t )0 41 | 42 | 43 | #endif // __LORA_COMMISSIONING_H__ 44 | -------------------------------------------------------------------------------- /src/loramac/LoRaMacClassBConfig.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LoRaMacClassBConfig.h 3 | * 4 | * \brief LoRa MAC Class B configuration 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Gregory Cristian ( Semtech ) 28 | * 29 | * \author Daniel Jaeckle ( STACKFORCE ) 30 | * 31 | * \defgroup LORAMACCLASSB LoRa MAC Class B configuration 32 | * This header file contains parameters to configure the class b operation. 33 | * By default, all parameters are set according to the specification. 34 | * \{ 35 | */ 36 | #ifndef __LORAMACCLASSBCONFIG_H__ 37 | #define __LORAMACCLASSBCONFIG_H__ 38 | 39 | /*! 40 | * Defines the beacon interval in ms 41 | */ 42 | #define CLASSB_BEACON_INTERVAL 128000 43 | 44 | /*! 45 | * Beacon reserved time in ms 46 | */ 47 | #define CLASSB_BEACON_RESERVED 2120 48 | 49 | /*! 50 | * Beacon guard time in ms 51 | */ 52 | #define CLASSB_BEACON_GUARD 3000 53 | 54 | /*! 55 | * Beacon window time in ms 56 | */ 57 | #define CLASSB_BEACON_WINDOW 122880 58 | 59 | /*! 60 | * Beacon window time in numer of slots 61 | */ 62 | #define CLASSB_BEACON_WINDOW_SLOTS 4096 63 | 64 | /*! 65 | * Ping slot length time in ms 66 | */ 67 | #define CLASSB_PING_SLOT_WINDOW 30 68 | 69 | /*! 70 | * Maximum allowed beacon less time in ms 71 | */ 72 | #define CLASSB_MAX_BEACON_LESS_PERIOD 7200000 73 | 74 | /*! 75 | * Delay time for the BeaconTimingAns in ms 76 | */ 77 | #define CLASSB_BEACON_DELAY_BEACON_TIMING_ANS 30 78 | 79 | /*! 80 | * Default symbol timeout for beacons and ping slot windows 81 | */ 82 | #define CLASSB_BEACON_SYMBOL_TO_DEFAULT 8 83 | 84 | /*! 85 | * Maximum symbol timeout for beacons 86 | */ 87 | #define CLASSB_BEACON_SYMBOL_TO_EXPANSION_MAX 255 88 | 89 | /*! 90 | * Maximum symbol timeout for ping slots 91 | */ 92 | #define CLASSB_PING_SLOT_SYMBOL_TO_EXPANSION_MAX 30 93 | 94 | /*! 95 | * Symbol expansion value for beacon windows in case of beacon 96 | * loss in symbols 97 | */ 98 | #define CLASSB_BEACON_SYMBOL_TO_EXPANSION_FACTOR 2 99 | 100 | /*! 101 | * Defines the default window movement time 102 | */ 103 | #define CLASSB_WINDOW_MOVE_DEFAULT 2 104 | 105 | /*! 106 | * Defines the maximum time for the beacon movement 107 | */ 108 | #define CLASSB_WINDOW_MOVE_EXPANSION_MAX 256 109 | 110 | /*! 111 | * Defines the expansion factor for the beacon movement 112 | */ 113 | #define CLASSB_WINDOW_MOVE_EXPANSION_FACTOR 2 114 | 115 | #endif // __LORAMACCLASSBCONFIG_H__ 116 | -------------------------------------------------------------------------------- /src/loramac/LoRaMacTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2017 Alibaba Group Holding Limited 3 | */ 4 | 5 | /*! 6 | * \file LoRaMacTest.h 7 | * 8 | * \brief LoRa MAC layer test function implementation 9 | * 10 | * \copyright Revised BSD License, see section \ref LICENSE. 11 | * 12 | * \code 13 | * ______ _ 14 | * / _____) _ | | 15 | * ( (____ _____ ____ _| |_ _____ ____| |__ 16 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 17 | * _____) ) ____| | | || |_| ____( (___| | | | 18 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 19 | * (C)2013 Semtech 20 | * 21 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 22 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 23 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 24 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 25 | * embedded.connectivity.solutions=============== 26 | * 27 | * \endcode 28 | * 29 | * \author Miguel Luis ( Semtech ) 30 | * 31 | * \author Gregory Cristian ( Semtech ) 32 | * 33 | * \author Daniel Jaeckle ( STACKFORCE ) 34 | * 35 | * \defgroup LORAMACTEST LoRa MAC layer test function implementation 36 | * This module specifies the API implementation of test function of the LoRaMAC layer. 37 | * The functions in this file are only for testing purposes only. 38 | * \{ 39 | */ 40 | #ifndef __LORAMACTEST_H__ 41 | #define __LORAMACTEST_H__ 42 | 43 | /*! 44 | * \brief Enabled or disables the reception windows 45 | * 46 | * \details This is a test function. It shall be used for testing purposes only. 47 | * Changing this attribute may lead to a non-conformance LoRaMac operation. 48 | * 49 | * \param [IN] enable - Enabled or disables the reception windows 50 | */ 51 | void LoRaMacTestRxWindowsOn( bool enable ); 52 | 53 | /*! 54 | * \brief Enables the MIC field test 55 | * 56 | * \details This is a test function. It shall be used for testing purposes only. 57 | * Changing this attribute may lead to a non-conformance LoRaMac operation. 58 | * 59 | * \param [IN] txPacketCounter - Fixed Tx packet counter value 60 | */ 61 | void LoRaMacTestSetMic( uint16_t txPacketCounter ); 62 | 63 | /*! 64 | * \brief Enabled or disables the duty cycle 65 | * 66 | * \details This is a test function. It shall be used for testing purposes only. 67 | * Changing this attribute may lead to a non-conformance LoRaMac operation. 68 | * 69 | * \param [IN] enable - Enabled or disables the duty cycle 70 | */ 71 | void LoRaMacTestSetDutyCycleOn( bool enable ); 72 | 73 | /*! 74 | * \brief Sets the channel index 75 | * 76 | * \details This is a test function. It shall be used for testing purposes only. 77 | * Changing this attribute may lead to a non-conformance LoRaMac operation. 78 | * 79 | * \param [IN] channel - Channel index 80 | */ 81 | void LoRaMacTestSetChannel( uint8_t channel ); 82 | 83 | /*! \} defgroup LORAMACTEST */ 84 | 85 | #endif // __LORAMACTEST_H__ 86 | -------------------------------------------------------------------------------- /src/loramac/cmac.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | Copyright (C) 2009 Lander Casado, Philippas Tsigas 3 | 4 | All rights reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files 8 | (the "Software"), to deal with the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | Redistributions of source code must retain the above copyright notice, 15 | this list of conditions and the following disclaimers. Redistributions in 16 | binary form must reproduce the above copyright notice, this list of 17 | conditions and the following disclaimers in the documentation and/or 18 | other materials provided with the distribution. 19 | 20 | In no event shall the authors or copyright holders be liable for any special, 21 | incidental, indirect or consequential damages of any kind, or any damages 22 | whatsoever resulting from loss of use, data or profits, whether or not 23 | advised of the possibility of damage, and on any theory of liability, 24 | arising out of or in connection with the use or performance of this software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 27 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 31 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 32 | DEALINGS WITH THE SOFTWARE 33 | 34 | *****************************************************************************/ 35 | 36 | #ifndef _CMAC_H_ 37 | #define _CMAC_H_ 38 | 39 | #include "aes.h" 40 | 41 | #define AES_CMAC_KEY_LENGTH 16 42 | #define AES_CMAC_DIGEST_LENGTH 16 43 | 44 | typedef struct _AES_CMAC_CTX { 45 | aes_context rijndael; 46 | uint8_t X[16]; 47 | uint8_t M_last[16]; 48 | uint32_t M_n; 49 | } AES_CMAC_CTX; 50 | 51 | //#include 52 | 53 | //__BEGIN_DECLS 54 | void AES_CMAC_Init(AES_CMAC_CTX * ctx); 55 | void AES_CMAC_SetKey(AES_CMAC_CTX * ctx, const uint8_t key[AES_CMAC_KEY_LENGTH]); 56 | void AES_CMAC_Update(AES_CMAC_CTX * ctx, const uint8_t * data, uint32_t len); 57 | // __attribute__((__bounded__(__string__,2,3))); 58 | void AES_CMAC_Final(uint8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX * ctx); 59 | // __attribute__((__bounded__(__minbytes__,1,AES_CMAC_DIGEST_LENGTH))); 60 | //__END_DECLS 61 | 62 | #endif /* _CMAC_H_ */ 63 | 64 | -------------------------------------------------------------------------------- /src/loramac/utilities.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2017 Alibaba Group Holding Limited 3 | */ 4 | 5 | /* 6 | / _____) _ | | 7 | ( (____ _____ ____ _| |_ _____ ____| |__ 8 | \____ \| ___ | (_ _) ___ |/ ___) _ \ 9 | _____) ) ____| | | || |_| ____( (___| | | | 10 | (______/|_____)_|_|_| \__)_____)\____)_| |_| 11 | (C)2013 Semtech 12 | 13 | Description: Helper functions implementation 14 | 15 | License: Revised BSD License, see LICENSE.TXT file include in the project 16 | 17 | Maintainer: Miguel Luis and Gregory Cristian 18 | */ 19 | #if !defined(HT_DE01)||defined(WIFI_Kit_32)||defined(WIFI_Kit_32_V3) 20 | #include 21 | #include 22 | #include 23 | #include "../loramac/utilities.h" 24 | #include "esp_attr.h" 25 | #include "esp_sleep.h" 26 | /*! 27 | * Redefinition of rand() and srand() standard C functions. 28 | * These functions are redefined in order to get the same behavior across 29 | * different compiler toolchains implementations. 30 | */ 31 | // Standard random functions redefinition start 32 | #define RAND_LOCAL_MAX 2147483647L 33 | 34 | RTC_DATA_ATTR static uint32_t next = 1; 35 | 36 | int32_t rand1( void ) 37 | { 38 | return ( ( next = next * 1103515245L + 12345L ) % RAND_LOCAL_MAX ); 39 | } 40 | 41 | void srand1( uint32_t seed ) 42 | { 43 | next = seed; 44 | } 45 | // Standard random functions redefinition end 46 | 47 | int32_t randr( int32_t min, int32_t max ) 48 | { 49 | return ( int32_t )rand1( ) % ( max - min + 1 ) + min; 50 | } 51 | 52 | void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size ) 53 | { 54 | while( size-- ) 55 | { 56 | *dst++ = *src++; 57 | } 58 | } 59 | 60 | void memcpyr( uint8_t *dst, const uint8_t *src, uint16_t size ) 61 | { 62 | dst = dst + ( size - 1 ); 63 | while( size-- ) 64 | { 65 | *dst-- = *src++; 66 | } 67 | } 68 | 69 | void memset1( uint8_t *dst, uint8_t value, uint16_t size ) 70 | { 71 | while( size-- ) 72 | { 73 | *dst++ = value; 74 | } 75 | } 76 | 77 | int8_t Nibble2HexChar( uint8_t a ) 78 | { 79 | if( a < 10 ) 80 | { 81 | return '0' + a; 82 | } 83 | else if( a < 16 ) 84 | { 85 | return 'A' + ( a - 10 ); 86 | } 87 | else 88 | { 89 | return '?'; 90 | } 91 | } 92 | 93 | uint32_t Crc32( uint8_t *buffer, uint16_t length ) 94 | { 95 | // The CRC calculation follows CCITT - 0x04C11DB7 96 | const uint32_t reversedPolynom = 0xEDB88320; 97 | 98 | // CRC initial value 99 | uint32_t crc = 0xFFFFFFFF; 100 | 101 | if( buffer == NULL ) 102 | { 103 | return 0; 104 | } 105 | 106 | for( uint16_t i = 0; i < length; ++i ) 107 | { 108 | crc ^= ( uint32_t )buffer[i]; 109 | for( uint16_t i = 0; i < 8; i++ ) 110 | { 111 | crc = ( crc >> 1 ) ^ ( reversedPolynom & ~( ( crc & 0x01 ) - 1 ) ); 112 | } 113 | } 114 | 115 | return ~crc; 116 | } 117 | 118 | uint32_t Crc32Init( void ) 119 | { 120 | return 0xFFFFFFFF; 121 | } 122 | 123 | uint32_t Crc32Update( uint32_t crcInit, uint8_t *buffer, uint16_t length ) 124 | { 125 | // The CRC calculation follows CCITT - 0x04C11DB7 126 | const uint32_t reversedPolynom = 0xEDB88320; 127 | 128 | // CRC initial value 129 | uint32_t crc = crcInit; 130 | 131 | if( buffer == NULL ) 132 | { 133 | return 0; 134 | } 135 | 136 | for( uint16_t i = 0; i < length; ++i ) 137 | { 138 | crc ^= ( uint32_t )buffer[i]; 139 | for( uint16_t i = 0; i < 8; i++ ) 140 | { 141 | crc = ( crc >> 1 ) ^ ( reversedPolynom & ~( ( crc & 0x01 ) - 1 ) ); 142 | } 143 | } 144 | return crc; 145 | } 146 | 147 | uint32_t Crc32Finalize( uint32_t crc ) 148 | { 149 | return ~crc; 150 | } 151 | 152 | #endif --------------------------------------------------------------------------------