Mini Client with the Arduino TRINKET and the ESP8266

January 19, 2015 1 comment

Sending the temperature to a ThingSpeak channel using the TMP35 sensor.

This is a small and low cost implementation of IoT (Internet of Things, possibly one of the next technological revolutions).

Mini-Client-Trinket-ThingSpeak

The ESP8266 can be used alone thanks to the apparition of several environments like LUA, C, Micro Python etc..

In this case I wanted to keep the solution in the Arduino environment to take advantage of many ready-to-use libraries and examples. Then I realized, due the reduced space in the Trinket (5.310Kb for code), the usability of such libraries it’s not so simple.

Programming the ATtiny85 with an ISP programmer will permit the use of the full 8K programming memory.

Anyway was a fun project, is great to see the small ATtiny85 acting as a Web Client.

Let’s make the Trinket do the job using just the Arduino IDE.

 


 

 

Power considerations:

The ESP8266 is power hungry when is communicating with a Wi-Fi spot. It can reach 215mA in Transmit Mode.

The 3.3Vregulator in the Trinket only supply 150mA max.

Then we need to use another 3.3V power source.

The L4931 (250 mA) is working at first. Two capacitors were added for stability, one in the input and another in the output.


 

Wiring diagram:

(….. on the works)

 


 

Making the ESP8266 breadboard friendly:

 To modify the ESP8266 we need a 0.1″ 4-pin right-angle male header (Not included in the part list).

The procedure is very simple:ESP8266-breadboard-09

First cut (remove) the row of pines closer to the board border.

Then, using a breadboard as guide and support, sold the right-angle header.

Use enough solder to obtain a good mechanical resistance.

 

 

More images in this post:

http://arduining.com/2015/01/02/making-esp8266-breadboard-frienly/

 


 

Mini breadboard wiring:

 

Wire color identification:MiniTrinket-ESP8266-Wiring_02

Black: ground.

Orange: 3.3V from the L4931 regulator.

Yellow: Trinket RX data (ESP8266 TX).

Purple: Trinket TX data (ESP8266 RX).

Green: Trinket analog input (TMP36 Vout).

 

 

 


 

Final assembly:

Mini-Client-Trinket_03

Everything in it’s place… let’s coding…

 


 

 

Temperature Sensor TMP35:

TMP35_chart

 


 

The Trinket Sketch:

At first, just ported the code from a working example made with the Meduino NANO and the DHT22 temperature sensor, finding out that the code size will be a problem.

open-style-packaging-2

 


 

Several changes were implemented to reduce the code size:

Changing to the TMP35 temperature sensor because is easier to read (don’t need a library ).

Avoiding the use of string manipulation functions.

Avoiding the use of floating math operations. (Only integer math was used).

Integrating CR and LF at the end of the strings and using print() function instead of println().

Many other changes until the compiler of the Arduino IDE announced:

Binary sketch size: 5,196 bytes (of a 5,310 byte maximum)


The Sketch:

(soon… need to be documented an cleaned….)

 

 


Mini Client part list :

Adafruit-Part-List

Pictures from the Adafruit Industries web page.

1.- USB cable – A/MiniB.                                                                   1

2.- Hook-up Wire 22AWG Solid Core (assorted colors) .                    1

3.- Tiny breadboard 170 contacts.                                                   1

4.- Adafruit’s Trinket – Mini Microcontroller – 3.3V Logic                   1

5.- 3.3V 250mA Linear Voltage Regulator – L4931-3.3 TO-92          1

6.- 10uF 50V Electrolytic Capacitor.                                                2

7.-TMP35 – Analog Temperature sensor.                                         1

8.- ESP8266 WiFi Module.                                                              1

A 0.1″ 4-pin right-angle male header is recommended to adapt the ESP8266 to the breadboard.


This Post Is Under Construction…

blogger-at-work


Making ESP8266 breadboard friendly

January 2, 2015 2 comments

Just receive some samples of the ESP-01 board. My first thought was how to use it with a breadboard?.

