Example #1
0
 public async Task PostReading(Bmp180 rd)
 {
     client = new HttpClient();
     try
     {
         string resourceAddress = "http://192.168.43.49/moosareback/api/Bmp180";
         //var gg = await client.GetStringAsync(resourceAddress);
         //Console.WriteLine("plop:  " + gg);
         string postBody = Common.JsonSerializer(rd);
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         await client.PostAsync(resourceAddress, new StringContent(postBody, Encoding.UTF8, "application/json"));
     }
     catch (Exception ex)
     {
         Console.WriteLine("error:  " + ex.Message);
         string error2 = ex.Message;
     }
 }
Example #2
0
 public Bmp180(string _busName)
 {
     bus = RPi.I2C.Net.I2CBus.Open(_busName);
     if (!Detect())
     {
         Console.WriteLine("Some error occurred during communication with the sensor. Please check the sensor.");
         Console.ReadLine();
         Environment.Exit(0);
     }
     InitParams();
     reading = new Bmp180()
     {
         _id       = Guid.NewGuid(),
         ok        = 1,
         msg       = "OK",
         sensor    = "pi_sensor_1",
         ip        = "666",
         time      = DateTime.Now,
         createdAt = DateTime.Now,
         pressure  = this.GetPressure(),
         temp      = this.GetTemperature()
     };
 }