Maximum Frequency of a ESP8266 – Revisited

By ctherouxNo Comments

The ESP8266 can yield a 163 kHZ wave using the Arduino IDE and writing the code in C.  The code used is:

int pin = 5;
void setup() {
  pinMode(pin, OUTPUT);
}
void loop() {
  digitalWrite(pin, HIGH);
  digitalWrite(pin, LOW);
}

Nevertheless the wave form is far from being square as show on the picture below.  Click on the picture to enlarge it.

ESP8266 generated wave In C

By adding a 5 uS delay, we get a pretty good square wave.  The frequency is then 85.6 kHZ.  The code used is:

int pin = 5;
void setup() {
  pinMode(pin, OUTPUT);
}
void loop() {
  digitalWrite(pin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pin, LOW);
}

The yielded wave form is given below.  Click on the picture to enlarge it.

ESP8266 generated wave In C with correction

The frequency is 60 times higher than running a similar code on the ESP8266 with NodeMCU.

ESP8266, Internet of Things, IoT

Maximum Frequency an ESP8266 can yield

By ctherouxNo Comments

An ESP8266 running NodeMCU can yield maximum frequency of 1.44 kHz with a duty cycle of 61%.  The wave form is given below.  The code used to perform this test is:

pin = 8
gpio.mode(pin, gpio.OUTPUT);
while true do
 tmr.wdclr()
 gpio.write(pin, gpio.LOW)
 gpio.write(pin, gpio.HIGH)
end

Without clearing the watch dog (tmr.wdclr), the device can yield a frequency of 1.84 kHz.  Without clearing the watch dog, the device reboots after a few seconds.

ESP8266 Wave Form

Click on the picture to enlarge it.

ESP8266, Internet of Things, IoT, NodeMCU

Interrupt NodeMCU init.lua

By ctherouxNo Comments

It can be sometimes challenging to regain control of the NodeMCU running on a ESP8266 when init.lua has a tight loop in it.  To do so,  first, download esptool.py from GitHub.

Execute the following command

python esptool.py --port /dev/ttyUSB0 --baud <baud-rate> erase_flash

where

<baud-rate> is the baud rate of the connection between the ESP8266 and your PC.  Typically, 9600.

<serial-port> is the serial port the ESP8266 is connected to.  Typically,  /dev/ttyUSBn on Linux.

After having done this, you will need to re-install NodeMCU.  It can be done using the following command:

python esptool.py --port /dev/ttyUSB0 --baud <baud-rate> 
     write_flash 0x00000 <nodemcu-path>

where

<baud-rate> is the baud rate of the connection between the ESP8266 and your PC.  Typically, 9600.

<serial-port> is the serial port the ESP8266 is connected to.  Typically,  /dev/ttyUSBn on Linux.

<nodemcu-path> is the filename an path of the NodeMCU image.  Example: ../nodemcu_float_0.9.6-dev_20150704.bin

ESP8266, Internet of Things, IoT, Linux, NodeMCU

ESP8266 Resources Page

By ctherouxNo Comments

I have written a page that contains many useful links about the ESP8266 platform.  You can display this page either using the top menu option “ESP8266 Resources” or by cliking on this link.

ESP8266, Internet of Things, IoT, NodeMCU

ESP8266 – Remarkable free book

By ctherouxNo Comments

NodeMCU LUA base ESP8266 Development Kit

A remarkable book about the ESP8266 is freely available.  It can be downloaded from Kolban’s book on the ESP8266.  It contains more than 300 pages of information.  This book is a very good overview of the technology and a great starting point if you want to develop around this device.

Table of Contents

  • Introduction
  • Overview
  • Connecting to the ESP8266
  • WiFi Theory
  • AT Command Programming
  • Assembling circuits
  • Programming
    • Boot mode
    • The ESP8266 SDK
    • Compiling
    • Linking
    • Debugging
    • Architecture
    • WiFi at startup
    • Working with WiFi
    • Working with TCP/IP
    • ESP-NOW
    • Working with I2C
    • Hardware SPI
    • Working with serial
    • Task handling
    • Timers and time
    • Working with memory
    • Working with flash memory
    • Pulse Width Modulation – PWM
    • Analog to digital conversion
    • Sleep modes
    • Watchdog timer
    • Security
    • Mapping from Arduino
    • Partner TCP/IP APIs
    • Programming using Eclipse
    • Programming using the Arduino IDE
    • Programming with JavaScript
    • Programming with Lua
    • Programming with Basic
    • Integration with Web Apps
    • Mobile apps
    • Sample Snippets
    • Sample applications
    • Sample Libraries
    • Reference materials
    • C++ Programming
    • Simple class definition
    • Lambda functions
    • Ignoring warnings
    • Eclipse
    • ESPFS breakdown
    • ESPHTTPD breakdown
    • Makefiles
    • Forums
    • Reference documents
    • Github
    • SDK
  • Heroes
  • Areas to Research
