I want to know how I can send messages between accounts and contracts.

The idea is that I have three Raspberry Pi devices. Each one is connected to an object (the first to a temperature sensor, the second to a LED and the third one to an LCD).

I want to create an autonomous system in which these objects can communicate through the Ethereum network.

How can I use Ethereum to send messages between connected machines?

2 Answers 2


For temporary messages, I'd use Events.

They can be used to send individual instructions to the devices.

For persistent data like the current temperature, you can use storage variables.

For example, this could turn the LED on if the temperature raises above 60 degrees.

contract IOT {

    uint public temperature;
    address sensor;
    address led;

    event Instruction( address device, string instruction)

    function IOT (address _sensor, address LED ){
        sensor = _sensor;
        led = LED;

    function updateTemp(uint temp){
        if(msg.sender != sensor) throw;
        temperature = temp;
        if (temperature > 60) {
            Instruction(led, "ON");
        else Instruction (led,"OFF");

The client would simply watch for events with their address. The device could also read the temperature directly, but I wanted to show some logic.

  • In your answer you mentioned that "The client would simply watch for events with their address". Can you please tell me how to specifically look for specific address? Oct 30, 2017 at 2:16

Communication between parties on the Ethereum network, if the messages are temporarily and shouldn't be stored for ever, can be done over the Whisper protocol.

If you want to give this a whirl and are using geth make sure to start your nodes with the --shh flag. This will enable whisper.

You can find more information about the Whisper API here. A working chat example can be found here.

  • 1
    so i should: 1) create 4 accounts for 3 raspberrys + 1 contract account to manage messages 2) use whisper to manage messages really i didn't understand how i will use whisper with ethreum and if i need a 4th account (contract ) to manage the whole thing or not thank you for replying Feb 9, 2016 at 16:11
  • 1
    I don't know what your contract will be doing, but the contract doesn't have it's own messaging. Only the nodes talk to the contract and to each other via Whisper. So you need three Ethereum nodes with Whisper enabled.
    – Maran
    Feb 9, 2016 at 16:21
  • 1
    i was thinking that the contract can be an interface between my Raspberrys so is whisper using the ethereum blockchain? (sorry for my stupid questions but i am beginner with ethereum) Feb 9, 2016 at 17:00
  • 2
    Whisper is a separate protocol that uses the same network as the blockchain but is not part of the blockchain. Smart contracts cannot use it. It isn't fully ready yet, and messages will not be relayed by the network if your nodes aren't directly connected. Feb 14, 2016 at 6:58
  • What could be the advantage of using Whisper Protocol? Messages would be sent faster using Whisper I guess. @Tjaden Hess♦
    – alper
    Jun 19, 2018 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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