hadim / bain

A DIY IoT wireless sensor for temperature, humidity and pressure.
MIT License
2 stars 0 forks source link
adafruit arduino bme280 diy home-assistant iot thermometer

Bain

Build Status

A DIY IoT wireless sensor for temperature, humidity and pressure. It is made of two parts:

This repository contains all the instructions to build the Bain sensor yourself.

Features

Instructions

Assembly on a breadboard

Follow the connections shown below. There is 4 connections (blue, red, yellow and green) in between the Feather ESP8266 board the BME280 chip. And also a last connection in purple to enable deep sleep mode and reduce battery consumption (optional).

Warning: Apparently, the Feather ESP8266 chip can't be flashed with the purple connection so you have to disconnect it, then flash and then reconnect it.

Feather ESP8266

Flash the controller

Environement Setup

You should use the Arduino IDE to flash the controller to the board. Note that a VSCode extension for Arduino IDE is also available and works well.

Controller Configuration

#ifndef BAIN_SECRET
#define BAIN_SECRET

#define WIFI_SSID "myssid"
#define WIFI_PASSWORD "mypassword"

#define MQTT_SERVER "your_server"
#define MQTT_PORT 1883
#define MQTT_CLIENT_ID "sensor1"
#define MQTT_MESSAGE_TOPIC "/bain_sensor/1"

// Leave blank to disable auth.
#define MQTT_USERNAME "your_username"
#define MQTT_PASSWORD "your_password"

#endif
#ifndef BAIN_PARAMETERS
#define BAIN_PARAMETERS

// Timezone
const int timeOffsetHours = -5;

// Delay between two measures in seconds.
const int loop_delay_s = 60;

// Enable deep sleep mode.
const boolean deep_sleep = true;

// Monitor battery level.
const boolean monitorBattery = true;

// LEDs. Disable by setting value to `-1`.
// Warning: Unused at the moment.
const int state_LED = -1;

#endif

Upload Firmware

Now you're ready to flash the controller.

By reading on the serial port, you should see logging messages about WiFi, the sensor and also the JSON string sent to the MQTT broker:

{
  "temperature": 25.23,
  "pressure": 1018.4,
  "humidty": 90.12,
  "timestamp": "2019-02-15 15:45:23",
  "batteryLevel": 82.3,
  "batteryCharging": false,
  "batteryVoltage": 3.76
}

Battery Level Monitoring

If you want to monitor the LiPo battery level, you need to add some connections to your circuit as shown below. For this you need the following parts:

Feather ESP8266

Then you need to set monitorBattery to true in bain/parameters.h.

This setup comes from https://github.com/lobeck/adafruit-feather-huzzah-8266-battery-monitor.

Final Assembly

Once you've checked your assembly works you can solder everything together using a FeatherWing proto board. Here is the final assembly diagram:

Bain Final Assembly

Case

TODO.

Home Assistant

If your MQTT broker is connected to an Home Assistant instance, Bain sensors should be automatically discovered.

License

MIT.

Author