ESP8266, Internet of Things, IoT, NodeMCU

EGit does not shows project decorations

By ctherouxNo Comments

EGit

Decorations are not displayed when some commits are not pushed EGit within the Eclipse IDE. These are the UP and DOWN arrows shown to the right of the project name in Eclipse Project Explorer. This issue can be resolved by going into the properties of the GIT repository in the Git Repositories view. Then click on Add Entry and add the following keys and values:

branch.master.remote = origin
branch.master.merge = refs/heads/master
Eclipse, GIT

Hard reset a Cree Connected light bulb

By ctheroux2 Comments

Hard Reset Cree Connected Light Bulb

I acquired a few days ago a Wink Hub along with a few Cree Connected light bulbs. I couldn’t pair them. Out of 5 bulbs, I was able to pair only one of them! After reading many posts on the Internet, I have made sure that the Wink Hub is not near my router, the light bulb was in range of the Wink Hub, and so on. I found out that one possible solution was to reset the light bulbs. I found the same recipe on many web sites, which were saying: “Turn the bulb off for 2 seconds, then on for 2 seconds. Repeat three more times. After the fourth cycle, the bulb will flash, indicating that the reset was successful.” It wasn’t working.

I contacted the technical support of Wink. They gave me the following method which worked right away. The method they gave me is:

1. Begin with the bulb turned off
2. Turn the bulb ON for 1 second
3. Turn the bulb OFF for 2 seconds
4. Repeat steps 2 and 3 until the bulb momentarily dims (about 4 or 5 times)
5. It will only dim for a second, signaling that it has been factory reset

Notice on step 2, 1 second, not 2. I could pair my 4 other bulbs without any problem.

automation, Cree, Wink

Maximum frequency an Arduino can generate

By ctherouxNo Comments

What is the maximum frequency an Arduino can generate? Typically, I obtained a frequency of less than 100 kHz using the Arduino function calls. The results were lower than I expected. I also observed that I had a frequency higher by 25 kHz using a pin from the 8 to 13 pin set than a pin from the 0 to 7 pin set. These tests yield a virtually perfect waveform. I obtained almost 4 MHz by accessing the register directly. The waveform was not as good as the waveform of the first four tests. The waveform is given in Figure 1.

Sketch 1 Frequency: 72.6 kHz
Duty Cycle: 47.7%
#include

#define OUTPUT_PIN 3

void setup() {
  pinMode(OUTPUT_PIN, OUTPUT);
}

void loop() {
  digitalWrite(OUTPUT_PIN, HIGH);
  digitalWrite(OUTPUT_PIN, LOW);
}

Sketch 2 Frequency: 74.3 kHz
Duty Cycle: 49.2%
#include

#define OUTPUT_PIN 3

void setup() {
  pinMode(OUTPUT_PIN, OUTPUT);
}

void loop() {
  while(1) {
    digitalWrite(OUTPUT_PIN, HIGH);
    digitalWrite(OUTPUT_PIN, LOW);
  }
}

Sketch 3 Frequency: 96.94 kHz
Duty Cycle: 49%
#include

#define OUTPUT_PIN 8

void setup() {
  pinMode(OUTPUT_PIN, OUTPUT);
}

void loop() {
  digitalWrite(OUTPUT_PIN, HIGH);
  digitalWrite(OUTPUT_PIN, LOW);
}

Sketch 4 Frequency: 96.94 kHz
Duty Cycle: 49%
#include

#define OUTPUT_PIN 8

void setup() {
  pinMode(OUTPUT_PIN, OUTPUT);
}

void loop() {
  while(1) {
    digitalWrite(OUTPUT_PIN, HIGH);
    digitalWrite(OUTPUT_PIN, LOW);
  }
}

