Showing posts with label micropython. Show all posts
Showing posts with label micropython. Show all posts

Friday, 17 March 2017

Solar heat

Our garage currently has no heating, sometimes when it's cold for a long time I put a electric heater there to make sure it doesn't go below freezing. For some time now I have thought about making a solar heater there and now I had some time to do it. One of the outside walls faces south and there is already an air intake, so that's a good starting point. I decided to only heat the incoming air and not make a full blown solar heat system with water circulation, it's cheaper and also I like to start small.

Collector

A house near us had it's windows replaced so I got one of the old ones for free. It was about the right size which reduced the work needed. Basically it's just a wooden box with polyurethane insulation I found in a dumpster, with the window put in front. Just behind the window is a tin foil paper with the paper side painted black and facing the window and sun. That way space where air heats and comes inside is covered with aluminium and there is no paint that might give out some fumes when heated. I ran out of paint so the collector isn't painted as black as it should, I'll probably paint it better in the summer as I have to take it out anyway so our garage wont heat too much. But I thought it would be good to get it installed and making heat, I can make it better later when I have some more data on how it works.

Controller

The controller needs foremost to control the flap on the air intake, because there are usually no people in the garage there is no need to get fresh air all the time, so the flap can be closed when there is no heat coming. Generally when air is hotter inside the collector we open the flap more, and when it's colder we close the flap some more. For operation there's only need for two temperature sensors, heated air and inside air, but I also want to monitor cold air coming to the collector so I have three sensors. That way I can monitor how much air heats and whats the temperature difference between north and south sides of our house. There is no fan, air is only moved by convection.

I also had a small solar cell from a Ikea garden lamp, which I added to get some reference to compare to when I make changes to the collector or controller. I put some resistors and diodes as a load, and scaled the voltage to 0 - 1 volts with a voltage divider.

All the values, temperatures, solar cell voltage and servo position are sent out with MQTT and then logged to a database so I can monitor how it works. And when I make changes I can see if it was a good or bad change.

On the left the protoboard version, and on the right the final veroboard version. Power supply is just some generic psu I had lying around as I use two dc-dc converters to make the needed 5 (LCD and servo) and 3.3 (ESP8266 and DS18B20 sensors) volts.


Controller in it's "final" installation. After one day I lowered the position of the servo some. It only opened the flap a few centimeters, now it opens some more.



Source and fritzing files can be found in github https://github.com/mika-koivusaari/solar_air_heat_controller

Friday, 28 October 2016

Wifi temperature sensor

I have need for some temperature sensors where I'm too lazy install cables or the need is only for a short while. I also wanted to try micropython on ESP8266, so why not combine the two.

Installing micropython on ESP8266 is pretty simple, but somewhat time consuming the first time. Micropythons ESP8266 has good build instructions. Same goes goes for the needed esp open sdk. Building the esp-open-sdk takes pretty long time, but you don't have to update it that often.

What I want to do is have the eps8266 measure temperatures once a minute and then send the values with MQTT. Because I'm using DS18b20 sensors and they have a unique address I can just add that to the MQTT topic, something like /house/temperatures/1wire/285cb4ce0100009a and then have time and value in the message.

Micropython has a separate library repository that has MQTT library, but trying to just import that on ESP8266 gives an error and it seems that error is because there is not enough ram to compile to source, so the only way to use it is to precompile it by copying it to modules directory before building the firmware. That way it gets precompiled and you can use just like any other python module.

I'm thinking of sending the time in the message along with the value, for that I need to keep somewhat accurate time on the ESP8266.  I wrote a little script to see how accurate the rtc was, and it drifted about ten minutes in five hours, so I definitely should check the time every time I wake up from deep sleep. Script can be found here https://gist.github.com/mika-koivusaari/90febd8a101412bf0e5c71d9c736e855

Fritzing drawing of the connections. There isn't much stuff so I just soldered it all on the board. Sensors, power and battery monitor leads are of course with connectors.  I actually used a 18650 cell but didn't have a Fritzing part for that. I also used a dc - dc converter instead of a linear regulator.


Finished product, held together with heat shrink tube and hot glue:)




Code is pretty simple.

  • Wake up
  • Check if stop pin is down
  • Make measuments (only temperature and battery voltage at this time)
  • Wait for wifi connection
  • Connect to MQTT broker
  • Send values
  • Go to deep sleep

Code and Fritzing files can be found in https://github.com/mika-koivusaari/remote_sensor.

There's probably some bugs still that I have to sort out. But for future I might add some different sensors, for example humidity. Only send measured data every x minutes and store it between sends, to conserve battery. Maybe think some more about MQTT topics so they would be logical and extendable. Some more configuration options, and a local ntp server.

Next I should probably code a MySql - MQTT gateway so I can store those readings:)