Tuesday, January 10, 2023

Creating a smart home temperature and humidity sensor system with ESP8266 SoCs, ESPHome, Home Assistant, and MQTT

As the weather gets colder, having accurate temperature and humidity readings in your home becomes increasingly important for comfort and safety. In this blog post, we will walk through the process of setting up a system of temperature and humidity sensors running on ESP8266 SoCs using the open-source software ESPHome, Home Assistant, and MQTT. This is a project I've been focused a lot on lately. I have sensors in nearly every room and even inside my Heat Recovery Ventilator. I can track how much heat I'm recovering when removing 'stale' air from within. Let me know of any questions!

First, you will need to gather the necessary hardware. For this project, you will need one or more ESP8266-based development boards, such as the D1 Mini, a DHT22 temperature and humidity sensor, and a 5v USB power supply. You will also need a computer or a Raspberry Pi to run Home Assistant and MQTT. I'm not going to discuss how to set up these in this post, in the future I want to break down my setup. I currently run HAOS on Proxmox. The ESP and DHT can be found for a few dollars on AliExpress, or if you're impatient you can get them from Adafruit or similar I'm sure. I don't affiliate, so no links.

The first step is to flash the ESP8266 development boards with the ESPHome firmware. ESPHome is a custom firmware for ESP8266 and ESP32 boards that allows for easy integration with Home Assistant. You can flash the firmware using the ESPHome wizard, which guides you through the process step by step.

Next, you will need to connect the DHT22 temperature and humidity sensor to the D1 Mini board. The sensor uses a single pin for data communication and requires a pull-up resistor of about 10kΩ. I selected D5.

With the sensor connected, you can now configure the ESPHome firmware on your D1 Mini board. Here is the sample ESPHome code you need to include in your configuration file:

sensor:

  - platform: dht

    pin: D5

    temperature:

      name: "Temperature Sensor"

    humidity:

      name: "Humidity Sensor"


In this code snippet, the platform is set to dht, pin is set to D5 (the pin the sensor is connected to) and we are giving custom name to sensors (Temperature Sensor and Humidity Sensor). Obviously place the name of the room you're sensing.

Once your ESP8266 board is configured, you can connect it to your Home Assistant installation. Home Assistant is an open-source home automation platform that can integrate with a variety of devices and services. To integrate your ESP8266 sensors, you will need to add a new sensor to your Home Assistant configuration file and specify the IP address and port of your MQTT server. Again not in this post. This is a general guide I created upon doing this myself.

At this point, you should have a working system of temperature and humidity sensors running on ESP8266 SoCs, integrated with ESPHome, Home Assistant, and MQTT. You can now use Home Assistant to view sensor readings and set up automations based on temperature and humidity levels.

This project is a great way to take control of your home's environment and make your home more comfortable and energy-efficient. Even just tracking the data within Home Assistant and passing that into InfluxDB is pretty nice. Having the data at a fingers reach is great, flashing cheap ESP8266 with ESPHome is going to be another topic.

Saturday, January 7, 2023

Migration

 I finally found some time to move my site over to a server within GCP. The domain is behind CloudFlare and is serving HTTPS. In the coming weeks I'm going to start uploading the previous disk dumps I had and keep on archiving what I have.

As for store stock I do have parts on the way and I have loads of boards queued up. Should be ready for Spring 2023!

As of right now the store is hosted on Shopify, Ex-Shopifolk here!, and this blog is via Blogger. The site is served via nginx on Ubuntu 22.04 LTS. Proxied behind Cloudflare for SSL and basic protection. I updated the 'Front Page' so to speak, not the Microsoft HTML tool FrontPage. I generated it using ChatGPT3 and  I enjoy the basic and crappy look of it.

I'm currently on the hunt for a special thing to start a new project and I can't seem to find one in working condition. I'll keep digging to see what I can find. More to come later.

Happy 2023 everyone and stay safe!

Monday, September 26, 2022

Syzygy-Systems & Stock

 It's been awhile since I posted on my blog. Nearly a year. I have been keeping busy in more ways than one. Between projects, moving, job changes, etc.; I've been busy.

Now of course I have had a TON of questions about when my store stock will replenish. Well to be honest I haven't tried very much. I have about 30 boards ready for modems, but no ESP8266 modules. The prices have increased, mostly the shipping, and It's hard to get them for a decent price. My goal for the Syzygy Europa, the C64 Wi-Fi Modem, was to make it cheap and sell it cheap. I can't do that when shipping costs more than the modem. So for now, my products are on hold.

With that said I am restarting my website. Right now the site is hosted on a GCP bucket. Very static. I will be changing that soon to allow the file downloads again.

I will also be posting more on my blog regarding 3D Printers and electronics. I now have a dedicated shop/garage and can focus a bit more on these.

Thanks anyone who is still hanging on. If you REALLY want a modem. Send me a message and we'll see what we can do. Cheers.

Keith

Monday, November 1, 2021

3D Printer & CNC Routing

I can print things, laser things why not cut?

So I posted about the fact that I added a Laser Diode Module to my tool-kit for my 3D Printer, Ender 3 if you're not aware. Before I bought the Laser Module I tested with the idea of engraving or cutting with a Dremel type tool.

I starting designing tool holders based on my No-Name-Dremel-Knock-Off tool. It has an attachment to allow for detailed engraving, cutting and such.


I designed this quickly and cheaply. I printed it at 160mm/s 0.32 Layer Height and with a 0.8mm nozzle. It didn't fit right. The idea was to have it sit to the rear of the gantry/nozzle. This design kinda worked, but didn't have enough force/friction to stay on when touching material.

I then created something from a design on ThingiVerse. Using a roller cover/clip I kept the router bit in the rear of the gantry. This was a mistake as this hits the rails before the X stop sensor. Oops.