Sketch 5 Frequency: 3.97 MHz
Duty Cycle: 25.6%
#include

void setup() {
  DDRB = B00000001;
}

void loop() {

  while(1) {
    PORTB = 0xff;
    PORTB = 0x00;
  }
}

Click on the image to improve the quality.

Wave generated by modifying directly the port

Figure 1: Waveform generated by modifying directly the port (Sketch 5)

Arduino

TRENDnet TK-207K KVM Mounting Bracket

By ctherouxNo Comments
TRENDnet TK-207K KVM Mounting Bracket

A “TRENDnet TK-207K KVM Mounting Bracket” is now available. More details at TRENDnet TK-207K KVM Mounting Bracket.

3D Printing, object

How about a Raspberry PI 2 as a firewall?

By ctherouxNo Comments

Raspberry PI 2

A Raspberry PI 2 performs as expected exceptionally well as a firewall. The download throughput achieved was 33 Mbits/sec under the same test conditions as the previous test (see Can A Raspberry PI Be Used As A Firewall? for more details). The CPU usage was about 5% during the download test. The CPU usage was around 2% while performing the upload test.

Networking, Raspberry PI, Unix, Wheezy

Can a Raspberry PI be used as a firewall?

By ctheroux1 Comment

Raspberry PI Model B

Can a Raspberry PI be used as a firewall? This question comes back often. Well, I have tested it. The test conditions are:

  • a Raspberry PI Model B (256MB of RAM)
  • a USB to Ethernet wired interface. 100 Mbits/sec.
  • Raspian (May 2015) as the OS.
  • My Internet connection is 30 Mbits/sec. for download, 10 Mbits/sec. for the upload speed.
  • www.speedtest.net has been used to carry the speed tests.

The answer is NO. I got a download speed of about 30 MBits/sec. Using a PC as the firewall with a similar setup, I achieved around 32 MBits/sec. While doing the download test, the CPU usage was 100% while being 20% for the upload test. Memory was not an issue with about 165 MB free.

I would certainly use this Raspberry PI as a firewall for an Internet connection of 20-20 Mbits/sec. or less.

A similar test will soon be performed using a Raspberry PI 2.

Networking, Raspberry PI, Wheezy

Cable Hanger for Doors

By ctherouxNo Comments
Cable Hanger

A “Cable Hanger for Doors” is now available. More details at Cable Hanger for Doors.

3D Printing, object

STM32 Minimum System Development Board

By ctheroux2 Comments

Upload code to a STM32 Minimum System Development Board

This post describes how to upload code to a STM32 Minimum System Development Board that can be bought from Ali Express or eBay for around $4.00 US. You will be able to compile and upload a led blinking program to the board at the end of this guide. This guide is using Arduino_STM32 by Roger Clark.
You will need:

  1. to download Roger Clark’s Arduino IDE STM32 board support files. It can be downloaded from this link.
  2. to download the latest Arduino IDE. It can be downloaded from this link.
  3. a USB to TTL Serial Cable that uses 3.3V signal level such as link or any equivalent cable.

The setup steps are:

  1. First, install the Arduino IDE following the provided instructions.
  2. Install Arduino SAM Boards (32 bits ARM Cortex-M3) using the Arduino IDE option Tools -> Board -> Boards Manager.
  3. Locate the hardware folder within the Arduino IDE installation folder.
  4. Un-archive the STM32 support files in the hardware directory found in the Arduino IDE installation folder.  Rename the top folder Arduino_STM32-master to Arduino_STM32.  If you restart the Arduino IDE, you will find in the Tools -> Board option a new set of boards including the STM32F103C Series.
  5. Connect the TTL Serial Cable ground pin to one of the ground pins of the board labeled G.   It is the black wire on the picture below. The TTL Serial Cable shall be disconnected from the PC at this stage.
  6. Connect the TTL Serial Cable 5V to the pin labeled 5V on the board.  It is the red wire on the picture below.  A 3.3V supply can also be used.  In this case, connect the 3.3V supply to a pin labeled 3.3 on the board.
  7. Connect the TTL Serial Cable RX pin to the board A9 pin. It is the white wire on the picture below.
  8. Connect the TTL Serial Cable TX pin to the board A10 pin. It is the green wire on the picture below.
  9. Set the jumpers.  Boot0 shall be set to 1 (HIGH) and Boot1 to 0 (LOW).  The Boot1 jumper is right beside the reset switch.
  10. Plug the TTL Serial Cable to the PC.  A red led should light up on the board indicating that it is powered.

