├── .github ├── dependabot.yml ├── release-drafter.yml └── workflows │ ├── code-formatting-check.yml │ └── compile.yml ├── LICENSE ├── README.md ├── docs ├── esptool.md └── images │ ├── connected.png │ ├── connecting.png │ └── successful.png ├── formatter.sh └── src └── ESP01Firmware └── ESP01Firmware.ino /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | updates: 4 | - package-ecosystem: github-actions 5 | directory: / 6 | schedule: 7 | interval: daily 8 | reviewers: 9 | - ascress 10 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name-template: 'Release v$RESOLVED_VERSION' 2 | tag-template: 'v$RESOLVED_VERSION' 3 | categories: 4 | - title: ':rocket: Features and Enhancements' 5 | labels: 6 | - 'feature' 7 | - 'enhancement' 8 | - title: ':bug: Bug Fixes' 9 | label: 'fix' 10 | - title: ':wrench: Maintenance' 11 | labels: 12 | - 'chore' 13 | - title: ':page_facing_up: Documentation' 14 | label: 'Documentation' 15 | change-template: '- $TITLE (#$NUMBER) - @$AUTHOR' 16 | exclude-contributors: 17 | - 'dependabot' 18 | - 'dependabot[bot]' 19 | exclude-labels: 20 | - 'dependencies' 21 | - 'chore' 22 | version-resolver: 23 | major: 24 | labels: 25 | - 'major' 26 | minor: 27 | labels: 28 | - 'minor' 29 | patch: 30 | labels: 31 | - 'patch' 32 | default: patch 33 | template: |- 34 | ## Changes 35 | $CHANGES 36 | 37 | This release was made possible thanks to $CONTRIBUTORS -------------------------------------------------------------------------------- /.github/workflows/code-formatting-check.yml: -------------------------------------------------------------------------------- 1 | name: Code Formatting Check 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | push: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | check-formatting: 13 | runs-on: ubuntu-latest 14 | 15 | env: 16 | CLANG_FORMAT_VERSION: 14.0.0 17 | 18 | steps: 19 | - name: Set environment variables 20 | run: | 21 | echo "CLANG_FORMAT_INSTALL_PATH=${{ runner.temp }}/clang-format" >> "$GITHUB_ENV" 22 | 23 | - name: Checkout 24 | uses: actions/checkout@v4 25 | 26 | - name: Download ClangFormat 27 | id: download 28 | uses: MrOctopus/download-asset-action@1.1 29 | with: 30 | repository: arduino/clang-static-binaries 31 | tag: ${{ env.CLANG_FORMAT_VERSION }} 32 | asset: clang-format_${{ env.CLANG_FORMAT_VERSION }}_Linux_64bit.tar.bz2 33 | target: ${{ env.CLANG_FORMAT_INSTALL_PATH }} 34 | 35 | - name: Install ClangFormat 36 | run: | 37 | cd "${{ env.CLANG_FORMAT_INSTALL_PATH }}" 38 | tar --extract --file="${{ steps.download.outputs.name }}" 39 | echo "${{ env.CLANG_FORMAT_INSTALL_PATH }}/clang_Linux_64bit" >> "$GITHUB_PATH" 40 | 41 | - name: Format examples 42 | run: | 43 | chmod +x ./formatter.sh 44 | ./formatter.sh 45 | 46 | - name: Check formatting 47 | run: | 48 | if ! git diff --color --exit-code src/; then 49 | echo "Please do an Auto Format on the sketches:" 50 | echo "Arduino IDE: Tools > Auto Format" 51 | echo "Arduino Web Editor: Ctrl + B" 52 | exit 1 53 | fi 54 | -------------------------------------------------------------------------------- /.github/workflows/compile.yml: -------------------------------------------------------------------------------- 1 | name: Compile 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | push: 8 | branches: 9 | - main 10 | env: 11 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 12 | 13 | jobs: 14 | build: 15 | name: ${{ matrix.board.fqbn }} 16 | runs-on: ubuntu-latest 17 | 18 | strategy: 19 | fail-fast: false 20 | matrix: 21 | board: 22 | - fqbn: esp8266:esp8266:generic 23 | 24 | steps: 25 | - name: Checkout 26 | uses: actions/checkout@v4 27 | 28 | - name: Compile Firmware 29 | uses: arduino/compile-sketches@v1 30 | with: 31 | fqbn: ${{ matrix.board.fqbn }} 32 | platforms: | 33 | - name: esp8266:esp8266 34 | source-url: http://arduino.esp8266.com/stable/package_esp8266com_index.json 35 | sketch-paths: src/ 36 | cli-compile-flags: | 37 | - --export-binaries 38 | 39 | - name: Draft Release 40 | if: ${{ github.event_name == 'push' }} 41 | id: draft-release 42 | uses: release-drafter/release-drafter@v6 43 | env: 44 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 45 | 46 | - name: Upload Release Assets 47 | if: ${{ github.event_name == 'push' }} 48 | run: | 49 | cd src/ESP01Firmware/build/esp8266.esp8266.generic 50 | zip ESP01Firmware.zip ESP01Firmware.ino.bin 51 | gh release upload ${{ steps.draft-release.outputs.tag_name }} ESP01Firmware.zip --clobber 52 | 53 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PSLab ESP01 Firmware 2 | This repository contains firmware for the ESP8266 ESP-01 chip to be used for implementing wireless connectivity with the [Pocket Science Lab (PSLab)](https://pslab.io/) open hardware platform. 3 | 4 | ## Pocket Science Lab 5 | 6 | The PSLab provides an array of test and measurement instruments for doing 7 | science and engineering experiments. Its built-in instruments include an 8 | oscilloscope, a waveform generator, a frequency counter, programmable voltage 9 | and current sources, and a logic analyzer. The PSLab also has UART, I2C, and SPI 10 | buses, via which external devices can be connected and controlled. 11 | 12 | The PSLab is a fully open source device, and FOSSASIA provides a complete hardware 13 | and software stack under open source licenses: 14 | 15 | - [Hardware](https://github.com/fossasia/pslab-hardware) 16 | - [Bootloader](https://github.com/fossasia/pslab-bootloader) 17 | - [Firmware](https://github.com/fossasia/pslab-firmware) 18 | - [Python library](https://github.com/fossasia/pslab-python) 19 | - [Graphical desktop application](https://github.com/fossasia/pslab-desktop) 20 | - [Android app](https://github.com/fossasia/pslab-android) 21 | 22 | ### Buy 23 | 24 | - You can get a Pocket Science Lab device from the 25 | [FOSSASIA shop](https://fossasia.com/). 26 | 27 | - More resellers are listed on the [PSLab website](https://pslab.io/shop/). 28 | 29 | ### Get in touch 30 | 31 | - The PSLab [chat channel is on Gitter](https://gitter.im/fossasia/pslab). 32 | - Please also join us on the 33 | [PSLab Mailing List](https://groups.google.com/forum/#!forum/pslab-fossasia). 34 | 35 | 36 | ## Prerequisites 37 | The following tools are required to build and flash the firmware: 38 | 39 | ### Hardware 40 | 41 | - **Arduino UNO** (with USB cable): This will act as a bridge to program the ESP01 chip. 42 | - **Jumper wires**: For connecting the ESP-01 to the Arduino UNO. 43 | - **Resistors** (Optional): Useful for logic level conversion to protect the ESP01 from higher voltage signals. 44 | - **Breadboard** (Optional): For convenient and secure connections. 45 | 46 | ### Software 47 | - **Arduino IDE**: The development environment for writing and uploading firmware to the ESP01. 48 | 49 | ## Preparing the IDE 50 | 51 | Before flashing the firmware to the ESP-01, you need to set up the Arduino IDE with the required boards and libraries. Follow these steps: 52 | 53 | 1. Open the Arduino IDE. 54 | 2. Navigate to **File > Preferences**. 55 | 3. In the "Additional Board Manager URLs" field, add the following URL: 56 | ```bash 57 | http://arduino.esp8266.com/stable/package_esp8266com_index.json 58 | ``` 59 | If there are existing URLs, separate them with a comma. 60 | 61 | 4. Click **OK** to save the changes. 62 | 5. Go to **Tools > Board > Boards Manager**. 63 | 6. In the search bar, type **ESP8266**. 64 | 7. Select the latest version of the **esp8266 by ESP8266 Community** package and click **Install**. 65 | 8. Wait for the installation to complete. 66 | 67 | Once these steps are completed, the Arduino IDE is ready to program the ESP-01 chip. 68 | 69 | ## Preparing the Board 70 | 71 | Before proceeding with flashing the firmware, it's important to upload a bare minimum sketch to the Arduino UNO. This ensures the board is in a known state and can act as a bridge for programming the ESP01. 72 | 73 | Follow these steps: 74 | 75 | 1. Connect the Arduino UNO to your computer using the USB cable. 76 | 2. Open the Arduino IDE. 77 | 3. Go to **File > Examples > 01.Basics > BareMinimum** to load the bare minimum sketch. 78 | 4. Select the **Arduino UNO** board from **Tools > Board**. 79 | 5. Select the appropriate **COM Port** from **Tools > Port**. 80 | 6. Click **Upload** to flash the bare minimum sketch to the Arduino UNO. 81 | 82 | This process ensures that the Arduino UNO is ready to act as a programmer for the ESP-01 chip. 83 | 84 | ## Making the Connections 85 | 86 | To program the ESP-01 chip using the Arduino UNO, establish the following connections: 87 | 88 | | Arduino UNO | ESP-01 | 89 | |-------------|-----------------| 90 | | RX | RX | 91 | | TX | TX | 92 | | 3.3 V | VCC | 93 | | GND | GND | 94 | | RESET | GND | 95 | | GND | GPIO_0 | 96 | | 3.3 V | CH_PD or CH_EN | 97 | | GND | RESET | 98 | 99 | ### Additional Notes: 100 | 101 | - All Ground pins from UNO and ESP-01 are common. 102 | - 3.3 V connections are common from UNO. 103 | - The RX pin connection between the UNO and the ESP-01 should be made through a voltage divider, since the ESP-01 operates on a 3.3 V logic level and receiving 5 V logic level from the UNO could damage it. A simple 3.3V voltage divider can be made very conveniently using two resistors (10K and 20K). 104 | 105 | ## Flashing the Firmware 106 | 107 | To flash the firmware onto your ESP01 chip using the Arduino IDE, follow these steps: 108 | 109 | 1. After cloning this repository, open the file containing the firmware (`ESP01Firmware.ino`) in Arduino IDE. 110 | 111 | 2. Select the **Generic ESP8266 Module** board from **Tools > Board**. 112 | 3. Select the appropriate **COM Port** from **Tools > Port**. 113 | 4. Click **Upload** and wait for the sketch to compile and uploading to begin. 114 | 5. At this point of time, you should be able to see something like this in the output window: 115 | ![connecting](docs/images/connecting.png) 116 | 6. In order to allow for the firmware to be uploaded, the RESET pin of the ESP-01 chip should be connected to GND only for a short interval of time. Thus, when you see the above output, wait for a short interval (approx. 1s) and then disconnect the RESET pin from GND. 117 | 7. Wait for the program to connect to the chip, until you see something like this: 118 | ![connected](docs/images/connected.png) This indicates that the firmware flashing has begun. 119 | 8. Wait for the flashing to complete until you see something like this: 120 | ![successful](docs/images/successful.png) 121 | This indicates that the firmware has been flashed successfully to the ESP-01 chip ! 122 | 123 | ## Preparing the PSLab board 124 | With the firmware successfully flashed onto the ESP-01 chip, the next step is to flash the appropriate firmware onto the PSLab board to enable communication over the UART2 bus. 125 | 126 | Use the 'pslab-firmware_v6_esp01.hex' image available from the firmware [release page](https://github.com/fossasia/pslab-firmware/releases/latest). 127 | 128 | Follow the steps as indicated in the [firmware repository](https://github.com/fossasia/pslab-firmware?tab=readme-ov-file#flashing) to flash firmware to the PSLab board. 129 | 130 | After flashing the firmware to the board, plug in the ESP-01 chip to the header on the board and you are good to go ! 131 | 132 | > [!NOTE] 133 | > After flashing this firmware to the PSLab, it will no longer communicate over the USB port. To restore the ability to communicate with the PSLab over USB, flash the 'pslab-firmware_v6.hex' image instead (the PSLab always communicates over USB while in bootloader mode, regardless of which application firmware is loaded). 134 | 135 | ## Building without Arduino IDE 136 | 137 | The firmware can be built without installing the Arduino IDE. 138 | 139 | ### Requirements 140 | 141 | - git 142 | - python 143 | - make 144 | 145 | ### Steps 146 | 147 | # Current working directory is pslab-esp01-firmware 148 | # Get the ESP8266 toolchain 149 | git clone https://github.com/esp8266/Arduino esp8266 150 | cd esp8266 151 | git submodule update --init 152 | cd tools 153 | python get.py 154 | cd ../.. 155 | export ESP_ROOT=$(readlink -f esp8266) 156 | # Get makefile 157 | git clone https://github.com/plerup/makeEspArduino 158 | # Build 159 | mkdir build 160 | make -f makeEspArduino/makeEspArduino.mk SKETCH=src/ESP01Firmware/ESP01Firmware.ino BUILD_DIR=build 161 | 162 | ESP01Firmware.bin is now built in the build/ directory. 163 | 164 | ## Flashing without Arduino 165 | 166 | See [docs/esptool.md](https://github.com/fossasia/pslab-esp01-firmware/tree/main/docs/esptool.md). 167 | -------------------------------------------------------------------------------- /docs/esptool.md: -------------------------------------------------------------------------------- 1 | # Flashing ESP-01 using esptool.py 2 | 3 | If you don't have an Arduino on hand, it is also possible to flash new firmware to the ESP-01 over any 3.3 V UART bus by using [esptool.py](https://docs.espressif.com/projects/esptool/en/latest/esp8266/index.html) directly (Arduino uses the same tool under the hood). 4 | 5 | The following example uses a Raspberry Pi. If you are using a different UART device, skip to the "Enter ESP-01 bootloader" section. 6 | 7 | ## Configuring Raspberry Pi for use with esptool.py 8 | 9 | All Raspberry Pi models have at least one easily accessible UART on the GPIO header. However, by default it is configured to provide a Linux console. In order to use the UART for something else, the terminal must first be disabled. Consult the [Raspberry Pi documentation](https://www.raspberrypi.com/documentation/computers/configuration.html#disabling-the-linux-serial-console) for up-to-date instructions on how to do this. 10 | 11 | ## Connect Raspberry Pi to ESP-01 12 | 13 | With the RPi's Linux console disabled, connect the ESP-01 to the RPi per the following table: 14 | 15 | | Raspberry Pi | ESP-01 | 16 | |-------------------|-----------------| 17 | | GPIO 14 TXD | RX | 18 | | GPIO 15 RXD | TX | 19 | | 3V3 power | VCC | 20 | | Ground | GND | 21 | | Ground | GPIO_0 | 22 | | 3V3 power | CH_PD or CH_EN | 23 | | Ground | RESET | 24 | 25 | ## Enter ESP-01 bootloader 26 | 27 | To flash new firmware to the ESP-01, it is necessary to first boot to its bootloader. With the ESP-01's GPIO_0 pin pulled low, reset the ESP-01 by briefly pulling its RESET pin high. This causes the ESP-01 to enter bootloader mode. 28 | 29 | ## Flash firmware with esptool.py 30 | 31 | Esptool.py can be installed from PyPI using `pip`: 32 | 33 | pip install esptool 34 | 35 | With esptool.py installed, first confirm that you can communicate with the ESP-01. If you are using a Raspberry Pi, use the primary UART, `/dev/serial0`: 36 | 37 | esptool.py --port /dev/serial0 chip_id 38 | 39 | You should see something like this: 40 | 41 | esptool.py v4.8.1 42 | Serial port /dev/serial0 43 | Connecting... 44 | Failed to get PID of a device on /dev/ttyS0, using standard reset sequence. 45 | 46 | Detecting chip type... Unsupported detection protocol, switching and trying again... 47 | Connecting... 48 | Failed to get PID of a device on /dev/ttyS0, using standard reset sequence. 49 | 50 | Detecting chip type... ESP8266 51 | Chip is ESP8266EX 52 | Features: WiFi 53 | Crystal is 26MHz 54 | MAC: e8:68:e7:88:59:35 55 | Stub is already running. No upload is necessary. 56 | Chip ID: 0x00885935 57 | Hard resetting via RTS pin... 58 | 59 | If you see an error, ensure the ESP-01 is in bootloader mode. 60 | 61 | Now it's time to flash the new firmware. First build or download the firmware image, `ESP01Firmware.bin`. Then write it to the ESP-01: 62 | 63 | esptool.py --port /dev/serial0 write_flash 0x0000 ESP01Firmware.bin 64 | 65 | You should see something like this: 66 | 67 | esptool.py v4.8.1 68 | Serial port /dev/serial0 69 | Connecting... 70 | Failed to get PID of a device on /dev/ttyS0, using standard reset sequence. 71 | 72 | Detecting chip type... Unsupported detection protocol, switching and trying again... 73 | Connecting... 74 | Failed to get PID of a device on /dev/ttyS0, using standard reset sequence. 75 | 76 | Detecting chip type... ESP8266 77 | Chip is ESP8266EX 78 | Features: WiFi 79 | Crystal is 26MHz 80 | MAC: e8:68:e7:88:59:35 81 | Stub is already running. No upload is necessary. 82 | Configuring flash size... 83 | Flash will be erased from 0x00000000 to 0x00044fff... 84 | Compressed 279936 bytes to 206898... 85 | Wrote 279936 bytes (206898 compressed) at 0x00000000 in 18.6 seconds (effective 120.2 kbit/s)... 86 | Hash of data verified. 87 | 88 | Leaving... 89 | Hard resetting via RTS pin... 90 | 91 | Now pull the ESP-01's GPIO_0 pin high and reset it. If the new firmware was flashed successfully, it will start broadcasting an SSID starting with "PSLab_" followed by the last three octets of the MAC address of the ESP-01 (e.g. "PSLab_0DCE2F"). 92 | -------------------------------------------------------------------------------- /docs/images/connected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fossasia/pslab-esp01-firmware/8792daf5c4f9a60b3f73b6d1901e888e6addb74e/docs/images/connected.png -------------------------------------------------------------------------------- /docs/images/connecting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fossasia/pslab-esp01-firmware/8792daf5c4f9a60b3f73b6d1901e888e6addb74e/docs/images/connecting.png -------------------------------------------------------------------------------- /docs/images/successful.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fossasia/pslab-esp01-firmware/8792daf5c4f9a60b3f73b6d1901e888e6addb74e/docs/images/successful.png -------------------------------------------------------------------------------- /formatter.sh: -------------------------------------------------------------------------------- 1 | if ! which clang-format &>/dev/null; then 2 | echo "clang-format not found or not in PATH. Please install: https://github.com/arduino/clang-static-binaries/releases" 3 | exit 1 4 | fi 5 | 6 | find \ 7 | src \ 8 | \( \ 9 | -name '*.c' -or \ 10 | -name '*.cpp' -or \ 11 | -name '*.h' -or \ 12 | -name '*.ino' -or \ 13 | -name '*.ipp' -or \ 14 | -name '*.tpp' \ 15 | \) \ 16 | -type f \ 17 | -exec \ 18 | clang-format \ 19 | --assume-filename=foo.cpp \ 20 | -i \ 21 | --style=file \ 22 | {} \; 23 | -------------------------------------------------------------------------------- /src/ESP01Firmware/ESP01Firmware.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | const char *ssid = "PSLab"; 5 | const char *password = "pslab123"; // Empty or 8-63 characters long 6 | 7 | WiFiServer server(80); 8 | 9 | void setup() { 10 | Serial.begin(1000000); 11 | 12 | WiFi.setPhyMode(WIFI_PHY_MODE_11N); 13 | 14 | WiFi.setSleepMode(WIFI_NONE_SLEEP); 15 | 16 | WiFi.softAP(ssid + get_suffix(), password); 17 | 18 | server.begin(); 19 | } 20 | 21 | void loop() { 22 | WiFiClient client = server.available(); 23 | 24 | if (client) { 25 | while (client.connected()) { 26 | if (client.available()) { 27 | char dataFromClient = client.read(); 28 | Serial.write(dataFromClient); 29 | } 30 | 31 | if (Serial.available()) { 32 | char dataFromMCU = Serial.read(); 33 | client.write(dataFromMCU); 34 | } 35 | } 36 | client.stop(); 37 | } 38 | } 39 | 40 | /** 41 | * @brief Return a suffix based on the NIC specific part of the MAC address 42 | * 43 | * @return The final three octets of the MAC address, prefixed with underscore 44 | */ 45 | String get_suffix() { 46 | // Remove vendor ID 47 | String mac = WiFi.macAddress().substring(9, 17); 48 | // Remove colons 49 | mac.replace(":", ""); 50 | return "_" + mac; 51 | } 52 | --------------------------------------------------------------------------------