woensdag 2 augustus 2017

Voice control V3 (Part 1)

An interesting input device is the ElecHouse Voice Recognition Module V3. It comes with a microphone and some pins to solder on the PCB. I ordered my "1set Speed Recognition, Voice Recognition Module V3" module on Aliexpress (between 17 and 18 euro 2017).
Voice Recognizer V3 & Arduino Uno
The question is what can this module do for your projects and how can you use it? The answer is simple: it  can recognize your voice and output a signal depending on the word or short phrase that you have learned the module. The good news is that (according to the spec) you can train this relative cheap module to recognize 80 words or phrases. These words or phrases are stored in memory on the module. The bad news is the module can only recognize 7 different phrases at the same time. And you also need to train the system first with all your phrases.
You can create a system that knows what to do with commands like:

"James light on"
"James light off"
"James light color white"
"James light color green"
"James light color blue"
"James light color yellow"

"James light dim 25"
"James light dim 50"
"James light dim 75"
"James light dim 100"

"James TV off"
"James TV on"
"James TV channel next"
"James TV channel prev"
"James TV channel one"

"James Radio on"
"James Radio off"

And yes, this are much more than 7 phrases! You can do this using a menu structure!

Teach the system all the separate words ("James", "light", "TV" ," Radio" "color" etc.)
Load only the word "James". If the module recognizes "James" load the three words "light" "TV" Radio" if the module recognizes "light", load the words "on" "off" "color" "dim" and build a menu system.
You can get the same (or even better) effect with Amazon Alexa or a Google app on your android. Using this module the voice recognition finds happens inside the module. You do not need internet access and perhaps even more important the privacy: The audio is not transmitted to the internet.

A small disadvantage is that you need to train the module. My first test of the module was with an Ardhuino Uno. The ElecHouse website has a link Arduino library with some examples including a voice training example. Connect GND and VCC (5v) , RXD to Arduino pin 3 and TXD to Arduino pin 2. (If you do not like to use pin 2 and 3 you can use other pins. However you need to make a small change in the software). You only need to connect this four pins on the V3 module (and the included microphone) to a working Arduino to start.

Some info from ElecHouse about the module:
ELECHOUSE Voice Recognition Module is a compact and easy-control speaking recognition board.
This product is a speaker-dependent voice recognition module. It supports up to 80 voice commands in all. Max 7 voice commands could work at the same time. Any sound could be trained as command. Users need to train the module first before let it recognizing any voice command.
This board has 2 controlling ways: Serial Port (full function), General Input Pins (part of function). General Output Pins on the board could generate several kinds of waves while corresponding voice command was recognized.
What's new?
We already have Voice Recognition module V2. It supports 15 commands in all and only 5 commands at the same time.
On V2, voice commands are separated into 3 groups while you training it. And only one group (5 commands) could to be imported into Recognizer. It means only 5 voice commands are effective at the same time.
On V3, voice commands are stored in one large group like a library. Any 7 voice commands in the library could be imported into recognizer. It means 7 commands are effective at the same time.
Parameter
Voltage: 4.5-5.5V
Current: <40mA
Digital Interface: 5V TTL level for UART interface and GPIO
Analog Interface: 3.5mm mono-channel microphone connector + microphone pin interface
Size: 31mm x 50mm
Recognition accuracy: 99% (under ideal environment)
Feature
Support maximum 80 voice commands, with each voice 1500ms (one or two words speaking)
Maximum 7 voice commands effective at same time
library is supplied
Easy Control: UART/GPIO

On internet is a lot more info about this and similar modules. Here is link to a YouTube video : S134 - Voice Recognition Module V3

dinsdag 18 juli 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.




maandag 17 juli 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/

dinsdag 11 juli 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.

dinsdag 4 juli 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

donderdag 22 juni 2017

PAM8403_Amplifier

At Aliexpress i ordered 5pcs/lot PAM8403 Super mini digital amplifier board 2 * 3W Class D digital amplifier board efficient 2.5 to 5V USB power supply for 0,87 euro.
That is about 18 euro cents for a stereo amplifier module! This module has no potentiometer to regulate the output volume.
There are also other PAM8403 modules available, some with potentiometer(s).
There are also PAM8403 modules with potentiometer but they are much more expensive ( 0,57 euro )
On one i soldered Dupont connectors for easy access to us it on a breadboard or other temporary experiments. On another i soldered wires to two cheap mini speakers and also some Dupont connectors.


Interesting very cheap
 amplifier !


woensdag 21 juni 2017

My First Lora Gateway

FRM95
RFM95 back LoRa breakout

As i like doing some projects with IoT i also wanted to experiment with LoRa.
Some time ago i ordered a cheap LoRa shield for my Arduino. Unfortunate i did not get it working. I could not find out if it was something with the code, the jumper settings, a hardware error or perhaps my shield could not reach a LoRa gateway in Almere.
Perhaps in another LoRa post in my blog you will read more about this shield.
RFM95 front LoRa breakout

