Skip to content

A fork of the excellent piWarmer to add features. Adds features such as Analog gas detection, light detection, Fona battery monitoring, time remaining calculations, temperature reporting, ... and more

Notifications You must be signed in to change notification settings

JohnMarzulli/HangarBuddy

 
 

Repository files navigation

HangarBuddy

This is a Python scipt that controls an AC/DC relay attached to a Raspberry Pi with a space heater plugged in. There is an adafruit GSM Board that receives text messages using a Ting SIM card connected to the Raspberry Pi. When the Pi receives a text messgae it will turn the AC/DC relay on or off accordingly, thus powering the heater on or off. The following are a list of commands that can be sent to the Pi that will control the heater.

In addition to the original heater control that this code performed, it has been extended and modified in a number of ways.

  1. Allow extensibility to add more features.
  2. Gas sensor is now sent through an analog converter so the exact gas level can be known.
  3. The gas sensor has a trigger level, and a lower "all clear" level so the alert will keep firing until the issue is addressed, but not spam your phone.
  4. The gas sensor will alert you to gas anytime it is detected, not just when the heater is being operated.
  5. A light sensor has been added so you can tell if you left the lights on.
  6. A temperature sensor has been added so you know if you need to turn on the heater.
  7. A LCD was added so you can position the unit and know what the signal quality is.
  8. Enhanced the "STATUS" command to give you a full rundown of all the sensor data.

Acknowledgements

This version was based on the piWarmer by Maria DeGrazia. https://github.com/mdegrazia/piWarmer

I want to extend my many thanks to Maria for starting such an amazing project!

The light sensor code is from "arenadorn" and tsl2591

The temperature, and gas sensor code is heavily based on the SunFounder sample code.

Disclaimer

HangarBuddy is to be used at your own risk This version of the code has been modified to increase the reliability and safety of the device, but it is an experimental device.

Commands

The commands are not case sensitive.

SMS Message Action
ON Turn the Relay/Heater on
OFF Turn the Relay/Heater off
STATUS Return status of the Relay/Heater (on or off)
HELP Return the list of commands.
SHUTDOWN Shutdown the Pi

Setup

You will need to modify the HangarBuddy.config file to match your installation. This file includes a list of phone numbers that are authorized to issue commands. The file also includes a phone number that any alerts will be sent to.

For a complete set of installation instructions, visit https://github.com/mdegrazia/piWarmer/wiki.

Wiring

Note: GPIO25 is physical pin 22

Relay

  • Red wire from GPIO25 to Relay "+"
  • Black wire from Relay "-" to GPIO GND

Fona

Fona Serial/Modem Communication

  • TTL Black to Fona "GND"
  • TTL White to Fona "TX"
  • TTL Green to Fona "RX"
  • TTL Red to Fona "Vio"
  • USB to Pi USB

Fona Status

  • ORANGE Fona PS to GPIO23
  • YELLOW Fona Key to GPIO GND
  • GREEN Fona RI to GPIO24

Fona Power... Again

  • USB power into the Fona mini-USB port

Note:GPIO23 is physical pin 16 Note:GPIO24 is physical pin 18

MQ2 Gas Sensor / ADC

ADC

  • Red F/M: VCC to GPIO 3V3
  • Black ADC GND to GPIO GND
  • White ADC SDA to GPIO SDAI
  • Gray ADC SCL to GPIO SCLI
  • White F/F ADC AIN0 to MQ2 White

MQ2

  • Pigtail Connector into reciever
  • Red to GPIO 3V3
  • Black to GPIO GND
  • Brown NOT USED

Temp Sensor

  • White plug into Temp Sensor
  • Yellow to GPIO04
  • Red to +5VO
  • Black to GPIO GND

Light Sensor

NOTE: If you have the IO hat installed on the Pi, then you can use the duplicate SDA/SLC connectors on the set screw side AND the connector pin side.

  • VCC (Red) to GPIO 3.3V
  • GND (Black) to GPIO Ground
  • SDA (White) to GPIO SDA
  • SLC (Gray) to GPIO SLC

Status Display

Additional Work

You may need to make to "Y" pig tails to support the additional i2c device.