The board setup looks like this using an Adafruit 954 TTL Serial Cable.

Upload code to a STM32 Minimum System Development Board

STM32 Minimum System Development Board Wiring

In the Arduino IDE:

  1. Create a new sketch (File -> New).
  2. Copy the code below.  It will make the onboard led blink.
  3. Select the board  Generic STM32F103C Series from the Tools -> Board option.
  4. Select STM32F103C8 (20k Ram, 64 k Flash) from Tools -> Variant option.
  5. Select Serial from the Tools -> Upload method option.
  6. Select the port of the TTL Serial Cable from the Tools -> Port option.
  7. Verify the sketch (Sketch -> Verify/Compile).
  8. Hit the reset button on the board and wait 4 seconds.  If you do not wait enough, you will get a “Failed to init device.” message.
  9. Upload the sketch to the board (File -> Upload).  You will get a bunch of messages.  The last line will be “Starting execution at address 0x08000000… done.”.
  10. The green led will now blink.

If you reset the board or unplug it, your program will not run unless you set both Boot0 and Boot1 jumpers to 0 (LOW).

The test sketch is:


void setup() {
pinMode(PC13, OUTPUT);
}


void loop() {
digitalWrite(PC13, HIGH);
delay(100);
digitalWrite(PC13, LOW);
delay(100);
}

Arduino, STM32

Change the Ubuntu login screen background?

By ctherouxNo Comments

Changing the login screen background is easy but not obvious. The image file you want to use as the login screen background must have a read access for everyone. Open the image with the Image viewer installed by default. Select the option Set as Wallpaper from the Image menu.

The Appearance option of the Settings will only let you change the desktop background.

Ubuntu, Ubuntu 12.04, Ubuntu 14.04, Ubuntu 15.04

Make an Apache2 SSL server more secure

By ctherouxNo Comments

These easy steps will improve significantly the security of your Apache2 SSL server. Edit your /etc/apache2/mods-enabled/ssl.conf file and replace the SSLProtocol, SSLCipherSuite and SSLHonorCipherOrder parameters with the following values.

SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA

SSLHonorCipherOrder on

SSLProtocol all -SSLv2 -SSLv3

apache, Debian, Linux, Ubuntu, Unix

Raspberry Pi Model B+ Drilling And Mounting Plates

By ctherouxNo Comments
Raspberry Pi B Plus view 2

“Raspberry Pi Model B+ Drilling And Mounting Plates” are now available. More details at Raspberry Pi Model B+ Drilling And Mounting Plates.

3D Printing, object

Raspberry Pi Model B Drilling And Mounting Plates

By ctherouxNo Comments
Raspberry Pi B view 1

“Raspberry Pi Model B Drilling And Mounting Plates” are now available. More details at Raspberry Pi Model B Drilling And Mounting Plates.

3D Printing, object

Arduino Mega / Mega 2560 / Due Drilling And Mounting Plates

By ctherouxNo Comments
Arduino Mega view 2

“Arduino Mega / Mega 2560 / Due Drilling And Mounting Plates ” are now available. More details at Arduino Mega / Mega 2560 / Due Drilling And Mounting Plates.

3D Printing, object

Arduino UNO / Duemilanove / Diecimila / Leonardo Drilling And Mounting Plates

By ctherouxNo Comments
Arduino UNO / Duemilanove / Diecimila / Leonardo / NG / Extreme Drilling And Mounting Plates

“Arduino UNO / Duemilanove / Diecimila / Leonardo / NG / Extreme Drilling And Mounting Plates” are now available. More details at Arduino UNO / Duemilanove / Diecimila / Leonardo / NG / Extreme Drilling And Mounting Plates.

3D Printing, object

Beaglebone Black Drilling And Mounting Plates

By ctherouxNo Comments
Beaglebone Black view 2

“Beaglebone Black Drilling And Mounting Plates” are now available. More details at Beaglebone Black Drilling And Mounting Plates.

3D Printing, object
Blue Taste Theme created by Jabox