Tuesday, July 18, 2017

Solar charger teardown

Several YouTube video review channels do sometimes a product teardown. When i ordered two of this Aliexpress i had no plans to do a teardown.
solar chargers at
When i orderd the power banks in february 2017 the Pcs 8000 mah Portable Solar Power Bank waterproof Enternal battery power bank phone charger for Iphone HTC Lenovo Mipad did cost € 6,51 each and i wanted to test them to use them for IOT devices, perhaps outdoor. and low power.


Features (according to seller):
8000mAh solar charger external battery power bank
Build-in 8000mAh lithium polymer battery
Super waterproof and dustproof.
Strong shockproof and drop resistance.
With dual USB and micro USB ports.
Emergency LED torch, the LED flashlight works perfectly in darkness, especially for emergency.
4 LED status of charge indicators indicate the charging and discharging process
Environmentally friendly silica gel and ABS+PC materials, and rubber paint surface process
Compact, portable & stylish design.
Specifications:
Model:S69
Battery Capacity: 8000mAh Li-polymer battery
Solar panel: 5V, 200mA
Power: 4W
Input: DC 5V/ 1A
Output: DC 5V/ 2 x 1A
Product size: 142* 75*13.6mm
Operation Temperature: 0-45 degree
Weight:140 g
Compatible: for iPhone, iPad, Android phone, GPS device, camera (most devices that use a USB cable to charge).
Color: ... (several colors available)

The package included:
1 x Solar Charger
1 x Free carabiner
1 x Micro USB charging cable