Using the same design, I mirrored it so the router would be in the front. This worked better, no longer struck the rails when homing. The biggest issue with using a router or even the laser is that he Z Axis cannot home properly. So you need to either do it manually or watch what you're doing. A Router bit hitting a glass bed isn't a good time!



Testing Time

With the mount setup and the Not-Dremel read to go. It was time for a test. Using the Creality Program, I know now how bad it is, I set out to engrave DickButt!


The results were, eh not great. Finding the Z plunge depth is fun. Since it's a 3D printer and not a CNC machine I had to make sure the Z was going down very very small or else the mount would fall off! This was about as far as I got with this. If you want to do something similar here are some tips.

  • Design a mount to fit onto its own gantry
  • Get real router bits, I used whatever came in the kit
  • Use better software, lots out there.
  • Get a laser instead!

Here is an example of me engraving with the laser instead.


Cleaner, easier and less mess!

Thanks :)

Thursday, October 28, 2021

Google Cloud and Static Sites

 I moved my site from a GCP Instance to a Bucket 💪

This wasn't because I wanted to, it was because Google changed the 'Free' Tier of the GCP VM's, sorry Instances. I ended up getting charged $12 for my website that sees about 3 visitors a month.

Running the Instance was, fun? I had a Gopher space page on there and of course my main page. I will probably spin up another Gopher page, but right now I wanted to get a blog up and running. So I copied my www folder off the old Debian 9 install, shut down the instance and removed it and it's storage. Rest easy 'ol stretchy.

Following Google's own guide to hosting a static site, via HTTP. I do plan on setting it up with HTTPS again using another free tier instance, this time with the correct settings for 2021. Following their guide was easy and I was able to share the bucket and host the static page successfully. 

The site itself is about a year out of date, I do plan on updating it to mention the delays I'm having and the failure to open the BBS by 2020. Also the public files download stopped working, I'm sure its just a matter of adjusting the link to the bucket itself instead of the old WWW server folder.

Overall it was easy to do. I don't have to maintain the OS, Server, etc. I just make the files/folders public and we're off! Once I get the effort to update the HTML I'll probably put it behind a load-balancer to offer the HTTPS certificate out.

Wednesday, October 27, 2021

3D Printing With Lasers!

Intro 

I have a Creality Ender 3 FDM 3D Printer. It's a workhorse. I've modded it, upgraded it, tweaked it, you name it. New Bed, Extruder, Motors, Springs, tons and tons. I also bought a laser for it.


The Creality company offers a Laser Engraving Kit, which I of course picked up. It was $37CAD on sale with Free Shipping. Took about 3-4 weeks to get here during the end of Summer '21.


It's a 500mW 24V Laser Diode. It's roughly around the 445nm wavelength. This means we can engrave most woods, especially soft wood. I of course experimented with a bunch of different materials, who wouldn't? The laser sticks to the printer via magnets. It just sits on the front of the fan cage for the printer's hot-end. You could mount the laser module to its own gantry and replace as required, but the magnets handle my workload just fine.

Since I have a newer Ender 3, not the V2, I had to perform a little firmware modification. My Ender 3 came with the Creality board 4.2.2 also known as 4.2.x. This thing has a 'bug' that has been open. These Laser Modules are Laser Diodes with some PWM guts. This kit included a Y adapter to allow me to split the power/signal from the parts cooling fan. This fan operates on 24V PWM and so does the Laser. The bug is that the PWM frequency is so low that the Laser cannot get enough power. The fix is to change the timer for the header since it's already in use. The GitHub issue is here.

Results

So what can this thing do? Well it started out rough. I used the software that Creality has and it's rough. I dug around for others and found some web-based tools and such. Nothing with great results. Pic related.


The bottom image was first. The laser wasn't shutting off for 'white' parts of the image. This was just a PNG/JPG of Dickbutt. The top part was done after when I figured out that the laser needs to be 1% to 'shut-off'' or else there is a delay in firing the laser. The image isn't very detailed and the lines are rough. The reason for this Creality's software can only fire the laser on/off. It doesn't have the ability to PWM the power.

LightBurn to the rescue? 

A friend of mine owns a business that does CNC/Laser work. He suggested LightBurn. This software is used for Laser Cutting on bigger machines, and smaller now! LightBurn offers a Marlin/GCode version that allows me to either copy gcode files to SD or connect my printer directly to the USB port on my Laptop. 


LightBurn properly controls the laser using PWM in the ranges that I select. I ran several power, speed and interval tests and found my butterzone. Overall I'm pleased with the results. I'm going to be offering custom made C64 stuff on my Tindie store and can't wait to see what else I can do with it.

Monday, October 25, 2021

Out of Stock

 Well I'm out of stock. Not just any stock, all of it.

For those that don't know I design, make and sell a couple of things for the Commodore 64. I sell these using Tindie. Volume is crazy low. I make design them via KiCAD and then ship them off to a PCB House in China, usually PCBWay. I then assemble the boards in my basement, and flash if required. This can take months due to the shipping times from China. I want to get away from using a PCB House and get back to making them by hand using either a CNC or my Laser Cutter. Someday.

The delays in shipping from China have gotten worse. So bad in fact that with my low volume I cannot even get them within 6 months. This makes it really hard to keep some in stock, especially when I don't know when to order!

So, my store is empty right now. If I order 20 boards I won't get them till about Feb '22. If you're looking for a C64 WiFi Modem or Breakout Boards. 2022 is your year!

-Keith

Creating a smart home temperature and humidity sensor system with ESP8266 SoCs, ESPHome, Home Assistant, and MQTT

As the weather gets colder, having accurate temperature and humidity readings in your home becomes increasingly important for comfort and sa...