While the Raspberry Pi can support a number of i2c devices, and all of the devices used are at different offsets, even with the IO hat, there are only connectors for two devices.

If you intend on using ALL THREE i2c devices (Gas Sensor, Light Sensor, and LCD) then a splitter for the SDAI and SCLI lines will need to be made.

If you intend to use two or fewer, then no work needs to be done, and any free SDA/SCL pins may be used.

  • Red wire from LCD VCC to GPIO 5V
  • Black wire from LCD GND to GPIO GND
  • White wire from LCD SDA to GPIO SDA
  • Gray wire from LCD SCL to GPIO SCL

Additional Links And Setup Notes

Enable analog-to-digital converter for the MQ-2 Gas Sensor

To do this, you need to enable I2C and 1-Wire using raspi-config

sudo raspi-config
  • Select Option 5 Interfacing Options
  • Select Option P5 I2C and enable
  • Select Option P7 1-Wire and enable
  • Save changes, exit raspi-config and reboot your Raspberry Pi

Enable the temperature sensor

Modprobe two modules for the temperature sensor:

sudo modprobe w1-gpio
sudo modprobe w1-therm

Materials List

All the parts listed are from Amazon

Absolutely Required

This assumes you are building "from scratch" and need to buy a Raspberry Pi and associate parts. I have picked a version of the Pi Zero that has Wireless, which is good if you want to pull the code down directly onto the Pi

Any version of the Raspberry Pi should work for this project as long as it has GPIO pins, and an I2C bus.

The LiPo battery is absolutely required and used directly by the GSM board.

A MicroUSB to USB adapter is required for the modem to connect into the Pi Zero's only USB port.

Antenna

You will need an antenna, and two options have been tried. One is a small antenna that will work if the device is near a window or your hangar has good reception. The 7dbi (high gain) antenna option should be used if reception is an issue

For Optional Gas Sensor

For Optional Temperature Sensor

For Optional Light Sensor

For Optional Status Display

Adapters

The Raspberry Pi zero uses a mini HDMI port for display. If you do not have an adapter, you will need one. This is not required in the installation once the device is "deployed". The USB hub makes coding and debugging on the PI possible as it allows a keyboard, mouse, and the Fona modem to be connected simultanously. When the HangarBuddy is "deployed" only the Fona will be plugged into the USB port.

Device Reference

MQ-2 Sensor

https://tutorials-raspberrypi.com/configure-and-read-out-the-raspberry-pi-gas-sensor-mq-x/ http://www.learningaboutelectronics.com/Articles/MQ-2-smoke-sensor-circuit-with-raspberry-pi.php

Sunfounder Temp Sensor

https://www.sunfounder.com/learn/Sensor-Kit-v1-0-for-Raspberry-Pi/lesson-17-ds18b20-temperature-sensor-sensor-kit-v1-0-for-pi.html

Adafruit Fona

https://learn.adafruit.com/adafruit-fona-808-cellular-plus-gps-breakout?view=all https://learn.adafruit.com/adafruit-fona-mini-gsm-gprs-cellular-phone-module?view=all https://learn.adafruit.com/adafruit-fona-mini-gsm-gprs-cellular-phone-module/handy-commands https://cdn-learn.adafruit.com/downloads/pdf/adafruit-fona-mini-gsm-gprs-cellular-phone-module.pdf

Installation

  1. Log in to your rasperry pi as the pi user.
  2. mkdir src
  3. cd src
  4. git clone https://github.com/JohnMarzulli/piWarmer/
  5. cd piWarmer
  6. sudo cp piWarmer.logrotate.conf /etc/logrotate.d/
  7. sudo chown root root /etc/logrotate.d/piWarmer.logrotate.conf
  8. sudo cp piWarmer.service /etc/systemd/system/
  9. sudo chown root root /etc/systemd/system/piWarmer.service
  10. sudo systemctl enable piWarmer.service
  11. sudo reboot

Once you reboot, the piWarmer service should be started automatically. You can view any startup errors for the service in /var/log/syslog.

About

A fork of the excellent piWarmer to add features. Adds features such as Analog gas detection, light detection, Fona battery monitoring, time remaining calculations, temperature reporting, ... and more

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.9%
  • Shell 0.1%