This document discusses using Microsoft Orleans grains as software agents or "avatars" to represent physical IoT devices in the cloud. An example railway simulation app is described that uses grains to represent trains. Each train has a corresponding "physical train" device that can detect its proximity to stations and rails using Bluetooth beacons and communicates with its grain avatar using MQTT. The frontends use SignalR for the web UI and MQTT for machine-to-machine communication. Physical trains are programmed using .NET Micro Framework and detect beacons using BLE, with an MQTT/iBeacon gateway and feedback simulator implemented in Node-Red.