DIY Small Weather Station (Single Battery Powered)

Publisher:hfy13567003617Latest update time:2022-06-27 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

It has been running at low power consumption for 91 days, the equipment has been shut down and no longer transmits data, and has not reached the 135-day goal;

insert image description here

Figure 1: The housing is dirty and the spring gasket does not appear to be stainless steel. It has taken effect.

insert image description here

Figure 2: After unscrewing the four screws, the interior is clean and free of water stains

insert image description here

Figure 3: The internal circuit is intact and continues to work after replacing the battery


//———————————————————————————————

The device has a certain waterproof capability. During outdoor operation, there was occasional light to moderate rain, but it did not affect the device.

//———————————————————————————————


Material

Power supply: 1 18650 battery (2000mah)

Main control: N76E003 microcontroller

Sensors: BMP180 air pressure sensor, BH1750 light sensor

Wireless serial port module: LC12S (2.4G)

LDO:XC6204

Shell: 3D printed PLA

Development environment: KEIL4


Circuit

insert image description here

PPG and PPG1 are push-pull outputs, which are used to power the sensor and provide pull-up power to the IIC bus.

CS1 is the sleep control pin of the wireless serial port module, which is set to open-drain output. (See the figure below for its features)

insert image description here

For some commonly used peripherals, it is certainly not ideal to connect them directly to the microcontroller power supply circuit. Even if they are low-power devices, even if they have a sleep mode, the current consumption is very high. What should we do?

1. Separate power supply: For some high-power peripherals, such as wireless communication modules, a MOS switch can be used to control whether to power the peripherals. For some low-power devices, such as op amps and memories, the actual maximum current consumption can be combined to directly use the I/O port to output a high level to power the chip. The I/O port can generally output 6-20ma, PP mode. Of course, don't forget to connect a very small resistor in series, 10 ohms, and the decoupling capacitor of the peripheral cannot be too large. If one I/O is not enough, you can use two to supply it together.

Make the output voltage of the voltage regulator slightly higher than the battery voltage, so that the battery will not be consumed when powered by an external power supply


Operation Logic

As can be seen from the above picture, this DIY does not have any external power supply (originally wanted to use solar energy, but gave up because of some well-known problems), the purpose is to test the ability of the N76E003 microcontroller to run with low power consumption (it had been running for 8 days before, and the lithium battery voltage dropped by 0.04V).


This experiment still uses the timed wake-up function of the N76E003 microcontroller, waking up once every 50 seconds, turning on the peripherals once an hour, and waking up the wireless serial port module to send detection data. After the transmission is completed, all peripherals are turned off, the push-pull mode is set low, and the wireless serial port module enters sleep mode.


For information about N76E003 MCU low power processing, please see here N76E003 Low Power Consumption (Power-down Mode & Timed Wake-up)


Structural design

Assembly drawing (the shell is still being printed, which will take about eight hours, and the finished product drawing will be added later)

insert image description here

Base (all with M4 screw holes)

insert image description here

Top cover (the protrusions on both sides are vent baffles to prevent rainwater from pouring in directly; the top opening is for the BH1750 light sensor)

insert image description here

The picture below shows the actual picture of the completed assembly. The bottom is provided with suction by four NdFeB. It is currently installed on the air conditioner outdoor unit.

insert image description here
insert image description here
insert image description here

data analysis

insert image description here

They are temperature, pressure, and light intensity. Through the above data, we can roughly analyze the daily sunset and sunrise, as well as temperature changes.


Main program code

#include "N76E003.h"

#include "Common.h"

#include "Delay.h"

#include "SFR_Macro.h"

#include "Function_define.h"

#include "BMP180.h"

#include "BH1750.h"


#define uint unsigned int

#define uchar unsigned  char


uchar abc[17]; //Serial port send buffer

uint WktCount=0;

bit WktFlag=0;


sbit CS1=P0^5; //CS sleep pin, open drain output

sbit PPG=P1^7; //power supply pin, push-pull output

sbit PPG1=P3^0; //same as above



int main (void)

{

int i;

Set_All_GPIO_Quasi_Mode;

P05_OpenDrain_Mode; //Set to open drain mode

P13_OpenDrain_Mode; //Set to open drain mode

P14_OpenDrain_Mode; //Set to open drain mode

P17_PushPull_Mode; //Push-pull output

P30_PushPull_Mode;

//----------I/O port layout----------------

CS1=1; //Wireless module sleep

PPG=0; //Turn off the power supply of peripheral devices

PPG1=0;

set_P06;

    set_P07; //Initialize the serial port   

//---------I/O port initialization------------

Init_BH1750(); //Initialize the light sensor  

set_ES_1; // Enable serial port 1 interrupt

InitialUART0_Timer1(9600);

//----------Serial port 1, serial port 0 configuration---------------- 

WKCON = 0x07; //Pre-scaling configuration 2048

RWK =255-211; //Set to 50s timing - 72 for one hour

set_EWKT; //Enable timer wake-up interrupt

set_WKTR; //Run the timer wake-up function

//----------WKT configuration------------------------

EA = 1; // Enable general interrupt

while(1)

{

if(WktFlag) //Determine if overflow

{

WktCount++;

WktFlag=0;

if(WktCount>=72)//send once every 1h

{

PPG=1; //Push-pull output, power supply for peripheral devices

PPG1=1;

CS1=0; //Pull low, ground to wake up the wireless transparent transmission module

Timer3_Delay100ms(1);


Init_BMP085(); //Initialize the barometer

bmp085Convert();

Timer3_Delay100ms(1);

EC_BH1750(); //Convert light intensity

abc[0]=0x54; //T temperature

abc[1]=temperature/100+48;

abc[2]=temperature%100/10+48;

abc[3]=0x2e;

abc[4]=temperature%10+48;

abc[5]=0x50; //P pressure

abc[6]=pressure/10000+48;

abc[7]=pressure%10000/1000+48;

abc[8]=pressure%1000/100+48;

abc[9]=0x4c; //L light

abc[10]=(int)BH1750_temp/10000+48;

abc[11]=(int)BH1750_temp%10000/1000+48;

abc[12]=(int)BH1750_temp%1000/100+48;

abc[13]=(int)BH1750_temp%100/10+48;

abc[14]=(int)BH1750_temp%10+48;

for(i=0;i<15;i++)

{

Send_Data_To_UART0(abc[i]);

}

WktCount=0;

}

ADCCON1 = 0X00; // Turn off ADC

clr_BODEN; //Disable undervoltage detection

set_PD; // Enter power-down mode

PPG=0; //Turn off the power supply of peripheral devices

PPG1=0;

CS1=1; //Wireless module enters sleep mode

}

}

}

//---------Timed wake-up interrupt service routine--------------

void WakeUp_Timer_ISR (void)   interrupt 17    

{

WktFlag=1;

  clr_WKTF; //Clear WKT overflow flag  

}


Summarize

Looking back at the previous blogs (articles on driving various sensors), I can see that I initially wanted to add GP2Y1010 (dust detection), DHT11 (temperature and humidity), HMC5883 (electronic compass), photoelectric encoder, etc. to measure wind speed and direction (see the figure below). Later, I gave up one by one due to size and power supply issues. The second is the lack of a good host computer. In the next few days, I will focus on learning python and QT, hoping to enter a new world.

insert image description here

Reference address:DIY Small Weather Station (Single Battery Powered)

Previous article:N76E003 HMC5883
Next article:N76E003 Ultrasonic Distance Measurement

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号