private static void DoTelemetry(string[] args) { TBTelemetry telemetry = new TBTelemetry(); foreach (var telValue in args) { var dataToSend = telValue.Split(':'); telemetry.Add(dataToSend[0], dataToSend[1]); } thingsBoard.SendTelemetry(telemetry); }
static void TelemetryLoop() { while (true) { TBTelemetry telemetry = new TBTelemetry(); telemetry.Add("temperature", random.Next(30)); telemetry.Add("humidity", random.Next(80)); thingsBoard.SendTelemetry(telemetry); Console.WriteLine("Message sent: " + telemetry.ToJson()); Thread.Sleep(60000); } }
static void TelemetryLoop() { while (true) { TBTelemetry telemetry = new TBTelemetry(); telemetry.Add("temperature", bme280Sensor.ReadTemperature()); telemetry.Add("humidity", bme280Sensor.ReadHumidity()); telemetry.Add("pressure", bme280Sensor.ReadPressure()); thingsBoard.SendTelemetry(telemetry); Debug.WriteLine("Message sent: " + telemetry.ToJson()); Thread.Sleep(60000); } }
static void TelemetryLoop() { while (true) { var bmeResult = bme280Sensor.Read(); TBTelemetry telemetry = new TBTelemetry(); telemetry.Add("temperature", bmeResult.Temperature.DegreesCelsius); telemetry.Add("humidity", bmeResult.Humidity.Percent); telemetry.Add("pressure", bmeResult.Pressure.Hectopascals); thingsBoard.SendTelemetry(telemetry); Debug.WriteLine("Message sent: " + telemetry.ToJson()); Thread.Sleep(60000); } }
public void SendTelemetry(TBTelemetry telemetry) { client.Publish(TELEMETRY_TOPIC, Encoding.UTF8.GetBytes(telemetry.ToJson()), QoS, false); }