We developed this project in partnership with JLCPCB and Robo Lúdico School. The used board files are available for download. Download the 2 boards for projects with Arduino.
Figure A - An Arduino Board for your projects.
Figure B - Shield for easy connection of your sensors and other devices to Arduino.
Link to download the Arduino compatible board: https://bit.ly/ArduinoGerberFilesPCB
Link to download the shield: https://bit.ly/3fNSNRI
I made the project with JLCPCB. They released a coupon to earn 5 units of that card. The coupon is: JLC-REBE
The process is simple:
- Download the Gerber files from the project link;
- Visit the website: https://www.jlcpcb.com/PFC
- Upload the Gerber files;
- Apply the JLC-REBE coupon in the payment area.
Let's start the project!
There are often no electrical power sources from the electrical grid to power our devices in the field.
Thus, it is necessary to use a battery to power the device in the field, but the batteries have a limited charge, so they will not be able to power our device for many days.
So there needs to be a charging system for the battery, solar energy is available all day long, so we can use it to charge our battery.
So in this article, we will learn how to use a photovoltaic panel to power the battery charger, thus being able to charge the battery.
We will use the following elements: an Arduino UNO, a BMP 280 sensor, a radio transmitter, to transmit the collected data to the receiver.
So, through this article you will learn:
- Carry out the assembly of the circuit on the breadboard
- Use of the photovoltaic panel, battery charger module TP 4056, Step - Up converter.
- Make the Arduino UNO communicate with the HC 12 module
- Understand how the BMP 280 sensor works
- Understand how serial communication works with a radio transceiver
Now, we will start the complete presentation of the development of the Solar Energy project to power devices in the field.
Development of solar charging system for monitoring devices
The figure below shows the electronic scheme of the project. How does the circuit work?
The solar panel is responsible for receiving sunlight and transmitting energy to the TP4056 charger. Use a Shottky diode between the solar panel and the TP4056 module.
It is used to protect the solar panel against polarity reversal in the battery charger.
Figure 1 – Schematic circuit with the connections of the solar panel and TP4056 charger and Step Up converter.
The battery must be connected to terminals B+ and B- of the TP4056 module. This module has the IC DW01 that protects the battery against overload.
Never use an inappropriate module to charge the battery, as it may explode, be careful.
The Out + and Out – outputs are connected to the Vin + and Vin – terminals of the Step-Up converter. Figure 2 shows the model of Step-Up converters used. This model features a USB output.
Figure 2 – Physical assembly of the battery charging system with the solar panel.
After assembling the charging system, we have the Arduino Uno circuit connected to the BMP 280 Sensor and the HC 12 radio module.
The BMP280 sensor uses I2C communication for data transmission, that is, it uses 2 wires for data transmission SDA (Serial data address) and SCL (Serial clock line) clock signal to send information. See the code below.
#include <SoftwareSerial.h>#include <Adafruit_Sensor.h> //INCLUSÃO DE BIBLIOTECA#include <Adafruit_BMP280.h> //INCLUSÃO DE BIBLIOTECA Adafruit_BMP280 bmp; //OBJETO DO TIPO Adafruit_BMP280 (I2C) SoftwareSerial HC12 (8,7); // RX TX float temp;int pressao,p,t ; byte TX[4];void setup(){ Serial.begin(9600); HC12.begin(9600); if(!bmp.begin(0x76)){ //SE O SENSOR NÃO FOR INICIALIZADO NO ENDEREÇO I2C 0x76, FAZ Serial.println(F("Sensor BMP280 não foi identificado! Verifique as conexões.")); //IMPRIME O TEXTO NO MONITOR SERIAL while(1); //SEMPRE ENTRE NO LOOP }}void loop() { temp = bmp.readTemperature(); pressao = bmp.readPressure(); t= (int)(temp*100); p= pressao; TX[0] = t/255; TX[1] = t%255; TX[2] = p/255; TX[3] = pressao%255; for(int i=0; i<4; i++) { HC12.write(TX[i]); } Serial.print(F("Temperatura: ")); //IMPRIME O TEXTO NO MONITOR SERIAL Serial.print(temp); //IMPRIME NO MONITOR SERIAL A TEMPERATURA Serial.println(" *C (Grau Celsius)"); //IMPRIME O TEXTO NO MONITOR SERIAL Serial.print(F("Pressão: ")); //IMPRIME O TEXTO NO MONITOR SERIAL Serial.print(pressao); //IMPRIME NO MONITOR SERIAL A PRESSÃO Serial.println(" Pa (Pascal)"); //IMPRIME O TEXTO NO MONITOR SERIAL Serial.println("-----------------------------------"); //IMPRIME UMA LINHA NO MONITOR SERIAL delay(2000); //INTERVALO DE 2 SEGUNDOS}
This code 3 libraries were used: Serial Software, Adafruit Sensor, and Adafruit _BMP280.
The Software Serial library is native to the Arduino IDE. Download the Adafruit Sensor and Adafruit BMP280 libraries and install them in the Arduino IDE.
#include <SoftwareSerial.h>#include <Adafruit_Sensor.h>#include <Adafruit_BMP280.h>
After this, we create the BMP object.
Adafruit_BMP280 bmp;
We have configured the two serial communication pins by software to communicate with the HC 12 module.
SoftwareSerial HC12 (8,7); // RX TX
We declare global variables.
float temp; //Variable that will store the temperature value read by the BMP 280 sensor.int pressao,p,t; //Variable that will store the pressure value read by the BMP 280 sensor.byte TX[4]; //Vector that will be used to transmit the temperature and pressure value.
Configuration of the void setup function. In this function, we will configure the Arduino's serial communication speed with the computer and the Arduino's speed with the HC 12 module.
Finally, it checks if there is a connection between the pressure sensor and the Arduino. If not connected, the code flow will enter the while(1) loop.
void setup(){Serial.begin(9600);HC12.begin(9600);if(!bmp.begin(0x76)){Serial.println(F("Sensor BMP280 não foi identificado! Verifique as conexões."));while(1);}}
In the void loop we read the sensor and the collected data are sent to the receiver through the HC 12 radio.
void loop(){temp = bmp.readTemperature();pressao = bmp.readPressure();
After reading, we convert the temperature to an integer value and multiply by 100. This calculation is necessary to transmit the values from the emitter to the receiver. Also, an integer variable occupies fewer bytes than the float variable.
t= (int)(temp*100);
The pressure variable is already of type integer so it is not necessary to convert – it.
p= pressao;
In the TX vector at position 0 we will store the value of the division of t by 255 (1 byte).
TX[0] = t/255;
In the TX vector in position 1 we will store the value of the remainder of the division of t by 255 (1 byte).
TX[1] = t%255;
In the TX vector in position 2 we will store the value of the division of p by 255 (1 byte).
TX[2] = p/255;
In the TX vector in position 3 we will store the value of the remainder of the division of p by 255 (1 byte).
TX[3] = pressao%255;
With the for loop it creates a repeating structure to transmit the 4 positions of the TX vector through the command HC12.write(TX[i]).
for(int i=0; i<4; i++){ HC12.write(TX[i]);}
Finally, we print the message on the serial monitor.
Serial.print(F("Temperatura: ")); //IMPRIME O TEXTO NO MONITOR SERIALSerial.print(temp); //IMPRIME NO MONITOR SERIAL A TEMPERATURASerial.println(" *C (Grau Celsius)"); //IMPRIME O TEXTO NO MONITOR SERIALSerial.print(F("Pressão: ")); //IMPRIME O TEXTO NO MONITOR SERIALSerial.print(pressao); //IMPRIME NO MONITOR SERIAL A PRESSÃOSerial.println(" Pa (Pascal)"); //IMPRIME O TEXTO NO MONITOR SERIALSerial.println("-----------------------------------"); //IMPRIME UMA LINHA NO MONITOR SERIALdelay(2000); //INTERVALO DE 2 SEGUNDOS}
In the figure below we have the temperature and pressure values displayed on the Arduino IDE Serial monitor.
Figure 4 - Serial monitor displaying measured values of temperature and pressure.
This data will be received by the HC-12 receiver module.
Conclusion
In this article, you learned how to create a climate monitoring system for places with difficult access to electricity. This system was created using a solar panel to charge a 18650 battery and a STEP-UP converter to power the Arduino.
In the next article, we will develop the receiver of these variables using the Arduino Mega and the HC12 module.
We developed this project in partnership with JLCPCB and Robo Lúdico School. The used board files are available for download. Download the 2 boards for projects with Arduino.
Figure A - An Arduino Board for your projects.
Figure B - Shield for easy connection of your sensors and other devices to Arduino.
Link to download the Arduino compatible board: https://bit.ly/ArduinoGerberFilesPCB
Link to download the shield: https://bit.ly/3fNSNRI
I made the project with JLCPCB. They released a coupon to earn 5 units of that card. The coupon is: JLC-REBE
The process is simple:
- Download the gerbers files from the project link;
- Visit the website: https://www.jlcpcb.com/PFC
- Upload the Gerber files;
- Apply the JLC-REBE coupon in the payment area.