Sunday, March 11, 2018

ESP8266 powered by a solar panel and a 18650 battery

On my setup described in here I've added this solar panel from Banggood. If in the past the maximum of battery operated was around 48 days on one charge, now with the help from solar panel I am expecting to run 24/7 without the need to recharge the battery myself.

The panel has dimensions 165x135x2mm and is made from monocrystalline silicon and is rated to 6W and 580 mA.
Exposing it to full sun will produce 6.54 volts and after the diode (I've used a 1N4007) will have 6.00 V.

To connect the solar panel to charger board I've cut a USB to micro-USB cable and I've soldered the part with the micro-USB to the solar panel. The micro-USB cable now can be plugged directly into the charger in its micro-USB connector.

The entire setup is now made from:

Wemos ESP8266  - 1pcs
Wemos Lithium charger board - 1pcs - this is an old version or Wemos Lithium charger board - 1pcs - the new version
BMP180 temperature and pressure sensor - 1pcs.
Battery 18650 -1pcs
Battery holder - 1pcs

The code is the same as in the original post in here.

This is the picture with the module and the LED being GREEN ( battery is fully charged )
Green LED - fully charged

And the entire module with solar panel attached to the window.

The entire module with solar power.

Just after I've added the solar panel the voltage of the battery has start to increase.

Just connected the solar panel to the charger

Now after few days you can see that what is consumed during the night and during the day when there is not enough sun will be recovered in few hour of sun. The panel is mounted to a window where is having sunlight for three four hours in the afternoon.

In the next picture you can see four peaks (one every day), where the charger actually stopped the charging of battery. The charger is cutting the power to the battery at 4.26 - 4.27 V. You can see that by looking to the LED on the charger board that will light green. In the led is red it means that the charger is charging the battery. If there is not enough sun the led will be off which is good because will not drain the battery.
4 days run on solar panel

Now it will run forever and I don't need to load the battery every 48 days.

This is the current voltage on my setup in real time:

After a two days without any sun ( two days of rain) you can see that there are no peeks of fully charged. You can see this in the picture bellow.

Two days without sun, so there are no peeks

It will be interesting to see if the battery will be fully charged again in the next days with sun.

As you can see in few hours with sun the battery is full again, recovering after a two cloudy days. The LED is green again now.

LED is green again, battery is fully charged
I've let the module to work exclusively on battery for 10 days. I've reconnected the solar panel and in two hours the battery was again fully charged.

Solar panel connected after 10 days on battery

(- I will continue to update this post - )

Thursday, December 21, 2017

Very good offer for books and videos from Packt Pub. On eBook $5

Packt Publishing has a new offer, for $5 you can get a lot of eBooks and videos.

Click here for a list. There are over 4000 books and over 1000 videos to choose from.

Saturday, December 2, 2017

New book on how to made a complete ready-to-sell home automated system with ESP8266

I've been busy in the latest months writing a book  to cover some key aspects of the ESP8266 ecosystem, the chip, the cloud and a mobile application.

The book will teach you and will give you a ready-to-sell solution for an IoT product.

You will discover how to work with the GPIOs on the ESP8266, how to build your basic thermostat for your house, how to control it from your mobile with your own cloud system based on MQTT.

Securing the data using authentication at the broker level and SSL is explained in a special chapter. 

Real-time communication has a dedicated chapter where you will learn how to send real-time data from an ESP8266 to an nodejs server.

You can buy the book from Amazon

I hope that you will enjoy the book.

BME280 and ESP8266

Latest environmental sensor from Bosh is the BME280 which can measure:

  • temperature
  • humidity
  • pressure

and can be found in mobile phones (Nexus 5). There are rumors  that the BMP280 is a BME280 which couldn't be calibrated for humidity, but I have no confirmation on this.


Can be used for:

  • Indoor navigation (based on changing the measured altitude - pressure)
  • Outdoor navigation
  • Weather forecast
  • Home application control
  • Context awareness ( change room detection)  
  • Internet of Things.

Temperature precision is ± 1 C degree in 0-60C range.

Can be found in multiple modules, from SPI connectivity to I2C.

Make sure that if you are using the I2C version  to change the I2C address to 0x76. ( Default value for I2C address in Adafruit's library is 0x77).

I2C version

The SPI version can be found around USD 5 here.

Code is similar with the BMP280 , just read the humidity

 * Catalin Batrinu 
 * Read temperature, humidity and pressure from BME280
 * and send it to

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#include <ESP8266WiFi.h>

Adafruit_BME280 bme; // I2C
// replace with your channel’s thingspeak API key,
String apiKey = "YOUR-API-KEY";
const char* ssid = "YOUR-SSID";
const char* password = "YOUR-ROUTER-PASSWORD";
const char* server = "";
WiFiClient client;

 *   S E T U P
void setup() {
  Serial.println(F("BMP280 test"));
  if (!bme.begin()) {  
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  WiFi.begin(ssid, password);
  Serial.print("Connecting to ");
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) 
  Serial.println("WiFi connected");  

 *  L O O P
void loop() {

    if (client.connect(server,80))  // "" or
        String postStr = apiKey;
        postStr +="&field1=";
        postStr += String(bme.readTemperature());
        postStr +="&field2=";
        postStr += String(bme.readHumidity());
        postStr +="&field3=";
        postStr += String(bme.readPressure() / 100.0F);
        postStr += "\r\n\r\n";
        client.print("POST /update HTTP/1.1\n");
        client.print("Connection: close\n");
        client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
        client.print("Content-Type: application/x-www-form-urlencoded\n");
        client.print("Content-Length: ");
    //every 20 sec   

If your readings are with almost 2 degrees more than the expected value is because the BME280 is to close to the ESP8266. Try to keep at least 10 cm between the BME280 and ESP8266 to eliminate the RF heating and heating produced by ESP8266. 

Also is possible that you run the BME280 in normal mode ( more samples per second) versus forced mode when you are reading the values exactly when you need them ( here the drift is around 0.6 degrees Celsius).

The complete datasheet can be found here.

Sunday, November 12, 2017

Getting air quality with ESP8266 and Amazon Alexa

If last week I've managed to get the temperature and humidity with ESP8266 and Alexa, now it's time to integrate the air quality sensor GP2Y1010AU0F from Sharp.

The GP2Y1010AU0F it is a compact optical dust sensor that has an infrared emitting diode and a phototransistor that are diagonally arranged. It detects in fact the reflected light of the present dust in the air. It is effective to detect very fine particle like cigarette smoke and it can distinguish from the house smoke from the house dust.

GP2Y1010AU0F sensor.
It has 6 pins and the electronic inside is split in two parts, the IRED emitting part and the phototransistor (receiving part)

Internal schematic
For the Air quality module I've used an wemos D1 board. The datasheet for the GP2Y1010AU0F is referring as VCC and the provided output by using a 5V power supply. Since the ESP8266 on analog input is limited to 1V and the wemos D1 is having an 220K and a 100K divider, I've choose to power the transmitter part to 5V and the receiver part with 3V3.

According to the specification in the datasheet also you will need an 150 ohm resistor and a 220uF capacitor, both came with the package.

Connect them according to the datasheet.

Resistor and capacitor

The provided analog output is proportional with the number of the dust particle in the air. Powering the phototransistor part with 3V3 will not get exact the output graph from the datasheet unless you will not use the 5V Vcc. If you need to be 100% to the datasheet and you are using an wemos D1, add a resistor in series with the output VO (pin 5) so the maximum voltage on the A0 input will not exceed 1V. Probably an 180k resistor will be fine.

Output voltage vs dust density

Based on the output voltage you can setup some steps for the air quality like excellent, very good, good, fair or dusty.

Here is a video clip on how is working with platform and Amazon Alexa.

Now eNVi-A is online. Total cost: 18.50 euro.