Click For YouTube Video Walkthrough
The purpose of the receiver app is to act as a state change listener for a smartcontract deployed to the Fantom Opera Mainnet-> DoorV3.sol. When the state of the door changes, as recorded on the blockchain (smart contract variable as either set too- 'open' vs. 'close) the contract emits a signal which can be picked up on by a web application/front-end. Furthermore, the web app regularly checks DoorV3.sol (the name of the smart contract used in my app) to see if the status of the coop door changes over time.
When this application is paried with the Blockchain Door Transmitter App it will cause the remote chicken door (picture below) to open or close:
The receiver app relies on connectivity to an Arduino/xBee module which is listening for serial response from the web app- and which will, in turn, transmit to another remote wireless module (seen in the picture of the door above) via xBee. The device (pictured below) must be plugged into a computer prior to use with the web app:
- When using the blockchain receiver app a user should navigate to the 'Connect to Door' route. Here they will be prompted with a button -"Connect to Door Controller." Prior to clicking this button a user must plug in their Arduino hardware device/xBee wireless transmitter via usb serial.
- After clicking the button you'll see a list of posssible USB devices you can connect to. A user will want to select the port associated with their Arduino/Xbee wireless trasmitter module
- After connecting, the application is listening to the blockchain- specifically DoorV3.sol for a state change on the status of the door. When it receives a signal it will transmit this out via the Arduino/Xbee wireless transmitter to another remote module (Arduino/Xbee pair) which controls the chicken coop door.
The original chicken coop door relied on a momentary push button to complete a circuit and toggle the door up/down between button press. I exposed the endpoints for these lines (by cutting and stripping the wires) and then soldered two green jumpwer wires so the door functionality could be adapted for an Arduino microcontroller/xBee pair:
The completed remote door module is pictured below- the Arduino with xBee wireless receiver listens for a signal being passed form the transitter (teathered to a computer and listening to the blockchain-specifically Fantom Opera Mainnet). When it get's a signal via USB serial it transmitts wirelessly to a remote module to toggle the coop door.
The tricky part about making this circuit was the use of a transistor to adapt the original momentary switch. Below is the diagram of how I hacked the original chicken coop door using a transistor element: