Hobby: Electronics, IoT
Resurrecting a GPU cooling fan using a micro-processor and PWM
June 16, 2018
Trying to rescue a GPU cooling system containing a 12V 4-wire fan using a PWM signal from ATtiny85 and reading a voltage from ADC from a potentiometer knob. Ultimately building a 4-wire fan controller.
25kHz PWM on ESP8266: https://github.com/esp8266/Arduino/issues/4598
Arduino Code: https://gist.github.com/debsahu/795922a2429bb41c18aa083e38b6678d
Building LED String using capacitive dropper
June 9, 2018
Convert a string of filament lights (X-mas decoration lights) into a LED string of lights.
Inspired from bigclive's project: https://www.youtube.com/watch?v=ewO-r8_d3uw
The Button: Amazon “Dash” type button to communicate to Home Assistant
June 3, 2018
GitHub: https://github.com/debsahu/TheButton
Things we want to achieve:
- Low on power consumtion: ESP8266 is OFF when the button is not pressed debsahu/ESP_External_Interrupt
- Portable: Uses 18650 battery, lasts years
- Talks to Home Assistant: debsahu/HARestAPI
Image recognition using Movidius Neural Compute Stick on a Raspberry Pi Zero W
May 29, 2018
Let’s build a security camera using Raspberry Pi Zero W and Movidius Neural Compute Stick to recognize a “person” on the video stream
Set up NCSDK API
- Install required packages on Pi
sudo apt-get install -y libusb-1.0-0-dev libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler libatlas-base-dev git automake byacc lsb-release cmake libgflags-dev libgoogle-glog-dev liblmdb-dev swig3.0 graphviz libxslt-dev libxml2-dev gfortran python3-dev python-pip python3-pip python3-setuptools python3-markdown python3-pillow python3-yaml python3-pygraphviz python3-h5py python3-nose python3-lxml python3-matplotlib python3-numpy python3-protobuf python3-dateutil python3-skimage python3-scipy python3-six python3-networkx python3-tk libboost-python-dev
- Clone NCSDK
cd ~
git clone https://github.com/movidius/ncsdk
- Compile and install NCSDK’s API framework
cd ~/ncsdk/api/src
make
sudo make install
- Test installation using sample code from NC App Zoo
cd ~
git clone https://github.com/movidius/ncappzoo
cd ncappzoo/apps/hello_ncs_py
python3 hello_ncs.py
Output should look something like this:
Hello NCS! Device opened normally.
Goodbye NCS! Device closed normally.
NCS device working.
Install Paho-MQTT
- Use pip3 to install Paho-MQTT
pip3 install paho-mqtt
sudo pip3 install paho-mqtt
Using these examples
- Clone this code
cd ~
git clone https://github.com/debsahu/PiCamMovidius
Native MobileSSD
- Enter into following directory
cd ~/PiCamMovidius/native/picam
- Edit picam.py with appropiate MQTT server IP, port and topic and run python script
python3 picam.py
OpenCV 3.2 YoLoV2
- Install pre-compiled OpenCV 3.2
- Add to apt-source list
echo 'deb [trusted=yes] http://dl.bintray.com/yoursunny/PiZero stretch-backports main' | sudo tee /etc/apt/sources.list.d/bintray-yoursunny-PiZero.list
- Update apt
sudo apt update
- Install OpenCV
sudo apt install python3-opencv
- Verify Install
python3 -c 'import cv2; print(cv2.__version__)'
- Enable V4L driver
sudo modprobe bcm2835-v4l2
- Enter into following directory
cd ~/PiCamMovidius/ocv3
make
- Edit picam.py with appropiate MQTT server IP, port and topic and run python script
python3 picam.py
MeshyMcLighting: NeoPixels lighting solution using Mesh Network
May 20, 2018
Idea: Wouldn’t be cool for many McLighting (RGB LED lighting using NeoPixels) to talk to each other and synchronize?
Implementation: Here is my naive attempt at this, which requires McLighting to be served as stand-alone web-client.
Link: https://github.com/toblum/McLighting/tree/experimental/Arduino/MeshyMcLighting
Features
- Uses painlessMesh to create mesh network and broadcasts state to every node
- Does not need WiFi connection to internet, standalone mode + mesh
- Web interface is borrowed from “WS2812FX esp8266” example, completely served on ESP8266
- Can do minimal file upload to SPIFFs
- Completely Async!
- Uses Task Scheduler, no more tickers
- No delays in entire code
- Has RESTful API (same API as McLighting, use set_mode for setting mode, speed, brighness)
- Async Websockets (ws://HOSTNAME/ws on port 80, same API as McLighting)
- Async MQTT/Home Assistant Intergration (Only SERVER connects to outside world)
- Auto Mode (same as McLighting)
- Button Mode (same as McLighting)
- Async WiFiManager for SERVER
Limitations/TODO
- For stability, compile both SERVER and CLIENTS on IwIP variant 1.4 Higher Bandwidth (very flaky in IwIP v2)
- Use Arduino ESP8266 GIT version (Issues with v2.4.1: not memory optimized)
- WS2812FX has delays meant for ESP32. Track issue here NeoAnimationFX has no delays.
Using RTL-SDR to read values from Wireless Electric/Gas/Water meters
May 20, 2018
An attempt to use RTL-SDR to read values from wireless electric/gas/water meters and visualize these values on Home Assistant.
Based on RTLAMR Project: https://github.com/bemasher/rtlamr
Home Assistant and Python Code: here
RobinhoodAPI: Live stock prices from Robinhood on ESP8266
May 20, 2018
Idea: Get LIVE stock price on ESP8266
Implementation: Develop a simple Arduino library that retrieves live stock prices from RobinHood in JSON format and processes it for ESP8266. In one example, we demonstrate a whole bunch of stock prices scrolling through a dot-matrix display.
Arduino Library: https://github.com/debsahu/RobinhoodAPI
Stock Prediction on Python using Machine Learning (NARX)
May 20, 2018
Here is a naive attempt at predicting a particular stock’s price and displaying it on a ESP8266. This algorithm is not the best one out there, but what is being shown here is the ability to port it elsewhere and easily integrate these complex models with micro-controllers (ESP8266) and other devices.
GitHub: https://github.com/debsahu/StockPredictionPython
- Install MATLAB 2017a Runtime v9.2 from here
- Goto Python/matlab_stock_python_lib folder and install “stock” python library using `python setup.py install`
- Use “requirements.txt” file to install required libraries. Console: “$ pip -r install requirements.txt”
- Enter appropriate values for MQTT server in “upload_stock_pred.py” and run “python upload_stock_pred.py”
- Upload Arduino files on your esp8266 using Arduino IDE
HARestAPI: Control Home Assistant directly using ESP8266
May 20, 2018
Idea: Control components on Home Assistant directly from ESP8266.
Implementation: Develop an Arduino Library that can be used in various projects without the requirement of setup of a MQTT sensor + automation on HA. This uses RESTful API commands (link).
Arduino HARestAPI Library: https://github.com/debsahu/HARestAPI
ESP8266 based Color Sensor talking to Home Assistant via RestAPI
May 20, 2018
Idea: Did you ever want to use ESP8266 to communicate to Home Assistant directly?
Implementation: Here we use a color sensor to read colors and change a RGB light in Home Assistant to the color observed.
Arduino Code: Link
RGB Lights connected to Home Assistant McLighting: https://github.com/toblum/McLighting
Quenching of a 360 MHz NMR Magnet
April 3, 2018
Watch liquid Helium boil off to gaseous state from a decommissioned 360 MHz NMR magnet. For every litre of liquid Helium, 750 litres of gaseous Helium is generated. When the Helium boils off the superconductor is no longer a superconductor and this seizes to be a magnet. Watch the steel screwdriver fall off once this happens.
Talking to Twitter using TwitterWebAPI for ESP8266
March 30, 2018
Idea:
- Use ESP8266 to talk to Twitter
- Get User Data or Tweet or Search Twitter
- Display the data on a Dot-Matrix display
Implementation:
I created an Arduino library to talk to Twitter using its Web API made for ESP8266. There are other approaches like using a bearer token arduino-twitter-api, but comes with limitations in terms of not being able to send tweet. This Arduino library TwitterWebAPI can both search/read and post tweets.
All the instructions and usage of library is described on my GitHub library page https://github.com/debsahu/TwitterWebAPI
Internet Connected Smoke Alarm
March 30, 2018
Idea:
- If there is smoke, smoke alarm detects it
- ESP8266 detects this digital signal from smoke detector, connects to WiFi and sends data to a MQTT server
- Esp8266 turns itself OFF
Implementation:
- Try to find where on the smoke detector is the 3.3V digital signal when it detects smoke
Third pin from top corner seems to send out 3.3V signal to speaker when it detects smoke
2. Lets connect our previously created ESP8266 circuit that wakes from external interrupt.
3. Configure Home Assistant to process MQTT message and send notifications.
Source code for this idea can be found on my GitHub: https://github.com/debsahu/Internet_Fire_Alarm
Extreme Power Saving of ESP8266 using External Interupt
March 30, 2018
Idea:
- Keep ESP8266 on OFF mode as default
- External 3.3V signal (can be short or long) arrives and turns ON ESP8266
- ESP8266 wakes up and keeps itself awake until a task is perfomed
- Send MQTT data to server
- Put ESP8266 back to power OFF state
Implementation:
- ESP8266 is in OFF state, GPIO0 is low
- 3.3V signal arrives externally, GPIO0 and CH_PD are high, turn ON ESP8266
- First thing ESP8266 does is turns GPIO0 to high, which means CH_PD remain high. So ESP8266 remains ON until GPIO0 is high
- GPIO12 is used to read value of external interupt
- If there is 3.3V external interrupt, GPIO is high and a MQTT message is sent as “Signal Received” or “ON” and keep ESP8266 ON until 0V signal is received.
- If there is 0V external interrupt, GPIO0 goes low and MQTT message is sent as “Signal Vanished” or “OFF” and turns OFF ESP8266
Source code for this idea can be found on my GitHub https://github.com/debsahu/ESP_External_Interrupt/
This circuit diagram has been derived from here.
Internet Connected Water Bowl Sensor
October 15, 2017
Wouldn’t it be nice to know if your dog’s water bowl is empty? Let us build a sensor that measures the water level every 5 minutes. This value is sent to MQTT server and Home Assistant automation takes care of the rest.
This sensor connects to MQTT and Home Assistant. See dogsensor.yaml for adding this to HA. Assumes that one has set up various notification sensors available in HA.
Things needed:
- 3D Printed Case
- 18650 Battery
- ESP8266 12E
- Rain Water Level Sensor
- Arduino Code
MOSFET used as switch to control a 12V Fan
March 12, 2017
Lets turn on and off low powered fan running at low (<20V) DC voltages. We shall use a MOSFET to achieve this.
MOSFETs have three terminals Drain (D), Source (S) and Gate (G), where source is connected to ground and the +12V or +5V along with load (Fan) is connected to drain. The MOSFET is on when gate voltage is higher than 1.7V and turned off when gate voltage is 0V.
This signal can be given out from a micro-controller as 3.3V/5V or 0V signals.
Twitter Mentions on a Dot-Matrix Display
February 19, 2017
Let’s say that you don’t have your smartphone around and someone mentions you on twitter. Wouldn’t it be nice to have a display that automatically reads your twitter mentions and show it on a scrolling display? So let’s build a internet controlled (IoT) dot-matrix display that does this for us using an ESP8266.
The plan to accomplish this is as follows:
- Someone mentions us on twitter (in my case @debsahu)
- IF This Then That (IFTTT) tracks these mentions and posts this data on Adafruit.io (MQTT Broker)
- An ESP8266 connects to Adafruit.io and shows this data on a Dot-Matrix display
We can’t control who mentions us on twitter, so we move to the second step in our plan to configure IFTTT and Adafruit.io.
To setup a data feed (MQTT topic) on Adafruit.io,
- Goto “feed” and “Create New Feed”
- Provide a unique name for the feed like “twitter-calls”, this means the MQTT topic that we need to subscribe to is “feed/twitter-calls”
To setup IFTTT to connect to twitter and Adafruit.io,
- Connect your twitter and Adafruit.io account to IFTTT by logging in and giving proper permissions
- Create a new applet
- For “this“: Select “twitter” and “New mention of you”
- For “that“: Select “Adafruit” and “Send data to Adafruit.io”. Remember to select the correct topic created above and a message template using ingredients that suits your need.
As a part of the third step in our plan, we need to subscribe to our MQTT topic and display this data on a Dot-Matrix display.
Hardware
Software
- Setup Arduino IDE to be able to program an ESP8266 (Instructions on how to do this is here as well as in the video below).
- Install Adafruit_MQTT and MAX7219 Dot-Matrix display libraries
- Upload the code found here on your ESP8266
Make these following connections between Max 7219 display and Wemos D1:
- VCC -> 5V
- GND -> GND
- DIN -> D7
- CS -> D8
- CLK -> D5
That’s it, now you should be able to see your latest twitter mentions on your Dot-Matrix displays.
Internet of Things (IoT)
February 19, 2017
Building electronics is one of my hobbies and I have in the recent year developed this skill to a point that I can help inspire others to make these things that make our day to day activities easier. Activities as simple as turning on and off lights using the internet (or using voice via siri/alexa/google voice) will help save energy and make our lives more easy aka… automated.
My MCU of choice will be ESP8266 which costs as low as $3 which operates at 80 MHz, equipped with WiFi and up to 8 GPIO pins. I own a few NodeMCU v1.0 and Wemos D1 mini that I will use for almost all of my projects.
I have a tons of ESP8266 (micro-processors with WiFi capability), relays, displays, motion sensors, led strips etc that I can assemble to make a functional product. There will be two aspects to this,
- Hardware building encompassing soldering and planning circuits
- Software (Arduino IDE) to take care of all this hardware functioning properly.
I will spare some time and build one product at a time, documenting it by videos and post the details over here. Some project examples will be something in the lines of internet controlled light switch or motion sensor based home automation or home security using laser trap or animations on a LED strip etc.