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

  • Possible duplicate of How do oracle services work under the hood? – Ismael Feb 27 '18 at 4:49
  • I have a pc with 2 miners running and a RPi with sensor connected to it. The problem is to send readings from sensor to the ethereum blockchain so that it could be read from the web application, without physical access to the sensor itself. To do so I need a smart contract and oracle that will make the system behave like it is explained above. It will update the readings upon reaching some threshold value, or 3 times a day, in case if two miners create enough gas – Nurbolat K Feb 27 '18 at 13:29
  • In your case is much more simple, you do not need an oracle. Create a smart contract, from the rpi push data to that contract, the webapp will read those changes to the contract and can process them or do something else. – Ismael Feb 27 '18 at 14:15
  • could you explain how to push the data to contract? – Nurbolat K Feb 27 '18 at 19:32
  • From javascript it should be something like myContract.sendData(dataToSend), if you want to send data as a sequence of bytes. If your data is more complex you can send it preprocessed, if sensor1, sensor2, .. are the integer values returned by the sensors then something like this myContract.sendSensorData([sensor1, sensor2, sensor3]) send data as an array of integers. – Ismael Feb 27 '18 at 21:43

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.

  • Maybe it will update upon reaching some threshold value, or 3 times a day, won’t miners create enough gas for that? and actually I don’t know how to write a external programm and how to serialize data, however I have some thoughts about smart contract itself – Nurbolat K Feb 26 '18 at 22:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.