Показаны сообщения с ярлыком HVAC. Показать все сообщения
Показаны сообщения с ярлыком HVAC. Показать все сообщения

среда, 24 сентября 2014 г.

Low power wireless sensor node, using stock arduino

Hi ardu-people,
There are a lot of posts in the Internet about making a low power arduino projects. However most of them assume you have to do it with custom built arduinos using atmega chips, I think it’s a correct approach, BUT it is still possible to do a low power node even on stock parts. Below are some hacks I discovered or confirmed while creating my low power projects.
  • LED lights
    There are a lot of articles about how much power do they really consume and I can only confirm that, even this tiny power led on your Pro Mini or Nano. I used sharp knife to cut the connection to the power led on my Pro Mini and I desoldered leds on all other peripherals such as radio power converter
  • Power down mode
    For my arduino I was using Narcoleptic library, and PowerDown mode for the nrf24l01 radio. For arduino everything worked perfectly, for radio see below
  • Cut power to peripheral devices
    To save some more power we can disable sensors while arduino and radio are sleeping, simple solution is to power up sensors using arduino pins, set pin to HIGH to enable device, LOW to power it down, this worked perfectly for me. If you see issues with measurements, you may need to add a delay after powering a sensor up. More appropriate solution is to use tip120 or something similar to disable/enable power for all sensors at once.
  • Radio nrf24l01 power down issues
    Unfortunately looks like Nfr chip doesn’t like power manipulations, after several cycles of powering it down with arduino pin as a power source as per above while radio is in the powerdown mode, the radio developed some kind of a power leak and started to consume more (~6ma). Radio is functioning properly, but consuming a lot for a sleep period. I’ve understood that it’s consuming power via MOSI line (pin11), the solution was to set all nrf pins to low and to switch MOSI pin to input mode, don’t forget to switch it back to output when powering everything back up.
Stay tuned, I’ll be working with reducing power consumption with relays, coz they are eating a LOT
Written with StackEdit.

вторник, 10 декабря 2013 г.

Talking to Arduino in PHP via USB in Linux

I'm really proud of myself. I was able to comeup with the solution for the problem which is being discussed in the internet a lot - how to properly talk to arduino from a PHP script, actually from any kind of script. The problem is that Arduino resets itself when you open a connection, this is not OK and most of people just apply some harware hacking to disable this behaviour. I wanted a software solution.

Also for some reasons I cannot read arduino output using "php_serial.class" code. SO, here is my alternative solution:


  • I've created a deamon which redirects arduino serial output to a log file. This daemon can be started and stopped, on re-start it will re-write the logfile. I've done this for maintenance purposes - the intention is to clean the log file periodically, so that it doesn't grow to Gigabytes which ultimately could affect the performance of the overall solution(so, not because I don't have enough storage - I'm doing this on Netgear STORA after all :)). I've created a daemon script and an init script for this daemon. The code for the daemon script is easy "cat /dev/ttyUSB0 > /home/com_log.txt &" and that's it. Init script is more complex - you have to properly remove the log file and kill the cat process. You can download the code here
  • Once I have a daemon - reading Arduino from any places without resetting it - is super easy. But you have to read last lines if you want latest output. I've created a script which sends to Arduino a command to print the updated information about temperature and humidity sensors, then the script reads new values from the log file and saves them into the MySQL database. Here is the code
  • The script above is added to the crontab to collect temperature/humidity samples every 10 minutes
  • Then I've created a page using Google's Charts JSAPI examples with chart for each counter. Code is here.
This is how it looks like (there is still some work to do with date picker, correct dates on axis, etc.)

Now my Stora is a temperature station :) and since I have relay connected to the Arduino I can adjust temperature by switching heating on or off, but this part is later... stay tuned.

BTW, here is an Arduino scetch - it's a modified version of arduino code from UberFridge project by some awesome guy.

P.S. Please forgive me for code quality - I'm doing this for myself rather than for opensource community :) If someone want to polish the code and make it available on some communities - you are absolutely free to do this, I would appreciate a link to my blog though.