I havea project in which I need to send the readings from the sensor connected to RPi to blockchain. Due to the fact that smart contract cannot manipulate data outside blockchain I need an oracle that will modify the sensor data (to be an integer) and address it to the Ethereum blockchain. I have no idea how to write oracles and how to run the script on RPi. Please, help
There's nothing particularily fancy about an oracle. They are just an external source that sends regular transactions to the blockchain. The transactions are in a well-defined format which can be read within the blockchain from other contracts.
So basically you have:
- An external program that gets external data and connects to the blockchain
- A way to serialize the external data in an understandable format to be stored in the blockchain (in a smart contract)
- A smart contract that can read the serialized data and provide it for whichever contract requires it
What you do need to be worried about is deciding on how you update the data in the blockchain. Is it regularily (once a day? once a minute?) or per-request? Each update costs you some gas and each read costs gas.