Thursday 8 September 2016

You have mail 2

After having done the hardware for checking mail I had to make some kind of user interface to show that data. I had previously used an old IPhone to display temperature and power usage, so it was an easy choice to continue using it.

Previously I had just used a simple php script to fetch and display data, now I wanted to try python and Flask. I used a tutorial found here to get started.

Code is pretty simple, temperature and electricity usage is fetched every time from database, but this page is usually only open on the extra phone that displays this data so there shouldn't be any reason to cache that data. That data is also updated to database every minute so it should be refreshed every time. Mail status is received over mqtt and it's sent only when it changes so it has to be cached.


I also made a couple of changes to the hardware/firmware section, for the firmware I set the retain flag in the mqtt message so that when clients connect they get the last know value of mail. For the hardware I added a bigger antenna because I have some trouble with the wifi reception. Reception is still not as good as I would like, I have to think about it. Maybe second wifi ap, I'm also thinking if I should build a separate network for IoT-devices, currently there is only one wifi device, but that could easily change. I also changed the psu to one that outputs more current and has a lower quiescent current as I thought that the wifi problem might be because the ESP8266 is not getting enough current to transmit, but that didn't solve the problem. Before I had a cheap chinese buck/boost converter, and now I have https://www.pololu.com/product/2830 which can ouput more current, but is only a buck converter and needs at least 4 volts to output 3.3 volts. So I had to replace the three aaa batteries with four aa batteries to get enough voltage.

Also there is a problem with the mailbox itself:) It let's sunlight through somewhere and that's enough so we can't see if the led is on or not. I'll have to think how to put some seals there.

Future improvements

Hardware
  • Monitor battery state.
  • Don't turn radio on on wake up, only when we need to send. NodeMCU bug might prevent this currently.
Software
  • Move temperature and electricity to mqtt also.
  • Add today's forecast.

No comments:

Post a Comment