From Free Pascal wiki
Revision as of 18:08, 30 December 2016 by Minesadorada (talk | contribs) (Added config file editing)

Lazarus and the Foobot air quality monitor

  • Foobot( is an InternetOfThings gadget that monitors indoor air quality.
  • Unfortunately, the company only supplies mobile phone apps to access the Foobot.
  • They do however publish an API which returns JSON data when queried, so I decided to port it to the PC using Lazarus and FPC
  • The API page is here:


  • Foobot Monitor


  • Foobot Interrogator


What you will need

1. A Foobot
2. A Foobot account
3. A free API Key (get one from the API page:

Binary Downloads: Foobot Monitor

Windows 32/64 binaries:
Linux 32/64 binaries:

Binary Downloads: Foobot Interrogator

Windows 32/64 binaries:
Linux 32/64 binaries:


Source code is in Lazarus CCR here:


There are two main functions in foobot_utility.pas for you to use. Both will populate TObjects in foobot_objects.pas which you can read.

// Populates FoobotIdentityObject.TFoobotIdentityList collection
function FetchFoobotIdentity(aUsername, aSecretKey: string): boolean;

// Populates FoobotDataObject
function FetchFoobotData(DataFetchType: TDataFetchType = dfLast;
  iCurrentFoobot: integer = 0; iLastIntervalSeconds: integer = 3600;
  iLastAverageBySeconds: integer = 0; iStartTimeSeconds: int64 = 0;
  iEndTimeSeconds: int64 = 0; aSecretKey: string = 'unknown'): boolean;

// Populates datapoint arrays from FoobotIdentityObject for easy access
// - also populates HighLow arrays
function FoobotDataObjectToArrays: boolean;


  • When first run Foobot Monitor will prompt you to enter your Foobot Username, Password and an API Key.
  • These values are then stored in an encrypted configuration file so that they will load automatically in future
  • The configurarion file is located:
    • Windows: %APPDATA%\username\Local\foobotmonitor\
    • Linux /etc/.foobotmonitor
  • You can alter/update the stored login data in the following way:

1. Open the foobotmonitor.cfg file
2. Make a new entry thus, then save the file. (using your values instead of the example <..> ones)

Foobot User=<username>
Secret Key=<Secret API Key>
  • Next time Foobot Monitor is run, these values are read, then encrypted and the plaintext is deleted
    • You can do this as many times as you like


License is GPLV2 (