Searching in the web saw some solutions, but all need to wait for breadboard adapters or too complicated approaches.

Another solution is to use female to male jumper cables.

After some brainstorming and a couple cups of coffee ..

IMG_20141231_181709

A 0.1″  right-angle male header and an adhesive silicone dot will provide the solution:

 


 

 

The following images explain  themselves:

ESP8266-breadboard-friendly

IMG_20141231_181832

 


 

Ready for IoT fun projects…

ESP8266-Meduino-NANO


 

Sending random values of temperature and humidity to ThingSpeak:

ESP8266-Meduino-Thingspeak



 

Meduino NANO a versatile Arduino NANO clone

December 24, 2014 Leave a comment

Two years ago I found the MEDUINO in Ebay (5 pieces for $44.95 including shipping).

Ebay_Meduino

Since then I have used them in several projects with good results.

For less than 10 bucks, you have an Arduino NANO compatible device with selectable working voltage (3.3V or 5V), additionally, you can use it as a USB-Serial adapter (FTDI chip) to interface or monitor other serial devices.

ADXL335_Meduino_NANOr

Meduino 3.3V capturing data from the ADXL335 accelerometer.

Meduino_photosensor

Meduino 5V transmiting light intensity from the Single Pixel Camera to Processing.

electric-imp-meduino-serial

Meduino 3.3V as a USB-Serial adapter to check MODBUS protocol with the electric imp.

Meduino-ESP8266-serial

Meduino 3.3V as power source and USB serial adapter for the ESP8266 Wi-Fi module.

The pin arrangement is like the Arduino NANO but with the Mini-USB connector on the opposite side. The PCB of the Meduino is also slightly larger.

Nano_Vs_Meduino

Meduino NANO and Arduino NANO pin assignment

The selectable Vcc (3.3/5V) is great to interface with different sensors and hardware.

ATmega328 overclocked:

One thing to consider for “serious” applications is the crystal frequency at 3.3V.

Meduino_Outlaw_d

The ATMega328 datasheet shows a Safe Operating Area, the maximum recommended frequency for 3.3V operation is 13.3 MHz.

The Meduino NANO with 3.3V at 16MHz is out of the recommended frequency but for experimenting purposes at room temperature, is a very handy and low cost Arduino.

Using the Linear Sensor Array TSL201R with Arduino

March 26, 2014 5 comments

Dealing with linear Sensor Arrays is not easy. After some research in the web, found some experiments with TSL1401, TSL202R and TSL201R, many of them without a happy ending.

My intent is to find out how to do simple image processing of Linear Sensor Arrays using the Arduino.

This will open the path to develop some interesting experiments and applications:

-Line Follower Robots.

-Optical Flow Sensor (to sense movement in robots and autonomous vehicles).

-Laser Range Finders.

-Imagen Scanners (Barcode, character recognition etc.)

-Position Sensors.

-Objet Detection and Objet Counting.

-Objet Shape Identification and Analysis.

-Light Spectrum Analyzers.

-Etc…

After reading the (64×1) linear Sensor Arrays TSL201R manual…

tsl201r-fingertip

…decided to buy some DIP-8 versions (package discontinued) in Aliexpress.com, (breadboard friendly).

This is the wiring diagram:

TSL201R_Wiring