Super waterproof and dustproof, strong shockproof and drop resistance. That would be nice for an outdoor IOT application.
( Now in july the seller only has e.g. Vidar waterproof 5000mah solar power bank polymer-Li portable solar charger. I can not find "my" 8000 mah version for a comparable price (yes i found some other 8000 mah power banks.)
One of the solar devices was put in my car under the window. I almost did forget it and now a semi automatic teardown has happened. Due to the heat of the sun one the power banks has opened itself.
Warning on the package!!
It was warm here in the Netherlands, but not extreme hot.
In a car behind the window the temperature can rise quick. In the specs/description an operation temperature of 0-45 degrees is mentioned.
I posted this as a warning do not let the powerbank in your car behind the glass and to show pictures of the solar powerbank and the batteries after further opening it.  One of the batteries has changed of shape and the enclosure can not be closed anymore.

 I did not a complete teardown as i wanted to rescue parts and the enclose. (And perhaps build an IOT device inside it). To look inside i opened it a bit more.  You can see the solar cell, a PCB and two (different) battery packs in parallel. According to the specs these two packs can deliver together the 8000 mah.




Monday, July 17, 2017

Microwave Radar Sensor RCWL-0516 with Arduino Uno

The Microwave Radar Sensor RCWL-0516 is an interesting cheap motion sensor.
At Aliexpress i found 5 pieces for  € 2,19 => € 0,44 / piece.

Info how to wire the device and a test program was found on https://www.14core.com/wiring-the-rcwl0516-auto-induction-doppler-microwave-radar-with-esp826632arduino/

I soldered some wires with Dupont connectors to one of my RCWL-0516 modules and tested the program with an Arduino Uno (clone). Not yet with ESP8266, perhaps that will come in another RCWL-0516 post. It found some little errors that i needed to corrected. When changing the program i also did put the serial output on one line for each change with a millis() timestamp.


The program after my changes:


/* 14CORE | DOPPLER RADAR TEST CODE 
*************************************
From https://www.14core.com/wiring-the-rcwl0516-auto-induction-doppler-microwave-radar-with-esp826632arduino/
Modified
2017 July 17 by @JanJeronimus  / Correction 'bool sens;'& 115200 /  Output one line , added additional and spacesMillis() 
*/
static bool value = -1;
bool sense;

const int8_t Output = 13;
#ifdef ESP8266
const int8_t sensor = D2;
#else
const int8_t sensor = 2;
#endif

void setup(){
Serial.begin(115200);
#ifdef ESP8266
Serial.println(" 14CORE | DOPPLER RADAR TEST CODE");
Serial.println("==================================");
Serial.println("ESP8266 Started......");
digitalWrite(Output,1);
#else
Serial.println("Arduino MCU Started......");
digitalWrite(Output,0);
#endif
pinMode(Output, OUTPUT);
pinMode(sensor, INPUT);
}

void loop(){  
sense = digitalRead(sensor);
if (sense != value){
  Serial.print( millis()); 
  Serial.print(" Raw Value : ");
  Serial.print(sensor);
  Serial.println(sense ? " +HIGH" : " -LOW");   
#ifdef ESP8266
  digitalWrite(Output, ! sense);
#else
  digitalWrite(Output, sense);
#endif
  value = sense;
  }
  delay(20);
}

To use the program you need to connect 3 pins
GND
OUT - connect this to an input pin (Arduino D2)
VIN 4 to 28 volt
It seems the CDS pin can be used to disable detection. You need not to connect it.
The 3V3 pin is for output not input!  (Interesting to try if it can be used to power an ESP8266!)

The sensor works fine and can detect motion even behind obstacles. It can detect motion at about 3 to 4 meter distance.

Some other references

Two videos about the RCWL-0516 by nenioc187 :



Specs & Pin info :
  https://www.elecrow.com/rcwl-0516-microwave-radar-sensor-switch-module-body-induction-module-4-28v-100ma.html

 https://github.com/jdesbonnet/RCWL-0516/

Tuesday, July 11, 2017

TM1638 8 bit digital Led module (1)


On Aliexpress i found this Key Display "For AVR Arduino" "New" 8-Bit Digital LED Tube 8-Bit TM1638 Module. I did put some quotes" in the name as this module is not for Arduino only, it can be used also in projects with other microcontrollers e.g. the ESP8266.
TM1638 module - Front
For this module i payed 2017Q1 only € 1,32 . Relative cheap for a module that only needs 3 lines from your microcontroller and gives you
  • 8 keys
  • 8 LEDs common cathode
  • 8 a digital 7 segment displays
The magic is done using the TM1638 digital tube drive chip.
For the wiring connect VCC GND to a 5V supply and connect STB CLK DIO to the microcontroller IO ports. Scanning display and key scan don't need microcontroller intervention, only need to register to display data related to reading and writing or testing buttons, save MCU resources.
The only disadvantage i found is, when putting this module in an enclosure the female connections pins of this module are pointing to the front. Depending of the enclosure you need to remove, bend or put them on the back side of the module.

I tested it with an Arduino (clone).
Sketch to test the display:
/*
 * Testing the TM1638 board
 Display test:
Programs dislights some leds and display
See code for details
Hardware connections: 
 Arduino              TM1638 based board
 3.3V   ------------------ VCC
 GND    ------------------ GND
 PIN #7 ------------------ STB
 PIN #8 ------------------ DIO
 PIN #9 ------------------ CLK

 Source
 https://blog.3d-logic.com/2015/01/10/using-a-tm1638-based-board-with-arduino/
 8 july 2017  JanJeronimus
*/

const int strobe = 7;
const int clock = 9;
const int data = 8;

void sendCommand(uint8_t value)
{
  digitalWrite(strobe, LOW);
  shiftOut(data, clock, LSBFIRST, value);
  digitalWrite(strobe, HIGH);
}

void reset()
{
  sendCommand(0x40); // set auto increment mode
  digitalWrite(strobe, LOW);
  shiftOut(data, clock, LSBFIRST, 0xc0);   // set starting address to 0
  for(uint8_t i = 0; i < 16; i++)
  {
    shiftOut(data, clock, LSBFIRST, 0x00);
  }
  digitalWrite(strobe, HIGH);
}

void setup()
{
  pinMode(strobe, OUTPUT);
  pinMode(clock, OUTPUT);
  pinMode(data, OUTPUT);

  sendCommand(0x8f);  // activate and set brightness to max
  reset();
}

void loop()
{
  sendCommand(0x44);  // set single address

  digitalWrite(strobe, LOW);
  shiftOut(data, clock, LSBFIRST, 0xc0); // 1st digit
  shiftOut(data, clock, LSBFIRST, 0xff);
  digitalWrite(strobe, HIGH);

  digitalWrite(strobe, LOW);
  shiftOut(data, clock, LSBFIRST, 0xc5); // 3rd LED
  shiftOut(data, clock, LSBFIRST, 0x01);
  digitalWrite(strobe, HIGH);

  digitalWrite(strobe, LOW);
  shiftOut(data, clock, LSBFIRST, 0xcb); // 3rd LED
  shiftOut(data, clock, LSBFIRST, 0x01);
  digitalWrite(strobe, HIGH);

  digitalWrite(strobe, LOW);
  shiftOut(data, clock, LSBFIRST, 0xce); // last digit
  shiftOut(data, clock, LSBFIRST, 0xff);
  digitalWrite(strobe, HIGH);
}

Arduino Uno (clone) with TM1638 display (and key) module.


Sketch to test input keys
./*
 * Testing the TM1638 board
 Button test:
 Progam scans buttons. If button pressed the led over the button will be lit
Hardware connections: 
 Arduino              TM1638 based board
 3.3V   ------------------ VCC
 GND    ------------------ GND
 PIN #7 ------------------ STB
 PIN #8 ------------------ DIO
 PIN #9 ------------------ CLK

 Source
 https://blog.3d-logic.com/2015/01/10/using-a-tm1638-based-board-with-arduino/
 8 july 2017  JanJeronimus
*/

const int strobe = 7;
const int clock = 9;
const int data = 8;

void sendCommand(uint8_t value)
{
  digitalWrite(strobe, LOW);
  shiftOut(data, clock, LSBFIRST, value);
  digitalWrite(strobe, HIGH);
}

void reset()
{
  sendCommand(0x40); // set auto increment mode
  digitalWrite(strobe, LOW);
  shiftOut(data, clock, LSBFIRST, 0xc0);   // set starting address to 0
  for(uint8_t i = 0; i < 16; i++)
  {
    shiftOut(data, clock, LSBFIRST, 0x00);
  }
  digitalWrite(strobe, HIGH);
}

void setup()
{
  pinMode(strobe, OUTPUT);
  pinMode(clock, OUTPUT);
  pinMode(data, OUTPUT);

  sendCommand(0x8f);  // activate and set brightness to max
  reset();
}

uint8_t readButtons(void)
{
  uint8_t buttons = 0;
  digitalWrite(strobe, LOW);
  shiftOut(data, clock, LSBFIRST, 0x42);

  pinMode(data, INPUT);

  for (uint8_t i = 0; i < 4; i++)
  {
    uint8_t v = shiftIn(data, clock, LSBFIRST) << i;
    buttons |= v;
  }

  pinMode(data, OUTPUT);
  digitalWrite(strobe, HIGH);
  return buttons;
}

void setLed(uint8_t value, uint8_t position)
{
  pinMode(data, OUTPUT);

  sendCommand(0x44);
  digitalWrite(strobe, LOW);
  shiftOut(data, clock, LSBFIRST, 0xC1 + (position << 1));
  shiftOut(data, clock, LSBFIRST, value);
  digitalWrite(strobe, HIGH);
}

void loop()
{
  uint8_t buttons = readButtons();

  for(uint8_t position = 0; position < 8; position++)
  {
    uint8_t mask = 0x1 << position;

    setLed(buttons & mask ? 1 : 0, position);
  }
}

Back side
There exists also a library to easy program this module.

Tuesday, July 4, 2017

Lora RFM95 breadboard friendly

The RFM95 LoRa module is standard not breadboard friendly. One of my RFM95 modules was used to make a one channel gateway. See details in a previous post on my blog.
A second module i made breadboard friendly using a 16 pin dip IC socket. The RFM95 module was joined to the IC socket with wires.
From the ground wires only one wire was connected from the dip socket to the three ground connections on the RFM95 module.
The antenna output was not connected to the dip socket. I added a 8,2 cm wire as antenna to this module.
As 3 pins of the 16pin dip socket are not connected to the RFM95 module. (The antenna and 2 of the 3 ground connections) also a 14 pin dip socket can be used.
I used a 16 pin version as this 16 pin socket that i had in stock has a better connection to the breadboard than the 14 pin version.
I have plans to use the 3 spare pins later to add some components. E.g. one pin connected to DIO0, DIO1 and DIO2 with diodes as used in some circuits / one or more leds (power led) or some sensor(s). Before adding this items want to do some tests first on a breadboard.
RFM95 connections
DIO2GND
DIO1MISO
DIO0MOSI
3.3VSCK
DIO4NSS
DIO3RESET
GND(1)DIO5
ANA(2)GND(1)
Not on 16 pin dip:
(1) GND all connected to one GND
(2) Antenna (wire antenna, not to 16 pin socket)

To test this module i wired it to a Wemos D1 mini the same way as my First (One Channel) LoRa Gateway, adapted the sketch (name of gateway/server) and uploaded it.
On the breadboard you can already see some diodes as used in some circuits and also a push button. They are not used in the circuit. Only the wire connections as in my first RFM95 - Wemos D1 mini LoRa gateway where made. This circuit worked just as my first 1CH gateway !!
Connections (for 1CH LoRa gateway):
RFM95 pinWemos D1 mini
(ESP8266) pin
3.3V3.3V
GNDGND
MISOD6 GPIO12/MISO
MOSID7 GPIO13/MOSI
SCKD5 GPIO14/CLK
NSSD8 GPIO15/CS
RESET*nc
DIO0D1, GPIO5
Wemos D1 mini  connected to RFM95 module