Recently, while working on an IoT blockchain integration solution, I found that Raspberry Pi-based setups were relatively straightforward due to native Web3j support. However, microcontrollers presented significant challenges. After some research, I discovered two projects: Web3-Arduino (2018) and Web3E (2020), both of which have been inactive for over a year. This guide serves as a compilation environment explanation - likely the third publicly available article about Ethereum frameworks for microcontrollers.
Hardware Requirements
- ESP32 Development Board: Purchase an affordable model (ยฅ20-30)
- USB Cable: For connection to your computer
- Computer: For development and programming
- Test Programs: Request these from your vendor to verify hardware functionality
Installation Process
Step 1: Visual Studio Code
Install VS Code through standard installation procedures.
Step 2: PlatformIO
- Requires online installation (slow process)
- Prone to errors during installation
Step 3: Project Setup
- Navigate to Quick Access โ Projects & Configuration
- Select Create New Project
Critical configuration:
- Identify your ESP32 architecture
- Select appropriate board
- Note: The finalization process may take considerable time
Required Modifications
platformio.ini:
lib_deps = Web3EMain Function:
- Incorporate example code from Web3E Examples
- Recommended: Query Token Balance (checks ERC20/ERC875 token balances)
Compilation and Execution
- Click the alien icon in VS Code's bottom-left corner
- Select Project Tasks โ Upload and Monitor
The system will:
- Automatically compile
- Download to device
- Monitor via serial output
Code Explanations
Core Structure
void setup(): Initializes once at startupvoid loop(): Runs repeatedly after setup
Configuration Code
const char *ssid = "<YOUR SSID>";
const char *password = "<YOUR WiFi PASSWORD>";
const char *INFURA_HOST = "kovan.infura.io";
const char *INFURA_PATH = "/v3/<your Infura token>";
#define NATIVE_ETH_TOKENS "Kovan ETH"
#define ERC875CONTRACT "0x0b70dd9f8ada11eee393c8ab0dd0d3df6a172876"
#define ERC20CONTRACT "0xb06d72a24df50d4e2cac133b320c5e7de3ef94cb"
#define USERACCOUNT "0x835bb27deec61e1cd81b3a2feec9fbd76b15971d"Setup Function
void setup() {
Serial.begin(115200);
setup_wifi();
string userAddress = USERACCOUNT;
queryERC20Balance(ERC20CONTRACT, USERACCOUNT);
queryERC875Balance(ERC875CONTRACT, USERACCOUNT);
}Current Challenges and Future Plans
Existing Issues:
- Frequent errors due to network restrictions
- Lack of updates for Web3E
- Limited example implementations
- Hardware compatibility constraints
Development Roadmap:
- Create more versatile Ethereum interface library
- Support STM32, ESP32, and ESP8266 platforms
- Develop solutions without network restrictions
- Implement universal IoT blockchain integration framework
๐ Essential Tools for Blockchain Development
FAQ Section
Q1: What microcontrollers support Web3E?
A: Primarily ESP32, with potential for STM32 and ESP8266 through custom implementations.
Q2: How to resolve PlatformIO installation errors?
A: Ensure stable internet connection and use VPN if necessary for complete package downloads.
Q3: Where can I find updated Web3E examples?
A: Check the AlphaWallet GitHub repository for the latest versions.
Q4: Can I use this framework without Infura?
A: Yes, but requires configuring alternative Ethereum node connections.
Q5: What's the minimum hardware requirement?
A: ESP32 with 4MB+ flash memory and stable WiFi connectivity.
๐ Complete ESP32 Development Kit
Q6: How to test ERC20/ERC875 balances?
A: Use the provided example code with your contract addresses and Infura endpoint.