Arduino NANO, solid wires (AWG#22) and an adequate breadboard  for the job.

TSL201R_Test_01_noFilter

Pinhole cameras using  PCB Relay’s cases:

tsl201r-test-panels

Because the small hole, more integration time is necessary.

The projected image field of view can be estimated using geometry…

pinhole-image-size-3

The application in Progressing shows the illuminance of each pixel sent by the arduino.

Integration time and frames per second (FPS) are also presented.

TSL201RView_06e

 Here is an example of how to use the sensor to estimate the position of a floating ball.

20140417_120633

Another  possible application, a laser ranger:

laser-ranger-concept

Working to increase the frames per second (FPS)…

Will be continued…

(in twitter you can follow my progress before it be posted here ): @arduining

 

Arduino Trinket Photo Session

February 19, 2014 1 comment

After receiving a bunch of Trinkets, my first impulse was to do some photographic composition…

AtHand

TrinketHandIntelligence at your fingertips.

Trinket_Photo_01Imagine what can be done…

roundGoing arround…

NestTrinketsTrinket nest…

man_002Distributed intelligence…

ArduinoTrinketsGo arduining…

Arduino Trinket and Serial LCD

February 17, 2014 2 comments

Testing the bit bang serial transmission to connect the Trinket with the Serial LCD Module 16×2 from NKC Electronics.
The first Sketch with string functions use 3,634 bytes, the second Sketch, avoiding string functions, use 1,362 bytes.

20140217_125246

Sketch with string functions:

/*	Test_LCD.ino
	Arduining.com  16 FEB 2014
	Binary sketch size: 3,634 bytes (of a 5,310 byte maximum)

	A timer is implemented presenting minutes and seconds elapsed since start.
	Bit Banging Serial transmission at 9600 bauds.
	Example using the Trinket from Adafruit (5V, 8 Mhz)
	and Serial LCD Module 16x2 from NKC Electronics.
*/

//----- defining bit banging serial values:------------------------------------
#define	TXDATA    1         // Pin used to transmit data.
#define BITTIME   93        // Adjusted with osciloscope to obtain 9600 bauds.

//----------variables:---------------------------------------------------------
int 	seconds= 0;		//seconds counter
String 	number;			//String to be sent to the display.
//=============================================================================
void setup() {                
	pinMode(TXDATA, OUTPUT);   // initialize the TXDATA pin as an output.
	digitalWrite(TXDATA,HIGH); // TXDATA = 5V when is resting.
//---LCD Display initialisation---
	delay(500);
	sendChar(0xFE);
	sendChar(0x41);		//display on.
	sendChar(0xFE);
	sendChar(0x51);		//clear display.
	sendChar(0xFE);
	sendChar(0x4C);		//cursor blinking Off.
	sendChar(0xFE);
	sendChar(0x48);		//cursor Off.
	sendChar(0xFE);
	sendChar(0x46);		//cursor at home.
	sendChar(0xFE);
	sendChar(0x53);		//backlight brightness command.
	sendChar(4);		//brightness 1-8
	sendChar(0xFE);
	sendChar(0x52);		//contrast command.
	sendChar(45);		//contrast 1-50
	show(" Arduining.com");
}

//================= Main loop =================================================
void loop() {
	if ((millis() % 1000)<2){ 				//Skip until the next second.

		sendChar(0xFE);
		sendChar(0x45);						// Set cursor at
		sendChar(0x45);						// line 2 pos 6

		number = String (seconds/60);		//elapsed minutes
		while(number.length()<2)number= "0" + number;   //format to 2 characters.
		show(number); 						//Show minutes in the display

		sendChar(':');

		number = String (seconds % 60);		//elapsed seconds
		while(number.length()<2)number= "0" + number;   //format to 2 characters.
		show(number); 						//Show seconds in the display

   		seconds++;
   		if (seconds >= 3600) seconds=0;		//roll over
	}
}

//-----------------------------------------------------------------------------
void sendChar(char c){
	delayMicroseconds(BITTIME*2);          		// wait 2 Stop bits.
	digitalWrite(TXDATA,LOW);              		// TXDATA=0.
	delayMicroseconds(BITTIME);            		// wait Start bit.
	for (int i=0; i<8;i++){
		digitalWrite(TXDATA,bitRead(c, i)); 	// bit out.
		delayMicroseconds(BITTIME);          	// wait bit
	}
	digitalWrite(TXDATA,HIGH);            		//TXDATA=1.
}

//-----------------------------------------------------------------------------
void show(String s){
	int lenght=s.length();
	for(int i=0;i<lenght;i++){
	sendChar(s[i]);
	}
}

Sketch without string functions:

/*	Test_LCD_01.ino
	Arduining.com  17 FEB 2014
	Based in Test_LCD.ino (2,278 bytes less avoiding string functions).
	Binary sketch size: 1,356 bytes (of a 5,310 byte maximum)

	A timer is implemented presenting minutes and seconds elapsed since start.
	Bit Banging Serial transmission at 9600 bauds.
	Example using the Trinket from Adafruit (5V, 8 Mhz)
	and Serial LCD Module 16x2 from NKC Electronics.
*/

//----- defining bit banging serial values:------------------------------------
#define	TXDATA    1         // Pin used to transmit data.
#define BITTIME   93        // Adjusted with osciloscope to obtain 9600 bauds.

//----------variables:---------------------------------------------------------
int 	seconds= 0;		//seconds counter
//=============================================================================
void setup() {                
	pinMode(TXDATA, OUTPUT);   // initialize the TXDATA pin as an output.
	digitalWrite(TXDATA,HIGH); // TXDATA = 5V when is resting.
//---LCD Display initialisation---
	delay(500);
	sendChar(0xFE);
	sendChar(0x41);		//display on.
	sendChar(0xFE);
	sendChar(0x51);		//clear display.
	sendChar(0xFE);
	sendChar(0x4C);		//cursor blinking Off.
	sendChar(0xFE);
	sendChar(0x48);		//cursor Off.
	sendChar(0xFE);
	sendChar(0x46);		//cursor at home.
	sendChar(0xFE);
	sendChar(0x53);		//backlight brightness command.
	sendChar(4);		//brightness 1-8
	sendChar(0xFE);
	sendChar(0x52);		//contrast command.
	sendChar(45);		//contrast 1-50
	show(" Arduining.com");
}

//================= Main loop =================================================
void loop() {
	if ((millis() % 1000)<2){ 				//Skip until the next second.

		sendChar(0xFE);
		sendChar(0x45);						// Set cursor at
		sendChar(0x45);						// line 2 pos 6

		sendChar((seconds/600)+'0');		//show tens of minutes 
		sendChar(((seconds/60) % 10)+'0');	//show units of minutes
		sendChar(':');
		sendChar(((seconds % 60)/10)+'0');	//show tens of seconds
		sendChar((seconds % 10)+'0');		//show units of seconds
   		seconds++;
   		if (seconds >= 3600) seconds=0;		//roll over
	}
}

//-----------------------------------------------------------------------------
void sendChar(char c){
	delayMicroseconds(BITTIME*2);          		// wait 2 Stop bits.
	digitalWrite(TXDATA,LOW);              		// TXDATA=0.
	delayMicroseconds(BITTIME);            		// wait Start bit.
	for (int i=0; i<8;i++){
		digitalWrite(TXDATA,bitRead(c, i)); 	// bit out.
		delayMicroseconds(BITTIME);          	// wait bit
	}
	digitalWrite(TXDATA,HIGH);            		//TXDATA=1.
}

//-----------------------------------------------------------------------------
void show(char s[]){
	int i=0;
	while(s[i]!=0){					//looking for the string end.
		sendChar(s[i]);
		i++	;
	}
}

Arduino Trinket and Gauge Stepper Motor

January 31, 2014 4 comments

Driving directly a stepper motor used for Vehicle’s Instrument Gauges.

wpid-20140131_232948.jpg

The motor must be removed during the Sketch Loading (disconnect from USB pins) .

wpid-IMG_20140131_235102.jpg

This kind of motors can be driven directly by the Trinket.
The motor follows the potentiometer.

IMG_0009

The Sketch is the same used in the “Arduino Driving a Micro Stepper Motor” in this blog, just change the pin mapping to use the Trinket .

http://arduining.com/2012/04/22/arduino-driving-a-micro-stepper-motor/

Change the definitions in “Gauge_Pot01.ino”:

#define  STEPS  720    // steps per revolution (limited to 315°)
#define COIL1  1
#define COIL2  3
#define COIL3  4
#define COIL4  0
#define POTIN  1

The YouTube video…

 

Follow

Get every new post delivered to your Inbox.