Physical Device
Controlling a Physical Device via Moonchain
Section titled “Controlling a Physical Device via Moonchain”This demonstration illustrates how to control a physical device using Moonchain, specifically through remotely toggling an LED on or off. It emphasizes the seamless integration of blockchain technology with real-world hardware, showcasing the potential for secure, decentralized control in various applications.
English
Section titled “English”German
Section titled “German”Moonchain Info
Section titled “Moonchain Info”- Contract Proposals: MEPs Repository
- Deployed Contrace Addresses:
- MEP801:
0x070B3e2229a27CDd34126E96B2Ce65c63BD1A5CE
- MEP802:
0x28479D68cD3ef5661BDB7505EFD1712D5D0951F6
- MEP803:
0xBFc77Ee5959699eC4171891b625D6EccdC9e00cD
- MEP801:
- Private Key:
318dee0c207c20f4767e342a52e876b816379334a53277773c783b0e9348d368
318dee0c207c20f4767e342a52e876b816379334a53277773c783b0e9348d368
Change the X2E Firmware
Section titled “Change the X2E Firmware”- Firmware Repository: Moonchain-Control-X2E
- Download the Mobile App Tool (Nordic DFU):
- Google Play Store
- Apple App Store(requires iOS 16 or higher)
- Update Firmware:
- Copy
demo_controls_dfu_ism2400.zip
to your mobile phone (Place it in the download folder for recognition). - Open the DFU App, select the firmware binary file, and start scanning for BLE devices.
- Hold the X2E board’s “USER” button for 5 seconds to initiate DFU mode.
- Select the X2E board on the app, tap “Start” to upgrade the firmware, and wait for completion.
- Copy
Connection of X2E
Section titled “Connection of X2E”To control an LED, follow these connection guidelines:
Purchase a Provision ID (PID)
Section titled “Purchase a Provision ID (PID)”-
Obtain a temporary email address to receive the PID. This prevents exposing your personal email on Moonchain.
-
Check Device Profile
- Ensure it matches the firmware of your X2E board. Use the ISM2400 profile with index 3.
Terminal window cast call 0xBFc77Ee5959699eC4171891b625D6EccdC9e00cD "deviceProfileList(uint256) (uint256,string,address,string,bool,uint256)" 3 --rpc-url https://Hudson-rpc.moonchain.com --private-key 318dee0c207c20f4767e342a52e876b816379334a53277773c783b0e9348d368- Response will be similar to one below
Terminal window 3X2E Class C - ISM24000xD9892d06C864a41A38915dDd48DF11A0DBfdCf89https://api.github.com/repos/MatchX-GmbH/iso-device-profile/contents/matchx/x2e_class_c_ism2400.jsontrue100000000000000000` -
Check PID Unit Price
cast call 0x28479D68cD3ef5661BDB7505EFD1712D5D0951F6 "pidUnitPrice() (uint256)" --rpc-url https://Hudson-rpc.moonchain.com --private-key 318dee0c207c20f4767e342a52e876b816379334a53277773c783b0e9348d368
- Response: `123450000000000000000 wei` (123.45 MCH).
- Purchase PID
- Replace the email with your own and use the following command to purchase a PID via MEP802.
Terminal window cast send 0x28479D68cD3ef5661BDB7505EFD1712D5D0951F6 "producePid(string,uint256,uint256)" "temporary.email@example.com" 1 3 --rpc-url https://Hudson-rpc.moonchain.com --private-key 318dee0c207c20f4767e342a52e876b816379334a53277773c783b0e9348d368 --value 123450000000000000000- After a few minutes, you will receive an email with a PID CSV file.
- Extract PID and pidZkevmHash
- Use the PID and pidZkevmHash from the CSV file to set up the X2E board.
- Use the PID and pidZkevmHash from the CSV file to set up the X2E board.
Setup the X2E Board
Section titled “Setup the X2E Board”- Connect the X2E board to your computer using a USB Type-C cable.
- Launch a serial terminal program (e.g., minicom on Linux or PuTTY on Windows) with settings
115200 8N1
.- Use the following command:
Terminal window minicom -b 115200 -8 -D /dev/ttyACM0 -o - Send “AT” command to verify connection. You should receive “OK”.
- Run the
AT
command
- Run the
- Change the PID of the X2E board:
- Use the following command:
Terminal window AT+CQRCODE={"PID":"K2ILSDXUOO3O4EEIWZDDW6SL","B":"MatchX","M":"X2E","V":"1.3"} - Clear all data and reboot
- Run the command below:
Terminal window AT+IREBOOT=8
Wait for a while, the X2E board will finish the provisioning process with the new PID. After that, it will start to join the network and send data. After it joined, the status LED will lite steady and the Control pin (IO14) will go higher. If you are using the suggested connection, the target LED will be lit.
If this doesn’t happen after 6 minutes, please check the status of your NEO miner and make sure it is running.
Mint the Sensor NFT for the X2E Board
Section titled “Mint the Sensor NFT for the X2E Board”- Check Minting Price
Terminal window cast call 0x28479D68cD3ef5661BDB7505EFD1712D5D0951F6 "priceInfoList(uint256) (uint256,uint,bool)" 0 --rpc-url https://Hudson-rpc.moonchain.com --private-key 318dee0c207c20f4767e342a52e876b816379334a53277773c783b0e9348d368- Response
9876500000000000000 wei
(9.8765 MCH).
- Response
- Mint the NFT
- Replace
0xf6d4bd...
with the pidZkevmHash and use the following command:
Terminal window cast send 0x28479D68cD3ef5661BDB7505EFD1712D5D0951F6 "mintSensorNFT(uint256,uint256,string)" 0xf6d4bda9e25797a1423a41c485bfaa8e03930f0dbdf2d2b324d79fa71d8c9108 0 "https://global.matchx.io/iso/x2e/x2e_ref_sensor.jpeg" --rpc-url https://Hudson-rpc.moonchain.com --private-key 318dee0c207c20f4767e342a52e876b816379334a53277773c783b0e9348d368 --value 9876500000000000000 - Replace
- Burn Sensor NFT to Repeat Process
cast send 0x28479D68cD3ef5661BDB7505EFD1712D5D0951F6 "burnSensorNFT(uint256)" 0xf6d4bda9e25797a1423a41c485bfaa8e03930f0dbdf2d2b324d79fa71d8c9108 --rpc-url https://Hudson-rpc.moonchain.com --private-key 318dee0c207c20f4767e342a52e876b816379334a53277773c783b0e9348d368
Controlling via Moonchain
Section titled “Controlling via Moonchain”You can control the pin output in three modes: always low, always high, or cycling (blinking). Replace 0xf6d4bd...
with the pidZkevmHash from earlier commands.
- Set to Low (Turn off LED)
Terminal window cast send 0x28479D68cD3ef5661BDB7505EFD1712D5D0951F6 "enqueueDownlink(uint256,string,uint8,uint8)" 0xf6d4bda9e25797a1423a41c485bfaa8e03930f0dbdf2d2b324d79fa71d8c9108 "Qh