When asking advice someone was so friendly to send me documentation to make a simple one channel test LoRa gateway with an RFM95 and a Wemos D1 mini.

On Aliexpress i found two RFM95 breakout boards for 13 Euro so i decided to order them. I have done several experiments and projects with different ESP8266 boards but until now i never used the Wemos version.
Between the  RFM95 and the  Wemos D1 mini (ESP8266) you need to make the some connections.
Wemos D1 mini
Wemos D1 mini
According to a descriptions i connected this:
RFM95 pinESP8266 pin
3.3V3.3V
GNDGND
MISOD6 GPIO12/MISO
MOSID7 GPIO13/MOSI
SCKD5 GPIO14/CLK
NSSD8 GPIO15/CS
RESET*nc
DIO0D1, GPIO5

The Wemos D1 mini came with 2 sets of male pins, 2 sets of female pins and 2 sets of female with long male pins. I decided to build the circuit on a small prototype PCB board. (It is also possible to order a Wemos PCB for the RFM95 or connect them direct.)
I decided to solder the female with long male pins on the Wemos D1 mini. On the PCB i soldered the two sets of female pins so i could separate the ESP8266 from the circuit if needed. As the Wemos can be put in two ways in the connector of the PCB i marked the side of the Antenna.
The Lora RFM95 is not breadboard friendly. I soldered it direct on the prototype PCB next to female pins for the Wifi ESP8266 Wemos module. Each RFM95 pin (except the Antenna pin) is connected to a Dupont male pin. To the Antenna pin i soldered a 8,2 cm wire to use this as a first test antenna. (Perhaps after some testing i change this to an SMA connector as in the documentation.)
After this is soldered the wires between the RFM95 and the Wemos connector on the PCB as in the table above. (Most of these connections are made on the copper side of the PCB so you can not see them on the pictures in this blog article!) 
I added a button between D4 and ground to have a simple input button to test the ESP8266
The Wemos D1 mini already has a Reset button.
Next to the GND and 5V of the Wemos i added male pins to have easy access to GND and 5V and there is also a third pin connected to the 3V3. I only have tested my module by powering via USB
I tried to connect the Wemos to my computer using USB. At first it did not work as i used an USB power cable instead of an USB data cable. (I think i need to label my USB cables!).
After finding the right cable i tried to upload the Blinck sketch first to test the connection and the Wemos module.
I got the system message "Error board is unknown / (Package ESP8266 )" and solved this problem (
http://arduino-esp8266.readthedocs.io/en/latest/faq/a04-board-generic-is-unknown.html )
In the directory ' Users\<MyName>\Arduino15\packages\esp8266\hardware\esp8266 '  i needed to manual clean up old software. So i removed there everything and Blinck worked.

Now the 1ch Wemos gateway software. When installing this on my computer "Time" was already installed on my computer. As i did not know if this was the right version i decided to rename the old version.
Stupid as this did not work. When starting the Arduino software to upload it to my Wemos i got an error message that there where two versions of "Time" with a link to my renamed version.
So i moved my old "Time" version to another directory and this problem was solved.
Now i got the error message "Documents\Arduino\ESP-sc-gway30\ESP-sc-gway30.ino:67:92: fatal error: gBase64.h: No such file or directory"
Googled and installed another "base64" but this did not solve my problem.
Finally i found the latest 1ch gateway software ( Version 4. ) . This package included gbase64 and after adapting the configuration parameters it worked.
The error message "The management functions only work over _THINGPORT and not over _TTNPORT" also went away by adapting the parameters.
In the end i got a working 1 channel test LoRa gateway. The IP address of the Wemos ESP8266 gives a simple webpage to check and configure some parameters,
Some things i want to do with this device:
- testing this gateway with another LoRa device (my Arduino LoRa shield?),
- putting this device in an enclosure
- adding connector for another antenna
- adding one or more sensors (temperature) to this LoRa gateway
- adding a better power supply

zaterdag 17 juni 2017

Cables USB / Power cable

In my waste i found an old USB power connector cable.
The connection cables (2 cables) where very short but still could soldered.
You can find more and more devices using an USB powered cable. I expected the USB connector could be used to make a power cable (e.g. to connect to my regulated power supply from a previous post.
I searched on the internet to find out the connections. On https://www.usb3.com/usb3-info.html is this picture:
USB: Ground / Data+ / Data- / Power (5VDC)
( This, and more info can also be found on wikipedia  )
With my multi-meter i checked the connections to find out which of the two wires is the power + and which is the ground - wire.
I soldered two wires (Red to power + and black to ground - ) to the connector and used heat shrink tube to insulate the wire. Each wire is insulated separate and after this heat shrink is for botch wires.
On the other side of the cable i added two banana plugs.
After checking the connections and checking for possible shortcuts with this my multimeter the USB power adapter cable was ready.

To use it with a (B3603) regulated power supply set the voltage to +5V and a (protective) limited max current.
I am very happy with this USB adapter. Perhaps when i will make a new lab power supply i will  include a fixed 5V output with USB connector.