c0nrad's c0rner

Learning and learning

Jan 8, 2021 - 2 minute read - electronics

Thermoshat Pt. 3

Setting up a metrics endpoint for thermoshat.

Background

Before going back to the balance bot, I realized it would be good to setup a metrics server to collect information about the runtime environment.

Originally I was going to setup a quick endpoint to record data and dump it into MongoDB, but then I remembered I can use MongoDB Stitch Realm to accept HTTP requests and pipe it into MongoDB Atlas.

So that’s what I did, all said and done it took about 30 minutes, and now I have a simple reporting server and dashboard (using MongoDB Charts).

Data Pipeline

  1. Every 30 seconds or so my program sends two json bodies with the angle and temperature. code
{
  "version": GIT_VERSION,
  "ts": datetime.datetime.now().isoformat(),
  "name": "temperature",
  "temperature": 68
}
  1. MongoDB Realm ingests the data, stores it into the appropriate database and collection in MongoDB Atlas

The code can be found here: https://gist.github.com/c0nrad/beb9dd7413b5b3438c94d83160bffefd

  1. MongoDB Charts then reads from MongoDB Atlas and displays the dashboard

Dashboard

The angle is the orientation of the dial. 180 points directly up, which is medium heat.

What went wrong

  • Dates are stupid. It took a little bit of massaging to get MongoDB Charts to accept my datetime. I ended up parsing and re-serializing the data in the Realm HTTP Endpoint.

Future

It would be nice to have a realtime data server, but that’s for another day. I think when I start playing with camera’s I’ll setup a real server. Until then this will work well enough!