Table of contents

Tuesday, 21 April 2015

Solar powered wireless weather station - part 2


Over the weekend I have built a prototype of a sensor/transmitter.  The only job it will have to do is:
-  wake up periodically
-  power up the sensors
-  read: temperature (DS18B20), humidity (DHT11), light (LDR), battery voltage
-  send a package using NRF24L01+
-  power off the sensors
-  go back to sleep



Having this setup on a breadboard I have written a very simple program using Arduino (my goal is to write optimised code in C, but at this stage I just wanted to prove the concept).

After compilation, Transmitter.ino takes 14kB (15k with serial output) of available 32kB flash in ATmega328P. One thing I don’t like in my program is that I have hardcoded the sensor ID – it means that if I wanted 10 sensors I would need to flash 10 different programs.

I think I will add 4 or 5-way dip-switch allowing me to choose one of 15 or 31 addresses (the receiver has ID=0 hence only 15/31 are left for the sensors).

I hooked it up to a solar power bank (it has 2600mAh LiPo battery). I have connected the uC directly to the battery (4.1V max. once charged) but I had to add 1N4148 diode before the radio transceiver (it operates at 3.3V). Using a variable PSU I have discovered that everything works fine until 3.1V (minus voltage drop on the diode for the radio), then the DHT11 humidity sensor goes mental (0% humidity) and then at 2.9V the radio stops transmitting (which is good as I’m already getting rubbish readings at this voltage).

The solar bank circuit shuts off the step-up converter if there is nothing plugged in to the 5V USB port (which is good in my case as I’m connecting the uC to the battery directly) but the solar circuit works and charges the battery if enough light is provided.

The funny thing is that it has a built-in LED indicating charging the battery.
In specific conditions (little amount of sunlight) the solar panel was producing enough voltage to trigger the LED on, which was draining the built-in battery...
I don’t have exact figures off the top of my head but it was something like 3mA going from the panel and additional 6mA from the battery (?!?). After cutting off the LED, the current started to flow into the battery J
It wasn’t of course a problem in a direct sunlight but even then, the LED was consuming more energy than my complete circuit will.


The receiver is just another Arduino with NRF24L01+, formatting and forwarding the packet to the serial port. Receiver.ino – 8kB of flash (or 10k with serial output).

Here is an example of what comes out of transmitter:

27: 220C 3323V 40% 299
WRITE OK

27        - sensor’s packet counter
220C      - temperature: 22.0C
3323V     - battery voltage: 3.323V
40%       - humidity (0-99%)
299       - light amount (0-1023)
WRITE OK  - NRF24L01+ acknowledgment


And here is how it looks in a serial monitor on the receiver’s side:

260-27: 1  220C  3323V  40%  299

260    - receiver’s packet counter
27     - received sensor’s packet counter
1      - senor ID (extracted from transmission header)
220C   - received temperature: 22.0C
3323V  - received voltage: 3.323V
40%    - received humidity (0-99%)
299    - received light amount (0-1023)


The next step I’m thinking of is building a second sensor/transmitter and a better, standalone receiver, probably with some LCD displaying the readings.


All comments/support appreciated as usual.


Cheers,
LJ


If you like my project and/or you would like to support it, please use the Donate button ☺ 
Follow me on Twitter, Google+, YouTube, Thingiverse or by email to receive the latest updates.



Thursday, 9 April 2015

Solar powered wireless weather station - part 1


As TheLAMPA project needs to be put on hold – some parts are on the way, I have decided to start a new one.

This time it will be a solar powered wireless weather station. The concept is:
  1. 10-12 transmitters with solar panels + rechargeable batteries. Each transmitter would send: temperature, humidity, light and battery voltage. 
  2. 1 main station that collects and processes all the data. #
  3. add a screen to the main station to present the data + SD card to keep the recordings/draw history plot. 
  4. OR use a cheap tablet just to  present the data (this would save me a lot of time reinventing the wheel as I would have a large screen with proper driver, lots of memory, nice casing, SQLite, etc. right out of the box.  
Thoughts: 
  1. I’m thinking of ATmega328P, sleeping constantly and waking up every 10-20 seconds, powering up all the sensors, reading temperature from DS18B20, humidity from DHT11, light amount (LDR), voltage of the battery, sending a package over NRF24L01+, turning off all the peripherals and going back to sleep. This would be powered from a  solar mobile charger that has built in Li-ion or LiPo battery. 
  2. Main station would never sleep, constantly waiting for incoming packages from sensors. Each sensor would have unique ID so it will be easy to understand where the data is coming from. Additional it would have a pressure sensor (probably BMP180). 
  3. Long and painful process to implement all the libraries for SD card, graphical LCD, etc. Also, smaller (and cheaper) screens will not show all the data (10 sensors sending 4 values = 40 numbers to present). That’s why I think solution 3b is better 
  4. I would need to add Bluetooth support (probably HC-06) to the main station and then pair it with a tablet/phone. Additional piece of work would be to write a mobile app to present the data but in my opinion it is much easier task than doing it on a microcontroller. Also, the crappiest tablets have at least 256MB of ram, 4-8GB of storage with a screen of at least 1024x600 (most of the time it is 1280x800), clock, nice cover, charging circuit, possibility to install additional apps/libraries when required, SQLite to keep all the historical data. Let’s say that each sensor sends:
    • ID (1-15) – 1 byte (unsigned byte) 
    • Temp -30.0C...+50.0C without decimal point (-300...+500) – 2 bytes (signed char) 
    • Humidity (00-99%) – 1 byte (unsigned byte) 
    • Light (v1) (0-1023) – 2 bytes (unsigned char) 
    • Light (v2) (00-99%) – 1 byte (unsigned byte) 
    • Voltage without decimal point (500 for 5.00V) – 2 bytes (unsigned char) 
    It means I would need 8 bytes of storage per record. 10 sensors = 80 bytes. Even with sending the readings every 10 seconds, I would need to store 80b x 6 times a minute = 0.5kb per minute, which gives 720kb per day. So it is 250MB per year. With 4GB of available memory I could store up to 16 years of historical data. 16GB SD card would provide a lifetime storage.


If you like my project and/or you would like to support it, please use the Donate button ☺ 

Follow me on Twitter, Google+, Thingiverse, YouTube or by email to receive the latest updates.